Skip to content

Commit

Permalink
adds type guards for backwards compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Aug 16, 2021
1 parent 3fcdb14 commit 370ac1d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,12 @@ export type RuleNameOverride = t.TypeOf<typeof rule_name_override>;
export const ruleNameOverrideOrUndefined = t.union([rule_name_override, t.undefined]);
export type RuleNameOverrideOrUndefined = t.TypeOf<typeof ruleNameOverrideOrUndefined>;

export const status = t.keyof({ open: null, closed: null, acknowledged: null });
export const status = t.keyof({
open: null,
closed: null,
acknowledged: null,
'in-progress': null, // TODO: Remove after `acknowledged` migrations
});
export type Status = t.TypeOf<typeof status>;

export enum RuleExecutionStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({
case 'open':
title = i18n.OPENED_ALERT_SUCCESS_TOAST(updated);
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_SUCCESS_TOAST(updated);
}
Expand All @@ -192,6 +193,7 @@ export const AlertsTableComponent: React.FC<AlertsTableComponentProps> = ({
case 'open':
title = i18n.OPENED_ALERT_FAILED_TOAST;
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_FAILED_TOAST;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const useAlertsActions = ({
case 'open':
title = i18n.OPENED_ALERT_SUCCESS_TOAST(updated);
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_SUCCESS_TOAST(updated);
}
Expand All @@ -82,6 +83,7 @@ export const useAlertsActions = ({
case 'open':
title = i18n.OPENED_ALERT_FAILED_TOAST;
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_FAILED_TOAST;
}
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/timelines/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const DEFAULT_NUMBER_FORMAT = 'format:number:defaultPattern';

export const FILTER_OPEN: AlertStatus = 'open';
export const FILTER_CLOSED: AlertStatus = 'closed';

/**
* @deprecated
* TODO: Remove after `acknowledged` migration
*/
export const FILTER_IN_PROGRESS: AlertStatus = 'in-progress';
export const FILTER_ACKNOWLEDGED: AlertStatus = 'acknowledged';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,10 @@ export interface BulkActionsObjectProp {
}
export type BulkActionsProp = boolean | BulkActionsObjectProp;

export type AlertStatus = 'open' | 'closed' | 'acknowledged';
/**
* @deprecated
* TODO: remove when `acknowledged` migrations are finished
*/
export type InProgressStatus = 'in-progress';

export type AlertStatus = 'open' | 'closed' | 'acknowledged' | InProgressStatus;
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const AlertStatusBulkActionsComponent = React.memo<StatefulAlertStatusBul
case 'open':
title = i18n.OPENED_ALERT_SUCCESS_TOAST(updated);
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_SUCCESS_TOAST(updated);
}
Expand All @@ -122,6 +123,7 @@ export const AlertStatusBulkActionsComponent = React.memo<StatefulAlertStatusBul
case 'open':
title = i18n.OPENED_ALERT_FAILED_TOAST;
break;
case 'in-progress':
case 'acknowledged':
title = i18n.ACKNOWLEDGED_ALERT_FAILED_TOAST;
}
Expand Down

0 comments on commit 370ac1d

Please sign in to comment.