Alerting: small typescript fix for Policy (#70655)

pull/70730/head
Gilles De Mey 2 years ago committed by GitHub
parent 8ea74333f1
commit 9e0f6ceb57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      public/app/features/alerting/unified/components/notification-policies/Policy.tsx

@ -345,18 +345,13 @@ const InheritedProperties: FC<{ properties: InhertitableProperties }> = ({ prope
placement="top"
content={
<Stack direction="row" gap={0.5}>
{Object.entries(properties).map(([key, value]) => {
// no idea how to do this with TypeScript without type casting...
return (
<Label
key={key}
// @ts-ignore
label={routePropertyToLabel(key)}
// @ts-ignore
value={<Strong>{routePropertyToValue(key, value)}</Strong>}
/>
);
})}
{Object.entries(properties).map(([key, value]) => (
<Label
key={key}
label={routePropertyToLabel(key)}
value={<Strong>{routePropertyToValue(key, value)}</Strong>}
/>
))}
</Stack>
}
>
@ -524,7 +519,7 @@ function getContactPointErrors(contactPoint: string, contactPointsState: Receive
return contactPointErrors;
}
const routePropertyToLabel = (key: keyof InhertitableProperties): string => {
const routePropertyToLabel = (key: keyof InhertitableProperties | string): string => {
switch (key) {
case 'receiver':
return 'Contact Point';
@ -538,10 +533,15 @@ const routePropertyToLabel = (key: keyof InhertitableProperties): string => {
return 'Mute timings';
case 'repeat_interval':
return 'Repeat interval';
default:
return key;
}
};
const routePropertyToValue = (key: keyof InhertitableProperties, value: string | string[]): React.ReactNode => {
const routePropertyToValue = (
key: keyof InhertitableProperties | string,
value: string | string[]
): React.ReactNode => {
const isNotGrouping = key === 'group_by' && Array.isArray(value) && value[0] === '...';
const isSingleGroup = key === 'group_by' && Array.isArray(value) && value.length === 0;

Loading…
Cancel
Save