From 77604e3bcb1ca3f80372ba9041f00dc0686b2132 Mon Sep 17 00:00:00 2001 From: Jovan Cvetkovic Date: Mon, 20 Mar 2023 18:30:15 +0100 Subject: [PATCH] Edit detector - UX improvements and updates #482 Signed-off-by: Jovan Cvetkovic --- .../Alerts/__snapshots__/Alerts.test.tsx.snap | 1 + .../DetectorRulesView.test.tsx.snap | 1 + .../UpdateDetectorBasicDetails.test.tsx.snap | 2 + .../components/UpdateRules/UpdateRules.tsx | 5 +- .../UpdateDetectorRules.test.tsx.snap | 6 +++ .../AlertTriggersView.test.tsx.snap | 1 + .../DetectorDetails.test.tsx.snap | 2 + .../DetectorDetailsView.test.tsx.snap | 2 + .../EditFieldMappings.test.tsx.snap | 47 +++++++++++++++++-- 9 files changed, 63 insertions(+), 4 deletions(-) diff --git a/public/pages/Alerts/containers/Alerts/__snapshots__/Alerts.test.tsx.snap b/public/pages/Alerts/containers/Alerts/__snapshots__/Alerts.test.tsx.snap index 050feb771..08f80250c 100644 --- a/public/pages/Alerts/containers/Alerts/__snapshots__/Alerts.test.tsx.snap +++ b/public/pages/Alerts/containers/Alerts/__snapshots__/Alerts.test.tsx.snap @@ -943,6 +943,7 @@ exports[` spec renders the component 1`] = ` title="Alerts" > spec renders the component 1`] = ` title="Active rules (2)" > spec renders the component 1`] = ` titleSize="m" > spec renders the component 1`] = ` title="Detector schedule" > = (props) = const detectorId = props.location.pathname.replace(`${ROUTES.EDIT_DETECTOR_RULES}/`, ''); const [flyoutData, setFlyoutData] = useState(null); const [fieldMappings, setFieldMappings] = useState(); + const [showMappings, setShowMappings] = useState(false); const context = useContext(CoreServicesContext); @@ -126,6 +127,7 @@ export const UpdateDetectorRules: React.FC = (props) = }, [services, detectorId]); const onToggle = (changedItem: RuleItem, isActive: boolean) => { + setShowMappings(true); switch (changedItem.library) { case 'Custom': setCustomRuleItems( @@ -147,6 +149,7 @@ export const UpdateDetectorRules: React.FC = (props) = }; const onAllRulesToggle = (isActive: boolean) => { + setShowMappings(true); setCustomRuleItems(customRuleItems.map((rule) => ({ ...rule, active: isActive }))); setPrePackagedRuleItems(prePackagedRuleItems.map((rule) => ({ ...rule, active: isActive }))); }; @@ -264,7 +267,7 @@ export const UpdateDetectorRules: React.FC = (props) = - {detector?.inputs[0]?.detector_input.indices[0] ? ( + {showMappings ? ( +
@@ -714,6 +717,9 @@ Object {
+
diff --git a/public/pages/Detectors/containers/AlertTriggersView/__snapshots__/AlertTriggersView.test.tsx.snap b/public/pages/Detectors/containers/AlertTriggersView/__snapshots__/AlertTriggersView.test.tsx.snap index 4b134ef5d..5d4b67e59 100644 --- a/public/pages/Detectors/containers/AlertTriggersView/__snapshots__/AlertTriggersView.test.tsx.snap +++ b/public/pages/Detectors/containers/AlertTriggersView/__snapshots__/AlertTriggersView.test.tsx.snap @@ -200,6 +200,7 @@ exports[` spec renders the component 1`] = ` title="Alert triggers (2)" > spec renders the component 1`] = ` title="Detector details" > spec renders the component 1`] = ` title="Active rules (2)" > spec renders the component 1`] = ` title="Detector details" > spec renders the component 1`] = ` title="Active rules (2)" > spec renders the component 1`] = ` } } fieldMappings={Array []} - fieldMappingService={ + filedMappingService={ FieldMappingService { "createMappings": [Function], "getMappings": [Function], @@ -190,7 +190,9 @@ exports[` spec renders the component 1`] = ` loading={false} replaceFieldMappings={[MockFunction]} > -
+
spec renders the component 1`] = ` } } fieldMappings={Array []} - fieldMappingService={ + filedMappingService={ FieldMappingService { "createMappings": [Function], "getMappings": [Function], @@ -1103,6 +1105,45 @@ exports[` spec renders the component 1`] = ` className="euiSpacer euiSpacer--m" /> + +
+
+ + We have automatically mapped 0 field(s) + +
+ +
+ +
+

+ Your data sources have been mapped with every rule field name. No action is needed. +

+
+
+
+
+
+