-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding feature direction and moving suppression rules to each feature #960
Conversation
1e72613
to
104aa8a
Compare
Signed-off-by: Amit Galitzky <[email protected]>
104aa8a
to
553c521
Compare
I will address these issue, in addition, I missed on the part with the default rules, I will make sure we show them correctly in UI and also now for every detector with a feature direction we will have just that one default rule show along with the change on the UI so selection for only one shows. |
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
feature: any; | ||
featureIndex: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add types instead of any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added types
const cleanedSuppressionRules = | ||
form.values.suppressionRules.filter( | ||
(_, i) => i === props.featureIndex | ||
); | ||
form.setFieldValue( | ||
`suppressionRules.`, | ||
cleanedSuppressionRules | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these lines? Is arrayHelpers.remove enough? Also, should we use the following instead since you want to filter out any rule with props.featureIndex?
const cleanedSuppressionRules = form.values.suppressionRules.filter(
(_, i) => i !== props.featureIndex
);
form.setFieldValue('suppressionRules', cleanedSuppressionRules);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I previously had this to fix a bug where if there was only 1 suppression rule it wouldn't let me delete the last rule and fully clean up the array. I can remove this now though
public/pages/ConfigureModel/components/SuppressionRules/SuppressionRules.tsx
Outdated
Show resolved
Hide resolved
@@ -101,7 +83,7 @@ export function SuppressionRules(props: SuppressionRulesProps) { | |||
]} | |||
hintLink={`${BASE_DOCS_LINK}/ad`} | |||
isInvalid={isInvalid(field.name, form)} | |||
error={extractArrayError(field.name, form)} | |||
//error={extractArrayError(field.name, form)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you really want to hide error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to remove this completely as now I have errors seen before each field individually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, can you add comment about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment about new extractError
isInvalid={ | ||
!!extractError( | ||
`suppressionRules.${ | ||
props.featureIndex | ||
}[${index}].${ | ||
isPercentage === false | ||
? 'absoluteThreshold' | ||
: 'relativeThreshold' | ||
}`, | ||
form | ||
) | ||
} | ||
error={extractError( | ||
`suppressionRules.${ | ||
props.featureIndex | ||
}[${index}].${ | ||
isPercentage === false | ||
? 'absoluteThreshold' | ||
: 'relativeThreshold' | ||
}`, | ||
form | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to call the function extractError only once like
const thresholdFieldName = `suppressionRules.${props.featureIndex}[${index}].${
isPercentage === false ? 'absoluteThreshold' : 'relativeThreshold'
}`;
const thresholdError = extractError(thresholdFieldName, form);
<FormattedFormRow
isInvalid={!!thresholdError}
error={thresholdError}
fullWidth
>
{/* … */}
</FormattedFormRow>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I just have to put inside an inline expression and do something like this:
{(() => {
const thresholdFieldName = `suppressionRules.${props.featureIndex}[${index}].${
isPercentage === false ? 'absoluteThreshold' : 'relativeThreshold'
}`;
const thresholdError = extractError(thresholdFieldName, form);
return (
<FormattedFormRow
isInvalid={!!thresholdError}
error={thresholdError}
fullWidth
>
but need to make sure I have correct access to all the constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the change
Signed-off-by: Amit Galitzky <[email protected]>
@@ -63,6 +63,8 @@ export function Features(props: FeaturesProps) { | |||
<EuiFlexGroup direction="column" style={{ margin: '0px' }}> | |||
<FieldArray name="featureList" validateOnChange={true}> | |||
{({ push, remove, form: { values } }: FieldArrayRenderProps) => { | |||
console.log("values.featureList: " + JSON.stringify(values.featureList)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep this log line? Looks like debug message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, added it when I was checking the types I added
Signed-off-by: Amit Galitzky <[email protected]>
…#960) * adding feature direction and moving suppression rules to each feature Signed-off-by: Amit Galitzky <[email protected]> * fixing bug where two conditions didn't display Signed-off-by: Amit Galitzky <[email protected]> * improve error handling Signed-off-by: Amit Galitzky <[email protected]> * style changes and removing extra errors Signed-off-by: Amit Galitzky <[email protected]> * remove console log Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]> (cherry picked from commit e60e4e9)
…opensearch-project#960) * adding feature direction and moving suppression rules to each feature Signed-off-by: Amit Galitzky <[email protected]> * fixing bug where two conditions didn't display Signed-off-by: Amit Galitzky <[email protected]> * improve error handling Signed-off-by: Amit Galitzky <[email protected]> * style changes and removing extra errors Signed-off-by: Amit Galitzky <[email protected]> * remove console log Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
…#960) (#966) * adding feature direction and moving suppression rules to each feature * fixing bug where two conditions didn't display * improve error handling * style changes and removing extra errors * remove console log --------- Signed-off-by: Amit Galitzky <[email protected]>
Description
Check List
--signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.