mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: small typescript fix for Policy (#70655)
This commit is contained in:
parent
8ea74333f1
commit
9e0f6ceb57
@ -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…
Reference in New Issue
Block a user