@backstage/plugin-notifications 0.5.8-next.2 → 0.5.9-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/alpha.d.ts +3 -3
  3. package/dist/alpha.esm.js +1 -1
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/api/NotificationsApi.esm.js.map +1 -1
  6. package/dist/api/NotificationsClient.esm.js.map +1 -1
  7. package/dist/components/NotificationsFilters/NotificationsFilters.esm.js.map +1 -1
  8. package/dist/components/NotificationsPage/NotificationsPage.esm.js.map +1 -1
  9. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js +32 -18
  10. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js.map +1 -1
  11. package/dist/components/NotificationsTable/BulkActions.esm.js.map +1 -1
  12. package/dist/components/NotificationsTable/NotificationIcon.esm.js.map +1 -1
  13. package/dist/components/NotificationsTable/NotificationsTable.esm.js.map +1 -1
  14. package/dist/components/NotificationsTable/SelectAll.esm.js.map +1 -1
  15. package/dist/components/NotificationsTable/SeverityIcon.esm.js.map +1 -1
  16. package/dist/components/UserNotificationSettingsCard/NoBorderTableCell.esm.js.map +1 -1
  17. package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js +2 -2
  18. package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js.map +1 -1
  19. package/dist/components/UserNotificationSettingsCard/TopicRow.esm.js.map +1 -1
  20. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsCard.esm.js.map +1 -1
  21. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.esm.js +30 -26
  22. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.esm.js.map +1 -1
  23. package/dist/hooks/useNotificationsApi.esm.js.map +1 -1
  24. package/dist/hooks/useTitleCounter.esm.js.map +1 -1
  25. package/dist/hooks/useWebNotifications.esm.js.map +1 -1
  26. package/dist/index.d.ts +34 -4
  27. package/dist/package.json.esm.js +1 -1
  28. package/dist/plugin.esm.js +1 -1
  29. package/dist/plugin.esm.js.map +1 -1
  30. package/dist/routes.esm.js.map +1 -1
  31. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @backstage/plugin-notifications
2
2
 
3
+ ## 0.5.9-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/core-compat-api@0.5.2-next.0
9
+ - @backstage/core-components@0.17.5
10
+ - @backstage/core-plugin-api@1.10.9
11
+ - @backstage/errors@1.2.7
12
+ - @backstage/frontend-plugin-api@0.11.0
13
+ - @backstage/theme@0.6.8
14
+ - @backstage/types@1.2.1
15
+ - @backstage/plugin-notifications-common@0.1.0
16
+ - @backstage/plugin-signals-react@0.0.15
17
+
18
+ ## 0.5.8
19
+
20
+ ### Patch Changes
21
+
22
+ - e4ddf22: Internal update to align with new blueprint parameter naming in the new frontend system.
23
+ - f2f133c: Internal update to use the new variant of `ApiBlueprint`.
24
+ - 5a70981: Fix duplicate notification origins with multiple channels
25
+ - 8a24e0f: Improve customization of the notification snackbar.
26
+
27
+ Users can now customize the notification snackbar by providing custom components and icons
28
+ for different severity levels. Additionally, the location of the snackbar notifications
29
+ can be modified, the density of the snackbar can be changed, and the number of snacks can
30
+ be limited.
31
+
32
+ - Updated dependencies
33
+ - @backstage/core-components@0.17.5
34
+ - @backstage/frontend-plugin-api@0.11.0
35
+ - @backstage/core-compat-api@0.5.0
36
+ - @backstage/theme@0.6.8
37
+ - @backstage/plugin-notifications-common@0.1.0
38
+
3
39
  ## 0.5.8-next.2
4
40
 
5
41
  ### Patch Changes
package/dist/alpha.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import * as react from 'react';
1
+ import * as React from 'react';
2
2
  import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
3
3
 
4
4
  /** @alpha */
5
- declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
5
+ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin<{
6
6
  root: _backstage_frontend_plugin_api.RouteRef<undefined>;
7
7
  }, {}, {
8
8
  "api:notifications": _backstage_frontend_plugin_api.ExtensionDefinition<{
@@ -23,7 +23,7 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
23
23
  configInput: {
24
24
  path?: string | undefined;
25
25
  };
26
- output: _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
26
+ output: _backstage_frontend_plugin_api.ExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<React.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
27
27
  optional: true;
28
28
  }>;
29
29
  inputs: {};
package/dist/alpha.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { PageBlueprint, ApiBlueprint, discoveryApiRef, fetchApiRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
2
+ import { PageBlueprint, ApiBlueprint, fetchApiRef, discoveryApiRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
3
3
  import { rootRouteRef } from './routes.esm.js';
4
4
  import { convertLegacyRouteRef, convertLegacyRouteRefs } from '@backstage/core-compat-api';
5
5
  import { notificationsApiRef } from './api/NotificationsApi.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n PageBlueprint,\n createFrontendPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { rootRouteRef } from './routes';\nimport {\n convertLegacyRouteRef,\n convertLegacyRouteRefs,\n} from '@backstage/core-compat-api';\nimport { NotificationsClient, notificationsApiRef } from './api';\n\nconst page = PageBlueprint.make({\n params: {\n path: '/notifications',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/NotificationsPage').then(m => (\n <m.NotificationsPage />\n )),\n },\n});\n\nconst api = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'notifications',\n info: { packageJson: () => import('../package.json') },\n routes: convertLegacyRouteRefs({\n root: rootRouteRef,\n }),\n // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually\n extensions: [page, api],\n});\n"],"names":[],"mappings":";;;;;;;AA8BA,MAAM,IAAA,GAAO,cAAc,IAAK,CAAA;AAAA,EAC9B,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,gBAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,MAAA,EAAQ,MACN,OAAO,6CAAgC,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,qBAC3C,GAAA,CAAA,CAAA,CAAE,iBAAF,EAAA,EAAoB,CACtB;AAAA;AAEP,CAAC,CAAA;AAED,MAAM,GAAA,GAAM,aAAa,IAAK,CAAA;AAAA,EAC5B,MAAA,EAAQ,kBACN,YAAa,CAAA;AAAA,IACX,GAAK,EAAA,mBAAA;AAAA,IACL,IAAM,EAAA,EAAE,YAAc,EAAA,eAAA,EAAiB,UAAU,WAAY,EAAA;AAAA,IAC7D,OAAA,EAAS,CAAC,EAAE,YAAc,EAAA,QAAA,EACxB,KAAA,IAAI,mBAAoB,CAAA,EAAE,YAAc,EAAA,QAAA,EAAU;AAAA,GACrD;AACL,CAAC,CAAA;AAGD,YAAe,oBAAqB,CAAA;AAAA,EAClC,QAAU,EAAA,eAAA;AAAA,EACV,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAE,EAAA;AAAA,EACrD,QAAQ,sBAAuB,CAAA;AAAA,IAC7B,IAAM,EAAA;AAAA,GACP,CAAA;AAAA;AAAA,EAED,UAAA,EAAY,CAAC,IAAA,EAAM,GAAG;AACxB,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n PageBlueprint,\n createFrontendPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { rootRouteRef } from './routes';\nimport {\n convertLegacyRouteRef,\n convertLegacyRouteRefs,\n} from '@backstage/core-compat-api';\nimport { NotificationsClient, notificationsApiRef } from './api';\n\nconst page = PageBlueprint.make({\n params: {\n path: '/notifications',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/NotificationsPage').then(m => (\n <m.NotificationsPage />\n )),\n },\n});\n\nconst api = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'notifications',\n info: { packageJson: () => import('../package.json') },\n routes: convertLegacyRouteRefs({\n root: rootRouteRef,\n }),\n // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually\n extensions: [page, api],\n});\n"],"names":[],"mappings":";;;;;;;AA8BA,MAAM,IAAA,GAAO,cAAc,IAAA,CAAK;AAAA,EAC9B,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,gBAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,MAAA,EAAQ,MACN,OAAO,6CAAgC,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAC5C,GAAA,CAAC,CAAA,CAAE,iBAAA,EAAF,EAAoB,CACtB;AAAA;AAEP,CAAC,CAAA;AAED,MAAM,GAAA,GAAM,aAAa,IAAA,CAAK;AAAA,EAC5B,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,mBAAA;AAAA,IACL,IAAA,EAAM,EAAE,YAAA,EAAc,eAAA,EAAiB,UAAU,WAAA,EAAY;AAAA,IAC7D,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,QAAA,EAAS,KACjC,IAAI,mBAAA,CAAoB,EAAE,YAAA,EAAc,QAAA,EAAU;AAAA,GACrD;AACL,CAAC,CAAA;AAGD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,eAAA;AAAA,EACV,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAA,EAAE;AAAA,EACrD,QAAQ,sBAAA,CAAuB;AAAA,IAC7B,IAAA,EAAM;AAAA,GACP,CAAA;AAAA;AAAA,EAED,UAAA,EAAY,CAAC,IAAA,EAAM,GAAG;AACxB,CAAC,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsApi.esm.js","sources":["../../src/api/NotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationSettings,\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport const notificationsApiRef = createApiRef<NotificationsApi>({\n id: 'plugin.notifications.service',\n});\n\n/** @public */\nexport type GetNotificationsCommonOptions = {\n search?: string;\n read?: boolean;\n saved?: boolean;\n createdAfter?: Date;\n minimumSeverity?: NotificationSeverity;\n};\n\n/** @public */\nexport type GetNotificationsOptions = GetNotificationsCommonOptions & {\n offset?: number;\n limit?: number;\n sort?: 'created' | 'topic' | 'origin';\n sortOrder?: 'asc' | 'desc';\n topic?: string;\n};\n\n/** @public */\nexport type GetTopicsOptions = GetNotificationsCommonOptions;\n\n/** @public */\nexport type UpdateNotificationsOptions = {\n ids: string[];\n read?: boolean;\n saved?: boolean;\n};\n\n/** @public */\nexport type GetNotificationsResponse = {\n notifications: Notification[];\n totalCount: number;\n};\n\n/** @public */\nexport type GetTopicsResponse = {\n topics: string[];\n};\n\n/** @public */\nexport interface NotificationsApi {\n getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse>;\n\n getNotification(id: string): Promise<Notification>;\n\n getStatus(): Promise<NotificationStatus>;\n\n updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]>;\n\n getNotificationSettings(): Promise<NotificationSettings>;\n\n updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings>;\n\n getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse>;\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"NotificationsApi.esm.js","sources":["../../src/api/NotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationSettings,\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport const notificationsApiRef = createApiRef<NotificationsApi>({\n id: 'plugin.notifications.service',\n});\n\n/** @public */\nexport type GetNotificationsCommonOptions = {\n search?: string;\n read?: boolean;\n saved?: boolean;\n createdAfter?: Date;\n minimumSeverity?: NotificationSeverity;\n};\n\n/** @public */\nexport type GetNotificationsOptions = GetNotificationsCommonOptions & {\n offset?: number;\n limit?: number;\n sort?: 'created' | 'topic' | 'origin';\n sortOrder?: 'asc' | 'desc';\n topic?: string;\n};\n\n/** @public */\nexport type GetTopicsOptions = GetNotificationsCommonOptions;\n\n/** @public */\nexport type UpdateNotificationsOptions = {\n ids: string[];\n read?: boolean;\n saved?: boolean;\n};\n\n/** @public */\nexport type GetNotificationsResponse = {\n notifications: Notification[];\n totalCount: number;\n};\n\n/** @public */\nexport type GetTopicsResponse = {\n topics: string[];\n};\n\n/** @public */\nexport interface NotificationsApi {\n getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse>;\n\n getNotification(id: string): Promise<Notification>;\n\n getStatus(): Promise<NotificationStatus>;\n\n updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]>;\n\n getNotificationSettings(): Promise<NotificationSettings>;\n\n updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings>;\n\n getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse>;\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,sBAAsB,YAAA,CAA+B;AAAA,EAChE,EAAA,EAAI;AACN,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsClient.esm.js","sources":["../../src/api/NotificationsClient.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n GetNotificationsCommonOptions,\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsOptions,\n GetTopicsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\n NotificationSettings,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport class NotificationsClient implements NotificationsApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n public constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse> {\n const queryString = new URLSearchParams();\n if (options?.limit !== undefined) {\n queryString.append('limit', options.limit.toString(10));\n }\n if (options?.offset !== undefined) {\n queryString.append('offset', options.offset.toString(10));\n }\n if (options?.sort !== undefined) {\n queryString.append(\n 'orderField',\n `${options.sort},${options?.sortOrder ?? 'desc'}`,\n );\n }\n\n this.appendCommonQueryStrings(queryString, options);\n\n if (options?.topic !== undefined) {\n queryString.append('topic', options.topic);\n }\n\n return await this.request<GetNotificationsResponse>(\n `/notifications?${queryString}`,\n );\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(\n `/notifications/${encodeURIComponent(id)}`,\n );\n }\n\n async getStatus(): Promise<NotificationStatus> {\n return await this.request<NotificationStatus>('/status');\n }\n\n async updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]> {\n return await this.request<Notification[]>('/notifications/update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getNotificationSettings(): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings');\n }\n\n async updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings', {\n method: 'POST',\n body: JSON.stringify(settings),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse> {\n const queryString = new URLSearchParams();\n this.appendCommonQueryStrings(queryString, options);\n\n return await this.request<GetTopicsResponse>(`/topics?${queryString}`);\n }\n\n private appendCommonQueryStrings(\n queryString: URLSearchParams,\n options?: GetNotificationsCommonOptions,\n ) {\n if (options?.search) {\n queryString.append('search', options.search);\n }\n if (options?.read !== undefined) {\n queryString.append('read', options.read ? 'true' : 'false');\n }\n if (options?.saved !== undefined) {\n queryString.append('saved', options.saved ? 'true' : 'false');\n }\n if (options?.createdAfter !== undefined) {\n queryString.append('createdAfter', options.createdAfter.toISOString());\n }\n if (options?.minimumSeverity !== undefined) {\n queryString.append('minimumSeverity', options.minimumSeverity);\n }\n }\n\n private async request<T>(path: string, init?: RequestInit): Promise<T> {\n const baseUrl = await this.discoveryApi.getBaseUrl('notifications');\n const res = await this.fetchApi.fetch(`${baseUrl}${path}`, init);\n\n if (!res.ok) {\n throw await ResponseError.fromResponse(res);\n }\n\n return res.json() as Promise<T>;\n }\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EAEV,YAAY,OAGhB,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AAAA;AAC1B,EAEA,MAAM,iBACJ,OACmC,EAAA;AACnC,IAAM,MAAA,WAAA,GAAc,IAAI,eAAgB,EAAA;AACxC,IAAI,IAAA,OAAA,EAAS,UAAU,KAAW,CAAA,EAAA;AAChC,MAAA,WAAA,CAAY,OAAO,OAAS,EAAA,OAAA,CAAQ,KAAM,CAAA,QAAA,CAAS,EAAE,CAAC,CAAA;AAAA;AAExD,IAAI,IAAA,OAAA,EAAS,WAAW,KAAW,CAAA,EAAA;AACjC,MAAA,WAAA,CAAY,OAAO,QAAU,EAAA,OAAA,CAAQ,MAAO,CAAA,QAAA,CAAS,EAAE,CAAC,CAAA;AAAA;AAE1D,IAAI,IAAA,OAAA,EAAS,SAAS,KAAW,CAAA,EAAA;AAC/B,MAAY,WAAA,CAAA,MAAA;AAAA,QACV,YAAA;AAAA,QACA,GAAG,OAAQ,CAAA,IAAI,CAAI,CAAA,EAAA,OAAA,EAAS,aAAa,MAAM,CAAA;AAAA,OACjD;AAAA;AAGF,IAAK,IAAA,CAAA,wBAAA,CAAyB,aAAa,OAAO,CAAA;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AM,aAAc,CAAA,YAAA,CAAa,GAAG,CAAA;AAAA;AAG5C,IAAA,OAAO,IAAI,IAAK,EAAA;AAAA;AAEpB;;;;"}
