UI: Optimize filter allow notification type

This commit is contained in:
Vladyslav_Prykhodko 2023-04-10 11:21:11 +03:00
parent 25e1d73ca0
commit eda7cf3619
2 changed files with 16 additions and 7 deletions

View File

@ -442,11 +442,16 @@ export class RuleNotificationDialogComponent extends
} }
private allowTriggerTypes(): TriggerType[] { private allowTriggerTypes(): TriggerType[] {
const sysAdminAllowTriggerTypes = new Set([
TriggerType.ENTITIES_LIMIT,
TriggerType.API_USAGE_LIMIT,
TriggerType.NEW_PLATFORM_VERSION,
]);
if (this.isSysAdmin()) { if (this.isSysAdmin()) {
return [TriggerType.ENTITIES_LIMIT, TriggerType.API_USAGE_LIMIT, TriggerType.NEW_PLATFORM_VERSION]; return Array.from(sysAdminAllowTriggerTypes);
} }
return Object.values(TriggerType).filter(type => type !== TriggerType.ENTITIES_LIMIT && type !== TriggerType.API_USAGE_LIMIT return Object.values(TriggerType).filter(type => !sysAdminAllowTriggerTypes.has(type));
&& type !== TriggerType.NEW_PLATFORM_VERSION);
} }
get allowEntityTypeForEntityAction(): EntityType[] { get allowEntityTypeForEntityAction(): EntityType[] {

View File

@ -177,11 +177,15 @@ export class TemplateNotificationDialogComponent
} }
private allowNotificationType(): NotificationType[] { private allowNotificationType(): NotificationType[] {
const sysAdminAllowNotificationTypes = new Set([
NotificationType.ENTITIES_LIMIT,
NotificationType.API_USAGE_LIMIT,
NotificationType.NEW_PLATFORM_VERSION,
]);
if (this.isSysAdmin()) { if (this.isSysAdmin()) {
return [NotificationType.GENERAL, NotificationType.ENTITIES_LIMIT, NotificationType.API_USAGE_LIMIT, NotificationType.NEW_PLATFORM_VERSION]; return [NotificationType.GENERAL, ...sysAdminAllowNotificationTypes];
} }
return Object.values(NotificationType) return Object.values(NotificationType).filter(type => !sysAdminAllowNotificationTypes.has(type));
.filter(type => type !== NotificationType.ENTITIES_LIMIT && type !== NotificationType.API_USAGE_LIMIT
&& type !== NotificationType.NEW_PLATFORM_VERSION);
} }
} }