fix(notifications): export notificationSeverities for reuse
The ordered array of constants is exported by the notifications-common for reusability by other plugins. Signed-off-by: Marek Libra <marek.libra@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
import {
|
||||
Notification,
|
||||
NotificationSeverity,
|
||||
notificationSeverities,
|
||||
} from '@backstage/plugin-notifications-common';
|
||||
import { Knex } from 'knex';
|
||||
|
||||
@@ -49,16 +50,9 @@ const NOTIFICATION_COLUMNS = [
|
||||
'saved',
|
||||
];
|
||||
|
||||
const severities: NotificationSeverity[] = [
|
||||
'critical',
|
||||
'high',
|
||||
'normal',
|
||||
'low',
|
||||
];
|
||||
|
||||
export const normalizeSeverity = (input?: string): NotificationSeverity => {
|
||||
let lower = (input ?? 'normal').toLowerCase() as NotificationSeverity;
|
||||
if (severities.indexOf(lower) < 0) {
|
||||
if (notificationSeverities.indexOf(lower) < 0) {
|
||||
lower = 'normal';
|
||||
}
|
||||
return lower;
|
||||
@@ -219,8 +213,8 @@ export class DatabaseNotificationsStore implements NotificationsStore {
|
||||
} // or match both if undefined
|
||||
|
||||
if (options.minimumSeverity !== undefined) {
|
||||
const idx = severities.indexOf(options.minimumSeverity);
|
||||
const equalOrHigher = severities.slice(0, idx + 1);
|
||||
const idx = notificationSeverities.indexOf(options.minimumSeverity);
|
||||
const equalOrHigher = notificationSeverities.slice(0, idx + 1);
|
||||
query.whereIn('severity', equalOrHigher);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user