Skip to content

Commit

Permalink
Edit detector - UX improvements and updates opensearch-project#482
Browse files Browse the repository at this point in the history
Signed-off-by: Jovan Cvetkovic <[email protected]>
  • Loading branch information
jovancvetkovic3006 committed Mar 20, 2023
1 parent 6ea7fe9 commit 77604e3
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ exports[`<Alerts /> spec renders the component 1`] = `
title="Alerts"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ exports[`<DetectorRulesView /> spec renders the component 1`] = `
title="Active rules (2)"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
titleSize="m"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down Expand Up @@ -1105,6 +1106,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
title="Detector schedule"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =
const detectorId = props.location.pathname.replace(`${ROUTES.EDIT_DETECTOR_RULES}/`, '');
const [flyoutData, setFlyoutData] = useState<RuleTableItem | null>(null);
const [fieldMappings, setFieldMappings] = useState<FieldMapping[]>();
const [showMappings, setShowMappings] = useState(false);

const context = useContext(CoreServicesContext);

Expand Down Expand Up @@ -126,6 +127,7 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =
}, [services, detectorId]);

const onToggle = (changedItem: RuleItem, isActive: boolean) => {
setShowMappings(true);
switch (changedItem.library) {
case 'Custom':
setCustomRuleItems(
Expand All @@ -147,6 +149,7 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =
};

const onAllRulesToggle = (isActive: boolean) => {
setShowMappings(true);
setCustomRuleItems(customRuleItems.map((rule) => ({ ...rule, active: isActive })));
setPrePackagedRuleItems(prePackagedRuleItems.map((rule) => ({ ...rule, active: isActive })));
};
Expand Down Expand Up @@ -264,7 +267,7 @@ export const UpdateDetectorRules: React.FC<UpdateDetectorRulesProps> = (props) =

<EuiSpacer size="xl" />

{detector?.inputs[0]?.detector_input.indices[0] ? (
{showMappings ? (
<NewFieldMappings
{...props}
detector={detector}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ Object {
<div
class="euiSpacer euiSpacer--xl"
/>
<div
class="euiSpacer euiSpacer--xl"
/>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--justifyContentFlexEnd euiFlexGroup--directionRow euiFlexGroup--responsive"
>
Expand Down Expand Up @@ -714,6 +717,9 @@ Object {
<div
class="euiSpacer euiSpacer--xl"
/>
<div
class="euiSpacer euiSpacer--xl"
/>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--justifyContentFlexEnd euiFlexGroup--directionRow euiFlexGroup--responsive"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ exports[`<AlertTriggersView /> spec renders the component 1`] = `
title="Alert triggers (2)"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ exports[`<DetectorDetails /> spec renders the component 1`] = `
title="Detector details"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down Expand Up @@ -2739,6 +2740,7 @@ exports[`<DetectorDetails /> spec renders the component 1`] = `
title="Active rules (2)"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ exports[`<DetectorDetailsView /> spec renders the component 1`] = `
title="Detector details"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down Expand Up @@ -1535,6 +1536,7 @@ exports[`<DetectorDetailsView /> spec renders the component 1`] = `
title="Active rules (2)"
>
<EuiPanel
className=""
style={
Object {
"paddingLeft": "0px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ exports[`<EditFieldMappings /> spec renders the component 1`] = `
}
}
fieldMappings={Array []}
fieldMappingService={
filedMappingService={
FieldMappingService {
"createMappings": [Function],
"getMappings": [Function],
Expand All @@ -190,7 +190,9 @@ exports[`<EditFieldMappings /> spec renders the component 1`] = `
loading={false}
replaceFieldMappings={[MockFunction]}
>
<div>
<div
className="editFieldMappings"
>
<EuiPanel>
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow"
Expand Down Expand Up @@ -469,7 +471,7 @@ exports[`<EditFieldMappings /> spec renders the component 1`] = `
}
}
fieldMappings={Array []}
fieldMappingService={
filedMappingService={
FieldMappingService {
"createMappings": [Function],
"getMappings": [Function],
Expand Down Expand Up @@ -1103,6 +1105,45 @@ exports[`<EditFieldMappings /> spec renders the component 1`] = `
className="euiSpacer euiSpacer--m"
/>
</EuiSpacer>
<EuiCallOut
color="success"
title="We have automatically mapped 0 field(s)"
>
<div
className="euiCallOut euiCallOut--success"
>
<div
className="euiCallOutHeader"
>
<span
className="euiCallOutHeader__title"
>
We have automatically mapped 0 field(s)
</span>
</div>
<EuiText
color="default"
size="s"
>
<div
className="euiText euiText--small"
>
<EuiTextColor
color="default"
component="div"
>
<div
className="euiTextColor euiTextColor--default"
>
<p>
Your data sources have been mapped with every rule field name. No action is needed.
</p>
</div>
</EuiTextColor>
</div>
</EuiText>
</div>
</EuiCallOut>
<EuiSpacer
size="m"
>
Expand Down

0 comments on commit 77604e3

Please sign in to comment.