Skip to content

Commit

Permalink
Revert "remove WsClientActivity notifications"
Browse files Browse the repository at this point in the history
This reverts commit 0375352.
  • Loading branch information
andrewazores committed Dec 21, 2023
1 parent 05392e1 commit 4381211
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/app/Shared/Services/NotificationChannel.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class NotificationChannel {
fn.apply(this.notifications, [
'WebSocket connection lost',
msg,
'Client Status',
NotificationCategory.WsClientActivity,
fn === this.notifications.info,
]);
},
Expand Down
13 changes: 11 additions & 2 deletions src/app/Shared/Services/Notifications.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ export class NotificationService {

cryostatStatusNotifications(): Observable<Notification[]> {
return this.notifications().pipe(
map((a) => a.filter((n) => this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n))),
map((a) =>
a.filter(
(n) =>
(this.isWsClientActivity(n) || this.isJvmDiscovery(n)) && !NotificationService.isProblemNotification(n),
),
),
);
}

Expand Down Expand Up @@ -148,7 +153,11 @@ export class NotificationService {
}

private isActionNotification(n: Notification): boolean {
return !this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n);
return !this.isWsClientActivity(n) && !this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n);
}

private isWsClientActivity(n: Notification): boolean {
return n.category === NotificationCategory.WsClientActivity;
}

