# What this PR does ## Which issue(s) this PR fixes ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
20 lines
938 B
TypeScript
20 lines
938 B
TypeScript
import { AlertReceiveChannel } from 'models/alert_receive_channel/alert_receive_channel.types';
|
|
|
|
const countNumberOfInheritedAndCustomLabels = (alert_group_labels: AlertReceiveChannel['alert_group_labels']) => {
|
|
const inheritedCount = alert_group_labels.inheritable
|
|
? Object.keys(alert_group_labels.inheritable).filter((labelKey) => alert_group_labels.inheritable?.[labelKey])
|
|
.length
|
|
: 0;
|
|
const customCount = alert_group_labels.custom?.length || 0;
|
|
return inheritedCount + customCount;
|
|
};
|
|
|
|
export const getIsTooManyLabelsWarningVisible = (
|
|
alert_group_labels: AlertReceiveChannel['alert_group_labels'],
|
|
limit = 15
|
|
) => countNumberOfInheritedAndCustomLabels(alert_group_labels) > limit;
|
|
|
|
export const getIsAddBtnDisabled = ({ custom }: AlertReceiveChannel['alert_group_labels']) => {
|
|
const lastItem = custom.at(-1);
|
|
return lastItem && (lastItem?.key.id === undefined || lastItem?.value.id === undefined);
|
|
};
|