diff --git a/src/locales/de-DE/messages.po b/src/locales/de-DE/messages.po index c9263336..fd49c205 100644 --- a/src/locales/de-DE/messages.po +++ b/src/locales/de-DE/messages.po @@ -59,6 +59,21 @@ msgstr "{0} Prüfungen sind fehlgeschlagen." msgid "{0} checks fixed." msgstr "{0} Prüfungen behoben" +#: src/shared/event-button/EventButton.tsx:57 +#: src/shared/event-button/EventButton.tsx:63 +msgid "{0} Cloud account configured, id: {1}" +msgstr "{0} Cloud-Konto konfiguriert, ID: {1}" + +#: src/shared/event-button/EventButton.tsx:69 +#: src/shared/event-button/EventButton.tsx:75 +msgid "{0} Cloud account degraded, id: {1}" +msgstr "{0} Cloud-Konto beeinträchtigt, ID: {1}" + +#: src/shared/event-button/EventButton.tsx:81 +#: src/shared/event-button/EventButton.tsx:87 +msgid "{0} Cloud account discovered, id: {1}" +msgstr "{0} Cloud-Konto entdeckt, ID: {1}" + #: src/pages/panel/workspace-settings-billing/ProductTierComp.tsx:63 msgid "{0} cloud accounts included" msgstr "{0} Cloud-Konten enthalten" @@ -464,18 +479,6 @@ msgstr "Schließen" msgid "Cloud" msgstr "Cloud" -#: src/shared/event-button/EventButton.tsx:57 -msgid "Cloud account configured, id: {0}" -msgstr "Cloud-Konto konfiguriert, ID: {0}" - -#: src/shared/event-button/EventButton.tsx:63 -msgid "Cloud account degraded, id: {0}" -msgstr "Cloud-Konto beeinträchtigt, ID: {0}" - -#: src/shared/event-button/EventButton.tsx:69 -msgid "Cloud account discovered, id: {0}" -msgstr "Cloud-Konto entdeckt, ID: {0}" - #: src/shared/layouts/panel-layout/PanelBreadcrumbs.tsx:14 msgid "Cloud Setup" msgstr "Cloud Setup" @@ -765,7 +768,7 @@ msgstr "Engineers kennzeichnen ihre temporären Ressourcen gerne mit der Zeichen msgid "Enterprise" msgstr "Unternehmen" -#: src/shared/event-button/EventButton.tsx:103 +#: src/shared/event-button/EventButton.tsx:121 msgid "Events" msgstr "Veranstaltungen" diff --git a/src/locales/en-US/messages.po b/src/locales/en-US/messages.po index 29db6e8e..e9837abc 100644 --- a/src/locales/en-US/messages.po +++ b/src/locales/en-US/messages.po @@ -59,6 +59,21 @@ msgstr "{0} checks failed." msgid "{0} checks fixed." msgstr "{0} checks fixed." +#: src/shared/event-button/EventButton.tsx:57 +#: src/shared/event-button/EventButton.tsx:63 +msgid "{0} Cloud account configured, id: {1}" +msgstr "{0} Cloud account configured, id: {1}" + +#: src/shared/event-button/EventButton.tsx:69 +#: src/shared/event-button/EventButton.tsx:75 +msgid "{0} Cloud account degraded, id: {1}" +msgstr "{0} Cloud account degraded, id: {1}" + +#: src/shared/event-button/EventButton.tsx:81 +#: src/shared/event-button/EventButton.tsx:87 +msgid "{0} Cloud account discovered, id: {1}" +msgstr "{0} Cloud account discovered, id: {1}" + #: src/pages/panel/workspace-settings-billing/ProductTierComp.tsx:63 msgid "{0} cloud accounts included" msgstr "{0} cloud accounts included" @@ -464,18 +479,6 @@ msgstr "Close" msgid "Cloud" msgstr "Cloud" -#: src/shared/event-button/EventButton.tsx:57 -msgid "Cloud account configured, id: {0}" -msgstr "Cloud account configured, id: {0}" - -#: src/shared/event-button/EventButton.tsx:63 -msgid "Cloud account degraded, id: {0}" -msgstr "Cloud account degraded, id: {0}" - -#: src/shared/event-button/EventButton.tsx:69 -msgid "Cloud account discovered, id: {0}" -msgstr "Cloud account discovered, id: {0}" - #: src/shared/layouts/panel-layout/PanelBreadcrumbs.tsx:14 msgid "Cloud Setup" msgstr "Cloud Setup" @@ -765,7 +768,7 @@ msgstr "Engineers like to tag their temporary resources with the string \"delete msgid "Enterprise" msgstr "Enterprise" -#: src/shared/event-button/EventButton.tsx:103 +#: src/shared/event-button/EventButton.tsx:121 msgid "Events" msgstr "Events" diff --git a/src/pages/panel/setup-cloud/SetupCloudPage.tsx b/src/pages/panel/setup-cloud/SetupCloudPage.tsx index c258e2ee..78c55346 100644 --- a/src/pages/panel/setup-cloud/SetupCloudPage.tsx +++ b/src/pages/panel/setup-cloud/SetupCloudPage.tsx @@ -27,7 +27,7 @@ export default function SetupCloud() { useEffect(() => { return addListener('event-button', (ev) => { - if (ev.kind === 'aws_account_discovered') { + if (ev.kind === 'aws_account_discovered' || ev.kind === 'cloud_account_discovered') { navigate(hasBenchmark ? '/accounts' : '/security') } }) diff --git a/src/shared/event-button/EventButton.tsx b/src/shared/event-button/EventButton.tsx index f2e9de12..865ffee7 100644 --- a/src/shared/event-button/EventButton.tsx +++ b/src/shared/event-button/EventButton.tsx @@ -50,23 +50,55 @@ export const EventButton = () => { predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace'), }) break - case 'aws_account_configured': + case 'cloud_account_configured': void queryClient.invalidateQueries({ predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), }) - void showSnackbar(t`Cloud account configured, id: ${ev.data.aws_account_id}`, { severity: 'success', autoHideDuration: null }) + void showSnackbar(t`${ev.data.cloud.toUpperCase()} Cloud account configured, id: ${ev.data.account_id}`, { + severity: 'success', + autoHideDuration: null, + }) + break + case 'aws_account_configured': // TODO: remove aws specific events + void queryClient.invalidateQueries({ + predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), + }) + void showSnackbar(t`${ev.data.aws_account_id ? 'AWS' : ''} Cloud account configured, id: ${ev.data.aws_account_id}`, { + severity: 'success', + autoHideDuration: null, + }) + break + case 'cloud_account_degraded': + void queryClient.invalidateQueries({ + predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), + }) + void showSnackbar(t`${ev.data.cloud.toUpperCase()} Cloud account degraded, id: ${ev.data.account_id}`, { + severity: 'warning', + autoHideDuration: null, + }) break case 'aws_account_degraded': void queryClient.invalidateQueries({ predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), }) - void showSnackbar(t`Cloud account degraded, id: ${ev.data.aws_account_id}`, { severity: 'warning', autoHideDuration: null }) + void showSnackbar(t`${ev.data.aws_account_id ? 'AWS' : ''} Cloud account degraded, id: ${ev.data.aws_account_id}`, { + severity: 'warning', + autoHideDuration: null, + }) + break + case 'cloud_account_discovered': + void queryClient.invalidateQueries({ + predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), + }) + void showSnackbar(t`${ev.data.cloud.toUpperCase()} Cloud account discovered, id: ${ev.data.account_id}`, { severity: 'info' }) break case 'aws_account_discovered': void queryClient.invalidateQueries({ predicate: (query) => typeof query.queryKey[0] === 'string' && query.queryKey[0].startsWith('workspace-cloud-accounts'), }) - void showSnackbar(t`Cloud account discovered, id: ${ev.data.aws_account_id}`, { severity: 'info' }) + void showSnackbar(t`${ev.data.aws_account_id ? 'AWS' : ''} Cloud account discovered, id: ${ev.data.aws_account_id}`, { + severity: 'info', + }) break case 'collect-error': void queryClient.invalidateQueries({ @@ -100,7 +132,7 @@ export const EventButton = () => { return hasNoEvents ? null : ( - + diff --git a/src/shared/event-button/EventItem.stories.tsx b/src/shared/event-button/EventItem.stories.tsx index 2ab82a2a..a8dddcce 100644 --- a/src/shared/event-button/EventItem.stories.tsx +++ b/src/shared/event-button/EventItem.stories.tsx @@ -14,7 +14,16 @@ const meta = { at: { control: 'date' }, id: { control: 'text' }, kind: { - options: ['aws_account_discovered', 'aws_account_configured', 'aws_account_deleted', 'aws_account_degraded'], + options: [ + 'cloud_account_discovered', + 'aws_account_discovered', + 'cloud_account_configured', + 'aws_account_configured', + 'cloud_account_deleted', + 'aws_account_deleted', + 'cloud_account_degraded', + 'aws_account_degraded', + ], }, publisher: { control: 'text' }, data: { diff --git a/src/shared/event-button/EventItem.tsx b/src/shared/event-button/EventItem.tsx index b381df81..23b122d8 100644 --- a/src/shared/event-button/EventItem.tsx +++ b/src/shared/event-button/EventItem.tsx @@ -8,14 +8,19 @@ interface EventItemProps { } const getSeverity = (kind: WebSocketEvent['kind']): AlertProps['severity'] => { + // TODO: remove aws specific events switch (kind) { + case 'cloud_account_configured': case 'aws_account_configured': return 'success' + case 'cloud_account_degraded': case 'aws_account_degraded': return 'warning' + case 'cloud_account_discovered': case 'aws_account_discovered': case 'collect-progress': return 'info' + case 'cloud_account_deleted': case 'aws_account_deleted': case 'collect-error': return 'error' diff --git a/src/shared/types/server/web-socket-event/WebSocketEvent.ts b/src/shared/types/server/web-socket-event/WebSocketEvent.ts index d7c5f827..5d2b1a2c 100644 --- a/src/shared/types/server/web-socket-event/WebSocketEvent.ts +++ b/src/shared/types/server/web-socket-event/WebSocketEvent.ts @@ -6,21 +6,29 @@ interface WebSocketGenericEvent @@ -33,6 +41,16 @@ export type AWSAccountConfiguredEvent = WebSocketGenericEvent< } > +export type CloudAccountDeletedEvent = WebSocketGenericEvent< + 'cloud_account_deleted', + { + cloud: CloudAccountType + cloud_account_id: string + workspace_id: string + account_id: string + } +> + export type AWSAccountDeletedEvent = WebSocketGenericEvent< 'aws_account_deleted', { @@ -42,6 +60,35 @@ export type AWSAccountDeletedEvent = WebSocketGenericEvent< } > +export type CloudAccountDiscoveredEvent = WebSocketGenericEvent< + 'cloud_account_discovered', + { + cloud: CloudAccountType + cloud_account_id: string + workspace_id: string + account_id: string + } +> + +export type AWSAccountDiscoveredEvent = WebSocketGenericEvent< + 'aws_account_discovered', + { + cloud_account_id: string + workspace_id: string + aws_account_id: string + } +> + +export type CloudAccountDegradedEvent = WebSocketGenericEvent< + 'cloud_account_degraded', + { + cloud: CloudAccountType + cloud_account_id: string + workspace_id: string + account_id: string + } +> + export type AWSAccountDegradedEvent = WebSocketGenericEvent< 'aws_account_degraded', { @@ -51,7 +98,7 @@ export type AWSAccountDegradedEvent = WebSocketGenericEvent< } > -export type AWSTenantAccountCollectedEvent = WebSocketGenericEvent< +export type TenantAccountCollectedEvent = WebSocketGenericEvent< 'tenant_accounts_collected', { tenant_id: string @@ -98,10 +145,14 @@ export type CollectErrorEvent = WebSocketGenericEvent< > export type WebSocketEvent = + | CloudAccountConfiguredEvent | AWSAccountConfiguredEvent + | CloudAccountDegradedEvent | AWSAccountDegradedEvent + | CloudAccountDeletedEvent | AWSAccountDeletedEvent + | CloudAccountDiscoveredEvent | AWSAccountDiscoveredEvent - | AWSTenantAccountCollectedEvent + | TenantAccountCollectedEvent | CollectProgressEvent | CollectErrorEvent diff --git a/src/shared/types/server/web-socket-event/index.ts b/src/shared/types/server/web-socket-event/index.ts index b2c0ba3d..c29ded21 100644 --- a/src/shared/types/server/web-socket-event/index.ts +++ b/src/shared/types/server/web-socket-event/index.ts @@ -3,6 +3,8 @@ export type { AWSAccountDegradedEvent, AWSAccountDeletedEvent, AWSAccountDiscoveredEvent, + CloudAccountConfiguredEvent, + CloudAccountDeletedEvent, CollectErrorEvent, CollectProgressEvent, WebSocketEvent,