From 5c4571f231aa65eacd8689a1a215aa36e0ace34d Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Tue, 20 Jun 2023 14:49:54 +0200 Subject: [PATCH] Alerting: Align notification policies design (#70345) --- .../notification-policies/Policy.tsx | 270 +++++++++--------- 1 file changed, 133 insertions(+), 137 deletions(-) diff --git a/public/app/features/alerting/unified/components/notification-policies/Policy.tsx b/public/app/features/alerting/unified/components/notification-policies/Policy.tsx index 07ea8cdbf97..dcb21534895 100644 --- a/public/app/features/alerting/unified/components/notification-policies/Policy.tsx +++ b/public/app/features/alerting/unified/components/notification-policies/Policy.tsx @@ -127,133 +127,135 @@ const Policy: FC = ({ {/* continueMatching and showMatchesAllLabelsWarning are mutually exclusive so the icons can't overlap */} {continueMatching && } {showMatchesAllLabelsWarning && } - - {/* Matchers and actions */} -
- - {isDefaultPolicy ? ( - - ) : hasMatchers ? ( - - ) : ( - No matchers - )} - - {/* TODO maybe we should move errors to the gutter instead? */} - {errors.length > 0 && } - {!readOnly && ( - - - - onEditPolicy(currentRoute, isDefaultPolicy)} - /> - {isDeletable && ( - <> - - onDeletePolicy(currentRoute)} - /> - - )} - - } - > +
+ + {/* Matchers and actions */} +
+ + {isDefaultPolicy ? ( + + ) : hasMatchers ? ( + + ) : ( + No matchers + )} + + {/* TODO maybe we should move errors to the gutter instead? */} + {errors.length > 0 && } + {!readOnly && ( +
+ > + New nested policy + + + onEditPolicy(currentRoute, isDefaultPolicy)} + /> + {isDeletable && ( + <> + + onDeletePolicy(currentRoute)} + /> + + )} + + } + > +
- {/* Metadata row */} -
- - {matchingInstancesPreview.enabled && ( - { - matchingAlertGroups && onShowAlertInstances(matchingAlertGroups, matchers); - }} - data-testid="matching-instances" - > - {numberOfAlertInstances ?? '-'} - {pluralize('instance', numberOfAlertInstances)} - - )} - {contactPoint && ( - - Delivered to - - - )} - {!inheritedGrouping && ( - <> - {customGrouping && ( - - Grouped by - {groupBy.join(', ')} - - )} - {singleGroup && ( - - Single group - - )} - {noGrouping && ( - - Not grouping - - )} - - )} - {hasMuteTimings && ( - - Muted when - - - )} - {timingOptions && Object.values(timingOptions).some(Boolean) && ( - - )} - {hasInheritedProperties && ( - <> - - Inherited - + {/* Metadata row */} +
+ + {matchingInstancesPreview.enabled && ( + { + matchingAlertGroups && onShowAlertInstances(matchingAlertGroups, matchers); + }} + data-testid="matching-instances" + > + {numberOfAlertInstances ?? '-'} + {pluralize('instance', numberOfAlertInstances)} - - )} - -
-
+ )} + {contactPoint && ( + + Delivered to + + + )} + {!inheritedGrouping && ( + <> + {customGrouping && ( + + Grouped by + {groupBy.join(', ')} + + )} + {singleGroup && ( + + Single group + + )} + {noGrouping && ( + + Not grouping + + )} + + )} + {hasMuteTimings && ( + + Muted when + + + )} + {timingOptions && Object.values(timingOptions).some(Boolean) && ( + + )} + {hasInheritedProperties && ( + <> + + Inherited + + + + )} + +
+
+
{/* pass the "readOnly" prop from the parent, because if you can't edit the parent you can't edit children */} @@ -574,7 +576,7 @@ const getStyles = (theme: GrafanaTheme2) => ({ font-size: ${theme.typography.bodySmall.fontSize}; border: solid 1px ${borderColor}; - border-radius: ${theme.shape.borderRadius(2)}; + border-radius: ${theme.shape.borderRadius(1)}; `, }; }, @@ -593,23 +595,22 @@ const getStyles = (theme: GrafanaTheme2) => ({ margin-left: -20px; } `, + policyItemWrapper: css` + padding: ${theme.spacing(1.5)}; + `, metadataRow: css` - background: ${theme.colors.background.primary}; - padding: ${theme.spacing(1.5)}; + background: ${theme.colors.background.secondary}; - border-bottom-left-radius: ${theme.shape.borderRadius(2)}; - border-bottom-right-radius: ${theme.shape.borderRadius(2)}; - `, - matchersRow: css` - padding: ${theme.spacing(1.5)}; - border-bottom: solid 1px ${theme.colors.border.weak}; + border-bottom-left-radius: ${theme.shape.borderRadius(1)}; + border-bottom-right-radius: ${theme.shape.borderRadius(1)}; `, + matchersRow: css``, policyWrapper: (hasFocus = false) => css` flex: 1; position: relative; background: ${theme.colors.background.secondary}; - border-radius: ${theme.shape.borderRadius(2)}; + border-radius: ${theme.shape.borderRadius(1)}; border: solid 1px ${theme.colors.border.weak}; ${hasFocus && @@ -628,11 +629,6 @@ const getStyles = (theme: GrafanaTheme2) => ({ height: 0; margin-bottom: ${theme.spacing(2)}; `, - // TODO I'm not quite sure why the margins are different for non-child policies, should investigate a bit more - addPolicyWrapper: (hasChildPolicies: boolean) => css` - margin-top: -${theme.spacing(hasChildPolicies ? 1.5 : 2)}; - margin-bottom: ${theme.spacing(1)}; - `, gutterIcon: css` position: absolute; @@ -648,7 +644,7 @@ const getStyles = (theme: GrafanaTheme2) => ({ text-align: center; border: solid 1px ${theme.colors.border.weak}; - border-radius: ${theme.shape.borderRadius(2)}; + border-radius: ${theme.shape.borderRadius(1)}; padding: 0; `,