private isJvmDiscovery(n: Notification): boolean {
Expand Down
1 change: 1 addition & 0 deletions src/app/Shared/Services/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export interface Notification {
}

export enum NotificationCategory {
WsClientActivity = 'WsClientActivity',
TargetJvmDiscovery = 'TargetJvmDiscovery',
ActiveRecordingCreated = 'ActiveRecordingCreated',
ActiveRecordingStopped = 'ActiveRecordingStopped',
Expand Down
13 changes: 13 additions & 0 deletions src/app/Shared/Services/api.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ export const messageKeys = new Map([
},
} as NotificationMessageMapper,
],
[
NotificationCategory.WsClientActivity,
{
variant: AlertVariant.info,
title: 'WebSocket Client Activity',
body: (evt) => {
const addr = Object.keys(evt.message)[0];
const status = evt.message[addr];
return `Client at ${addr} ${status}`;
},
hidden: true,
} as NotificationMessageMapper,
],
[
NotificationCategory.ActiveRecordingCreated,
{
Expand Down
20 changes: 19 additions & 1 deletion src/mirage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@ export const startMirage = ({ environment = 'development' } = {}) => {

// Create a mock server socket to send notifications
let websocket: Client;
wsServer.on('connection', (_) => {});
wsServer.on('connection', (socket) => {
websocket = socket;
socket.on('message', (_) => {
socket.send(
JSON.stringify({
meta: {
category: 'WsClientActivity',
type: {
type: 'application',
subtype: 'json',
},
},
message: {
'127.0.0.1': 'accepted',
},
}),
);
});
});

// Create a MirageJS Server to intercept network requests
return createServer({
Expand Down
12 changes: 6 additions & 6 deletions src/test/Settings/NotificationControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ describe('<NotificationControl/>', () => {

await user.click(expandButton);

const targetDiscovery = screen.getByLabelText('Target JVM Discovery');
expect(targetDiscovery).toBeInTheDocument();
expect(targetDiscovery).toBeVisible();
expect(targetDiscovery).toBeChecked();
const webSocketAct = screen.getByLabelText('WebSocket Client Activity');
expect(webSocketAct).toBeInTheDocument();
expect(webSocketAct).toBeVisible();
expect(webSocketAct).toBeChecked();

await user.click(targetDiscovery);
await user.click(webSocketAct);

expect(targetDiscovery).not.toBeChecked();
expect(webSocketAct).not.toBeChecked();
expect(enableSwitch).not.toBeChecked();
});
});
87 changes: 63 additions & 24 deletions src/test/Settings/__snapshots__/NotificationControl.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,45 @@ exports[`<NotificationControl/> renders correctly 1`] = `
data-ouia-component-id="OUIA-Generated-Switch-2"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="WsClientActivity"
>
<input
aria-label=""
aria-labelledby="WsClientActivity-on"
checked={true}
className="pf-c-switch__input"
disabled={false}
id="WsClientActivity"
onChange={[Function]}
type="checkbox"
/>
<span
className="pf-c-switch__toggle"
/>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-on"
id="WsClientActivity-on"
>
WebSocket Client Activity
</span>
<span
aria-hidden="true"
className="pf-c-switch__label pf-m-off"
id="WsClientActivity-off"
>
WebSocket Client Activity
</span>
</label>
</div>
<div
className="pf-l-stack__item"
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-3"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="TargetJvmDiscovery"
>
<input
Expand Down Expand Up @@ -275,7 +314,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-3"
data-ouia-component-id="OUIA-Generated-Switch-4"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ActiveRecordingCreated"
Expand Down Expand Up @@ -314,7 +353,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-4"
data-ouia-component-id="OUIA-Generated-Switch-5"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ActiveRecordingStopped"
Expand Down Expand Up @@ -353,7 +392,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-5"
data-ouia-component-id="OUIA-Generated-Switch-6"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ActiveRecordingSaved"
Expand Down Expand Up @@ -392,7 +431,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-6"
data-ouia-component-id="OUIA-Generated-Switch-7"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ActiveRecordingDeleted"
Expand Down Expand Up @@ -431,7 +470,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-7"
data-ouia-component-id="OUIA-Generated-Switch-8"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="SnapshotCreated"
Expand Down Expand Up @@ -470,7 +509,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-8"
data-ouia-component-id="OUIA-Generated-Switch-9"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="SnapshotDeleted"
Expand Down Expand Up @@ -509,7 +548,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-9"
data-ouia-component-id="OUIA-Generated-Switch-10"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ArchivedRecordingCreated"
Expand Down Expand Up @@ -548,7 +587,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-10"
data-ouia-component-id="OUIA-Generated-Switch-11"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ArchivedRecordingDeleted"
Expand Down Expand Up @@ -587,7 +626,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-11"
data-ouia-component-id="OUIA-Generated-Switch-12"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="TemplateUploaded"
Expand Down Expand Up @@ -626,7 +665,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-12"
data-ouia-component-id="OUIA-Generated-Switch-13"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="TemplateDeleted"
Expand Down Expand Up @@ -665,7 +704,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-13"
data-ouia-component-id="OUIA-Generated-Switch-14"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ProbeTemplateUploaded"
Expand Down Expand Up @@ -704,7 +743,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-14"
data-ouia-component-id="OUIA-Generated-Switch-15"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ProbeTemplateDeleted"
Expand Down Expand Up @@ -743,7 +782,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-15"
data-ouia-component-id="OUIA-Generated-Switch-16"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ProbeTemplateApplied"
Expand Down Expand Up @@ -782,7 +821,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-16"
data-ouia-component-id="OUIA-Generated-Switch-17"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="ProbesRemoved"
Expand Down Expand Up @@ -821,7 +860,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-17"
data-ouia-component-id="OUIA-Generated-Switch-18"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="RuleCreated"
Expand Down Expand Up @@ -860,7 +899,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-18"
data-ouia-component-id="OUIA-Generated-Switch-19"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="RuleUpdated"
Expand Down Expand Up @@ -899,7 +938,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-19"
data-ouia-component-id="OUIA-Generated-Switch-20"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="RuleDeleted"
Expand Down Expand Up @@ -938,7 +977,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-20"
data-ouia-component-id="OUIA-Generated-Switch-21"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="RecordingMetadataUpdated"
Expand Down Expand Up @@ -977,7 +1016,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-21"
data-ouia-component-id="OUIA-Generated-Switch-22"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="GrafanaConfiguration"
Expand Down Expand Up @@ -1016,7 +1055,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-22"
data-ouia-component-id="OUIA-Generated-Switch-23"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="LayoutTemplateCreated"
Expand Down Expand Up @@ -1055,7 +1094,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-23"
data-ouia-component-id="OUIA-Generated-Switch-24"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="TargetCredentialsStored"
Expand Down Expand Up @@ -1094,7 +1133,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-24"
data-ouia-component-id="OUIA-Generated-Switch-25"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="TargetCredentialsDeleted"
Expand Down Expand Up @@ -1133,7 +1172,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-25"
data-ouia-component-id="OUIA-Generated-Switch-26"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="CredentialsStored"
Expand Down Expand Up @@ -1172,7 +1211,7 @@ exports[`<NotificationControl/> renders correctly 1`] = `
>
<label
className="pf-c-switch"
data-ouia-component-id="OUIA-Generated-Switch-26"
data-ouia-component-id="OUIA-Generated-Switch-27"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="CredentialsDeleted"
Expand Down

0 comments on commit 4381211

Please sign in to comment.