1
+ {"version":3,"file":"NotificationsClient.esm.js","sources":["../../src/api/NotificationsClient.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n GetNotificationsCommonOptions,\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsOptions,\n GetTopicsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\n NotificationSettings,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport class NotificationsClient implements NotificationsApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n public constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse> {\n const queryString = new URLSearchParams();\n if (options?.limit !== undefined) {\n queryString.append('limit', options.limit.toString(10));\n }\n if (options?.offset !== undefined) {\n queryString.append('offset', options.offset.toString(10));\n }\n if (options?.sort !== undefined) {\n queryString.append(\n 'orderField',\n `${options.sort},${options?.sortOrder ?? 'desc'}`,\n );\n }\n\n this.appendCommonQueryStrings(queryString, options);\n\n if (options?.topic !== undefined) {\n queryString.append('topic', options.topic);\n }\n\n return await this.request<GetNotificationsResponse>(\n `/notifications?${queryString}`,\n );\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(\n `/notifications/${encodeURIComponent(id)}`,\n );\n }\n\n async getStatus(): Promise<NotificationStatus> {\n return await this.request<NotificationStatus>('/status');\n }\n\n async updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]> {\n return await this.request<Notification[]>('/notifications/update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getNotificationSettings(): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings');\n }\n\n async updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings', {\n method: 'POST',\n body: JSON.stringify(settings),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse> {\n const queryString = new URLSearchParams();\n this.appendCommonQueryStrings(queryString, options);\n\n return await this.request<GetTopicsResponse>(`/topics?${queryString}`);\n }\n\n private appendCommonQueryStrings(\n queryString: URLSearchParams,\n options?: GetNotificationsCommonOptions,\n ) {\n if (options?.search) {\n queryString.append('search', options.search);\n }\n if (options?.read !== undefined) {\n queryString.append('read', options.read ? 'true' : 'false');\n }\n if (options?.saved !== undefined) {\n queryString.append('saved', options.saved ? 'true' : 'false');\n }\n if (options?.createdAfter !== undefined) {\n queryString.append('createdAfter', options.createdAfter.toISOString());\n }\n if (options?.minimumSeverity !== undefined) {\n queryString.append('minimumSeverity', options.minimumSeverity);\n }\n }\n\n private async request<T>(path: string, init?: RequestInit): Promise<T> {\n const baseUrl = await this.discoveryApi.getBaseUrl('notifications');\n const res = await this.fetchApi.fetch(`${baseUrl}${path}`, init);\n\n if (!res.ok) {\n throw await ResponseError.fromResponse(res);\n }\n\n return res.json() as Promise<T>;\n }\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,mBAAA,CAAgD;AAA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C/B,MAAA,WAAA,CAAY,MAAA,CAAO,MAAA,EAAQ,OAAA,CAAQ,IAAA,GAAO,SAAS,OAAO,CAAA;AAAA,IAC5D;AACA,IAAA,IAAI,OAAA,EAAS,UAAU,MAAA,EAAW;AAChC,MAAA,WAAA,CAAY,MAAA,CAAO,OAAA,EAAS,OAAA,CAAQ,KAAA,GAAQ,SAAS,OAAO,CAAA;AAAA,IAC9D;AACA,IAAA,IAAI,OAAA,EAAS,iBAAiB,MAAA,EAAW;AACvC,MAAA,WAAA,CAAY,MAAA,CAAO,cAAA,EAAgB,OAAA,CAAQ,YAAA,CAAa,aAAa,CAAA;AAAA,IACvE;AACA,IAAA,IAAI,OAAA,EAAS,oBAAoB,MAAA,EAAW;AAC1C,MAAA,WAAA,CAAY,MAAA,CAAO,iBAAA,EAAmB,OAAA,CAAQ,eAAe,CAAA;AAAA,IAC/D;AAAA,EACF;AAAA,EAEA,MAAc,OAAA,CAAW,IAAA,EAAc,IAAA,EAAgC;AACrE,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,YAAA,CAAa,WAAW,eAAe,CAAA;AAClE,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA;AAE/D,IAAA,IAAI,CAAC,IAAI,EAAA,EAAI;AACX,MAAA,MAAM,MAAM,aAAA,CAAc,YAAA,CAAa,GAAG,CAAA;AAAA,IAC5C;AAEA,IAAA,OAAO,IAAI,IAAA,EAAK;AAAA,EAClB;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsFilters.esm.js","sources":["../../../src/components/NotificationsFilters/NotificationsFilters.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ChangeEvent } from 'react';\n\nimport Divider from '@material-ui/core/Divider';\nimport FormControl from '@material-ui/core/FormControl';\nimport Grid from '@material-ui/core/Grid';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport Typography from '@material-ui/core/Typography';\nimport { GetNotificationsOptions } from '../../api';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\n\nexport type SortBy = Required<\n Pick<GetNotificationsOptions, 'sort' | 'sortOrder'>\n>;\n\nexport type NotificationsFiltersProps = {\n unreadOnly?: boolean;\n onUnreadOnlyChanged: (checked: boolean | undefined) => void;\n createdAfter?: string;\n onCreatedAfterChanged: (value: string) => void;\n sorting: SortBy;\n onSortingChanged: (sortBy: SortBy) => void;\n saved?: boolean;\n onSavedChanged: (checked: boolean | undefined) => void;\n severity: NotificationSeverity;\n onSeverityChanged: (severity: NotificationSeverity) => void;\n topic?: string;\n onTopicChanged: (value: string | undefined) => void;\n allTopics?: string[];\n};\n\nconst ALL = '___all___';\n\nexport const CreatedAfterOptions: {\n [key: string]: { label: string; getDate: () => Date };\n} = {\n last24h: {\n label: 'Last 24h',\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n label: 'Last week',\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n label: 'Any time',\n getDate: () => new Date(0),\n },\n};\n\nexport const SortByOptions: {\n [key: string]: {\n label: string;\n sortBy: SortBy;\n };\n} = {\n newest: {\n label: 'Newest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'desc',\n },\n },\n oldest: {\n label: 'Oldest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'asc',\n },\n },\n topic: {\n label: 'Topic',\n sortBy: {\n sort: 'topic',\n sortOrder: 'asc',\n },\n },\n origin: {\n label: 'Origin',\n sortBy: {\n sort: 'origin',\n sortOrder: 'asc',\n },\n },\n};\n\nconst getSortByText = (sortBy?: SortBy): string => {\n if (sortBy?.sort === 'created' && sortBy?.sortOrder === 'asc') {\n return 'oldest';\n }\n if (sortBy?.sort === 'topic') {\n return 'topic';\n }\n if (sortBy?.sort === 'origin') {\n return 'origin';\n }\n\n return 'newest';\n};\n\nconst AllSeverityOptions: { [key in NotificationSeverity]: string } = {\n critical: 'Critical',\n high: 'High',\n normal: 'Normal',\n low: 'Low',\n};\n\nexport const NotificationsFilters = ({\n sorting,\n onSortingChanged,\n unreadOnly,\n onUnreadOnlyChanged,\n createdAfter,\n onCreatedAfterChanged,\n saved,\n onSavedChanged,\n severity,\n onSeverityChanged,\n topic,\n onTopicChanged,\n allTopics,\n}: NotificationsFiltersProps) => {\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnViewChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n if (event.target.value === 'unread') {\n onUnreadOnlyChanged(true);\n onSavedChanged(undefined);\n } else if (event.target.value === 'read') {\n onUnreadOnlyChanged(false);\n onSavedChanged(undefined);\n } else if (event.target.value === 'saved') {\n onUnreadOnlyChanged(undefined);\n onSavedChanged(true);\n } else {\n // All\n onUnreadOnlyChanged(undefined);\n onSavedChanged(undefined);\n }\n };\n\n const handleOnSortByChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const idx = (event.target.value as string) || 'newest';\n const option = SortByOptions[idx];\n onSortingChanged({ ...option.sortBy });\n };\n\n let viewValue = 'all';\n if (saved) {\n viewValue = 'saved';\n } else if (unreadOnly) {\n viewValue = 'unread';\n } else if (unreadOnly === false) {\n viewValue = 'read';\n }\n\n const handleOnSeverityChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value: NotificationSeverity =\n (event.target.value as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\n\n const handleOnTopicChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value = event.target.value as string;\n onTopicChanged(value === ALL ? undefined : value);\n };\n\n const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));\n\n return (\n <>\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Filters</Typography>\n <Divider variant=\"fullWidth\" />\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-view\">View</InputLabel>\n <Select\n labelId=\"notifications-filter-view\"\n label=\"View\"\n value={viewValue}\n onChange={handleOnViewChanged}\n >\n <MenuItem value=\"unread\">Unread notifications</MenuItem>\n <MenuItem value=\"read\">Read notifications</MenuItem>\n <MenuItem value=\"saved\">Saved</MenuItem>\n <MenuItem value=\"all\">All</MenuItem>\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-created\">Sent out</InputLabel>\n\n <Select\n label=\"Sent out\"\n labelId=\"notifications-filter-created\"\n placeholder=\"Notifications since\"\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n >\n {Object.keys(CreatedAfterOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {CreatedAfterOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-sort\">Sort by</InputLabel>\n\n <Select\n label=\"Sort by\"\n labelId=\"notifications-filter-sort\"\n placeholder=\"Field to sort by\"\n value={sortByText}\n onChange={handleOnSortByChanged}\n >\n {Object.keys(SortByOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {SortByOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-severity\">\n Min severity\n </InputLabel>\n\n <Select\n label=\"Min severity\"\n labelId=\"notifications-filter-severity\"\n value={severity}\n onChange={handleOnSeverityChanged}\n >\n {Object.keys(AllSeverityOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {AllSeverityOptions[key as NotificationSeverity]}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-topic\">Topic</InputLabel>\n\n <Select\n label=\"Topic\"\n labelId=\"notifications-filter-topic\"\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n >\n <MenuItem value={ALL} key={ALL}>\n Any topic\n </MenuItem>\n\n {sortedAllTopics.map((item: string) => (\n <MenuItem value={item} key={item}>\n {item}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA+CA,MAAM,GAAM,GAAA,WAAA;AAEL,MAAM,mBAET,GAAA;AAAA,EACF,OAAS,EAAA;AAAA,IACP,KAAO,EAAA,UAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAI,EAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI;AAAA,GACvD;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAK,CAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI;AAAA,GAC3D;AAAA,EACA,GAAK,EAAA;AAAA,IACH,KAAO,EAAA,UAAA;AAAA,IACP,OAAS,EAAA,sBAAU,IAAA,IAAA,CAA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A,EAAA,WAAA,EAAA,EAAL,GAE3B,CAAA;AAAA,YAEC,eAAA,CAAgB,GAAI,CAAA,CAAC,IACpB,qBAAA,GAAA,CAAC,YAAS,KAAO,EAAA,IAAA,EACd,QADyB,EAAA,IAAA,EAAA,EAAA,IAE5B,CACD;AAAA;AAAA;AAAA;AACH,KAAA,EACF,CACF,EAAA;AAAA,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"NotificationsFilters.esm.js","sources":["../../../src/components/NotificationsFilters/NotificationsFilters.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ChangeEvent } from 'react';\n\nimport Divider from '@material-ui/core/Divider';\nimport FormControl from '@material-ui/core/FormControl';\nimport Grid from '@material-ui/core/Grid';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport Typography from '@material-ui/core/Typography';\nimport { GetNotificationsOptions } from '../../api';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\n\nexport type SortBy = Required<\n Pick<GetNotificationsOptions, 'sort' | 'sortOrder'>\n>;\n\nexport type NotificationsFiltersProps = {\n unreadOnly?: boolean;\n onUnreadOnlyChanged: (checked: boolean | undefined) => void;\n createdAfter?: string;\n onCreatedAfterChanged: (value: string) => void;\n sorting: SortBy;\n onSortingChanged: (sortBy: SortBy) => void;\n saved?: boolean;\n onSavedChanged: (checked: boolean | undefined) => void;\n severity: NotificationSeverity;\n onSeverityChanged: (severity: NotificationSeverity) => void;\n topic?: string;\n onTopicChanged: (value: string | undefined) => void;\n allTopics?: string[];\n};\n\nconst ALL = '___all___';\n\nexport const CreatedAfterOptions: {\n [key: string]: { label: string; getDate: () => Date };\n} = {\n last24h: {\n label: 'Last 24h',\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n label: 'Last week',\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n label: 'Any time',\n getDate: () => new Date(0),\n },\n};\n\nexport const SortByOptions: {\n [key: string]: {\n label: string;\n sortBy: SortBy;\n };\n} = {\n newest: {\n label: 'Newest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'desc',\n },\n },\n oldest: {\n label: 'Oldest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'asc',\n },\n },\n topic: {\n label: 'Topic',\n sortBy: {\n sort: 'topic',\n sortOrder: 'asc',\n },\n },\n origin: {\n label: 'Origin',\n sortBy: {\n sort: 'origin',\n sortOrder: 'asc',\n },\n },\n};\n\nconst getSortByText = (sortBy?: SortBy): string => {\n if (sortBy?.sort === 'created' && sortBy?.sortOrder === 'asc') {\n return 'oldest';\n }\n if (sortBy?.sort === 'topic') {\n return 'topic';\n }\n if (sortBy?.sort === 'origin') {\n return 'origin';\n }\n\n return 'newest';\n};\n\nconst AllSeverityOptions: { [key in NotificationSeverity]: string } = {\n critical: 'Critical',\n high: 'High',\n normal: 'Normal',\n low: 'Low',\n};\n\nexport const NotificationsFilters = ({\n sorting,\n onSortingChanged,\n unreadOnly,\n onUnreadOnlyChanged,\n createdAfter,\n onCreatedAfterChanged,\n saved,\n onSavedChanged,\n severity,\n onSeverityChanged,\n topic,\n onTopicChanged,\n allTopics,\n}: NotificationsFiltersProps) => {\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnViewChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n if (event.target.value === 'unread') {\n onUnreadOnlyChanged(true);\n onSavedChanged(undefined);\n } else if (event.target.value === 'read') {\n onUnreadOnlyChanged(false);\n onSavedChanged(undefined);\n } else if (event.target.value === 'saved') {\n onUnreadOnlyChanged(undefined);\n onSavedChanged(true);\n } else {\n // All\n onUnreadOnlyChanged(undefined);\n onSavedChanged(undefined);\n }\n };\n\n const handleOnSortByChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const idx = (event.target.value as string) || 'newest';\n const option = SortByOptions[idx];\n onSortingChanged({ ...option.sortBy });\n };\n\n let viewValue = 'all';\n if (saved) {\n viewValue = 'saved';\n } else if (unreadOnly) {\n viewValue = 'unread';\n } else if (unreadOnly === false) {\n viewValue = 'read';\n }\n\n const handleOnSeverityChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value: NotificationSeverity =\n (event.target.value as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\n\n const handleOnTopicChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value = event.target.value as string;\n onTopicChanged(value === ALL ? undefined : value);\n };\n\n const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));\n\n return (\n <>\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Filters</Typography>\n <Divider variant=\"fullWidth\" />\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-view\">View</InputLabel>\n <Select\n labelId=\"notifications-filter-view\"\n label=\"View\"\n value={viewValue}\n onChange={handleOnViewChanged}\n >\n <MenuItem value=\"unread\">Unread notifications</MenuItem>\n <MenuItem value=\"read\">Read notifications</MenuItem>\n <MenuItem value=\"saved\">Saved</MenuItem>\n <MenuItem value=\"all\">All</MenuItem>\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-created\">Sent out</InputLabel>\n\n <Select\n label=\"Sent out\"\n labelId=\"notifications-filter-created\"\n placeholder=\"Notifications since\"\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n >\n {Object.keys(CreatedAfterOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {CreatedAfterOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-sort\">Sort by</InputLabel>\n\n <Select\n label=\"Sort by\"\n labelId=\"notifications-filter-sort\"\n placeholder=\"Field to sort by\"\n value={sortByText}\n onChange={handleOnSortByChanged}\n >\n {Object.keys(SortByOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {SortByOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-severity\">\n Min severity\n </InputLabel>\n\n <Select\n label=\"Min severity\"\n labelId=\"notifications-filter-severity\"\n value={severity}\n onChange={handleOnSeverityChanged}\n >\n {Object.keys(AllSeverityOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {AllSeverityOptions[key as NotificationSeverity]}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-topic\">Topic</InputLabel>\n\n <Select\n label=\"Topic\"\n labelId=\"notifications-filter-topic\"\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n >\n <MenuItem value={ALL} key={ALL}>\n Any topic\n </MenuItem>\n\n {sortedAllTopics.map((item: string) => (\n <MenuItem value={item} key={item}>\n {item}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA+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K,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,EAAA,EACb,QAAA,kBAAA,IAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAS,IAAA,EAAC,OAAA,EAAQ,UAAA,EAAW,MAAK,OAAA,EAC7C,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAG,4BAAA,EAA6B,QAAA,EAAA,OAAA,EAAK,CAAA;AAAA,sBAEjD,IAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,OAAA;AAAA,UACN,OAAA,EAAQ,4BAAA;AAAA,UACR,OAAO,KAAA,IAAS,GAAA;AAAA,UAChB,QAAA,EAAU,oBAAA;AAAA,UAEV,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAO,GAAA,EAAe,QAAA,EAAA,WAAA,EAAA,EAAL,GAE3B,CAAA;AAAA,YAEC,eAAA,CAAgB,GAAA,CAAI,CAAC,IAAA,qBACpB,GAAA,CAAC,YAAS,KAAA,EAAO,IAAA,EACd,QAAA,EAAA,IAAA,EAAA,EADyB,IAE5B,CACD;AAAA;AAAA;AAAA;AACH,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsPage.esm.js","sources":["../../../src/components/NotificationsPage/NotificationsPage.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport { ConfirmProvider } from 'material-ui-confirm';\nimport { useSignal } from '@backstage/plugin-signals-react';\n\nimport { NotificationsTable } from '../NotificationsTable';\nimport { useNotificationsApi } from '../../hooks';\nimport {\n CreatedAfterOptions,\n NotificationsFilters,\n SortBy,\n SortByOptions,\n} from '../NotificationsFilters';\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsResponse,\n} from '../../api';\nimport {\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\nconst ThrottleDelayMs = 2000;\n\n/** @public */\nexport type NotificationsPageProps = {\n /** Mark notification as read when opening the link it contains, defaults to false */\n markAsReadOnLinkOpen?: boolean;\n title?: string;\n themeId?: string;\n subtitle?: string;\n tooltip?: string;\n type?: string;\n typeLink?: string;\n};\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => {\n const {\n title = 'Notifications',\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n } = props ?? {};\n\n const [refresh, setRefresh] = useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = useState<boolean | undefined>(true);\n const [saved, setSaved] = useState<boolean | undefined>(undefined);\n const [pageNumber, setPageNumber] = useState(0);\n const [pageSize, setPageSize] = useState(5);\n const [containsText, setContainsText] = useState<string>();\n const [createdAfter, setCreatedAfter] = useState<string>('all');\n const [sorting, setSorting] = useState<SortBy>(SortByOptions.newest.sortBy);\n const [severity, setSeverity] = useState<NotificationSeverity>('low');\n const [topic, setTopic] = useState<string>();\n\n const { error, value, retry, loading } = useNotificationsApi<\n [GetNotificationsResponse, NotificationStatus, GetTopicsResponse]\n >(\n api => {\n const options: GetNotificationsOptions = {\n search: containsText,\n limit: pageSize,\n offset: pageNumber * pageSize,\n minimumSeverity: severity,\n ...(sorting || {}),\n };\n if (unreadOnly !== undefined) {\n options.read = !unreadOnly;\n }\n if (saved !== undefined) {\n options.saved = saved;\n }\n if (topic !== undefined) {\n options.topic = topic;\n }\n\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return Promise.all([\n api.getNotifications(options),\n api.getStatus(),\n api.getTopics(options),\n ]);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n topic,\n ],\n );\n\n const throttledSetRefresh = useMemo(\n () => throttle(setRefresh, ThrottleDelayMs),\n [setRefresh],\n );\n\n useEffect(() => {\n if (refresh && !loading) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry, loading]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n throttledSetRefresh(true);\n }\n }, [lastSignal, throttledSetRefresh]);\n\n const onUpdate = () => {\n throttledSetRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const notifications = value?.[0]?.notifications;\n const totalCount = value?.[0]?.totalCount;\n const isUnread = !!value?.[1]?.unread;\n const allTopics = value?.[2]?.topics;\n\n let tableTitle = `All notifications (${totalCount})`;\n if (saved) {\n tableTitle = `Saved notifications (${totalCount})`;\n } else if (unreadOnly === true) {\n tableTitle = `Unread notifications (${totalCount})`;\n } else if (unreadOnly === false) {\n tableTitle = `Read notifications (${totalCount})`;\n }\n\n return (\n <PageWithHeader\n title={title}\n themeId={themeId}\n tooltip={tooltip}\n subtitle={subtitle}\n type={type}\n typeLink={typeLink}\n >\n <Content>\n <ConfirmProvider>\n <Grid container>\n <Grid item xs={2}>\n <NotificationsFilters\n unreadOnly={unreadOnly}\n onUnreadOnlyChanged={setUnreadOnly}\n createdAfter={createdAfter}\n onCreatedAfterChanged={setCreatedAfter}\n onSortingChanged={setSorting}\n sorting={sorting}\n saved={saved}\n onSavedChanged={setSaved}\n severity={severity}\n onSeverityChanged={setSeverity}\n topic={topic}\n onTopicChanged={setTopic}\n allTopics={allTopics}\n />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n title={tableTitle}\n isLoading={loading}\n isUnread={isUnread}\n markAsReadOnLinkOpen={markAsReadOnLinkOpen}\n notifications={notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={totalCount}\n />\n </Grid>\n </Grid>\n </ConfirmProvider>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,eAAkB,GAAA,GAAA;AAcX,MAAA,iBAAA,GAAoB,CAAC,KAAmC,KAAA;AACnE,EAAM,MAAA;AAAA,IACJ,KAAQ,GAAA,eAAA;AAAA,IACR,OAAU,GAAA,MAAA;AAAA,IACV,QAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,SAAS,EAAC;AAEd,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,eAAe,CAAA;AAChD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAA8B,IAAI,CAAA;AACtE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAA8B,KAAS,CAAA,CAAA;AACjE,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,CAAC,CAAA;AAC9C,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,CAAC,CAAA;AAC1C,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAiB,EAAA;AACzD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAi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AAAA,YACA,oBAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YACA,eAAA;AAAA,YACA,YAAc,EAAA,aAAA;AAAA,YACd,mBAAqB,EAAA,WAAA;AAAA,YACrB,IAAM,EAAA,UAAA;AAAA,YACN,QAAA;AAAA,YACA;AAAA;AAAA,SAEJ,EAAA;AAAA,OAAA,EACF,GACF,CACF,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"NotificationsPage.esm.js","sources":["../../../src/components/NotificationsPage/NotificationsPage.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport { ConfirmProvider } from 'material-ui-confirm';\nimport { useSignal } from '@backstage/plugin-signals-react';\n\nimport { NotificationsTable } from '../NotificationsTable';\nimport { useNotificationsApi } from '../../hooks';\nimport {\n CreatedAfterOptions,\n NotificationsFilters,\n SortBy,\n SortByOptions,\n} from '../NotificationsFilters';\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsResponse,\n} from '../../api';\nimport {\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\nconst ThrottleDelayMs = 2000;\n\n/** @public */\nexport type NotificationsPageProps = {\n /** Mark notification as read when opening the link it contains, defaults to false */\n markAsReadOnLinkOpen?: boolean;\n title?: string;\n themeId?: string;\n subtitle?: string;\n tooltip?: string;\n type?: string;\n typeLink?: string;\n};\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => {\n const {\n title = 'Notifications',\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n } = props ?? {};\n\n const [refresh, setRefresh] = useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = useState<boolean | undefined>(true);\n const [saved, setSaved] = useState<boolean | undefined>(undefined);\n const [pageNumber, setPageNumber] = useState(0);\n const [pageSize, setPageSize] = useState(5);\n const [containsText, setContainsText] = useState<string>();\n const [createdAfter, setCreatedAfter] = useState<string>('all');\n const [sorting, setSorting] = useState<SortBy>(SortByOptions.newest.sortBy);\n const [severity, setSeverity] = useState<NotificationSeverity>('low');\n const [topic, setTopic] = useState<string>();\n\n const { error, value, retry, loading } = useNotificationsApi<\n [GetNotificationsResponse, NotificationStatus, GetTopicsResponse]\n >(\n api => {\n const options: GetNotificationsOptions = {\n search: containsText,\n limit: pageSize,\n offset: pageNumber * pageSize,\n minimumSeverity: severity,\n ...(sorting || {}),\n };\n if (unreadOnly !== undefined) {\n options.read = !unreadOnly;\n }\n if (saved !== undefined) {\n options.saved = saved;\n }\n if (topic !== undefined) {\n options.topic = topic;\n }\n\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return Promise.all([\n api.getNotifications(options),\n api.getStatus(),\n api.getTopics(options),\n ]);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n topic,\n ],\n );\n\n const throttledSetRefresh = useMemo(\n () => throttle(setRefresh, ThrottleDelayMs),\n [setRefresh],\n );\n\n useEffect(() => {\n if (refresh && !loading) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry, loading]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n throttledSetRefresh(true);\n }\n }, [lastSignal, throttledSetRefresh]);\n\n const onUpdate = () => {\n throttledSetRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const notifications = value?.[0]?.notifications;\n const totalCount = value?.[0]?.totalCount;\n const isUnread = !!value?.[1]?.unread;\n const allTopics = value?.[2]?.topics;\n\n let tableTitle = `All notifications (${totalCount})`;\n if (saved) {\n tableTitle = `Saved notifications (${totalCount})`;\n } else if (unreadOnly === true) {\n tableTitle = `Unread notifications (${totalCount})`;\n } else if (unreadOnly === false) {\n tableTitle = `Read notifications (${totalCount})`;\n }\n\n return (\n <PageWithHeader\n title={title}\n themeId={themeId}\n tooltip={tooltip}\n subtitle={subtitle}\n type={type}\n typeLink={typeLink}\n >\n <Content>\n <ConfirmProvider>\n <Grid container>\n <Grid item xs={2}>\n <NotificationsFilters\n unreadOnly={unreadOnly}\n onUnreadOnlyChanged={setUnreadOnly}\n createdAfter={createdAfter}\n onCreatedAfterChanged={setCreatedAfter}\n onSortingChanged={setSorting}\n sorting={sorting}\n saved={saved}\n onSavedChanged={setSaved}\n severity={severity}\n onSeverityChanged={setSeverity}\n topic={topic}\n onTopicChanged={setTopic}\n allTopics={allTopics}\n />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n title={tableTitle}\n isLoading={loading}\n isUnread={isUnread}\n markAsReadOnLinkOpen={markAsReadOnLinkOpen}\n notifications={notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={totalCount}\n />\n </Grid>\n </Grid>\n </ConfirmProvider>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,eAAA,GAAkB,GAAA;AAcjB,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAmC;AACnE,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,eAAA;AAAA,IACR,OAAA,GAAU,M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C,IAAA,EAAA,EAAK,WAAS,IAAA,EACb,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,CAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,oBAAA;AAAA,UAAA;AAAA,YACC,UAAA;AAAA,YACA,mBAAA,EAAqB,aAAA;AAAA,YACrB,YAAA;AAAA,YACA,qBAAA,EAAuB,eAAA;AAAA,YACvB,gBAAA,EAAkB,UAAA;AAAA,YAClB,OAAA;AAAA,YACA,KAAA;AAAA,YACA,cAAA,EAAgB,QAAA;AAAA,YAChB,QAAA;AAAA,YACA,iBAAA,EAAmB,WAAA;AAAA,YACnB,KAAA;AAAA,YACA,cAAA,EAAgB,QAAA;AAAA,YAChB;AAAA;AAAA,SACF,EACF,CAAA;AAAA,wBACA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,kBAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,UAAA;AAAA,YACP,SAAA,EAAW,OAAA;AAAA,YACX,QAAA;AAAA,YACA,oBAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YACA,eAAA;AAAA,YACA,YAAA,EAAc,aAAA;AAAA,YACd,mBAAA,EAAqB,WAAA;AAAA,YACrB,IAAA,EAAM,UAAA;AAAA,YACN,QAAA;AAAA,YACA;AAAA;AAAA,SACF,EACF;AAAA,OAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { useState, useCallback, useEffect } from 'react';
2
+ import { useMemo, useState, useCallback, useEffect } from 'react';
3
3
  import { useNotificationsApi } from '../../hooks/useNotificationsApi.esm.js';
4
4
  import { useWebNotifications } from '../../hooks/useWebNotifications.esm.js';
5
5
  import { useTitleCounter } from '../../hooks/useTitleCounter.esm.js';
@@ -50,9 +50,18 @@ const NotificationsSidebarItem = (props) => {
50
50
  } = props ?? {
51
51
  webNotificationsEnabled: false,
52
52
  titleCounterEnabled: true,
53
- snackbarEnabled: true,
54
- snackbarAutoHideDuration: 1e4
53
+ snackbarProps: {
54
+ enabled: true,
55
+ autoHideDuration: 1e4
56
+ }
55
57
  };
58
+ const snackbarProps = useMemo(
59
+ () => props?.snackbarProps ?? {
60
+ enabled: snackbarEnabled,
61
+ autoHideDuration: snackbarAutoHideDuration
62
+ },
63
+ [props?.snackbarProps, snackbarAutoHideDuration, snackbarEnabled]
64
+ );
56
65
  const { loading, error, value, retry } = useNotificationsApi(
57
66
  (api) => api.getStatus()
58
67
  );
@@ -123,7 +132,7 @@ const NotificationsSidebarItem = (props) => {
123
132
  }, [refresh, retry]);
124
133
  useEffect(() => {
125
134
  const handleNotificationSignal = (signal) => {
126
- if (!webNotificationsEnabled && !snackbarEnabled || signal.action !== "new_notification") {
135
+ if (!webNotificationsEnabled && !snackbarProps.enabled || signal.action !== "new_notification") {
127
136
  return;
128
137
  }
129
138
  notificationsApi.getNotification(signal.notification_id).then((notification) => {
@@ -138,15 +147,19 @@ const NotificationsSidebarItem = (props) => {
138
147
  link: notification.payload.link
139
148
  });
140
149
  }
141
- if (snackbarEnabled) {
150
+ if (snackbarProps.enabled) {
142
151
  const { action } = getSnackbarProperties(notification);
143
152
  const snackBarText = notification.payload.title.length > 50 ? `${notification.payload.title.substring(0, 50)}...` : notification.payload.title;
144
153
  enqueueSnackbar(snackBarText, {
145
154
  key: notification.id,
155
+ style: snackbarProps.snackStyle,
146
156
  variant: notification.payload.severity,
147
- anchorOrigin: { vertical: "bottom", horizontal: "right" },
157
+ anchorOrigin: snackbarProps.anchorOrigin ?? {
158
+ vertical: "bottom",
159
+ horizontal: "right"
160
+ },
148
161
  action,
149
- autoHideDuration: snackbarAutoHideDuration
162
+ autoHideDuration: snackbarProps.autoHideDuration
150
163
  });
151
164
  }
152
165
  }).catch(() => {
@@ -164,11 +177,10 @@ const NotificationsSidebarItem = (props) => {
164
177
  lastSignal,
165
178
  sendWebNotification,
166
179
  webNotificationsEnabled,
167
- snackbarEnabled,
168
- snackbarAutoHideDuration,
169
180
  notificationsApi,
170
181
  alertApi,
171
- getSnackbarProperties
182
+ getSnackbarProperties,
183
+ snackbarProps
172
184
  ]);
173
185
  useEffect(() => {
174
186
  if (!loading && !error && value) {
@@ -186,16 +198,18 @@ const NotificationsSidebarItem = (props) => {
186
198
  SnackbarProvider,
187
199
  {
188
200
  iconVariant: {
189
- normal: /* @__PURE__ */ jsx(SeverityIcon, { severity: "normal" }),
190
- critical: /* @__PURE__ */ jsx(SeverityIcon, { severity: "critical" }),
191
- high: /* @__PURE__ */ jsx(SeverityIcon, { severity: "high" }),
192
- low: /* @__PURE__ */ jsx(SeverityIcon, { severity: "low" })
201
+ normal: snackbarProps?.iconVariant?.normal ?? /* @__PURE__ */ jsx(SeverityIcon, { severity: "normal" }),
202
+ critical: snackbarProps?.iconVariant?.critical ?? /* @__PURE__ */ jsx(SeverityIcon, { severity: "critical" }),
203
+ high: snackbarProps?.iconVariant?.high ?? /* @__PURE__ */ jsx(SeverityIcon, { severity: "high" }),
204
+ low: snackbarProps?.iconVariant?.low ?? /* @__PURE__ */ jsx(SeverityIcon, { severity: "low" })
193
205
  },
206
+ dense: snackbarProps?.dense,
207
+ maxSnack: snackbarProps?.maxSnack,
194
208
  Components: {
195
- normal: StyledMaterialDesignContent,
196
- critical: StyledMaterialDesignContent,
197
- high: StyledMaterialDesignContent,
198
- low: StyledMaterialDesignContent
209
+ normal: snackbarProps?.Components?.normal ?? StyledMaterialDesignContent,
210
+ critical: snackbarProps?.Components?.critical ?? StyledMaterialDesignContent,
211
+ high: snackbarProps?.Components?.high ?? StyledMaterialDesignContent,
212
+ low: snackbarProps?.Components?.low ?? StyledMaterialDesignContent
199
213
  }
200
214
  }
201
215
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsSideBarItem.esm.js","sources":["../../../src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useCallback, useEffect } from 'react';\nimport { useNotificationsApi } from '../../hooks';\nimport { Link, SidebarItem } from '@backstage/core-components';\nimport NotificationsIcon from '@material-ui/icons/Notifications';\nimport {\n alertApiRef,\n IconComponent,\n useApi,\n useRouteRef,\n} from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../routes';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport {\n Notification,\n NotificationSignal,\n} from '@backstage/plugin-notifications-common';\nimport { useWebNotifications } from '../../hooks/useWebNotifications';\nimport { useTitleCounter } from '../../hooks/useTitleCounter';\nimport { notificationsApiRef } from '../../api';\nimport {\n closeSnackbar,\n enqueueSnackbar,\n MaterialDesignContent,\n OptionsWithExtraProps,\n SnackbarKey,\n SnackbarProvider,\n VariantType,\n} from 'notistack';\nimport { SeverityIcon } from '../NotificationsTable/SeverityIcon';\nimport OpenInNew from '@material-ui/icons/OpenInNew';\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport IconButton from '@material-ui/core/IconButton';\nimport Chip from '@material-ui/core/Chip';\nimport { styled } from '@material-ui/core/styles';\n\nconst StyledMaterialDesignContent = styled(MaterialDesignContent)(\n ({ theme }) => ({\n '&.notistack-MuiContent-low': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-normal': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-high': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-critical': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n }),\n);\n\ndeclare module 'notistack' {\n interface VariantOverrides {\n // Custom variants for the snackbar\n low: true;\n normal: true;\n high: true;\n critical: true;\n }\n}\n\n/** @public */\nexport const NotificationsSidebarItem = (props?: {\n webNotificationsEnabled?: boolean;\n titleCounterEnabled?: boolean;\n snackbarEnabled?: boolean;\n snackbarAutoHideDuration?: number | null;\n className?: string;\n icon?: IconComponent;\n text?: string;\n disableHighlight?: boolean;\n noTrack?: boolean;\n}) => {\n const {\n webNotificationsEnabled = false,\n titleCounterEnabled = true,\n snackbarEnabled = true,\n snackbarAutoHideDuration = 10000,\n icon = NotificationsIcon,\n text = 'Notifications',\n ...restProps\n } = props ?? {\n webNotificationsEnabled: false,\n titleCounterEnabled: true,\n snackbarEnabled: true,\n snackbarAutoHideDuration: 10000,\n };\n\n const { loading, error, value, retry } = useNotificationsApi(api =>\n api.getStatus(),\n );\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const [unreadCount, setUnreadCount] = useState(0);\n const notificationsRoute = useRouteRef(rootRouteRef)();\n // TODO: Do we want to add long polling in case signals are not available\n const { lastSignal } = useSignal<NotificationSignal>('notifications');\n const { sendWebNotification, requestUserPermission } = useWebNotifications(\n webNotificationsEnabled,\n );\n const [refresh, setRefresh] = useState(false);\n const { setNotificationCount } = useTitleCounter();\n\n const getSnackbarProperties = useCallback(\n (notification: Notification) => {\n const action = (snackBarId: SnackbarKey) => (\n <>\n <IconButton\n component={Link}\n to={notification.payload.link ?? notificationsRoute}\n onClick={() => {\n if (notification.payload.link) {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: true,\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to mark notification as read',\n severity: 'error',\n });\n });\n }\n closeSnackbar(snackBarId);\n }}\n >\n <OpenInNew fontSize=\"small\" />\n </IconButton>\n <IconButton\n onClick={() => {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: true,\n })\n .then(() => {\n closeSnackbar(snackBarId);\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to mark notification as read',\n severity: 'error',\n });\n });\n }}\n >\n <MarkAsReadIcon fontSize=\"small\" />\n </IconButton>\n </>\n );\n\n return { action };\n },\n [notificationsRoute, notificationsApi, alertApi],\n );\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, retry]);\n\n useEffect(() => {\n const handleNotificationSignal = (signal: NotificationSignal) => {\n if (\n (!webNotificationsEnabled && !snackbarEnabled) ||\n signal.action !== 'new_notification'\n ) {\n return;\n }\n notificationsApi\n .getNotification(signal.notification_id)\n .then(notification => {\n if (!notification) {\n return;\n }\n if (webNotificationsEnabled) {\n sendWebNotification({\n id: notification.id,\n title: notification.payload.title,\n description: notification.payload.description ?? '',\n link: notification.payload.link,\n });\n }\n if (snackbarEnabled) {\n const { action } = getSnackbarProperties(notification);\n const snackBarText =\n notification.payload.title.length > 50\n ? `${notification.payload.title.substring(0, 50)}...`\n : notification.payload.title;\n enqueueSnackbar(snackBarText, {\n key: notification.id,\n variant: notification.payload.severity,\n anchorOrigin: { vertical: 'bottom', horizontal: 'right' },\n action,\n autoHideDuration: snackbarAutoHideDuration,\n } as OptionsWithExtraProps<VariantType>);\n }\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to fetch notification',\n severity: 'error',\n });\n });\n };\n\n if (lastSignal && lastSignal.action) {\n handleNotificationSignal(lastSignal);\n setRefresh(true);\n }\n }, [\n lastSignal,\n sendWebNotification,\n webNotificationsEnabled,\n snackbarEnabled,\n snackbarAutoHideDuration,\n notificationsApi,\n alertApi,\n getSnackbarProperties,\n ]);\n\n useEffect(() => {\n if (!loading && !error && value) {\n setUnreadCount(value.unread);\n }\n }, [loading, error, value]);\n\n useEffect(() => {\n if (titleCounterEnabled) {\n setNotificationCount(unreadCount);\n }\n }, [titleCounterEnabled, unreadCount, setNotificationCount]);\n\n const count = !error && !!unreadCount ? unreadCount : undefined;\n\n return (\n <>\n {snackbarEnabled && (\n <SnackbarProvider\n iconVariant={{\n normal: <SeverityIcon severity=\"normal\" />,\n critical: <SeverityIcon severity=\"critical\" />,\n high: <SeverityIcon severity=\"high\" />,\n low: <SeverityIcon severity=\"low\" />,\n }}\n Components={{\n normal: StyledMaterialDesignContent,\n critical: StyledMaterialDesignContent,\n high: StyledMaterialDesignContent,\n low: StyledMaterialDesignContent,\n }}\n />\n )}\n <SidebarItem\n to={notificationsRoute}\n onClick={() => {\n requestUserPermission();\n }}\n text={text}\n icon={icon}\n {...restProps}\n >\n {count && <Chip size=\"small\" label={count > 99 ? '99+' : count} />}\n </SidebarItem>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,2BAAA,GAA8B,OAAO,qBAAqB,CAAA;AAAA,EAC9D,CAAC,EAAE,KAAA,EAAa,MAAA;AAAA,IACd,4BAA8B,EAAA;AAAA,MAC5B,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,OAAA;AAAA,MAC1C,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,KAC5B;AAAA,IACA,+BAAiC,EAAA;AAAA,MAC/B,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,OAAA;AAAA,MAC1C,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,KAC5B;AAAA,IACA,6BAA+B,EAAA;AAAA,MAC7B,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,OAAA;AAAA,MAC1C,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,KAC5B;AAAA,IACA,iCAAmC,EAAA;AAAA,MACjC,eAAA,EAAiB,KAAM,CAAA,OAAA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CAAA;AAE3D,EAAA,MAAM,QAAQ,CAAC,KAAA,IAAS,CAAC,CAAC,cAAc,WAAc,GAAA,KAAA,CAAA;AAEtD,EAAA,uBAEK,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,IACC,eAAA,oBAAA,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,WAAa,EAAA;AAAA,UACX,MAAQ,kBAAA,GAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,QAAS,EAAA,CAAA;AAAA,UACxC,QAAU,kBAAA,GAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,UAAW,EAAA,CAAA;AAAA,UAC5C,IAAM,kBAAA,GAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,MAAO,EAAA,CAAA;AAAA,UACpC,GAAK,kBAAA,GAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,KAAM,EAAA;AAAA,SACpC;AAAA,QACA,UAAY,EAAA;AAAA,UACV,MAAQ,EAAA,2BAAA;AAAA,UACR,QAAU,EAAA,2BAAA;AAAA,UACV,IAAM,EAAA,2BAAA;AAAA,UACN,GAAK,EAAA;AAAA;AACP;AAAA,KACF;AAAA,oBAEF,GAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACC,EAAI,EAAA,kBAAA;AAAA,QACJ,SAAS,MAAM;AACb,UAAsB,qBAAA,EAAA;AAAA,SACxB;AAAA,QACA,IAAA;AAAA,QACA,IAAA;AAAA,QACC,GAAG,SAAA;AAAA,QAEH,QAAA,EAAA,KAAA,wBAAU,IAAK,EAAA,EAAA,IAAA,EAAK,SAAQ,KAAO,EAAA,KAAA,GAAQ,EAAK,GAAA,KAAA,GAAQ,KAAO,EAAA;AAAA;AAAA;AAClE,GACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"NotificationsSideBarItem.esm.js","sources":["../../../src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as React from 'react';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useNotificationsApi } from '../../hooks';\nimport { Link, SidebarItem } from '@backstage/core-components';\nimport NotificationsIcon from '@material-ui/icons/Notifications';\nimport {\n alertApiRef,\n IconComponent,\n useApi,\n useRouteRef,\n} from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../routes';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport {\n Notification,\n NotificationSeverity,\n NotificationSignal,\n} from '@backstage/plugin-notifications-common';\nimport { useWebNotifications } from '../../hooks/useWebNotifications';\nimport { useTitleCounter } from '../../hooks/useTitleCounter';\nimport { notificationsApiRef } from '../../api';\nimport {\n closeSnackbar,\n enqueueSnackbar,\n MaterialDesignContent,\n OptionsWithExtraProps,\n SnackbarKey,\n SnackbarProvider,\n VariantType,\n} from 'notistack';\nimport { SeverityIcon } from '../NotificationsTable/SeverityIcon';\nimport OpenInNew from '@material-ui/icons/OpenInNew';\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport IconButton from '@material-ui/core/IconButton';\nimport Chip from '@material-ui/core/Chip';\nimport { styled } from '@material-ui/core/styles';\n\nconst StyledMaterialDesignContent = styled(MaterialDesignContent)(\n ({ theme }) => ({\n '&.notistack-MuiContent-low': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-normal': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-high': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n '&.notistack-MuiContent-critical': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n }),\n);\n\ndeclare module 'notistack' {\n interface VariantOverrides {\n // Custom variants for the snackbar\n low: true;\n normal: true;\n high: true;\n critical: true;\n }\n}\n\n/**\n * @public\n */\nexport type NotificationSnackbarProperties = {\n enabled?: boolean;\n autoHideDuration?: number | null;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n dense?: boolean;\n maxSnack?: number;\n snackStyle?: React.CSSProperties;\n iconVariant?: Partial<Record<NotificationSeverity, React.ReactNode>>;\n Components?: {\n [key in NotificationSeverity]: React.JSXElementConstructor<any>;\n };\n};\n\n/**\n * @public\n */\nexport type NotificationsSideBarItemProps = {\n webNotificationsEnabled?: boolean;\n titleCounterEnabled?: boolean;\n /**\n * @deprecated Use `snackbarProps` instead.\n */\n snackbarEnabled?: boolean;\n /**\n * @deprecated Use `snackbarProps` instead.\n */\n snackbarAutoHideDuration?: number | null;\n snackbarProps?: NotificationSnackbarProperties;\n className?: string;\n icon?: IconComponent;\n text?: string;\n disableHighlight?: boolean;\n noTrack?: boolean;\n};\n\n/** @public */\nexport const NotificationsSidebarItem = (\n props?: NotificationsSideBarItemProps,\n) => {\n const {\n webNotificationsEnabled = false,\n titleCounterEnabled = true,\n snackbarEnabled = true,\n snackbarAutoHideDuration = 10000,\n icon = NotificationsIcon,\n text = 'Notifications',\n ...restProps\n } = props ?? {\n webNotificationsEnabled: false,\n titleCounterEnabled: true,\n snackbarProps: {\n enabled: true,\n autoHideDuration: 10000,\n },\n };\n\n const snackbarProps = useMemo(\n () =>\n props?.snackbarProps ?? {\n enabled: snackbarEnabled,\n autoHideDuration: snackbarAutoHideDuration,\n },\n [props?.snackbarProps, snackbarAutoHideDuration, snackbarEnabled],\n );\n\n const { loading, error, value, retry } = useNotificationsApi(api =>\n api.getStatus(),\n );\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const [unreadCount, setUnreadCount] = useState(0);\n const notificationsRoute = useRouteRef(rootRouteRef)();\n // TODO: Do we want to add long polling in case signals are not available\n const { lastSignal } = useSignal<NotificationSignal>('notifications');\n const { sendWebNotification, requestUserPermission } = useWebNotifications(\n webNotificationsEnabled,\n );\n const [refresh, setRefresh] = useState(false);\n const { setNotificationCount } = useTitleCounter();\n\n const getSnackbarProperties = useCallback(\n (notification: Notification) => {\n const action = (snackBarId: SnackbarKey) => (\n <>\n <IconButton\n component={Link}\n to={notification.payload.link ?? notificationsRoute}\n onClick={() => {\n if (notification.payload.link) {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: true,\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to mark notification as read',\n severity: 'error',\n });\n });\n }\n closeSnackbar(snackBarId);\n }}\n >\n <OpenInNew fontSize=\"small\" />\n </IconButton>\n <IconButton\n onClick={() => {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: true,\n })\n .then(() => {\n closeSnackbar(snackBarId);\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to mark notification as read',\n severity: 'error',\n });\n });\n }}\n >\n <MarkAsReadIcon fontSize=\"small\" />\n </IconButton>\n </>\n );\n\n return { action };\n },\n [notificationsRoute, notificationsApi, alertApi],\n );\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, retry]);\n\n useEffect(() => {\n const handleNotificationSignal = (signal: NotificationSignal) => {\n if (\n (!webNotificationsEnabled && !snackbarProps.enabled) ||\n signal.action !== 'new_notification'\n ) {\n return;\n }\n notificationsApi\n .getNotification(signal.notification_id)\n .then(notification => {\n if (!notification) {\n return;\n }\n if (webNotificationsEnabled) {\n sendWebNotification({\n id: notification.id,\n title: notification.payload.title,\n description: notification.payload.description ?? '',\n link: notification.payload.link,\n });\n }\n if (snackbarProps.enabled) {\n const { action } = getSnackbarProperties(notification);\n const snackBarText =\n notification.payload.title.length > 50\n ? `${notification.payload.title.substring(0, 50)}...`\n : notification.payload.title;\n enqueueSnackbar(snackBarText, {\n key: notification.id,\n style: snackbarProps.snackStyle,\n variant: notification.payload.severity,\n anchorOrigin: snackbarProps.anchorOrigin ?? {\n vertical: 'bottom',\n horizontal: 'right',\n },\n action,\n autoHideDuration: snackbarProps.autoHideDuration,\n } as OptionsWithExtraProps<VariantType>);\n }\n })\n .catch(() => {\n alertApi.post({\n message: 'Failed to fetch notification',\n severity: 'error',\n });\n });\n };\n\n if (lastSignal && lastSignal.action) {\n handleNotificationSignal(lastSignal);\n setRefresh(true);\n }\n }, [\n lastSignal,\n sendWebNotification,\n webNotificationsEnabled,\n notificationsApi,\n alertApi,\n getSnackbarProperties,\n snackbarProps,\n ]);\n\n useEffect(() => {\n if (!loading && !error && value) {\n setUnreadCount(value.unread);\n }\n }, [loading, error, value]);\n\n useEffect(() => {\n if (titleCounterEnabled) {\n setNotificationCount(unreadCount);\n }\n }, [titleCounterEnabled, unreadCount, setNotificationCount]);\n\n const count = !error && !!unreadCount ? unreadCount : undefined;\n\n return (\n <>\n {snackbarEnabled && (\n <SnackbarProvider\n iconVariant={{\n normal: snackbarProps?.iconVariant?.normal ?? (\n <SeverityIcon severity=\"normal\" />\n ),\n critical: snackbarProps?.iconVariant?.critical ?? (\n <SeverityIcon severity=\"critical\" />\n ),\n high: snackbarProps?.iconVariant?.high ?? (\n <SeverityIcon severity=\"high\" />\n ),\n low: snackbarProps?.iconVariant?.low ?? (\n <SeverityIcon severity=\"low\" />\n ),\n }}\n dense={snackbarProps?.dense}\n maxSnack={snackbarProps?.maxSnack}\n Components={{\n normal:\n snackbarProps?.Components?.normal ?? StyledMaterialDesignContent,\n critical:\n snackbarProps?.Components?.critical ??\n StyledMaterialDesignContent,\n high:\n snackbarProps?.Components?.high ?? StyledMaterialDesignContent,\n low: snackbarProps?.Components?.low ?? StyledMaterialDesignContent,\n }}\n />\n )}\n <SidebarItem\n to={notificationsRoute}\n onClick={() => {\n requestUserPermission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AG,SAAA;AAAA,QAEH,QAAA,EAAA,KAAA,wBAAU,IAAA,EAAA,EAAK,IAAA,EAAK,SAAQ,KAAA,EAAO,KAAA,GAAQ,EAAA,GAAK,KAAA,GAAQ,KAAA,EAAO;AAAA;AAAA;AAClE,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BulkActions.esm.js","sources":["../../../src/components/NotificationsTable/BulkActions.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport MarkAsUnreadIcon from '@material-ui/icons/Markunread' /* TODO: use Drafts and MarkAsUnread once we have mui 5 icons */;\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport MarkAsUnsavedIcon from '@material-ui/icons/LabelOff' /* TODO: use BookmarkRemove and BookmarkAdd once we have mui 5 icons */;\nimport MarkAsSavedIcon from '@material-ui/icons/Label';\nimport MarkAllReadIcon from '@material-ui/icons/DoneAll';\n\nexport const BulkActions = ({\n selectedNotifications,\n notifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n}: {\n selectedNotifications: Set<Notification['id']>;\n notifications: Notification[];\n isUnread?: boolean;\n onSwitchReadStatus: (ids: Notification['id'][], newStatus: boolean) => void;\n onSwitchSavedStatus: (ids: Notification['id'][], newStatus: boolean) => void;\n onMarkAllRead?: () => void;\n}) => {\n const isDisabled = selectedNotifications.size === 0;\n const bulkNotifications = notifications.filter(notification =>\n selectedNotifications.has(notification.id),\n );\n\n const isOneRead = !!bulkNotifications.find(\n (notification: Notification) => !!notification.read,\n );\n const isOneSaved = !!bulkNotifications.find(\n (notification: Notification) => !!notification.saved,\n );\n\n const markAsReadText = isOneRead\n ? 'Return selected among unread'\n : 'Mark selected as read';\n const IconComponent = isOneRead ? MarkAsUnreadIcon : MarkAsReadIcon;\n\n const markAsSavedText = isOneSaved\n ? 'Undo save for selected'\n : 'Save selected for later';\n const SavedIconComponent = isOneSaved ? MarkAsUnsavedIcon : MarkAsSavedIcon;\n\n return (\n <Grid container wrap=\"nowrap\">\n <Grid item xs={3}>\n {onMarkAllRead ? (\n <Tooltip title=\"Mark all read\">\n <div>\n {/* The <div> here is a workaround for the Tooltip which does not work for a \"disabled\" child */}\n <IconButton disabled={!isUnread} onClick={onMarkAllRead}>\n <MarkAllReadIcon aria-label={markAsSavedText} />\n </IconButton>\n </div>\n </Tooltip>\n ) : (\n <div />\n )}\n </Grid>\n\n <Grid item xs={3}>\n <Tooltip title={markAsSavedText}>\n <div>\n {/* The <div> here is a workaround for the Tooltip which does not work for a \"disabled\" child */}\n <IconButton\n disabled={isDisabled}\n onClick={() => {\n onSwitchSavedStatus([...selectedNotifications], !isOneSaved);\n }}\n >\n <SavedIconComponent aria-label={markAsSavedText} />\n </IconButton>\n </div>\n </Tooltip>\n </Grid>\n\n <Grid item xs={3}>\n <Tooltip title={markAsReadText}>\n <div>\n <IconButton\n disabled={isDisabled}\n onClick={() => {\n onSwitchReadStatus([...selectedNotifications], !isOneRead);\n }}\n >\n <IconComponent aria-label={markAsReadText} />\n </IconButton>\n </div>\n </Tooltip>\n </Grid>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyBO,MAAM,cAAc,CAAC;AAAA,EAC1B,qBAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,E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AA,CAAC,SAAI,CAET,EAAA,CAAA;AAAA,oBAEA,GAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,EAAA,EAAI,CACb,EAAA,QAAA,kBAAA,GAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAO,eACd,EAAA,QAAA,kBAAA,GAAA,CAAC,KAEC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,UAAA;AAAA,QACV,SAAS,MAAM;AACb,UAAA,mBAAA,CAAoB,CAAC,GAAG,qBAAqB,CAAA,EAAG,CAAC,UAAU,CAAA;AAAA,SAC7D;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,kBAAmB,EAAA,EAAA,YAAA,EAAY,eAAiB,EAAA;AAAA;AAAA,KACnD,EACF,GACF,CACF,EAAA,CAAA;AAAA,oBAEA,GAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,EAAA,EAAI,CACb,EAAA,QAAA,kBAAA,GAAA,CAAC,OAAQ,EAAA,EAAA,KAAA,EAAO,cACd,EAAA,QAAA,kBAAA,GAAA,CAAC,KACC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,UAAA;AAAA,QACV,SAAS,MAAM;AACb,UAAA,kBAAA,CAAmB,CAAC,GAAG,qBAAqB,CAAA,EAAG,CAAC,SAAS,CAAA;AAAA,SAC3D;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,aAAc,EAAA,EAAA,YAAA,EAAY,cAAgB,EAAA;AAAA;AAAA,KAC7C,EACF,GACF,CACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"BulkActions.esm.js","sources":["../../../src/components/NotificationsTable/BulkActions.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport MarkAsUnreadIcon from '@material-ui/icons/Markunread' /* TODO: use Drafts and MarkAsUnread once we have mui 5 icons */;\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport MarkAsUnsavedIcon from '@material-ui/icons/LabelOff' /* TODO: use BookmarkRemove and BookmarkAdd once we have mui 5 icons */;\nimport MarkAsSavedIcon from '@material-ui/icons/Label';\nimport MarkAllReadIcon from '@material-ui/icons/DoneAll';\n\nexport const BulkActions = ({\n selectedNotifications,\n notifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n}: {\n selectedNotifications: Set<Notification['id']>;\n notifications: Notification[];\n isUnread?: boolean;\n onSwitchReadStatus: (ids: Notification['id'][], newStatus: boolean) => void;\n onSwitchSavedStatus: (ids: Notification['id'][], newStatus: boolean) => void;\n onMarkAllRead?: () => void;\n}) => {\n const isDisabled = selectedNotifications.size === 0;\n const bulkNotifications = notifications.filter(notification =>\n selectedNotifications.has(notification.id),\n );\n\n const isOneRead = !!bulkNotifications.find(\n (notification: Notification) => !!notification.read,\n );\n const isOneSaved = !!bulkNotifications.find(\n (notification: Notification) => !!notification.saved,\n );\n\n const markAsReadText = isOneRead\n ? 'Return selected among unread'\n : 'Mark selected as read';\n const IconComponent = isOneRead ? MarkAsUnreadIcon : MarkAsReadIcon;\n\n const markAsSavedText = isOneSaved\n ? 'Undo save for selected'\n : 'Save selected for later';\n const SavedIconComponent = isOneSaved ? MarkAsUnsavedIcon : MarkAsSavedIcon;\n\n return (\n <Grid container wrap=\"nowrap\">\n <Grid item xs={3}>\n {onMarkAllRead ? (\n <Tooltip title=\"Mark all read\">\n <div>\n {/* The <div> here is a workaround for the Tooltip which does not work for a \"disabled\" child */}\n <IconButton disabled={!isUnread} onClick={onMarkAllRead}>\n <MarkAllReadIcon aria-label={markAsSavedText} />\n </IconButton>\n </div>\n </Tooltip>\n ) : (\n <div />\n )}\n </Grid>\n\n <Grid item xs={3}>\n <Tooltip title={markAsSavedText}>\n <div>\n {/* The <div> here is a workaround for the Tooltip which does not work for a \"disabled\" child */}\n <IconButton\n disabled={isDisabled}\n onClick={() => {\n onSwitchSavedStatus([...selectedNotifications], !isOneSaved);\n }}\n >\n <SavedIconComponent aria-label={markAsSavedText} />\n </IconButton>\n </div>\n </Tooltip>\n </Grid>\n\n <Grid item xs={3}>\n <Tooltip title={markAsReadText}>\n <div>\n <IconButton\n disabled={isDisabled}\n onClick={() => {\n onSwitchReadStatus([...selectedNotifications], !isOneRead);\n }}\n >\n <IconComponent aria-label={markAsReadText} />\n </IconButton>\n </div>\n </Tooltip>\n </Grid>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyBO,MAAM,cAAc,CAAC;AAAA,EAC1B,qBAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAA,KAOM;AACJ,EAAA,MAAM,UAAA,GAAa,sBAAsB,IAAA,KAAS,CAAA;AAClD,EAAA,MAAM,oBAAoB,aAAA,CAAc,MAAA;AAAA,IAAO,CAAA,YAAA,KAC7C,qBAAA,CAAsB,GAAA,CAAI,YAAA,CAAa,EAAE;AAAA,GAC3C;AAEA,EAAA,MAAM,SAAA,GAAY,CAAC,CAAC,iBAAA,CAAkB,IAAA;AAAA,IACpC,CAAC,YAAA,KAA+B,CAAC,CAAC,YAAA,CAAa;AAAA,GACjD;AAC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A,mBAAA,CAAoB,CAAC,GAAG,qBAAqB,CAAA,EAAG,CAAC,UAAU,CAAA;AAAA,QAC7D,CAAA;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,kBAAA,EAAA,EAAmB,YAAA,EAAY,eAAA,EAAiB;AAAA;AAAA,KACnD,EACF,GACF,CAAA,EACF,CAAA;AAAA,oBAEA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,CAAA,EACb,QAAA,kBAAA,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAO,cAAA,EACd,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,QAAA,EAAU,UAAA;AAAA,QACV,SAAS,MAAM;AACb,UAAA,kBAAA,CAAmB,CAAC,GAAG,qBAAqB,CAAA,EAAG,CAAC,SAAS,CAAA;AAAA,QAC3D,CAAA;AAAA,QAEA,QAAA,kBAAA,GAAA,CAAC,aAAA,EAAA,EAAc,YAAA,EAAY,cAAA,EAAgB;AAAA;AAAA,KAC7C,EACF,GACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationIcon.esm.js","sources":["../../../src/components/NotificationsTable/NotificationIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport SvgIcon from '@material-ui/core/SvgIcon';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { SeverityIcon } from './SeverityIcon';\n\nexport const NotificationIcon = ({\n notification,\n}: {\n notification: Notification;\n}) => {\n const app = useApp();\n\n if (notification.payload.icon) {\n const Icon = app.getSystemIcon(notification.payload.icon) ?? SvgIcon;\n return <Icon />;\n }\n return <SeverityIcon severity={notification.payload.severity} />;\n};\n"],"names":[],"mappings":";;;;;AAoBO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AACF,CAEM,KAAA;AACJ,EAAA,MAAM,MAAM,MAAO,EAAA;AAEnB,EAAI,IAAA,YAAA,CAAa,QAAQ,IAAM,EAAA;AAC7B,IAAA,MAAM,OAAO,GAAI,CAAA,aAAA,CAAc,YAAa,CAAA,OAAA,CAAQ,IAAI,CAAK,IAAA,OAAA;AAC7D,IAAA,2BAAQ,IAAK,EAAA,EAAA,CAAA;AAAA;AAEf,EAAA,uBAAQ,GAAA,CAAA,YAAA,EAAA,EAAa,QAAU,EAAA,YAAA,CAAa,QAAQ,QAAU,EAAA,CAAA;AAChE;;;;"}
1
+ {"version":3,"file":"NotificationIcon.esm.js","sources":["../../../src/components/NotificationsTable/NotificationIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport SvgIcon from '@material-ui/core/SvgIcon';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { SeverityIcon } from './SeverityIcon';\n\nexport const NotificationIcon = ({\n notification,\n}: {\n notification: Notification;\n}) => {\n const app = useApp();\n\n if (notification.payload.icon) {\n const Icon = app.getSystemIcon(notification.payload.icon) ?? SvgIcon;\n return <Icon />;\n }\n return <SeverityIcon severity={notification.payload.severity} />;\n};\n"],"names":[],"mappings":";;;;;AAoBO,MAAM,mBAAmB,CAAC;AAAA,EAC/B;AACF,CAAA,KAEM;AACJ,EAAA,MAAM,MAAM,MAAA,EAAO;AAEnB,EAAA,IAAI,YAAA,CAAa,QAAQ,IAAA,EAAM;AAC7B,IAAA,MAAM,OAAO,GAAA,CAAI,aAAA,CAAc,YAAA,CAAa,OAAA,CAAQ,IAAI,CAAA,IAAK,OAAA;AAC7D,IAAA,2BAAQ,IAAA,EAAA,EAAK,CAAA;AAAA,EACf;AACA,EAAA,uBAAO,GAAA,CAAC,YAAA,EAAA,EAAa,QAAA,EAAU,YAAA,CAAa,QAAQ,QAAA,EAAU,CAAA;AAChE;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsTable.esm.js","sources":["../../../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useCallback, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport CheckBox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { useConfirm } from 'material-ui-confirm';\nimport BroadcastIcon from '@material-ui/icons/RssFeed';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n Link,\n Table,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\n\nimport { notificationsApiRef } from '../../api';\nimport { SelectAll } from './SelectAll';\nimport { BulkActions } from './BulkActions';\nimport { NotificationIcon } from './NotificationIcon';\n\nconst ThrottleDelayMs = 1000;\n\nconst useStyles = makeStyles(theme => ({\n description: {\n maxHeight: '5rem',\n overflow: 'auto',\n },\n severityItem: {\n alignContent: 'center',\n },\n broadcastIcon: {\n fontSize: '1rem',\n verticalAlign: 'text-bottom',\n },\n notificationInfoRow: {\n marginLeft: theme.spacing(0.5),\n marginRight: theme.spacing(0.5),\n },\n}));\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'\n> & {\n markAsReadOnLinkOpen?: boolean;\n isLoading?: boolean;\n isUnread: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n title,\n markAsReadOnLinkOpen,\n isLoading,\n notifications = [],\n isUnread,\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const classes = useStyles();\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const confirm = useConfirm();\n\n const [selectedNotifications, setSelectedNotifications] = useState(\n new Set<Notification['id']>(),\n );\n\n const onNotificationsSelectChange = useCallback(\n (ids: Notification['id'][], checked: boolean) => {\n let newSelect: Set<Notification['id']>;\n if (checked) {\n newSelect = new Set([...selectedNotifications, ...ids]);\n } else {\n newSelect = new Set(selectedNotifications);\n ids.forEach(id => newSelect.delete(id));\n }\n setSelectedNotifications(newSelect);\n },\n [selectedNotifications, setSelectedNotifications],\n );\n\n const onSwitchReadStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n read: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onSwitchSavedStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n saved: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onMarkAllRead = useCallback(() => {\n confirm({\n title: 'Are you sure?',\n description: (\n <>\n Mark <b>all</b> notifications as <b>read</b>.\n </>\n ),\n confirmationText: 'Mark All',\n })\n .then(async () => {\n const ids = (\n await notificationsApi.getNotifications({ read: false })\n ).notifications?.map(notification => notification.id);\n\n return notificationsApi\n .updateNotifications({\n ids,\n read: true,\n })\n .then(onUpdate);\n })\n .catch(e => {\n if (e) {\n // if e === undefined, the Cancel button has been hit\n alertApi.post({\n message: 'Failed to mark all notifications as read',\n severity: 'error',\n });\n }\n });\n }, [alertApi, confirm, notificationsApi, onUpdate]);\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n useEffect(() => {\n const allShownIds = new Set(notifications.map(n => n.id));\n const intersect = [...selectedNotifications].filter(id =>\n allShownIds.has(id),\n );\n if (selectedNotifications.size !== intersect.length) {\n setSelectedNotifications(new Set(intersect));\n }\n }, [notifications, selectedNotifications]);\n\n const compactColumns = useMemo((): TableColumn<Notification>[] => {\n const showToolbar = notifications.length > 0;\n return [\n {\n /* selection column */\n width: '1rem',\n title: showToolbar ? (\n <SelectAll\n count={selectedNotifications.size}\n totalCount={notifications.length}\n onSelectAll={() =>\n onNotificationsSelectChange(\n notifications.map(notification => notification.id),\n selectedNotifications.size !== notifications.length,\n )\n }\n />\n ) : undefined,\n render: (notification: Notification) => (\n <CheckBox\n color=\"primary\"\n checked={selectedNotifications.has(notification.id)}\n onChange={(_, checked) =>\n onNotificationsSelectChange([notification.id], checked)\n }\n />\n ),\n },\n {\n /* compact-data column */\n customFilterAndSearch: () =>\n true /* Keep sorting&filtering on backend due to pagination. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <Grid container>\n <Grid item className={classes.severityItem}>\n <NotificationIcon notification={notification} />\n </Grid>\n <Grid item xs={11}>\n <Box>\n <Typography variant=\"subtitle1\">\n {notification.payload.link ? (\n <Link\n to={notification.payload.link}\n onClick={() => {\n if (markAsReadOnLinkOpen && !notification.read) {\n onSwitchReadStatus([notification.id], true);\n }\n }}\n >\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n {notification.payload.description ? (\n <Typography variant=\"body2\" className={classes.description}>\n {notification.payload.description}\n </Typography>\n ) : null}\n\n <Typography variant=\"caption\">\n {!notification.user && (\n <>\n <BroadcastIcon className={classes.broadcastIcon} />\n </>\n )}\n {notification.origin && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.origin}\n </Typography>\n &bull;\n </>\n )}\n {notification.payload.topic && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.payload.topic}\n </Typography>\n &bull;\n </>\n )}\n {notification.created && (\n <RelativeTime\n value={notification.created}\n className={classes.notificationInfoRow}\n />\n )}\n </Typography>\n </Box>\n </Grid>\n </Grid>\n );\n },\n },\n {\n /* actions column */\n width: '1rem',\n title: showToolbar ? (\n <BulkActions\n notifications={notifications}\n selectedNotifications={selectedNotifications}\n isUnread={isUnread}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n onMarkAllRead={onMarkAllRead}\n />\n ) : undefined,\n render: (notification: Notification) => (\n <BulkActions\n notifications={[notification]}\n selectedNotifications={new Set([notification.id])}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n />\n ),\n },\n ];\n }, [\n notifications,\n selectedNotifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n onNotificationsSelectChange,\n classes.severityItem,\n classes.description,\n classes.broadcastIcon,\n classes.notificationInfoRow,\n markAsReadOnLinkOpen,\n ]);\n\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n padding: 'dense',\n search: true,\n paging: true,\n pageSize,\n header: true,\n sorting: false,\n }}\n title={title}\n onPageChange={onPageChange}\n onRowsPerPageChange={onRowsPerPageChange}\n page={page}\n totalCount={totalCount}\n onSearchChange={throttledContainsTextHandler}\n data={notifications}\n columns={compactColumns}\n />\n );\n};\n"],"names":["CheckBox"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,eAAkB,GAAA,GAAA;AAExB,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,WAAa,EAAA;AAAA,IACX,SAAW,EAAA,MAAA;AAAA,IACX,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,aAAe,EAAA;AAAA,IACb,QAAU,EAAA,MAAA;AAAA,IACV,aAAe,EAAA;AAAA,GACjB;AAAA,EACA,mBAAqB,EAAA;AAAA,IACnB,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC7B,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA;AAElC,CAAE,CAAA,CAAA;AAiBK,MAAM,qBAAqB,CAAC;AAAA,EACjC,KAAA;AAAA,EACA,oBAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAgB,EAAC;AAAA,EACjB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAA+B,KAAA;AAC7B,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AACnD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,UAAU,UAAW,EAAA;AAE3B,EAAM,MAA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CAAa,EAAE,CAAC,CAAA;AAAA,YAChD,kBAAA;AAAA,YACA;AAAA;AAAA;AACF;AAEJ,KACF;AAAA,GACC,EAAA;AAAA,IACD,aAAA;AAAA,IACA,qBAAA;AAAA,IACA,QAAA;AAAA,IACA,kBAAA;AAAA,IACA,mBAAA;AAAA,IACA,aAAA;AAAA,IACA,2BAAA;AAAA,IACA,OAAQ,CAAA,YAAA;AAAA,IACR,OAAQ,CAAA,WAAA;AAAA,IACR,OAAQ,CAAA,aAAA;AAAA,IACR,OAAQ,CAAA,mBAAA;AAAA,IACR;AAAA,GACD,CAAA;AAED,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,OAAS,EAAA,OAAA;AAAA,QACT,MAAQ,EAAA,IAAA;AAAA,QACR,MAAQ,EAAA,IAAA;AAAA,QACR,QAAA;AAAA,QACA,MAAQ,EAAA,IAAA;AAAA,QACR,OAAS,EAAA;AAAA,OACX;AAAA,MACA,KAAA;AAAA,MACA,YAAA;AAAA,MACA,mBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAgB,EAAA,4BAAA;AAAA,MAChB,IAAM,EAAA,aAAA;AAAA,MACN,OAAS,EAAA;AAAA;AAAA,GACX;AAEJ;;;;"}
1
+ {"version":3,"file":"NotificationsTable.esm.js","sources":["../../../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useCallback, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport CheckBox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { useConfirm } from 'material-ui-confirm';\nimport BroadcastIcon from '@material-ui/icons/RssFeed';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n Link,\n Table,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\n\nimport { notificationsApiRef } from '../../api';\nimport { SelectAll } from './SelectAll';\nimport { BulkActions } from './BulkActions';\nimport { NotificationIcon } from './NotificationIcon';\n\nconst ThrottleDelayMs = 1000;\n\nconst useStyles = makeStyles(theme => ({\n description: {\n maxHeight: '5rem',\n overflow: 'auto',\n },\n severityItem: {\n alignContent: 'center',\n },\n broadcastIcon: {\n fontSize: '1rem',\n verticalAlign: 'text-bottom',\n },\n notificationInfoRow: {\n marginLeft: theme.spacing(0.5),\n marginRight: theme.spacing(0.5),\n },\n}));\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'\n> & {\n markAsReadOnLinkOpen?: boolean;\n isLoading?: boolean;\n isUnread: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n title,\n markAsReadOnLinkOpen,\n isLoading,\n notifications = [],\n isUnread,\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const classes = useStyles();\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const confirm = useConfirm();\n\n const [selectedNotifications, setSelectedNotifications] = useState(\n new Set<Notification['id']>(),\n );\n\n const onNotificationsSelectChange = useCallback(\n (ids: Notification['id'][], checked: boolean) => {\n let newSelect: Set<Notification['id']>;\n if (checked) {\n newSelect = new Set([...selectedNotifications, ...ids]);\n } else {\n newSelect = new Set(selectedNotifications);\n ids.forEach(id => newSelect.delete(id));\n }\n setSelectedNotifications(newSelect);\n },\n [selectedNotifications, setSelectedNotifications],\n );\n\n const onSwitchReadStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n read: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onSwitchSavedStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n saved: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onMarkAllRead = useCallback(() => {\n confirm({\n title: 'Are you sure?',\n description: (\n <>\n Mark <b>all</b> notifications as <b>read</b>.\n </>\n ),\n confirmationText: 'Mark All',\n })\n .then(async () => {\n const ids = (\n await notificationsApi.getNotifications({ read: false })\n ).notifications?.map(notification => notification.id);\n\n return notificationsApi\n .updateNotifications({\n ids,\n read: true,\n })\n .then(onUpdate);\n })\n .catch(e => {\n if (e) {\n // if e === undefined, the Cancel button has been hit\n alertApi.post({\n message: 'Failed to mark all notifications as read',\n severity: 'error',\n });\n }\n });\n }, [alertApi, confirm, notificationsApi, onUpdate]);\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n useEffect(() => {\n const allShownIds = new Set(notifications.map(n => n.id));\n const intersect = [...selectedNotifications].filter(id =>\n allShownIds.has(id),\n );\n if (selectedNotifications.size !== intersect.length) {\n setSelectedNotifications(new Set(intersect));\n }\n }, [notifications, selectedNotifications]);\n\n const compactColumns = useMemo((): TableColumn<Notification>[] => {\n const showToolbar = notifications.length > 0;\n return [\n {\n /* selection column */\n width: '1rem',\n title: showToolbar ? (\n <SelectAll\n count={selectedNotifications.size}\n totalCount={notifications.length}\n onSelectAll={() =>\n onNotificationsSelectChange(\n notifications.map(notification => notification.id),\n selectedNotifications.size !== notifications.length,\n )\n }\n />\n ) : undefined,\n render: (notification: Notification) => (\n <CheckBox\n color=\"primary\"\n checked={selectedNotifications.has(notification.id)}\n onChange={(_, checked) =>\n onNotificationsSelectChange([notification.id], checked)\n }\n />\n ),\n },\n {\n /* compact-data column */\n customFilterAndSearch: () =>\n true /* Keep sorting&filtering on backend due to pagination. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <Grid container>\n <Grid item className={classes.severityItem}>\n <NotificationIcon notification={notification} />\n </Grid>\n <Grid item xs={11}>\n <Box>\n <Typography variant=\"subtitle1\">\n {notification.payload.link ? (\n <Link\n to={notification.payload.link}\n onClick={() => {\n if (markAsReadOnLinkOpen && !notification.read) {\n onSwitchReadStatus([notification.id], true);\n }\n }}\n >\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n {notification.payload.description ? (\n <Typography variant=\"body2\" className={classes.description}>\n {notification.payload.description}\n </Typography>\n ) : null}\n\n <Typography variant=\"caption\">\n {!notification.user && (\n <>\n <BroadcastIcon className={classes.broadcastIcon} />\n </>\n )}\n {notification.origin && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.origin}\n </Typography>\n &bull;\n </>\n )}\n {notification.payload.topic && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.payload.topic}\n </Typography>\n &bull;\n </>\n )}\n {notification.created && (\n <RelativeTime\n value={notification.created}\n className={classes.notificationInfoRow}\n />\n )}\n </Typography>\n </Box>\n </Grid>\n </Grid>\n );\n },\n },\n {\n /* actions column */\n width: '1rem',\n title: showToolbar ? (\n <BulkActions\n notifications={notifications}\n selectedNotifications={selectedNotifications}\n isUnread={isUnread}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n onMarkAllRead={onMarkAllRead}\n />\n ) : undefined,\n render: (notification: Notification) => (\n <BulkActions\n notifications={[notification]}\n selectedNotifications={new Set([notification.id])}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n />\n ),\n },\n ];\n }, [\n notifications,\n selectedNotifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n onNotificationsSelectChange,\n classes.severityItem,\n classes.description,\n classes.broadcastIcon,\n classes.notificationInfoRow,\n markAsReadOnLinkOpen,\n ]);\n\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n padding: 'dense',\n search: true,\n paging: true,\n pageSize,\n header: true,\n sorting: false,\n }}\n title={title}\n onPageChange={onPageChange}\n onRowsPerPageChange={onRowsPerPageChange}\n page={page}\n totalCount={totalCount}\n onSearchChange={throttledContainsTextHandler}\n data={notifications}\n columns={compactColumns}\n />\n );\n};\n"],"names":["CheckBox"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,eAAA,GAAkB,GAAA;AAExB,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,WAAA,EAAa;AAAA,IACX,SAAA,EAAW,MAAA;AAAA,IACX,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,aAAA,EAAe;AAAA,IACb,QAAA,EAAU,MAAA;AAAA,IACV,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,mBAAA,EAAqB;AAAA,IACnB,UAAA,EAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC7B,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,GAAG;AAAA;AAElC,CAAA,CAAE,CAAA;AAiBK,MAAM,qBAAqB,CAAC;AAAA,EACjC,KAAA;AAAA,EACA,oBAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAgB,EAAC;AAAA,EACjB,QAAA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@ -1 +1 @@
1
- {"version":3,"file":"SelectAll.esm.js","sources":["../../../src/components/NotificationsTable/SelectAll.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles({\n label: {\n marginLeft: '0px',\n maxWidth: '2rem',\n '& span': {\n paddingRight: '0px',\n },\n },\n});\n\nexport const SelectAll = ({\n count,\n totalCount,\n onSelectAll,\n}: {\n count: number;\n totalCount: number;\n onSelectAll: () => void;\n}) => {\n const classes = useStyles();\n\n return (\n <FormControlLabel\n label={count > 0 ? `(${count})` : undefined}\n className={classes.label}\n control={\n <Checkbox\n color=\"primary\"\n disabled={!totalCount}\n checked={count > 0}\n indeterminate={count > 0 && totalCount !== count}\n onChange={onSelectAll}\n />\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;AAmBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,KAAO,EAAA;AAAA,IACL,UAAY,EAAA,KAAA;AAAA,IACZ,QAAU,EAAA,MAAA;AAAA,IACV,QAAU,EAAA;AAAA,MACR,YAAc,EAAA;AAAA;AAChB;AAEJ,CAAC,CAAA;AAEM,MAAM,YAAY,CAAC;AAAA,EACxB,KAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,EACE,uBAAA,GAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,KAAA,GAAQ,CAAI,GAAA,CAAA,CAAA,EAAI,KAAK,CAAM,CAAA,CAAA,GAAA,KAAA,CAAA;AAAA,MAClC,WAAW,OAAQ,CAAA,KAAA;AAAA,MACnB,OACE,kBAAA,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,KAAM,EAAA,SAAA;AAAA,UACN,UAAU,CAAC,UAAA;AAAA,UACX,SAAS,KAAQ,GAAA,CAAA;AAAA,UACjB,aAAA,EAAe,KAAQ,GAAA,CAAA,IAAK,UAAe,KAAA,KAAA;AAAA,UAC3C,QAAU,EAAA;AAAA;AAAA;AACZ;AAAA,GAEJ;AAEJ;;;;"}
1
+ {"version":3,"file":"SelectAll.esm.js","sources":["../../../src/components/NotificationsTable/SelectAll.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles({\n label: {\n marginLeft: '0px',\n maxWidth: '2rem',\n '& span': {\n paddingRight: '0px',\n },\n },\n});\n\nexport const SelectAll = ({\n count,\n totalCount,\n onSelectAll,\n}: {\n count: number;\n totalCount: number;\n onSelectAll: () => void;\n}) => {\n const classes = useStyles();\n\n return (\n <FormControlLabel\n label={count > 0 ? `(${count})` : undefined}\n className={classes.label}\n control={\n <Checkbox\n color=\"primary\"\n disabled={!totalCount}\n checked={count > 0}\n indeterminate={count > 0 && totalCount !== count}\n onChange={onSelectAll}\n />\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;AAmBA,MAAM,YAAY,UAAA,CAAW;AAAA,EAC3B,KAAA,EAAO;AAAA,IACL,UAAA,EAAY,KAAA;AAAA,IACZ,QAAA,EAAU,MAAA;AAAA,IACV,QAAA,EAAU;AAAA,MACR,YAAA,EAAc;AAAA;AAChB;AAEJ,CAAC,CAAA;AAEM,MAAM,YAAY,CAAC;AAAA,EACxB,KAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAIM;AACJ,EAAA,MAAM,UAAU,SAAA,EAAU;AAE1B,EAAA,uBACE,GAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,KAAA,GAAQ,CAAA,GAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,CAAA,GAAM,MAAA;AAAA,MAClC,WAAW,OAAA,CAAQ,KAAA;AAAA,MACnB,OAAA,kBACE,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,SAAA;AAAA,UACN,UAAU,CAAC,UAAA;AAAA,UACX,SAAS,KAAA,GAAQ,CAAA;AAAA,UACjB,aAAA,EAAe,KAAA,GAAQ,CAAA,IAAK,UAAA,KAAe,KAAA;AAAA,UAC3C,QAAA,EAAU;AAAA;AAAA;AACZ;AAAA,GAEJ;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SeverityIcon.esm.js","sources":["../../../src/components/NotificationsTable/SeverityIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\nimport NormalIcon from '@material-ui/icons/CheckOutlined';\nimport CriticalIcon from '@material-ui/icons/ErrorOutline';\nimport HighIcon from '@material-ui/icons/WarningOutlined';\nimport LowIcon from '@material-ui/icons/InfoOutlined';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(theme => ({\n critical: {\n color: theme.palette.status.error,\n },\n high: {\n color: theme.palette.status.warning,\n },\n normal: {\n color: theme.palette.status.ok,\n },\n low: {\n color: theme.palette.status.running,\n },\n}));\n\nexport const SeverityIcon = ({\n severity,\n}: {\n severity?: NotificationSeverity;\n}) => {\n const classes = useStyles();\n\n switch (severity) {\n case 'critical':\n return <CriticalIcon className={classes.critical} />;\n case 'high':\n return <HighIcon className={classes.high} />;\n case 'low':\n return <LowIcon className={classes.low} />;\n case 'normal':\n default:\n return <NormalIcon className={classes.normal} />;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAsBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,QAAU,EAAA;AAAA,IACR,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,GAC9B;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,GAC9B;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,GAC9B;AAAA,EACA,GAAK,EAAA;AAAA,IACH,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA;AAEhC,CAAE,CAAA,CAAA;AAEK,MAAM,eAAe,CAAC;AAAA,EAC3B;AACF,CAEM,KAAA;AACJ,EAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,EAAA,QAAQ,QAAU;AAAA,IAChB,KAAK,UAAA;AACH,MAAA,uBAAQ,GAAA,CAAA,YAAA,EAAA,EAAa,SAAW,EAAA,OAAA,CAAQ,QAAU,EAAA,CAAA;AAAA,IACpD,KAAK,MAAA;AACH,MAAA,uBAAQ,GAAA,CAAA,QAAA,EAAA,EAAS,SAAW,EAAA,OAAA,CAAQ,IAAM,EAAA,CAAA;AAAA,IAC5C,KAAK,KAAA;AACH,MAAA,uBAAQ,GAAA,CAAA,OAAA,EAAA,EAAQ,SAAW,EAAA,OAAA,CAAQ,GAAK,EAAA,CAAA;AAAA,IAC1C,KAAK,QAAA;AAAA,IACL;AACE,MAAA,uBAAQ,GAAA,CAAA,UAAA,EAAA,EAAW,SAAW,EAAA,OAAA,CAAQ,MAAQ,EAAA,CAAA;AAAA;AAEpD;;;;"}
1
+ {"version":3,"file":"SeverityIcon.esm.js","sources":["../../../src/components/NotificationsTable/SeverityIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\nimport NormalIcon from '@material-ui/icons/CheckOutlined';\nimport CriticalIcon from '@material-ui/icons/ErrorOutline';\nimport HighIcon from '@material-ui/icons/WarningOutlined';\nimport LowIcon from '@material-ui/icons/InfoOutlined';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(theme => ({\n critical: {\n color: theme.palette.status.error,\n },\n high: {\n color: theme.palette.status.warning,\n },\n normal: {\n color: theme.palette.status.ok,\n },\n low: {\n color: theme.palette.status.running,\n },\n}));\n\nexport const SeverityIcon = ({\n severity,\n}: {\n severity?: NotificationSeverity;\n}) => {\n const classes = useStyles();\n\n switch (severity) {\n case 'critical':\n return <CriticalIcon className={classes.critical} />;\n case 'high':\n return <HighIcon className={classes.high} />;\n case 'low':\n return <LowIcon className={classes.low} />;\n case 'normal':\n default:\n return <NormalIcon className={classes.normal} />;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAsBA,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,QAAA,EAAU;AAAA,IACR,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO;AAAA,GAC9B;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO;AAAA,GAC9B;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO;AAAA,GAC9B;AAAA,EACA,GAAA,EAAK;AAAA,IACH,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO;AAAA;AAEhC,CAAA,CAAE,CAAA;AAEK,MAAM,eAAe,CAAC;AAAA,EAC3B;AACF,CAAA,KAEM;AACJ,EAAA,MAAM,UAAU,SAAA,EAAU;AAE1B,EAAA,QAAQ,QAAA;AAAU,IAChB,KAAK,UAAA;AACH,MAAA,uBAAO,GAAA,CAAC,YAAA,EAAA,EAAa,SAAA,EAAW,OAAA,CAAQ,QAAA,EAAU,CAAA;AAAA,IACpD,KAAK,MAAA;AACH,MAAA,uBAAO,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,OAAA,CAAQ,IAAA,EAAM,CAAA;AAAA,IAC5C,KAAK,KAAA;AACH,MAAA,uBAAO,GAAA,CAAC,OAAA,EAAA,EAAQ,SAAA,EAAW,OAAA,CAAQ,GAAA,EAAK,CAAA;AAAA,IAC1C,KAAK,QAAA;AAAA,IACL;AACE,MAAA,uBAAO,GAAA,CAAC,UAAA,EAAA,EAAW,SAAA,EAAW,OAAA,CAAQ,MAAA,EAAQ,CAAA;AAAA;AAEpD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NoBorderTableCell.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/NoBorderTableCell.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { withStyles } from '@material-ui/core/styles';\nimport MuiTableCell from '@material-ui/core/TableCell';\n\nexport const NoBorderTableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n"],"names":[],"mappings":";;;AAmBO,MAAM,oBAAoB,UAAW,CAAA;AAAA,EAC1C,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA;AAAA;AAElB,CAAC,EAAE,YAAY;;;;"}
1
+ {"version":3,"file":"NoBorderTableCell.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/NoBorderTableCell.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { withStyles } from '@material-ui/core/styles';\nimport MuiTableCell from '@material-ui/core/TableCell';\n\nexport const NoBorderTableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n"],"names":[],"mappings":";;;AAmBO,MAAM,oBAAoB,UAAA,CAAW;AAAA,EAC1C,IAAA,EAAM;AAAA,IACJ,YAAA,EAAc;AAAA;AAElB,CAAC,EAAE,YAAY;;;;"}
@@ -10,7 +10,7 @@ import { NoBorderTableCell } from './NoBorderTableCell.esm.js';
10
10
  import { useNotificationFormat } from './UserNotificationSettingsCard.esm.js';
11
11
 
12
12
  const OriginRow = (props) => {
13
- const { channel, origin, settings, handleChange, open, handleRowToggle } = props;
13
+ const { origin, settings, handleChange, open, handleRowToggle } = props;
14
14
  const { formatOriginName } = useNotificationFormat();
15
15
  return /* @__PURE__ */ jsxs(TableRow, { children: [
16
16
  /* @__PURE__ */ jsx(NoBorderTableCell, { children: origin.topics && origin.topics.length > 0 && /* @__PURE__ */ jsx(
@@ -33,7 +33,7 @@ const OriginRow = (props) => {
33
33
  settings.channels.map((ch) => /* @__PURE__ */ jsx(NoBorderTableCell, { align: "center", children: /* @__PURE__ */ jsx(
34
34
  Tooltip,
35
35
  {
36
- title: `Enable or disable ${channel.id.toLocaleLowerCase(
36
+ title: `Enable or disable ${ch.id.toLocaleLowerCase(
37
37
  "en-US"
38
38
  )} notifications from ${formatOriginName(origin.id)}`,
39
39
  children: /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"OriginRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/OriginRow.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ChannelSetting,\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport IconButton from '@material-ui/core/IconButton';\nimport Switch from '@material-ui/core/Switch';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';\nimport KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nexport const OriginRow = (props: {\n channel: ChannelSetting;\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n open: boolean;\n handleRowToggle: (originId: string) => void;\n}) => {\n const { channel, origin, settings, handleChange, open, handleRowToggle } =\n props;\n const { formatOriginName } = useNotificationFormat();\n return (\n <TableRow>\n <NoBorderTableCell>\n {origin.topics && origin.topics.length > 0 && (\n <Tooltip\n title={`Show Topics for the ${formatOriginName(origin.id)} origin`}\n >\n <IconButton\n aria-label=\"expand row\"\n size=\"small\"\n onClick={() => handleRowToggle(origin.id)}\n >\n {open ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}\n </IconButton>\n </Tooltip>\n )}\n </NoBorderTableCell>\n <NoBorderTableCell>{formatOriginName(origin.id)}</NoBorderTableCell>\n <NoBorderTableCell>all</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={ch.id} align=\"center\">\n <Tooltip\n title={`Enable or disable ${channel.id.toLocaleLowerCase(\n 'en-US',\n )} notifications from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n null,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, null, event.target.checked);\n }}\n />\n </Tooltip>\n </NoBorderTableCell>\n ))}\n </TableRow>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA+Ba,MAAA,SAAA,GAAY,CAAC,KAYpB,KAAA;AACJ,EAAA,MAAM,EAAE,OAAS,EAAA,MAAA,EAAQ,U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EnD,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,yBAAA;AAAA,cACP,QAAA;AAAA,cACA,EAAG,CAAA,EAAA;AAAA,cACH,MAAO,CAAA,EAAA;AAAA,cACP;AAAA,aACF;AAAA,YACA,QAAA,EAAU,CAAC,KAA+C,KAAA;AACxD,cAAA,YAAA,CAAa,GAAG,EAAI,EAAA,MAAA,CAAO,IAAI,IAAM,EAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAC3D;AAAA;AACF;AAAA,KACF,EAAA,EAjBsB,EAAG,CAAA,EAkB3B,CACD;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"OriginRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/OriginRow.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport IconButton from '@material-ui/core/IconButton';\nimport Switch from '@material-ui/core/Switch';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';\nimport KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nexport const OriginRow = (props: {\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n open: boolean;\n handleRowToggle: (originId: string) => void;\n}) => {\n const { origin, settings, handleChange, open, handleRowToggle } = props;\n const { formatOriginName } = useNotificationFormat();\n return (\n <TableRow>\n <NoBorderTableCell>\n {origin.topics && origin.topics.length > 0 && (\n <Tooltip\n title={`Show Topics for the ${formatOriginName(origin.id)} origin`}\n >\n <IconButton\n aria-label=\"expand row\"\n size=\"small\"\n onClick={() => handleRowToggle(origin.id)}\n >\n {open ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}\n </IconButton>\n </Tooltip>\n )}\n </NoBorderTableCell>\n <NoBorderTableCell>{formatOriginName(origin.id)}</NoBorderTableCell>\n <NoBorderTableCell>all</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={ch.id} align=\"center\">\n <Tooltip\n title={`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n null,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, null, event.target.checked);\n }}\n />\n </Tooltip>\n </NoBorderTableCell>\n ))}\n </TableRow>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA8BO,MAAM,SAAA,GAAY,CAAC,KAAA,KAWpB;AACJ,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAU,YAAA,EAAc,IAAA,EAAM,iBAAgB,GAAI,KAAA;AAClE,EAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,qBAAA,EAAsB;AACnD,EAAA,4BACG,QAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,qBACE,QAAA,EAAA,MAAA,CAAO,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA,oBACvC,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAO,CA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AAA,YAC3D;AAAA;AAAA;AACF;AAAA,KACF,EAAA,EAjBsB,EAAA,CAAG,EAkB3B,CACD;AAAA,GAAA,EACH,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TopicRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/TopicRow.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n TopicSetting,\n} from '@backstage/plugin-notifications-common';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Switch from '@material-ui/core/Switch';\nimport { withStyles } from '@material-ui/core/styles';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nconst TopicTableRow = withStyles({\n root: {\n paddingLeft: '4px',\n },\n})(TableRow);\n\nexport const TopicRow = (props: {\n topic: TopicSetting;\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n}) => {\n const { topic, origin, settings, handleChange } = props;\n const { formatOriginName, formatTopicName } = useNotificationFormat();\n return (\n <TopicTableRow>\n <NoBorderTableCell />\n <NoBorderTableCell />\n <NoBorderTableCell>{formatTopicName(topic.id)}</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={`${ch.id}-${topic}`} align=\"center\">\n <Tooltip\n title={`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications for the ${formatTopicName(\n topic.id,\n )} topic from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n topic.id,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, topic.id, event.target.checked);\n }}\n />\n </Tooltip>\n </NoBorderTableCell>\n ))}\n </TopicTableRow>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA6BA,MAAM,gBAAgB,UAAW,CAAA;AAAA,EAC/B,IAAM,EAAA;AAAA,IACJ,WAAa,EAAA;AAAA;AAEjB,CAAC,EAAE,QAAQ,CAAA;AAEE,MAAA,QAAA,GAAW,CAAC,KAUnB,KAAA;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,MAAQ,EAAA,QAAA,EAAU,cAAiB,GAAA,KAAA;AAClD,EAAA,MAAM,EAAE,gBAAA,EAAkB,eAAgB,EAAA,GAAI,qBAAsB,EAAA;AACpE,EAAA,4BACG,aACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAkB,EAAA,EAAA,CAAA;AAAA,wBAClB,iBAAkB,EAAA,EAAA,CAAA;AAAA,oBAClB,GAAA,CAAA,iBAAA,EAAA,EAAmB,QAAgB,EAAA,eAAA,CAAA,KAAA,CAAM,EAAE,CAAE,EAAA,CAAA;AAAA,IAC7C,SAAS,QAAS,CAAA,GAAA,CAAI,wBACpB,GAAA,CAAA,iBAAA,EAAA,EAA4C,OAAM,QACjD,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAO,CAAqB,kBAAA,EAAA,EAAA,CAAG,EAAG,CAAA,iBAAA;AAAA,UAChC;AAAA,SACD,CAA0B,uBAAA,EAAA,eAAA;AAAA,UACzB,KAAM,CAAA;AAAA,SACP,CAAA,YAAA,EAAe,gBAAiB,CAAA,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA;AAAA,QAE3C,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,yBAAA;AAAA,cACP,QAAA;AAAA,cACA,EAAG,CAAA,EAAA;AAAA,cACH,MAAO,CAAA,EAAA;AAAA,cACP,KAAM,CAAA;AAAA,aACR;AAAA,YACA,QAAA,EAAU,CAAC,KAA+C,KAAA;AACxD,cAAa,YAAA,CAAA,EAAA,CAAG,IAAI,MAAO,CAAA,EAAA,EAAI,MAAM,EAAI,EAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAC/D;AAAA;AACF;AAAA,SAlBoB,CAAG,EAAA,EAAA,CAAG,EAAE,CAAI,CAAA,EAAA,KAAK,EAoBzC,CACD;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TopicRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/TopicRow.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n TopicSetting,\n} from '@backstage/plugin-notifications-common';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Switch from '@material-ui/core/Switch';\nimport { withStyles } from '@material-ui/core/styles';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nconst TopicTableRow = withStyles({\n root: {\n paddingLeft: '4px',\n },\n})(TableRow);\n\nexport const TopicRow = (props: {\n topic: TopicSetting;\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n}) => {\n const { topic, origin, settings, handleChange } = props;\n const { formatOriginName, formatTopicName } = useNotificationFormat();\n return (\n <TopicTableRow>\n <NoBorderTableCell />\n <NoBorderTableCell />\n <NoBorderTableCell>{formatTopicName(topic.id)}</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={`${ch.id}-${topic}`} align=\"center\">\n <Tooltip\n title={`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications for the ${formatTopicName(\n topic.id,\n )} topic from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n topic.id,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, topic.id, event.target.checked);\n }}\n />\n </Tooltip>\n </NoBorderTableCell>\n ))}\n </TopicTableRow>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA6BA,MAAM,gBAAgB,UAAA,CAAW;AAAA,EAC/B,IAAA,EAAM;AAAA,IACJ,WAAA,EAAa;AAAA;AAEjB,CAAC,EAAE,QAAQ,CAAA;AAEJ,MAAM,QAAA,GAAW,CAAC,KAAA,KAUnB;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,cAAa,GAAI,KAAA;AAClD,EAAA,MAAM,EAAE,gBAAA,EAAkB,eAAA,EAAgB,GAAI,qBAAA,EAAsB;AACpE,EAAA,4BACG,aAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,CAAA;AAAA,wBAClB,iBAAA,EAAA,EAAkB,CAAA;AAAA,oBACnB,GAAA,CAAC,iBAAA,EAAA,EAAmB,QAAA,EAAA,eAAA,CAAgB,KAAA,CAAM,EAAE,CAAA,EAAE,CAAA;AAAA,IAC7C,SAAS,QAAA,CAAS,GAAA,CAAI,wBACrB,GAAA,CAAC,iBAAA,EAAA,EAA4C,OAAM,QAAA,EACjD,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAO,CAAA,kBAAA,EAAqB,EAAA,CAAG,EAAA,CAAG,iBAAA;AAAA,UAChC;AAAA,SACD,CAAA,uBAAA,EAA0B,eAAA;AAAA,UACzB,KAAA,CAAM;AAAA,SACP,CAAA,YAAA,EAAe,gBAAA,CAAiB,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA;AAAA,QAE3C,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAA,EAAS,yBAAA;AAAA,cACP,QAAA;AAAA,cACA,EAAA,CAAG,EAAA;AAAA,cACH,MAAA,CAAO,EAAA;AAAA,cACP,KAAA,CAAM;AAAA,aACR;AAAA,YACA,QAAA,EAAU,CAAC,KAAA,KAA+C;AACxD,cAAA,YAAA,CAAa,EAAA,CAAG,IAAI,MAAA,CAAO,EAAA,EAAI,MAAM,EAAA,EAAI,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA,YAC/D;AAAA;AAAA;AACF;AAAA,SAlBoB,CAAA,EAAG,EAAA,CAAG,EAAE,CAAA,CAAA,EAAI,KAAK,EAoBzC,CACD;AAAA,GAAA,EACH,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"UserNotificationSettingsCard.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContext, useState, useContext, useEffect } from 'react';\nimport { ErrorPanel, InfoCard, Progress } from '@backstage/core-components';\nimport { useNotificationsApi } from '../../hooks';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel';\nimport { capitalize } from 'lodash';\n\ntype FormatContextType = {\n formatOriginName: (id: string) => string;\n formatTopicName: (id: string) => string;\n};\n\nconst NotificationFormatContext = createContext<FormatContextType | undefined>(\n undefined,\n);\n\nexport const useNotificationFormat = () => {\n const context = useContext(NotificationFormatContext);\n if (!context)\n throw new Error(\n 'useNotificationFormat must be used within a NotificationFormatProvider',\n );\n return context;\n};\n\ntype Props = {\n children: React.ReactNode;\n originMap: Record<string, string> | undefined;\n topicMap: Record<string, string> | undefined;\n};\n\nexport const NotificationFormatProvider = ({\n children,\n originMap,\n topicMap,\n}: Props) => {\n const formatName = (\n id: string,\n nameMap: Record<string, string> | undefined,\n ) => {\n if (nameMap && id in nameMap) {\n return nameMap[id];\n }\n return capitalize(id.replaceAll(/[-_:]/g, ' '));\n };\n\n const formatOriginName = (originId: string) => {\n return formatName(originId, originMap);\n };\n\n const formatTopicName = (topicId: string) => {\n return formatName(topicId, topicMap);\n };\n return (\n <NotificationFormatContext.Provider\n value={{ formatOriginName, formatTopicName }}\n >\n {children}\n </NotificationFormatContext.Provider>\n );\n};\n\n/** @public */\nexport const UserNotificationSettingsCard = (props: {\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const [settings, setNotificationSettings] = useState<\n NotificationSettings | undefined\n >(undefined);\n\n const client = useApi(notificationsApiRef);\n const { error, value, loading } = useNotificationsApi(api => {\n return api.getNotificationSettings();\n });\n\n useEffect(() => {\n if (!loading && !error) {\n setNotificationSettings(value);\n }\n }, [loading, value, error]);\n\n const onUpdate = (newSettings: NotificationSettings) => {\n client\n .updateNotificationSettings(newSettings)\n .then(updatedSettings => setNotificationSettings(updatedSettings));\n };\n\n return (\n <InfoCard title=\"Notification settings\" variant=\"gridItem\">\n {loading && <Progress />}\n {error && <ErrorPanel title=\"Failed to load settings\" error={error} />}\n {settings && (\n <NotificationFormatProvider\n originMap={props.originNames}\n topicMap={props.topicNames}\n >\n <UserNotificationSettingsPanel\n settings={settings}\n onChange={onUpdate}\n />\n </NotificationFormatProvider>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,yBAA4B,GAAA,aAAA;AAAA,EAChC,KAAA;AACF,CAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAM,MAAA,OAAA,GAAU,WAAW,yBAAyB,CAAA;AACpD,EAAA,IAAI,CAAC,OAAA;AACH,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AACF,EAAO,OAAA,OAAA;AACT;AAQO,MAAM,6BAA6B,CAAC;AAAA,EACzC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,UAAA,GAAa,CACjB,EAAA,EACA,OACG,KAAA;AACH,IAAI,IAAA,OAAA,IAAW,MAAM,OAAS,EAAA;AAC5B,MAAA,OAAO,QAAQ,EAAE,CAAA;AAAA;AAEnB,IAAA,OAAO,UAAW,CAAA,EAAA,CAAG,UAAW,CAAA,QAAA,EAAU,GAAG,CAAC,CAAA;AAAA,GAChD;AAEA,EAAM,MAAA,gBAAA,GAAmB,CAAC,QAAqB,KAAA;AAC7C,IAAO,OAAA,UAAA,CAAW,UAAU,SAAS,CAAA;AAAA,GACvC;AAEA,EAAM,MAAA,eAAA,GAAkB,CAAC,OAAoB,KAAA;AAC3C,IAAO,OAAA,UAAA,CAAW,SAAS,QAAQ,CAAA;AAAA,GACrC;AACA,EACE,uBAAA,GAAA;AAAA,IAAC,yBAA0B,CAAA,QAAA;AAAA,IAA1B;AAAA,MACC,KAAA,EAAO,EAAE,gBAAA,EAA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AAAA;AAAA;AACZ;AAAA;AACF,GAEJ,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"UserNotificationSettingsCard.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createContext, useState, useContext, useEffect } from 'react';\nimport { ErrorPanel, InfoCard, Progress } from '@backstage/core-components';\nimport { useNotificationsApi } from '../../hooks';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel';\nimport { capitalize } from 'lodash';\n\ntype FormatContextType = {\n formatOriginName: (id: string) => string;\n formatTopicName: (id: string) => string;\n};\n\nconst NotificationFormatContext = createContext<FormatContextType | undefined>(\n undefined,\n);\n\nexport const useNotificationFormat = () => {\n const context = useContext(NotificationFormatContext);\n if (!context)\n throw new Error(\n 'useNotificationFormat must be used within a NotificationFormatProvider',\n );\n return context;\n};\n\ntype Props = {\n children: React.ReactNode;\n originMap: Record<string, string> | undefined;\n topicMap: Record<string, string> | undefined;\n};\n\nexport const NotificationFormatProvider = ({\n children,\n originMap,\n topicMap,\n}: Props) => {\n const formatName = (\n id: string,\n nameMap: Record<string, string> | undefined,\n ) => {\n if (nameMap && id in nameMap) {\n return nameMap[id];\n }\n return capitalize(id.replaceAll(/[-_:]/g, ' '));\n };\n\n const formatOriginName = (originId: string) => {\n return formatName(originId, originMap);\n };\n\n const formatTopicName = (topicId: string) => {\n return formatName(topicId, topicMap);\n };\n return (\n <NotificationFormatContext.Provider\n value={{ formatOriginName, formatTopicName }}\n >\n {children}\n </NotificationFormatContext.Provider>\n );\n};\n\n/** @public */\nexport const UserNotificationSettingsCard = (props: {\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const [settings, setNotificationSettings] = useState<\n NotificationSettings | undefined\n >(undefined);\n\n const client = useApi(notificationsApiRef);\n const { error, value, loading } = useNotificationsApi(api => {\n return api.getNotificationSettings();\n });\n\n useEffect(() => {\n if (!loading && !error) {\n setNotificationSettings(value);\n }\n }, [loading, value, error]);\n\n const onUpdate = (newSettings: NotificationSettings) => {\n client\n .updateNotificationSettings(newSettings)\n .then(updatedSettings => setNotificationSettings(updatedSettings));\n };\n\n return (\n <InfoCard title=\"Notification settings\" variant=\"gridItem\">\n {loading && <Progress />}\n {error && <ErrorPanel title=\"Failed to load settings\" error={error} />}\n {settings && (\n <NotificationFormatProvider\n originMap={props.originNames}\n topicMap={props.topicNames}\n >\n <UserNotificationSettingsPanel\n settings={settings}\n onChange={onUpdate}\n />\n </NotificationFormatProvider>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,yBAAA,GAA4B,aAAA;AAAA,EAChC;AACF,CAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAA,MAAM,OAAA,GAAU,WAAW,yBAAyB,CAAA;AACpD,EAAA,IAAI,CAAC,OAAA;AACH,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AACF,EAAA,OAAO,OAAA;AACT;AAQO,MAAM,6BAA6B,CAAC;AAAA,EACzC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,KAAa;AACX,EAAA,MAAM,UAAA,GAAa,CACjB,EAAA,EACA,OAAA,KACG;AACH,IAAA,IAAI,OAAA,IAAW,MAAM,OAAA,EAAS;AAC5B,MAAA,OAAO,QAAQ,EAAE,CAAA;AAA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uBACE,IAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAM,uBAAA,EAAwB,SAAQ,UAAA,EAC7C,QAAA,EAAA;AAAA,IAAA,OAAA,wBAAY,QAAA,EAAA,EAAS,CAAA;AAAA,IACrB,KAAA,oBAAS,GAAA,CAAC,UAAA,EAAA,EAAW,KAAA,EAAM,2BAA0B,KAAA,EAAc,CAAA;AAAA,IACnE,QAAA,oBACC,GAAA;AAAA,MAAC,0BAAA;AAAA,MAAA;AAAA,QACC,WAAW,KAAA,CAAM,WAAA;AAAA,QACjB,UAAU,KAAA,CAAM,UAAA;AAAA,QAEhB,QAAA,kBAAA,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,QAAA,EAAU;AAAA;AAAA;AACZ;AAAA;AACF,GAAA,EAEJ,CAAA;AAEJ;;;;"}
@@ -71,6 +71,13 @@ const UserNotificationSettingsPanel = (props) => {
71
71
  if (settings.channels.length === 0) {
72
72
  return /* @__PURE__ */ jsx(Typography, { variant: "body1", children: "No notification settings available, check back later" });
73
73
  }
74
+ const uniqueOriginsMap = settings.channels.flatMap((channel) => channel.origins).reduce((map, origin) => {
75
+ if (!map.has(origin.id)) {
76
+ map.set(origin.id, origin);
77
+ }
78
+ return map;
79
+ }, /* @__PURE__ */ new Map()).values();
80
+ const uniqueOrigins = Array.from(uniqueOriginsMap);
74
81
  return /* @__PURE__ */ jsxs(Table, { children: [
75
82
  /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
76
83
  /* @__PURE__ */ jsx(TableCell, {}),
@@ -78,32 +85,29 @@ const UserNotificationSettingsPanel = (props) => {
78
85
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: "Topic" }) }),
79
86
  settings.channels.map((channel) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", align: "center", children: channel.id }) }, channel.id))
80
87
  ] }) }),
81
- /* @__PURE__ */ jsx(TableBody, { children: settings.channels.map(
82
- (channel) => channel.origins.flatMap((origin) => [
83
- /* @__PURE__ */ jsx(
84
- OriginRow,
85
- {
86
- channel,
87
- origin,
88
- settings,
89
- open: expandedRows.has(origin.id),
90
- handleChange,
91
- handleRowToggle
92
- },
93
- origin.id
94
- ),
95
- ...expandedRows.has(origin.id) ? origin.topics?.map((topic) => /* @__PURE__ */ jsx(
96
- TopicRow,
97
- {
98
- topic,
99
- origin,
100
- settings,
101
- handleChange
102
- },
103
- `${origin.id}-${topic.id}`
104
- )) || [] : []
105
- ])
106
- ) })
88
+ /* @__PURE__ */ jsx(TableBody, { children: uniqueOrigins.flatMap((origin) => [
89
+ /* @__PURE__ */ jsx(
90
+ OriginRow,
91
+ {
92
+ origin,
93
+ settings,
94
+ open: expandedRows.has(origin.id),
95
+ handleChange,
96
+ handleRowToggle
97
+ },
98
+ origin.id
99
+ ),
100
+ ...expandedRows.has(origin.id) ? origin.topics?.map((topic) => /* @__PURE__ */ jsx(
101
+ TopicRow,
102
+ {
103
+ topic,
104
+ origin,
105
+ settings,
106
+ handleChange
107
+ },
108
+ `${origin.id}-${topic.id}`
109
+ )) || [] : []
110
+ ]) })
107
111
  ] });
108
112
  };
109
113
 
@@ -1 +1 @@
1
- {"version":3,"file":"UserNotificationSettingsPanel.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from 'react';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport Table from '@material-ui/core/Table';\nimport MuiTableCell from '@material-ui/core/TableCell';\nimport { withStyles } from '@material-ui/core/styles';\nimport TableHead from '@material-ui/core/TableHead';\nimport Typography from '@material-ui/core/Typography';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport { TopicRow } from './TopicRow';\nimport { OriginRow } from './OriginRow';\n\nconst TableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n\nexport const UserNotificationSettingsPanel = (props: {\n settings: NotificationSettings;\n onChange: (settings: NotificationSettings) => void;\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const { settings, onChange } = props;\n const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());\n\n const handleRowToggle = (originId: string) => {\n setExpandedRows(prevState => {\n const newExpandedRows = new Set(prevState);\n if (newExpandedRows.has(originId)) {\n newExpandedRows.delete(originId);\n } else {\n newExpandedRows.add(originId);\n }\n return newExpandedRows;\n });\n };\n const handleChange = (\n channelId: string,\n originId: string,\n topicId: string | null,\n enabled: boolean,\n ) => {\n const updatedSettings = {\n channels: settings.channels.map(channel => {\n if (channel.id !== channelId) {\n return channel;\n }\n return {\n ...channel,\n origins: channel.origins.map(origin => {\n if (origin.id !== originId) {\n return origin;\n }\n\n if (topicId === null) {\n return {\n ...origin,\n enabled,\n topics:\n origin.topics?.map(topic => {\n return { ...topic, enabled };\n }) ?? [],\n };\n }\n\n return {\n ...origin,\n topics:\n origin.topics?.map(topic => {\n if (topic.id === topicId) {\n return {\n ...topic,\n enabled: origin.enabled ? enabled : origin.enabled,\n };\n }\n return topic;\n }) ?? [],\n };\n }),\n };\n }),\n };\n onChange(updatedSettings);\n };\n\n if (settings.channels.length === 0) {\n return (\n <Typography variant=\"body1\">\n No notification settings available, check back later\n </Typography>\n );\n }\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableCell />\n <TableCell>\n <Typography variant=\"subtitle1\">Origin</Typography>\n </TableCell>\n <TableCell>\n <Typography variant=\"subtitle1\">Topic</Typography>\n </TableCell>\n {settings.channels.map(channel => (\n <TableCell key={channel.id}>\n <Typography variant=\"subtitle1\" align=\"center\">\n {channel.id}\n </Typography>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {settings.channels.map(channel =>\n channel.origins.flatMap(origin => [\n <OriginRow\n key={origin.id}\n channel={channel}\n origin={origin}\n settings={settings}\n open={expandedRows.has(origin.id)}\n handleChange={handleChange}\n handleRowToggle={handleRowToggle}\n />,\n ...(expandedRows.has(origin.id)\n ? origin.topics?.map(topic => (\n <TopicRow\n key={`${origin.id}-${topic.id}`}\n topic={topic}\n origin={origin}\n settings={settings}\n handleChange={handleChange}\n />\n )) || []\n : []),\n ]),\n )}\n </TableBody>\n </Table>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA;AAAA;AAElB,CAAC,EAAE,YAAY,CAAA;AAEF,MAAA,6BAAA,GAAgC,CAAC,KAKxC,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA;AAC/B,EAAA,MAAM,CAAC,YAAc,EAAA,eAAe,IAAI,QAAsB,iBAAA,IAAI,KAAK,CAAA;AAEvE,EAAM,MAAA,eAAA,GAAkB,CAAC,QAAqB,KAAA;AAC5C,IAAA,eAAA,CAAgB,CAAa,SAAA,KAAA;AAC3B,MAAM,MAAA,eAAA,GAAkB,IAAI,GAAA,CAAI,SAAS,CAAA;AACzC,MAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,QAAQ,CAAG,EAAA;AACjC,QAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA;AAAA,OAC1B,MAAA;AACL,QAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA;AAAA;AAE9B,MAAO,OAAA,eAAA;AAAA,KACR,CAAA;AA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AAI,aAAa,GAAI,CAAA,MAAA,CAAO,EAAE,CAC1B,GAAA,MAAA,CAAO,MAAQ,EAAA,GAAA,CAAI,CACjB,KAAA,qBAAA,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YAEC,KAAA;AAAA,YACA,MAAA;AAAA,YACA,QAAA;AAAA,YACA;AAAA,WAAA;AAAA,UAJK,CAAG,EAAA,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,MAAM,EAAE,CAAA;AAAA,SAMhC,CAAA,IAAK,EAAC,GACP;AAAC,OACN;AAAA,KAEL,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"UserNotificationSettingsPanel.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from 'react';\nimport {\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport Table from '@material-ui/core/Table';\nimport MuiTableCell from '@material-ui/core/TableCell';\nimport { withStyles } from '@material-ui/core/styles';\nimport TableHead from '@material-ui/core/TableHead';\nimport Typography from '@material-ui/core/Typography';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport { TopicRow } from './TopicRow';\nimport { OriginRow } from './OriginRow';\n\nconst TableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n\nexport const UserNotificationSettingsPanel = (props: {\n settings: NotificationSettings;\n onChange: (settings: NotificationSettings) => void;\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const { settings, onChange } = props;\n const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());\n\n const handleRowToggle = (originId: string) => {\n setExpandedRows(prevState => {\n const newExpandedRows = new Set(prevState);\n if (newExpandedRows.has(originId)) {\n newExpandedRows.delete(originId);\n } else {\n newExpandedRows.add(originId);\n }\n return newExpandedRows;\n });\n };\n const handleChange = (\n channelId: string,\n originId: string,\n topicId: string | null,\n enabled: boolean,\n ) => {\n const updatedSettings = {\n channels: settings.channels.map(channel => {\n if (channel.id !== channelId) {\n return channel;\n }\n return {\n ...channel,\n origins: channel.origins.map(origin => {\n if (origin.id !== originId) {\n return origin;\n }\n\n if (topicId === null) {\n return {\n ...origin,\n enabled,\n topics:\n origin.topics?.map(topic => {\n return { ...topic, enabled };\n }) ?? [],\n };\n }\n\n return {\n ...origin,\n topics:\n origin.topics?.map(topic => {\n if (topic.id === topicId) {\n return {\n ...topic,\n enabled: origin.enabled ? enabled : origin.enabled,\n };\n }\n return topic;\n }) ?? [],\n };\n }),\n };\n }),\n };\n onChange(updatedSettings);\n };\n\n if (settings.channels.length === 0) {\n return (\n <Typography variant=\"body1\">\n No notification settings available, check back later\n </Typography>\n );\n }\n\n const uniqueOriginsMap = settings.channels\n .flatMap(channel => channel.origins)\n .reduce((map, origin) => {\n if (!map.has(origin.id)) {\n map.set(origin.id, origin);\n }\n return map;\n }, new Map<string, OriginSetting>())\n .values();\n\n const uniqueOrigins = Array.from(uniqueOriginsMap);\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableCell />\n <TableCell>\n <Typography variant=\"subtitle1\">Origin</Typography>\n </TableCell>\n <TableCell>\n <Typography variant=\"subtitle1\">Topic</Typography>\n </TableCell>\n {settings.channels.map(channel => (\n <TableCell key={channel.id}>\n <Typography variant=\"subtitle1\" align=\"center\">\n {channel.id}\n </Typography>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {uniqueOrigins.flatMap(origin => [\n <OriginRow\n key={origin.id}\n origin={origin}\n settings={settings}\n open={expandedRows.has(origin.id)}\n handleChange={handleChange}\n handleRowToggle={handleRowToggle}\n />,\n ...(expandedRows.has(origin.id)\n ? origin.topics?.map(topic => (\n <TopicRow\n key={`${origin.id}-${topic.id}`}\n topic={topic}\n origin={origin}\n settings={settings}\n handleChange={handleChange}\n />\n )) || []\n : []),\n ])}\n </TableBody>\n </Table>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA+BA,MAAM,YAAY,UAAA,CAAW;AAAA,EAC3B,IAAA,EAAM;AAAA,IACJ,YAAA,EAAc;AAAA;AAElB,CAAC,EAAE,YAAY,CAAA;AAER,MAAM,6BAAA,GAAgC,CAAC,KAAA,KAKxC;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAS,GAAI,KAAA;AAC/B,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,IAAI,QAAA,iBAAsB,IAAI,KAAK,CAAA;AAEvE,EAAA,MAAM,eAAA,GAAkB,CAAC,QAAA,KAAqB;AAC5C,IAAA,eAAA,CAAgB,CAAA,SAAA,KAAa;AAC3B,MAAA,MAAM,eAAA,GAAkB,IAAI,GAAA,CAAI,SAAS,CAAA;AACzC,MAAA,IAAI,eAAA,CAAgB,GAAA,CAAI,QAAQ,CAAA,EAAG;AACjC,QAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA;AAAA,MACjC,CAAA,MAAO;AACL,QAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA;AAAA,MAC9B;AACA,MAAA,OAAO,eAAA;AAAA,IACT,CAAC,CAAA;AAAA,EACH,CAAA;AACA,EAAA,MAAM,YAAA,GAAe,CACnB,SAAA,EACA,QAAA,EACA,SACA,OAAA,KACG;AACH,IAAA,MAAM,eAAA,GAAkB;AAAA,MACtB,QAAA,EAAU,QAAA,CAAS,QAAA,CAAS,GAAA,CAAI,CAAA,OAAA,KAAW;AACzC,QAAA,IAAI,OAAA,CAAQ,OAA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AAA,QAAC,SAAA;AAAA,QAAA;AAAA,UAEC,MAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA,EAAM,YAAA,CAAa,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AAAA,UAChC,YAAA;AAAA,UACA;AAAA,SAAA;AAAA,QALK,MAAA,CAAO;AAAA,OAMd;AAAA,MACA,GAAI,aAAa,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,GAC1B,MAAA,CAAO,MAAA,EAAQ,GAAA,CAAI,CAAA,KAAA,qBACjB,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UAEC,KAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA;AAAA,SAAA;AAAA,QAJK,CAAA,EAAG,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,MAAM,EAAE,CAAA;AAAA,OAMhC,CAAA,IAAK,EAAC,GACP;AAAC,KACN,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNotificationsApi.esm.js","sources":["../../src/hooks/useNotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NotificationsApi, notificationsApiRef } from '../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\n/** @public */\nexport function useNotificationsApi<T>(\n f: (api: NotificationsApi) => Promise<T>,\n deps: any[] = [],\n) {\n const notificationsApi = useApi(notificationsApiRef);\n\n return useAsyncRetry(async () => {\n return await f(notificationsApi);\n }, deps);\n}\n"],"names":[],"mappings":";;;;;AAqBO,SAAS,mBACd,CAAA,CAAA,EACA,IAAc,GAAA,EACd,EAAA;AACA,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,OAAO,cAAc,YAAY;AAC/B,IAAO,OAAA,MAAM,EAAE,gBAAgB,CAAA;AAAA,KAC9B,IAAI,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"useNotificationsApi.esm.js","sources":["../../src/hooks/useNotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NotificationsApi, notificationsApiRef } from '../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\n/** @public */\nexport function useNotificationsApi<T>(\n f: (api: NotificationsApi) => Promise<T>,\n deps: any[] = [],\n) {\n const notificationsApi = useApi(notificationsApiRef);\n\n return useAsyncRetry(async () => {\n return await f(notificationsApi);\n }, deps);\n}\n"],"names":[],"mappings":";;;;;AAqBO,SAAS,mBAAA,CACd,CAAA,EACA,IAAA,GAAc,EAAC,EACf;AACA,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,OAAO,cAAc,YAAY;AAC/B,IAAA,OAAO,MAAM,EAAE,gBAAgB,CAAA;AAAA,EACjC,GAAG,IAAI,CAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTitleCounter.esm.js","sources":["../../src/hooks/useTitleCounter.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport throttle from 'lodash/throttle';\n\nconst getPrefix = (value: number) => (value === 0 ? '' : `(${value}) `);\n\nconst cleanTitle = (currentTitle: string) =>\n currentTitle.replace(/^\\(\\d+\\)\\s/, '');\n\nconst throttledSetTitle = throttle((shownTitle: string) => {\n document.title = shownTitle;\n}, 100);\n\n/** @internal */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n\n useEffect(() => {\n const baseTitle = cleanTitle(title);\n const shownTitle = `${getPrefix(count)}${baseTitle}`;\n if (document.title !== shownTitle) {\n throttledSetTitle(shownTitle);\n }\n return () => {\n document.title = cleanTitle(title);\n };\n }, [count, title]);\n\n useEffect(() => {\n const titleElement = document.querySelector('title');\n let observer: MutationObserver | undefined;\n if (titleElement) {\n observer = new MutationObserver(mutations => {\n if (mutations?.[0]?.target?.textContent) {\n setTitle(mutations[0].target.textContent);\n }\n });\n observer.observe(titleElement, {\n characterData: true,\n childList: true,\n });\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n };\n }, []);\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,YAAY,CAAC,KAAA,KAAmB,UAAU,CAAI,GAAA,EAAA,GAAK,IAAI,KAAK,CAAA,EAAA,CAAA;AAElE,MAAM,aAAa,CAAC,YAAA,KAClB,YAAa,CAAA,OAAA,CAAQ,cAAc,EAAE,CAAA;AAEvC,MAAM,iBAAA,GAA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AAI,QAAU,EAAA;AACZ,QAAA,QAAA,CAAS,UAAW,EAAA;AAAA;AACtB,KACF;AAAA,GACF,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,oBAAuB,GAAA,WAAA;AAAA,IAC3B,CAAC,QAAqB,KAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,IACvC;AAAC,GACH;AAEA,EAAA,OAAO,EAAE,oBAAqB,EAAA;AAChC;;;;"}
1
+ {"version":3,"file":"useTitleCounter.esm.js","sources":["../../src/hooks/useTitleCounter.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport throttle from 'lodash/throttle';\n\nconst getPrefix = (value: number) => (value === 0 ? '' : `(${value}) `);\n\nconst cleanTitle = (currentTitle: string) =>\n currentTitle.replace(/^\\(\\d+\\)\\s/, '');\n\nconst throttledSetTitle = throttle((shownTitle: string) => {\n document.title = shownTitle;\n}, 100);\n\n/** @internal */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n\n useEffect(() => {\n const baseTitle = cleanTitle(title);\n const shownTitle = `${getPrefix(count)}${baseTitle}`;\n if (document.title !== shownTitle) {\n throttledSetTitle(shownTitle);\n }\n return () => {\n document.title = cleanTitle(title);\n };\n }, [count, title]);\n\n useEffect(() => {\n const titleElement = document.querySelector('title');\n let observer: MutationObserver | undefined;\n if (titleElement) {\n observer = new MutationObserver(mutations => {\n if (mutations?.[0]?.target?.textContent) {\n setTitle(mutations[0].target.textContent);\n }\n });\n observer.observe(titleElement, {\n characterData: true,\n childList: true,\n });\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n };\n }, []);\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,YAAY,CAAC,KAAA,KAAmB,UAAU,CAAA,GAAI,EAAA,GAAK,IAAI,KAAK,CAAA,EAAA,CAAA;AAElE,MAAM,aAAa,CAAC,YAAA,KAClB,YAAA,CAAa,OAAA,CAAQ,cAAc,EAAE,CAAA;AAEvC,MAAM,iBAAA,GAAoB,QAAA,CAAS,CAAC,UAAA,KAAuB;AACzD,EAAA,QAAA,CAAS,KAAA,GAAQ,UAAA;AACnB,CAAA,EAAG,GAAG,CAAA;AAGC,SAAS,eAAA,GAAkB;AAChC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,CAAS,SAAS,KAAK,CAAA;AACjD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,CAAC,CAAA;AAEpC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,SAAA,GAAY,WAAW,KAAK,CAAA;AAClC,IAAA,MAAM,aAAa,CAAA,EAAG,SAAA,CAAU,KAAK,CAAC,GAAG,SAAS,CAAA,CAAA;AAClD,IAAA,IAAI,QAAA,CAAS,UAAU,UAAA,EAAY;AACjC,MAAA,iBAAA,CAAkB,UAAU,CAAA;AAAA,IAC9B;AACA,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,CAAS,KAAA,GAAQ,WAAW,KAAK,CAAA;AAAA,IACnC,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,YAAA,GAAe,QAAA,CAAS,aAAA,CAAc,OAAO,CAAA;AACnD,IAAA,IAAI,QAAA;AACJ,IAAA,IAAI,YAAA,EAAc;AAChB,MAAA,QAAA,GAAW,IAAI,iBAAiB,CAAA,SAAA,KAAa;AAC3C,QAAA,IAAI,SAAA,GAAY,CAAC,CAAA,EAAG,MAAA,EAAQ,WAAA,EAAa;AACvC,UAAA,QAAA,CAAS,SAAA,CAAU,CAAC,CAAA,CAAE,MAAA,CAAO,WAAW,CAAA;AAAA,QAC1C;AAAA,MACF,CAAC,CAAA;AACD,MAAA,QAAA,CAAS,QAAQ,YAAA,EAAc;AAAA,QAC7B,aAAA,EAAe,IAAA;AAAA,QACf,SAAA,EAAW;AAAA,OACZ,CAAA;AAAA,IACH;AACA,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,QAAA,EAAU;AACZ,QAAA,QAAA,CAAS,UAAA,EAAW;AAAA,MACtB;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,oBAAA,GAAuB,WAAA;AAAA,IAC3B,CAAC,QAAA,KAAqB,QAAA,CAAS,QAAQ,CAAA;AAAA,IACvC;AAAC,GACH;AAEA,EAAA,OAAO,EAAE,oBAAA,EAAqB;AAChC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWebNotifications.esm.js","sources":["../../src/hooks/useWebNotifications.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useState } from 'react';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { notificationsApiRef } from '../api';\nimport { rootRouteRef } from '../routes';\n\n/** @internal */\nexport function useWebNotifications(enabled: boolean) {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const notificationsRoute = useRouteRef(rootRouteRef)();\n const notificationsApi = useApi(notificationsApiRef);\n\n const requestUserPermission = useCallback(() => {\n if (\n enabled &&\n 'Notification' in window &&\n webNotificationPermission === 'default'\n ) {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [enabled, webNotificationPermission]);\n\n const sendWebNotification = useCallback(\n (options: {\n id: string;\n title: string;\n description: string;\n link?: string;\n }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n tag: options.id, // Prevent duplicates from multiple tabs\n });\n\n notification.onclick = event => {\n event.preventDefault();\n if (options.link) {\n window.open(options.link, '_blank');\n notificationsApi.updateNotifications({\n ids: [options.id],\n read: true,\n });\n } else {\n window.open(notificationsRoute);\n }\n notification.close();\n };\n\n return notification;\n },\n [webNotificationPermission, notificationsApi, notificationsRoute],\n );\n\n return { sendWebNotification, requestUserPermission };\n}\n"],"names":[],"mappings":";;;;;;AAqBO,SAAS,oBAAoB,OAAkB,EAAA;AACpD,EAAA,MAAM,CAAC,yBAAA,EAA2B,4BAA4B,CAAA,GAC5D,SAAS,SAAS,CAAA;AACpB,EAAM,MAAA,kBAAA,GAAqB,WAAY,CAAA,YAAY,CAAE,EAAA;AACrD,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAM,MAAA,qBAAA,GAAwB,YAAY,MAAM;AAC9C,IAAA,IACE,OACA,IAAA,cAAA,IAAkB,MAClB,IAAA,yBAAA,KAA8B,SAC9B,EAAA;AACA,MAAA,MAAA,CAAO,YAAa,CAAA,iBAAA,EAAoB,CAAA,IAAA,CAAK,CAAc,UAAA,KAAA;AACzD,QAAA,4BAAA,CAA6B,UAAU,CAAA;AAAA,OACxC,CAAA;AAAA;AACH,GACC,EAAA,CAAC,OAAS,EAAA,yBAAyB,CAAC,CAAA;AAEvC,EAAA,MAAM,mBAAsB,GAAA,WAAA;AAAA,IAC1B,CAAC,OAKK,KAAA;AACJ,MAAA,IAAI,8BAA8B,SAAW,EAAA;AAC3C,QAAO,OAAA,IAAA;AAAA;AAGT,MAAA,MAAM,YAAe,GAAA,IAAI,YAAa,CAAA,OAAA,CAAQ,KAAO,EAAA;AAAA,QACnD,MAAM,OAAQ,CAAA,WAAA;AAAA,QACd,KAAK,OAAQ,CAAA;AAAA;AAAA,OACd,CAAA;AAED,MAAA,YAAA,CAAa,UAAU,CAAS,KAAA,KAAA;AAC9B,QAAA,KAAA,CAAM,cAAe,EAAA;AACrB,QAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,UAAO,MAAA,CAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,EAAM,QAAQ,CAAA;AAClC,UAAA,gBAAA,CAAiB,mBAAoB,CAAA;AAAA,YACnC,GAAA,EAAK,CAAC,OAAA,CAAQ,EAAE,CAAA;AAAA,YAChB,IAAM,EAAA;AAAA,WACP,CAAA;AAAA,SACI,MAAA;AACL,UAAA,MAAA,CAAO,KAAK,kBAAkB,CAAA;AAAA;AAEhC,QAAA,YAAA,CAAa,KAAM,EAAA;AAAA,OACrB;AAEA,MAAO,OAAA,YAAA;AAAA,KACT;AAAA,IACA,CAAC,yBAA2B,EAAA,gBAAA,EAAkB,kBAAkB;AAAA,GAClE;AAEA,EAAO,OAAA,EAAE,qBAAqB,qBAAsB,EAAA;AACtD;;;;"}
1
+ {"version":3,"file":"useWebNotifications.esm.js","sources":["../../src/hooks/useWebNotifications.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useState } from 'react';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { notificationsApiRef } from '../api';\nimport { rootRouteRef } from '../routes';\n\n/** @internal */\nexport function useWebNotifications(enabled: boolean) {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const notificationsRoute = useRouteRef(rootRouteRef)();\n const notificationsApi = useApi(notificationsApiRef);\n\n const requestUserPermission = useCallback(() => {\n if (\n enabled &&\n 'Notification' in window &&\n webNotificationPermission === 'default'\n ) {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [enabled, webNotificationPermission]);\n\n const sendWebNotification = useCallback(\n (options: {\n id: string;\n title: string;\n description: string;\n link?: string;\n }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n tag: options.id, // Prevent duplicates from multiple tabs\n });\n\n notification.onclick = event => {\n event.preventDefault();\n if (options.link) {\n window.open(options.link, '_blank');\n notificationsApi.updateNotifications({\n ids: [options.id],\n read: true,\n });\n } else {\n window.open(notificationsRoute);\n }\n notification.close();\n };\n\n return notification;\n },\n [webNotificationPermission, notificationsApi, notificationsRoute],\n );\n\n return { sendWebNotification, requestUserPermission };\n}\n"],"names":[],"mappings":";;;;;;AAqBO,SAAS,oBAAoB,OAAA,EAAkB;AACpD,EAAA,MAAM,CAAC,yBAAA,EAA2B,4BAA4B,CAAA,GAC5D,SAAS,SAAS,CAAA;AACpB,EAAA,MAAM,kBAAA,GAAqB,WAAA,CAAY,YAAY,CAAA,EAAE;AACrD,EAAA,MAAM,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AAEnD,EAAA,MAAM,qBAAA,GAAwB,YAAY,MAAM;AAC9C,IAAA,IACE,OAAA,IACA,cAAA,IAAkB,MAAA,IAClB,yBAAA,KAA8B,SAAA,EAC9B;AACA,MAAA,MAAA,CAAO,YAAA,CAAa,iBAAA,EAAkB,CAAE,IAAA,CAAK,CAAA,UAAA,KAAc;AACzD,QAAA,4BAAA,CAA6B,UAAU,CAAA;AAAA,MACzC,CAAC,CAAA;AAAA,IACH;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,EAAS,yBAAyB,CAAC,CAAA;AAEvC,EAAA,MAAM,mBAAA,GAAsB,WAAA;AAAA,IAC1B,CAAC,OAAA,KAKK;AACJ,MAAA,IAAI,8BAA8B,SAAA,EAAW;AAC3C,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,MAAM,YAAA,GAAe,IAAI,YAAA,CAAa,OAAA,CAAQ,KAAA,EAAO;AAAA,QACnD,MAAM,OAAA,CAAQ,WAAA;AAAA,QACd,KAAK,OAAA,CAAQ;AAAA;AAAA,OACd,CAAA;AAED,MAAA,YAAA,CAAa,UAAU,CAAA,KAAA,KAAS;AAC9B,QAAA,KAAA,CAAM,cAAA,EAAe;AACrB,QAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,UAAA,MAAA,CAAO,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAM,QAAQ,CAAA;AAClC,UAAA,gBAAA,CAAiB,mBAAA,CAAoB;AAAA,YACnC,GAAA,EAAK,CAAC,OAAA,CAAQ,EAAE,CAAA;AAAA,YAChB,IAAA,EAAM;AAAA,WACP,CAAA;AAAA,QACH,CAAA,MAAO;AACL,UAAA,MAAA,CAAO,KAAK,kBAAkB,CAAA;AAAA,QAChC;AACA,QAAA,YAAA,CAAa,KAAA,EAAM;AAAA,MACrB,CAAA;AAEA,MAAA,OAAO,YAAA;AAAA,IACT,CAAA;AAAA,IACA,CAAC,yBAAA,EAA2B,gBAAA,EAAkB,kBAAkB;AAAA,GAClE;AAEA,EAAA,OAAO,EAAE,qBAAqB,qBAAA,EAAsB;AACtD;;;;"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
3
3
  import { DiscoveryApi, FetchApi, IconComponent } from '@backstage/core-plugin-api';
4
4
  import { NotificationSeverity, Notification, NotificationStatus, NotificationSettings } from '@backstage/plugin-notifications-common';
5
+ import * as React from 'react';
5
6
  import { TableProps } from '@backstage/core-components';
6
7
 
7
8
  /** @public */
@@ -119,18 +120,47 @@ declare module 'notistack' {
119
120
  critical: true;
120
121
  }
121
122
  }
122
- /** @public */
123
- declare const NotificationsSidebarItem: (props?: {
123
+ /**
124
+ * @public
125
+ */
126
+ type NotificationSnackbarProperties = {
127
+ enabled?: boolean;
128
+ autoHideDuration?: number | null;
129
+ anchorOrigin?: {
130
+ vertical: 'top' | 'bottom';
131
+ horizontal: 'left' | 'center' | 'right';
132
+ };
133
+ dense?: boolean;
134
+ maxSnack?: number;
135
+ snackStyle?: React.CSSProperties;
136
+ iconVariant?: Partial<Record<NotificationSeverity, React.ReactNode>>;
137
+ Components?: {
138
+ [key in NotificationSeverity]: React.JSXElementConstructor<any>;
139
+ };
140
+ };
141
+ /**
142
+ * @public
143
+ */
144
+ type NotificationsSideBarItemProps = {
124
145
  webNotificationsEnabled?: boolean;
125
146
  titleCounterEnabled?: boolean;
147
+ /**
148
+ * @deprecated Use `snackbarProps` instead.
149
+ */
126
150
  snackbarEnabled?: boolean;
151
+ /**
152
+ * @deprecated Use `snackbarProps` instead.
153
+ */
127
154
  snackbarAutoHideDuration?: number | null;
155
+ snackbarProps?: NotificationSnackbarProperties;
128
156
  className?: string;
129
157
  icon?: IconComponent;
130
158
  text?: string;
131
159
  disableHighlight?: boolean;
132
160
  noTrack?: boolean;
133
- }) => react_jsx_runtime.JSX.Element;
161
+ };
162
+ /** @public */
163
+ declare const NotificationsSidebarItem: (props?: NotificationsSideBarItemProps) => react_jsx_runtime.JSX.Element;
134
164
 
135
165
  /** @public */
136
166
  type NotificationsTableProps = Pick<TableProps, 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'> & {
@@ -151,4 +181,4 @@ declare const UserNotificationSettingsCard: (props: {
151
181
  topicNames?: Record<string, string>;
152
182
  }) => react_jsx_runtime.JSX.Element;
153
183
 
154
- export { type GetNotificationsCommonOptions, type GetNotificationsOptions, type GetNotificationsResponse, type GetTopicsOptions, type GetTopicsResponse, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
184
+ export { type GetNotificationsCommonOptions, type GetNotificationsOptions, type GetNotificationsResponse, type GetTopicsOptions, type GetTopicsResponse, type NotificationSnackbarProperties, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, type NotificationsSideBarItemProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
@@ -1,5 +1,5 @@
1
1
  var name = "@backstage/plugin-notifications";
2
- var version = "0.5.8-next.2";
2
+ var version = "0.5.9-next.0";
3
3
  var backstage = {
4
4
  role: "frontend-plugin",
5
5
  pluginId: "notifications",
@@ -1,4 +1,4 @@
1
- import { createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
1
+ import { createPlugin, createApiFactory, fetchApiRef, discoveryApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
2
2
  import { rootRouteRef } from './routes.esm.js';
3
3
  import { notificationsApiRef } from './api/NotificationsApi.esm.js';
4
4
  import { NotificationsClient } from './api/NotificationsClient.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { notificationsApiRef } from './api/NotificationsApi';\nimport { NotificationsClient } from './api';\n\n/** @public */\nexport const notificationsPlugin = createPlugin({\n id: 'notifications',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/** @public */\nexport const NotificationsPage = notificationsPlugin.provide(\n createRoutableExtension({\n name: 'NotificationsPage',\n component: () =>\n import('./components/NotificationsPage').then(m => m.NotificationsPage),\n mountPoint: rootRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;;;AA4BO,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,EAAI,EAAA,eAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA;AAAA,GACR;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,mBAAA;AAAA,MACL,IAAM,EAAA,EAAE,YAAc,EAAA,eAAA,EAAiB,UAAU,WAAY,EAAA;AAAA,MAC7D,OAAA,EAAS,CAAC,EAAE,YAAc,EAAA,QAAA,EACxB,KAAA,IAAI,mBAAoB,CAAA,EAAE,YAAc,EAAA,QAAA,EAAU;AAAA,KACrD;AAAA;AAEL,CAAC;AAGM,MAAM,oBAAoB,mBAAoB,CAAA,OAAA;AAAA,EACnD,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,mBAAA;AAAA,IACN,SAAA,EAAW,MACT,OAAO,6CAAgC,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,iBAAiB,CAAA;AAAA,IACxE,UAAY,EAAA;AAAA,GACb;AACH;;;;"}
1
+ {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { notificationsApiRef } from './api/NotificationsApi';\nimport { NotificationsClient } from './api';\n\n/** @public */\nexport const notificationsPlugin = createPlugin({\n id: 'notifications',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/** @public */\nexport const NotificationsPage = notificationsPlugin.provide(\n createRoutableExtension({\n name: 'NotificationsPage',\n component: () =>\n import('./components/NotificationsPage').then(m => m.NotificationsPage),\n mountPoint: rootRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;;;AA4BO,MAAM,sBAAsB,YAAA,CAAa;AAAA,EAC9C,EAAA,EAAI,eAAA;AAAA,EACJ,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,gBAAA,CAAiB;AAAA,MACf,GAAA,EAAK,mBAAA;AAAA,MACL,IAAA,EAAM,EAAE,YAAA,EAAc,eAAA,EAAiB,UAAU,WAAA,EAAY;AAAA,MAC7D,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,QAAA,EAAS,KACjC,IAAI,mBAAA,CAAoB,EAAE,YAAA,EAAc,QAAA,EAAU;AAAA,KACrD;AAAA;AAEL,CAAC;AAGM,MAAM,oBAAoB,mBAAA,CAAoB,OAAA;AAAA,EACnD,uBAAA,CAAwB;AAAA,IACtB,IAAA,EAAM,mBAAA;AAAA,IACN,SAAA,EAAW,MACT,OAAO,6CAAgC,EAAE,IAAA,CAAK,CAAA,CAAA,KAAK,EAAE,iBAAiB,CAAA;AAAA,IACxE,UAAA,EAAY;AAAA,GACb;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'notifications',\n});\n"],"names":[],"mappings":";;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'notifications',\n});\n"],"names":[],"mappings":";;AAiBO,MAAM,eAAe,cAAA,CAAe;AAAA,EACzC,EAAA,EAAI;AACN,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications",
3
- "version": "0.5.8-next.2",
3
+ "version": "0.5.9-next.0",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "notifications",
@@ -63,14 +63,14 @@
63
63
  "test": "backstage-cli package test"
64
64
  },
65
65
  "dependencies": {
66
- "@backstage/core-compat-api": "0.5.0-next.2",
67
- "@backstage/core-components": "0.17.5-next.1",
66
+ "@backstage/core-compat-api": "0.5.2-next.0",
67
+ "@backstage/core-components": "0.17.5",
68
68
  "@backstage/core-plugin-api": "1.10.9",
69
69
  "@backstage/errors": "1.2.7",
70
- "@backstage/frontend-plugin-api": "0.11.0-next.1",
71
- "@backstage/plugin-notifications-common": "0.0.10",
70
+ "@backstage/frontend-plugin-api": "0.11.0",
71
+ "@backstage/plugin-notifications-common": "0.1.0",
72
72
  "@backstage/plugin-signals-react": "0.0.15",
73
- "@backstage/theme": "0.6.8-next.0",
73
+ "@backstage/theme": "0.6.8",
74
74
  "@backstage/types": "1.2.1",
75
75
  "@material-ui/core": "^4.9.13",
76
76
  "@material-ui/icons": "^4.9.1",
@@ -82,11 +82,11 @@
82
82
  "react-use": "^17.2.4"
83
83
  },
84
84
  "devDependencies": {
85
- "@backstage/cli": "0.34.0-next.1",
85
+ "@backstage/cli": "0.34.1-next.0",
86
86
  "@backstage/core-app-api": "1.18.0",
87
- "@backstage/dev-utils": "1.1.13-next.1",
88
- "@backstage/plugin-signals": "0.0.22-next.2",
89
- "@backstage/test-utils": "1.7.11-next.0",
87
+ "@backstage/dev-utils": "1.1.14-next.0",
88
+ "@backstage/plugin-signals": "0.0.23-next.0",
89
+ "@backstage/test-utils": "1.7.11",
90
90
  "@testing-library/jest-dom": "^6.0.0",
91
91
  "@testing-library/react": "^16.0.0",
92
92
  "@testing-library/user-event": "^14.0.0",