From d4e92765e1238e15766427f6845824d37ef18dff Mon Sep 17 00:00:00 2001 From: Hareet Dhillon Date: Fri, 29 Apr 2022 15:24:21 -0700 Subject: [PATCH] fix(snapshots): remove successful snapshot creation notification handling (#427) * Remove successful snapshot creation notification handling * Add notification categories and mappers for snapshot creation/deletion * Fix active recordings state updating --- src/app/Recordings/ActiveRecordingsTable.tsx | 14 ++++++++++---- src/app/Shared/Services/Api.service.tsx | 4 +--- .../Services/NotificationChannel.service.tsx | 18 +++++++++++++++++- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/app/Recordings/ActiveRecordingsTable.tsx b/src/app/Recordings/ActiveRecordingsTable.tsx index 584c68382..8a4cfb924 100644 --- a/src/app/Recordings/ActiveRecordingsTable.tsx +++ b/src/app/Recordings/ActiveRecordingsTable.tsx @@ -43,10 +43,10 @@ import { ServiceContext } from '@app/Shared/Services/Services'; import { NO_TARGET } from '@app/Shared/Services/Target.service'; import { useSubscriptions} from '@app/utils/useSubscriptions'; import { Button, Checkbox, Label, Text, Toolbar, ToolbarContent, ToolbarItem } from '@patternfly/react-core'; -import { Tbody, Tr, Td, ExpandableRowContent } from '@patternfly/react-table'; +import { Tbody, Tr, Td, ExpandableRowContent } from '@patternfly/react-table'; import * as React from 'react'; import { useHistory, useRouteMatch } from 'react-router-dom'; -import { combineLatest, forkJoin, Observable, of } from 'rxjs'; +import { combineLatest, forkJoin, merge, Observable } from 'rxjs'; import { concatMap, filter, first } from 'rxjs/operators'; import { RecordingActions } from './RecordingActions'; import { RecordingsTable } from './RecordingsTable'; @@ -129,7 +129,10 @@ export const ActiveRecordingsTable: React.FunctionComponent { const currentTarget = parts[0]; @@ -146,7 +149,10 @@ export const ActiveRecordingsTable: React.FunctionComponent { const currentTarget = parts[0]; diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index e8a86494c..df04fea90 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -255,9 +255,7 @@ export class ApiService { method: 'POST', }).pipe( tap(resp => { - if (resp.status == 200) { - this.notifications.success('Recording Created'); - } else if (resp.status == 202) { + if (resp.status == 202) { this.notifications.warning('Snapshot Failed to Create', 'The resultant recording was unreadable for some reason, likely due to a lack of Active, non-Snapshot source recordings to take event data from'); } }), diff --git a/src/app/Shared/Services/NotificationChannel.service.tsx b/src/app/Shared/Services/NotificationChannel.service.tsx index 061dbc834..95e4fbb72 100644 --- a/src/app/Shared/Services/NotificationChannel.service.tsx +++ b/src/app/Shared/Services/NotificationChannel.service.tsx @@ -53,6 +53,8 @@ export enum NotificationCategory { ActiveRecordingStopped = 'ActiveRecordingStopped', ActiveRecordingSaved = 'ActiveRecordingSaved', ActiveRecordingDeleted = 'ActiveRecordingDeleted', + SnapshotCreated = 'SnapshotCreated', + SnapshotDeleted = 'SnapshotDeleted', ArchivedRecordingCreated = 'ArchivedRecordingCreated', ArchivedRecordingDeleted = 'ArchivedRecordingDeleted', TemplateUploaded = 'TemplateUploaded', @@ -119,7 +121,7 @@ export const messageKeys = new Map([ NotificationCategory.ActiveRecordingCreated, { variant: AlertVariant.success, title: 'Recording Created', - body: evt => `${evt.message.recording.name} created in target: ${evt.message.target}`, + body: evt => `${evt.message.recording.name} created in target: ${evt.message.target}` } as NotificationMessageMapper ], [ @@ -143,6 +145,20 @@ export const messageKeys = new Map([ body: evt => `${evt.message.recording.name} was deleted` } as NotificationMessageMapper ], + [ + NotificationCategory.SnapshotCreated, { + variant: AlertVariant.success, + title: 'Snapshot Created', + body: evt => `${evt.message.recording.name} was created in target: ${evt.message.target}` + } as NotificationMessageMapper + ], + [ + NotificationCategory.SnapshotDeleted, { + variant: AlertVariant.success, + title: 'Snapshot Deleted', + body: evt => `${evt.message.recording.name} was deleted` + } as NotificationMessageMapper + ], [ NotificationCategory.ArchivedRecordingCreated, { variant: AlertVariant.success,