@backstage/plugin-notifications 0.5.16-next.0 → 0.5.16-next.2

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 (52) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/alpha.d.ts +2 -1
  3. package/dist/alpha.esm.js +4 -1
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/components/NotificationsFilters/NotificationsFilters.esm.js +88 -103
  6. package/dist/components/NotificationsFilters/NotificationsFilters.esm.js.map +1 -1
  7. package/dist/components/NotificationsPage/NotificationsPage.esm.js +7 -8
  8. package/dist/components/NotificationsPage/NotificationsPage.esm.js.map +1 -1
  9. package/dist/components/NotificationsPage/index.esm.js +5 -1
  10. package/dist/components/NotificationsPage/index.esm.js.map +1 -1
  11. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js +65 -58
  12. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js.map +1 -1
  13. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.module.css.esm.js +8 -0
  14. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.module.css.esm.js.map +1 -0
  15. package/dist/components/NotificationsTable/BulkActions.esm.js +48 -32
  16. package/dist/components/NotificationsTable/BulkActions.esm.js.map +1 -1
  17. package/dist/components/NotificationsTable/NotificationDescription.esm.js +8 -11
  18. package/dist/components/NotificationsTable/NotificationDescription.esm.js.map +1 -1
  19. package/dist/components/NotificationsTable/NotificationIcon.esm.js +4 -3
  20. package/dist/components/NotificationsTable/NotificationIcon.esm.js.map +1 -1
  21. package/dist/components/NotificationsTable/NotificationsTable.esm.js +90 -114
  22. package/dist/components/NotificationsTable/NotificationsTable.esm.js.map +1 -1
  23. package/dist/components/NotificationsTable/NotificationsTable.module.css.esm.js +8 -0
  24. package/dist/components/NotificationsTable/NotificationsTable.module.css.esm.js.map +1 -0
  25. package/dist/components/NotificationsTable/SelectAll.esm.js +18 -33
  26. package/dist/components/NotificationsTable/SelectAll.esm.js.map +1 -1
  27. package/dist/components/NotificationsTable/SelectAll.module.css.esm.js +8 -0
  28. package/dist/components/NotificationsTable/SelectAll.module.css.esm.js.map +1 -0
  29. package/dist/components/NotificationsTable/SeverityIcon.esm.js +37 -25
  30. package/dist/components/NotificationsTable/SeverityIcon.esm.js.map +1 -1
  31. package/dist/components/NotificationsTable/SeverityIcon.module.css.esm.js +8 -0
  32. package/dist/components/NotificationsTable/SeverityIcon.module.css.esm.js.map +1 -0
  33. package/dist/components/UserNotificationSettingsCard/NoBorderTableCell.esm.js +6 -7
  34. package/dist/components/UserNotificationSettingsCard/NoBorderTableCell.esm.js.map +1 -1
  35. package/dist/components/UserNotificationSettingsCard/NoBorderTableCell.module.css.esm.js +8 -0
  36. package/dist/components/UserNotificationSettingsCard/NoBorderTableCell.module.css.esm.js.map +1 -0
  37. package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js +35 -43
  38. package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js.map +1 -1
  39. package/dist/components/UserNotificationSettingsCard/TopicRow.esm.js +22 -33
  40. package/dist/components/UserNotificationSettingsCard/TopicRow.esm.js.map +1 -1
  41. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.esm.js +20 -20
  42. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.esm.js.map +1 -1
  43. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.module.css.esm.js +8 -0
  44. package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.module.css.esm.js.map +1 -0
  45. package/dist/index.d.ts +2 -1
  46. package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +29 -0
  47. package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -0
  48. package/dist/{package.json.esm.js → plugins/notifications/package.json.esm.js} +2 -4
  49. package/dist/{package.json.esm.js.map → plugins/notifications/package.json.esm.js.map} +1 -1
  50. package/dist/translation.esm.js +3 -2
  51. package/dist/translation.esm.js.map +1 -1
  52. package/package.json +13 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @backstage/plugin-notifications
2
2
 
3
+ ## 0.5.16-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 19a2a03: Migrated notifications plugin to use backstage UI
8
+ - Updated dependencies
9
+ - @backstage/ui@0.14.0-next.2
10
+ - @backstage/errors@1.3.0-next.0
11
+ - @backstage/theme@0.7.3-next.0
12
+ - @backstage/core-components@0.18.9-next.1
13
+ - @backstage/core-plugin-api@1.12.5-next.2
14
+ - @backstage/frontend-plugin-api@0.16.0-next.2
15
+ - @backstage/plugin-notifications-common@0.2.2-next.0
16
+
17
+ ## 0.5.16-next.1
18
+
19
+ ### Patch Changes
20
+
21
+ - d156cf4: Added `title` and `icon` to the new frontend system plugin definition.
22
+ - Updated dependencies
23
+ - @backstage/ui@0.14.0-next.1
24
+ - @backstage/frontend-plugin-api@0.16.0-next.1
25
+ - @backstage/core-components@0.18.9-next.0
26
+ - @backstage/core-plugin-api@1.12.5-next.1
27
+
3
28
  ## 0.5.16-next.0
4
29
 
5
30
  ### Patch Changes
package/dist/alpha.d.ts CHANGED
@@ -75,8 +75,9 @@ declare const notificationsTranslationRef: _backstage_frontend_plugin_api.Transl
75
75
  readonly "table.bulkActions.returnSelectedAmongUnread": "Return selected among unread";
76
76
  readonly "table.bulkActions.saveSelectedForLater": "Save selected for later";
77
77
  readonly "table.bulkActions.undoSaveForSelected": "Undo save for selected";
78
+ readonly "table.confirmDialog.cancel": "Cancel";
78
79
  readonly "table.confirmDialog.title": "Are you sure?";
79
- readonly "table.confirmDialog.markAllReadDescription": "Mark <b>all</b> notifications as <b>read</b>.";
80
+ readonly "table.confirmDialog.markAllReadDescription": "Mark all notifications as read.";
80
81
  readonly "table.confirmDialog.markAllReadConfirmation": "Mark All";
81
82
  readonly "filters.view.all": "All";
82
83
  readonly "filters.view.label": "View";
package/dist/alpha.esm.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { PageBlueprint, ApiBlueprint, fetchApiRef, discoveryApiRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
3
+ import { RiNotification3Line } from '@remixicon/react';
3
4
  import { rootRouteRef } from './routes.esm.js';
4
5
  import { notificationsApiRef } from './api/NotificationsApi.esm.js';
5
6
  import { NotificationsClient } from './api/NotificationsClient.esm.js';
@@ -21,7 +22,9 @@ const api = ApiBlueprint.make({
21
22
  });
22
23
  var alpha = createFrontendPlugin({
23
24
  pluginId: "notifications",
24
- info: { packageJson: () => import('./package.json.esm.js') },
25
+ title: "Notifications",
26
+ icon: /* @__PURE__ */ jsx(RiNotification3Line, {}),
27
+ info: { packageJson: () => import('./plugins/notifications/package.json.esm.js') },
25
28
  routes: {
26
29
  root: rootRouteRef
27
30
  },
@@ -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 { NotificationsClient, notificationsApiRef } from './api';\n\nconst page = PageBlueprint.make({\n params: {\n path: '/notifications',\n routeRef: rootRouteRef,\n loader: () =>\n import('./components/NotificationsPage').then(m => (\n <m.NfsNotificationsPage />\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: {\n root: rootRouteRef,\n },\n // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually\n extensions: [page, api],\n});\n\nimport { notificationsTranslationRef as _notificationsTranslationRef } from './translation';\n\n/**\n * @alpha\n * @deprecated Import from `@backstage/plugin-notifications` instead.\n */\nexport const notificationsTranslationRef = _notificationsTranslationRef;\n"],"names":["_notificationsTranslationRef"],"mappings":";;;;;;;AA0BA,MAAM,IAAA,GAAO,cAAc,IAAA,CAAK;AAAA,EAC9B,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,gBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,6CAAgC,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAC5C,GAAA,CAAC,CAAA,CAAE,oBAAA,EAAF,EAAuB,CACzB;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,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA;AAAA,EAEA,UAAA,EAAY,CAAC,IAAA,EAAM,GAAG;AACxB,CAAC,CAAA;AAQM,MAAM,2BAAA,GAA8BA;;;;"}
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 { RiNotification3Line } from '@remixicon/react';\nimport { rootRouteRef } from './routes';\nimport { NotificationsClient, notificationsApiRef } from './api';\n\nconst page = PageBlueprint.make({\n params: {\n path: '/notifications',\n routeRef: rootRouteRef,\n loader: () =>\n import('./components/NotificationsPage').then(m => (\n <m.NfsNotificationsPage />\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 title: 'Notifications',\n icon: <RiNotification3Line />,\n info: { packageJson: () => import('../package.json') },\n routes: {\n root: rootRouteRef,\n },\n // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually\n extensions: [page, api],\n});\n\nimport { notificationsTranslationRef as _notificationsTranslationRef } from './translation';\n\n/**\n * @alpha\n * @deprecated Import from `@backstage/plugin-notifications` instead.\n */\nexport const notificationsTranslationRef = _notificationsTranslationRef;\n"],"names":["_notificationsTranslationRef"],"mappings":";;;;;;;;AA2BA,MAAM,IAAA,GAAO,cAAc,IAAA,CAAK;AAAA,EAC9B,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,gBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,6CAAgC,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAC5C,GAAA,CAAC,CAAA,CAAE,oBAAA,EAAF,EAAuB,CACzB;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,KAAA,EAAO,eAAA;AAAA,EACP,IAAA,sBAAO,mBAAA,EAAA,EAAoB,CAAA;AAAA,EAC3B,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,6CAAiB,CAAA,EAAE;AAAA,EACrD,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA;AAAA,EAEA,UAAA,EAAY,CAAC,IAAA,EAAM,GAAG;AACxB,CAAC,CAAA;AAQM,MAAM,2BAAA,GAA8BA;;;;"}
@@ -1,11 +1,5 @@
1
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import FormControl from '@material-ui/core/FormControl';
3
- import Divider from '@material-ui/core/Divider';
4
- import Grid from '@material-ui/core/Grid';
5
- import InputLabel from '@material-ui/core/InputLabel';
6
- import MenuItem from '@material-ui/core/MenuItem';
7
- import Select from '@material-ui/core/Select';
8
- import Typography from '@material-ui/core/Typography';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Flex, Text, Select } from '@backstage/ui';
9
3
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
10
4
  import { notificationsTranslationRef } from '../../translation.esm.js';
11
5
 
@@ -83,17 +77,19 @@ const NotificationsFilters = ({
83
77
  }) => {
84
78
  const { t } = useTranslationRef(notificationsTranslationRef);
85
79
  const sortByText = getSortByText(sorting);
86
- const handleOnCreatedAfterChanged = (event) => {
87
- onCreatedAfterChanged(event.target.value);
80
+ const handleOnCreatedAfterChanged = (key) => {
81
+ if (key !== null && !Array.isArray(key))
82
+ onCreatedAfterChanged(key);
88
83
  };
89
- const handleOnViewChanged = (event) => {
90
- if (event.target.value === "unread") {
84
+ const handleOnViewChanged = (key) => {
85
+ const value = Array.isArray(key) ? key[0] : key;
86
+ if (value === "unread") {
91
87
  onUnreadOnlyChanged(true);
92
88
  onSavedChanged(void 0);
93
- } else if (event.target.value === "read") {
89
+ } else if (value === "read") {
94
90
  onUnreadOnlyChanged(false);
95
91
  onSavedChanged(void 0);
96
- } else if (event.target.value === "saved") {
92
+ } else if (value === "saved") {
97
93
  onUnreadOnlyChanged(void 0);
98
94
  onSavedChanged(true);
99
95
  } else {
@@ -101,8 +97,8 @@ const NotificationsFilters = ({
101
97
  onSavedChanged(void 0);
102
98
  }
103
99
  };
104
- const handleOnSortByChanged = (event) => {
105
- const idx = event.target.value || "newest";
100
+ const handleOnSortByChanged = (key) => {
101
+ const idx = (Array.isArray(key) ? key[0] : key) || "newest";
106
102
  const option = SortByOptions[idx];
107
103
  onSortingChanged({ ...option.sortBy });
108
104
  };
@@ -114,98 +110,87 @@ const NotificationsFilters = ({
114
110
  } else if (unreadOnly === false) {
115
111
  viewValue = "read";
116
112
  }
117
- const handleOnSeverityChanged = (event) => {
118
- const value = event.target.value || "normal";
113
+ const handleOnSeverityChanged = (key) => {
114
+ const value = (Array.isArray(key) ? key[0] : key) || "normal";
119
115
  onSeverityChanged(value);
120
116
  };
121
- const handleOnTopicChanged = (event) => {
122
- const value = event.target.value;
117
+ const handleOnTopicChanged = (key) => {
118
+ const value = Array.isArray(key) ? key[0] : key;
123
119
  onTopicChanged(value === ALL ? void 0 : value);
124
120
  };
125
- const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));
126
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Grid, { container: true, children: [
127
- /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
128
- /* @__PURE__ */ jsx(Typography, { variant: "h6", children: t("filters.title") }),
129
- /* @__PURE__ */ jsx(Divider, { variant: "fullWidth" })
130
- ] }),
131
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
132
- /* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-view", children: t("filters.view.label") }),
133
- /* @__PURE__ */ jsxs(
134
- Select,
135
- {
136
- labelId: "notifications-filter-view",
137
- label: t("filters.view.label"),
138
- value: viewValue,
139
- onChange: handleOnViewChanged,
140
- children: [
141
- /* @__PURE__ */ jsx(MenuItem, { value: "unread", children: t("filters.view.unread") }),
142
- /* @__PURE__ */ jsx(MenuItem, { value: "read", children: t("filters.view.read") }),
143
- /* @__PURE__ */ jsx(MenuItem, { value: "saved", children: t("filters.view.saved") }),
144
- /* @__PURE__ */ jsx(MenuItem, { value: "all", children: t("filters.view.all") })
145
- ]
146
- }
147
- )
148
- ] }) }),
149
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
150
- /* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-created", children: t("filters.createdAfter.label") }),
151
- /* @__PURE__ */ jsx(
152
- Select,
153
- {
154
- label: t("filters.createdAfter.label"),
155
- labelId: "notifications-filter-created",
156
- placeholder: t("filters.createdAfter.placeholder"),
157
- value: createdAfter,
158
- onChange: handleOnCreatedAfterChanged,
159
- children: Object.keys(CreatedAfterOptions).map((key) => /* @__PURE__ */ jsx(MenuItem, { value: key, children: t(
121
+ const sortedAllTopics = [...allTopics ?? []].sort(
122
+ (a, b) => a.localeCompare(b)
123
+ );
124
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", children: [
125
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { variant: "title-x-small", children: t("filters.title") }) }),
126
+ /* @__PURE__ */ jsx(
127
+ Select,
128
+ {
129
+ label: t("filters.view.label"),
130
+ value: viewValue,
131
+ onChange: handleOnViewChanged,
132
+ options: [
133
+ { value: "unread", label: t("filters.view.unread") },
134
+ { value: "read", label: t("filters.view.read") },
135
+ { value: "saved", label: t("filters.view.saved") },
136
+ { value: "all", label: t("filters.view.all") }
137
+ ]
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsx(
141
+ Select,
142
+ {
143
+ label: t("filters.createdAfter.label"),
144
+ value: createdAfter,
145
+ onChange: handleOnCreatedAfterChanged,
146
+ options: Object.keys(CreatedAfterOptions).map((key) => ({
147
+ value: key,
148
+ label: t(
160
149
  CreatedAfterOptions[key].labelKey
161
- ) }, key))
162
- }
163
- )
164
- ] }) }),
165
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
166
- /* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-sort", children: t("filters.sortBy.label") }),
167
- /* @__PURE__ */ jsx(
168
- Select,
169
- {
170
- label: t("filters.sortBy.label"),
171
- labelId: "notifications-filter-sort",
172
- placeholder: t("filters.sortBy.placeholder"),
173
- value: sortByText,
174
- onChange: handleOnSortByChanged,
175
- children: Object.keys(SortByOptions).map((key) => /* @__PURE__ */ jsx(MenuItem, { value: key, children: t(SortByOptions[key].labelKey) }, key))
176
- }
177
- )
178
- ] }) }),
179
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
180
- /* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-severity", children: t("filters.severity.label") }),
181
- /* @__PURE__ */ jsx(
182
- Select,
183
- {
184
- label: t("filters.severity.label"),
185
- labelId: "notifications-filter-severity",
186
- value: severity,
187
- onChange: handleOnSeverityChanged,
188
- children: ["critical", "high", "normal", "low"].map((key) => /* @__PURE__ */ jsx(MenuItem, { value: key, children: t(`filters.severity.${key}`) }, key))
189
- }
190
- )
191
- ] }) }),
192
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
193
- /* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-topic", children: t("filters.topic.label") }),
194
- /* @__PURE__ */ jsxs(
195
- Select,
196
- {
197
- label: t("filters.topic.label"),
198
- labelId: "notifications-filter-topic",
199
- value: topic ?? ALL,
200
- onChange: handleOnTopicChanged,
201
- children: [
202
- /* @__PURE__ */ jsx(MenuItem, { value: ALL, children: t("filters.topic.anyTopic") }, ALL),
203
- sortedAllTopics.map((item) => /* @__PURE__ */ jsx(MenuItem, { value: item, children: item }, item))
204
- ]
205
- }
206
- )
207
- ] }) })
208
- ] }) });
150
+ )
151
+ }))
152
+ }
153
+ ),
154
+ /* @__PURE__ */ jsx(
155
+ Select,
156
+ {
157
+ label: t("filters.sortBy.label"),
158
+ value: sortByText,
159
+ onChange: handleOnSortByChanged,
160
+ options: Object.keys(SortByOptions).map((key) => ({
161
+ value: key,
162
+ label: t(SortByOptions[key].labelKey)
163
+ }))
164
+ }
165
+ ),
166
+ /* @__PURE__ */ jsx(
167
+ Select,
168
+ {
169
+ label: t("filters.severity.label"),
170
+ value: severity,
171
+ onChange: handleOnSeverityChanged,
172
+ options: ["critical", "high", "normal", "low"].map((key) => ({
173
+ value: key,
174
+ label: t(`filters.severity.${key}`)
175
+ }))
176
+ }
177
+ ),
178
+ /* @__PURE__ */ jsx(
179
+ Select,
180
+ {
181
+ label: t("filters.topic.label"),
182
+ value: topic ?? ALL,
183
+ onChange: handleOnTopicChanged,
184
+ options: [
185
+ { value: ALL, label: t("filters.topic.anyTopic") },
186
+ ...sortedAllTopics.map((item) => ({
187
+ value: item,
188
+ label: item
189
+ }))
190
+ ]
191
+ }
192
+ )
193
+ ] });
209
194
  };
210
195
 
211
196
  export { CreatedAfterOptions, NotificationsFilters, SortByOptions };
@@ -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';\nimport FormControl from '@material-ui/core/FormControl';\nimport Divider from '@material-ui/core/Divider';\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 { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\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\ntype TranslationKey = keyof (typeof notificationsTranslationRef)['T'];\n\nexport const CreatedAfterOptions = {\n last24h: {\n labelKey: 'filters.createdAfter.last24h' satisfies TranslationKey,\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n labelKey: 'filters.createdAfter.lastWeek' satisfies TranslationKey,\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n labelKey: 'filters.createdAfter.anyTime' satisfies TranslationKey,\n getDate: () => new Date(0),\n },\n} as const;\n\nexport const SortByOptions = {\n newest: {\n labelKey: 'filters.sortBy.newest' satisfies TranslationKey,\n sortBy: {\n sort: 'created' as const,\n sortOrder: 'desc' as const,\n },\n },\n oldest: {\n labelKey: 'filters.sortBy.oldest' satisfies TranslationKey,\n sortBy: {\n sort: 'created' as const,\n sortOrder: 'asc' as const,\n },\n },\n topic: {\n labelKey: 'filters.sortBy.topic' satisfies TranslationKey,\n sortBy: {\n sort: 'topic' as const,\n sortOrder: 'asc' as const,\n },\n },\n origin: {\n labelKey: 'filters.sortBy.origin' satisfies TranslationKey,\n sortBy: {\n sort: 'origin' as const,\n sortOrder: 'asc' as const,\n },\n },\n} as const;\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\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 { t } = useTranslationRef(notificationsTranslationRef);\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) ||\n 'newest') as keyof typeof SortByOptions;\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\">{t('filters.title')}</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\">\n {t('filters.view.label')}\n </InputLabel>\n <Select\n labelId=\"notifications-filter-view\"\n label={t('filters.view.label')}\n value={viewValue}\n onChange={handleOnViewChanged}\n >\n <MenuItem value=\"unread\">{t('filters.view.unread')}</MenuItem>\n <MenuItem value=\"read\">{t('filters.view.read')}</MenuItem>\n <MenuItem value=\"saved\">{t('filters.view.saved')}</MenuItem>\n <MenuItem value=\"all\">{t('filters.view.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\">\n {t('filters.createdAfter.label')}\n </InputLabel>\n\n <Select\n label={t('filters.createdAfter.label')}\n labelId=\"notifications-filter-created\"\n placeholder={t('filters.createdAfter.placeholder')}\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n >\n {Object.keys(CreatedAfterOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {t(\n CreatedAfterOptions[key as keyof typeof CreatedAfterOptions]\n .labelKey,\n )}\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\">\n {t('filters.sortBy.label')}\n </InputLabel>\n\n <Select\n label={t('filters.sortBy.label')}\n labelId=\"notifications-filter-sort\"\n placeholder={t('filters.sortBy.placeholder')}\n value={sortByText}\n onChange={handleOnSortByChanged}\n >\n {Object.keys(SortByOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {t(SortByOptions[key as keyof typeof SortByOptions].labelKey)}\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 {t('filters.severity.label')}\n </InputLabel>\n\n <Select\n label={t('filters.severity.label')}\n labelId=\"notifications-filter-severity\"\n value={severity}\n onChange={handleOnSeverityChanged}\n >\n {(\n ['critical', 'high', 'normal', 'low'] as NotificationSeverity[]\n ).map(key => (\n <MenuItem value={key} key={key}>\n {t(`filters.severity.${key}`)}\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\">\n {t('filters.topic.label')}\n </InputLabel>\n\n <Select\n label={t('filters.topic.label')}\n labelId=\"notifications-filter-topic\"\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n >\n <MenuItem value={ALL} key={ALL}>\n {t('filters.topic.anyTopic')}\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":";;;;;;;;;;;AAgDA,MAAM,GAAA,GAAM,WAAA;AAIL,MAAM,mBAAA,GAAsB;AAAA,EACjC,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,8BAAA;AAAA,IACV,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GACvD;AAAA,EACA,QAAA,EAAU;AAAA,IACR,QAAA,EAAU,+BAAA;AAAA,IACV,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,IAAA,CAAK,KAAI,GAAI,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GAC3D;AAAA,EACA,GAAA,EAAK;AAAA,IACH,QAAA,EAAU,8BAAA;AAAA,IACV,OAAA,EAAS,sBAAM,IAAI,IAAA,CAAK,CAAC;AAAA;AAE7B;AAEO,MAAM,aAAA,GAAgB;AAAA,EAC3B,MAAA,EAAQ;AAAA,IACN,QAAA,EAAU,uBAAA;AAAA,IACV,MAAA,EAAQ;AAAA,MACN,IAAA,EA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A;AAAA,UACR,OAAO,KAAA,IAAS,GAAA;AAAA,UAChB,QAAA,EAAU,oBAAA;AAAA,UAEV,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,YAAS,KAAA,EAAO,GAAA,EACd,QAAA,EAAA,CAAA,CAAE,wBAAwB,KADF,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
+ {"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 { Select, Text, Flex } from '@backstage/ui';\nimport type { Key } from 'react-aria-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\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\ntype TranslationKey = keyof (typeof notificationsTranslationRef)['T'];\n\nexport const CreatedAfterOptions = {\n last24h: {\n labelKey: 'filters.createdAfter.last24h' satisfies TranslationKey,\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n labelKey: 'filters.createdAfter.lastWeek' satisfies TranslationKey,\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n labelKey: 'filters.createdAfter.anyTime' satisfies TranslationKey,\n getDate: () => new Date(0),\n },\n} as const;\n\nexport const SortByOptions = {\n newest: {\n labelKey: 'filters.sortBy.newest' satisfies TranslationKey,\n sortBy: {\n sort: 'created' as const,\n sortOrder: 'desc' as const,\n },\n },\n oldest: {\n labelKey: 'filters.sortBy.oldest' satisfies TranslationKey,\n sortBy: {\n sort: 'created' as const,\n sortOrder: 'asc' as const,\n },\n },\n topic: {\n labelKey: 'filters.sortBy.topic' satisfies TranslationKey,\n sortBy: {\n sort: 'topic' as const,\n sortOrder: 'asc' as const,\n },\n },\n origin: {\n labelKey: 'filters.sortBy.origin' satisfies TranslationKey,\n sortBy: {\n sort: 'origin' as const,\n sortOrder: 'asc' as const,\n },\n },\n} as const;\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\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 { t } = useTranslationRef(notificationsTranslationRef);\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (key: Key | Key[] | null) => {\n if (key !== null && !Array.isArray(key))\n onCreatedAfterChanged(key as string);\n };\n\n const handleOnViewChanged = (key: Key | Key[] | null) => {\n const value = Array.isArray(key) ? key[0] : key;\n if (value === 'unread') {\n onUnreadOnlyChanged(true);\n onSavedChanged(undefined);\n } else if (value === 'read') {\n onUnreadOnlyChanged(false);\n onSavedChanged(undefined);\n } else if (value === 'saved') {\n onUnreadOnlyChanged(undefined);\n onSavedChanged(true);\n } else {\n // All\n onUnreadOnlyChanged(undefined);\n onSavedChanged(undefined);\n }\n };\n\n const handleOnSortByChanged = (key: Key | Key[] | null) => {\n const idx = (((Array.isArray(key) ? key[0] : key) as string) ||\n 'newest') as keyof typeof SortByOptions;\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 = (key: Key | Key[] | null) => {\n const value: NotificationSeverity =\n ((Array.isArray(key) ? key[0] : key) as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\n\n const handleOnTopicChanged = (key: Key | Key[] | null) => {\n const value = (Array.isArray(key) ? key[0] : key) as string;\n onTopicChanged(value === ALL ? undefined : value);\n };\n\n const sortedAllTopics = [...(allTopics ?? [])].sort((a, b) =>\n a.localeCompare(b),\n );\n\n return (\n <Flex direction=\"column\" gap=\"4\">\n <div>\n <Text variant=\"title-x-small\">{t('filters.title')}</Text>\n </div>\n\n <Select\n label={t('filters.view.label')}\n value={viewValue}\n onChange={handleOnViewChanged}\n options={[\n { value: 'unread', label: t('filters.view.unread') },\n { value: 'read', label: t('filters.view.read') },\n { value: 'saved', label: t('filters.view.saved') },\n { value: 'all', label: t('filters.view.all') },\n ]}\n />\n\n <Select\n label={t('filters.createdAfter.label')}\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n options={Object.keys(CreatedAfterOptions).map((key: string) => ({\n value: key,\n label: t(\n CreatedAfterOptions[key as keyof typeof CreatedAfterOptions]\n .labelKey,\n ),\n }))}\n />\n\n <Select\n label={t('filters.sortBy.label')}\n value={sortByText}\n onChange={handleOnSortByChanged}\n options={Object.keys(SortByOptions).map((key: string) => ({\n value: key,\n label: t(SortByOptions[key as keyof typeof SortByOptions].labelKey),\n }))}\n />\n\n <Select\n label={t('filters.severity.label')}\n value={severity}\n onChange={handleOnSeverityChanged}\n options={(\n ['critical', 'high', 'normal', 'low'] as NotificationSeverity[]\n ).map(key => ({\n value: key,\n label: t(`filters.severity.${key}`),\n }))}\n />\n\n <Select\n label={t('filters.topic.label')}\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n options={[\n { value: ALL, label: t('filters.topic.anyTopic') },\n ...sortedAllTopics.map((item: string) => ({\n value: item,\n label: item,\n })),\n ]}\n />\n </Flex>\n );\n};\n"],"names":[],"mappings":";;;;;AA0CA,MAAM,GAAA,GAAM,WAAA;AAIL,MAAM,mBAAA,GAAsB;AAAA,EACjC,OAAA,EAAS;AAAA,IACP,QAAA,EAAU,8BAAA;AAAA,IACV,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GACvD;AAAA,EACA,QAAA,EAAU;AAAA,IACR,QAAA,EAAU,+BAAA;AAAA,IACV,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,IAAA,CAAK,KAAI,GAAI,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GAC3D;AAAA,EACA,GAAA,EAAK;AAAA,IACH,QAAA,EAAU,8BAAA;AAAA,IACV,OAAA,EAAS,sBAAM,IAAI,IAAA,CAAK,CAAC;AAAA;AAE7B;AAEO,MAAM,aAAA,GAAgB;AAAA,EAC3B,MAAA,EAAQ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A,QACC,KAAA,EAAO,EAAE,wBAAwB,CAAA;AAAA,QACjC,KAAA,EAAO,QAAA;AAAA,QACP,QAAA,EAAU,uBAAA;AAAA,QACV,OAAA,EACE,CAAC,UAAA,EAAY,MAAA,EAAQ,UAAU,KAAK,CAAA,CACpC,IAAI,CAAA,GAAA,MAAQ;AAAA,UACZ,KAAA,EAAO,GAAA;AAAA,UACP,KAAA,EAAO,CAAA,CAAE,CAAA,iBAAA,EAAoB,GAAG,CAAA,CAAE;AAAA,SACpC,CAAE;AAAA;AAAA,KACJ;AAAA,oBAEA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAO,EAAE,qBAAqB,CAAA;AAAA,QAC9B,OAAO,KAAA,IAAS,GAAA;AAAA,QAChB,QAAA,EAAU,oBAAA;AAAA,QACV,OAAA,EAAS;AAAA,UACP,EAAE,KAAA,EAAO,GAAA,EAAK,KAAA,EAAO,CAAA,CAAE,wBAAwB,CAAA,EAAE;AAAA,UACjD,GAAG,eAAA,CAAgB,GAAA,CAAI,CAAC,IAAA,MAAkB;AAAA,YACxC,KAAA,EAAO,IAAA;AAAA,YACP,KAAA,EAAO;AAAA,WACT,CAAE;AAAA;AACJ;AAAA;AACF,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -1,9 +1,8 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useMemo, useEffect } from 'react';
3
3
  import throttle from 'lodash/throttle';
4
- import { ResponseErrorPanel, PageWithHeader, Content } from '@backstage/core-components';
5
- import Grid from '@material-ui/core/Grid';
6
- import { ConfirmProvider } from 'material-ui-confirm';
4
+ import { ResponseErrorPanel, Content, PageWithHeader } from '@backstage/core-components';
5
+ import { Grid } from '@backstage/ui';
7
6
  import { useSignal } from '@backstage/plugin-signals-react';
8
7
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
9
8
  import { notificationsTranslationRef } from '../../translation.esm.js';
@@ -14,7 +13,7 @@ import '../../api/NotificationsApi.esm.js';
14
13
  import '@backstage/errors';
15
14
  import '../../routes.esm.js';
16
15
  import '../../hooks/useTitleCounter.esm.js';
17
- import { SortByOptions, CreatedAfterOptions, NotificationsFilters } from '../NotificationsFilters/NotificationsFilters.esm.js';
16
+ import { SortByOptions, NotificationsFilters, CreatedAfterOptions } from '../NotificationsFilters/NotificationsFilters.esm.js';
18
17
 
19
18
  const TableTitleKeys = {
20
19
  all: "notificationsPage.tableTitle.all",
@@ -127,8 +126,8 @@ function NotificationsPageContent(props) {
127
126
  count: totalCount ?? 0
128
127
  });
129
128
  }
130
- const pageContent = /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(ConfirmProvider, { children: /* @__PURE__ */ jsxs(Grid, { container: true, children: [
131
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 2, children: /* @__PURE__ */ jsx(
129
+ const pageContent = /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsxs(Grid.Root, { columns: "12", gap: "6", children: [
130
+ /* @__PURE__ */ jsx(Grid.Item, { colSpan: "2", children: /* @__PURE__ */ jsx(
132
131
  NotificationsFilters,
133
132
  {
134
133
  unreadOnly,
@@ -146,7 +145,7 @@ function NotificationsPageContent(props) {
146
145
  allTopics
147
146
  }
148
147
  ) }),
149
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 10, children: /* @__PURE__ */ jsx(
148
+ /* @__PURE__ */ jsx(Grid.Item, { colSpan: "10", children: /* @__PURE__ */ jsx(
150
149
  NotificationsTable,
151
150
  {
152
151
  title: tableTitle,
@@ -163,7 +162,7 @@ function NotificationsPageContent(props) {
163
162
  totalCount
164
163
  }
165
164
  ) })
166
- ] }) }) });
165
+ ] }) });
167
166
  if (headerVariant === "bui") {
168
167
  return pageContent;
169
168
  }
@@ -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 { useEffect, useMemo, useState } 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';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\n\nconst TableTitleKeys = {\n all: 'notificationsPage.tableTitle.all',\n saved: 'notificationsPage.tableTitle.saved',\n unread: 'notificationsPage.tableTitle.unread',\n read: 'notificationsPage.tableTitle.read',\n} as const;\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\nfunction NotificationsPageContent(\n props: NotificationsPageProps & { headerVariant: 'legacy' | 'bui' },\n) {\n const { t } = useTranslationRef(notificationsTranslationRef);\n const {\n title = t('notificationsPage.title'),\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n headerVariant,\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 =\n CreatedAfterOptions[\n createdAfter as keyof typeof CreatedAfterOptions\n ].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: string = t(TableTitleKeys.all, {\n count: totalCount ?? 0,\n });\n if (saved) {\n tableTitle = t(TableTitleKeys.saved, {\n count: totalCount ?? 0,\n });\n } else if (unreadOnly === true) {\n tableTitle = t(TableTitleKeys.unread, {\n count: totalCount ?? 0,\n });\n } else if (unreadOnly === false) {\n tableTitle = t(TableTitleKeys.read, {\n count: totalCount ?? 0,\n });\n }\n\n const pageContent = (\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 );\n\n if (headerVariant === 'bui') {\n return pageContent;\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 {pageContent}\n </PageWithHeader>\n );\n}\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => (\n <NotificationsPageContent {...(props ?? {})} headerVariant=\"legacy\" />\n);\n\nexport const NfsNotificationsPage = (props?: NotificationsPageProps) => (\n <NotificationsPageContent {...(props ??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AAA;AAAA,QACA,aAAA;AAAA,QACA,QAAA;AAAA,QACA,eAAA;AAAA,QACA,YAAA,EAAc,aAAA;AAAA,QACd,mBAAA,EAAqB,WAAA;AAAA,QACrB,IAAA,EAAM,UAAA;AAAA,QACN,QAAA;AAAA,QACA;AAAA;AAAA,KACF,EACF;AAAA,GAAA,EACF,GACF,CAAA,EACF,CAAA;AAGF,EAAA,IAAI,kBAAkB,KAAA,EAAO;AAC3B,IAAA,OAAO,WAAA;AAAA,EACT;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,QAAA;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ;AAEO,MAAM,iBAAA,GAAoB,CAAC,KAAA,qBAChC,GAAA,CAAC,wBAAA,EAAA,EAA0B,GAAI,KAAA,IAAS,EAAC,EAAI,aAAA,EAAc,QAAA,EAAS;AAG/D,MAAM,oBAAA,GAAuB,CAAC,KAAA,qBACnC,GAAA,CAAC,wBAAA,EAAA,EAA0B,GAAI,KAAA,IAAS,EAAC,EAAI,aAAA,EAAc,KAAA,EAAM;;;;"}
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 { useEffect, useMemo, useState } from 'react';\nimport throttle from 'lodash/throttle';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { Grid } from '@backstage/ui';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\n\nconst TableTitleKeys = {\n all: 'notificationsPage.tableTitle.all',\n saved: 'notificationsPage.tableTitle.saved',\n unread: 'notificationsPage.tableTitle.unread',\n read: 'notificationsPage.tableTitle.read',\n} as const;\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\nfunction NotificationsPageContent(\n props: NotificationsPageProps & { headerVariant: 'legacy' | 'bui' },\n) {\n const { t } = useTranslationRef(notificationsTranslationRef);\n const {\n title = t('notificationsPage.title'),\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n headerVariant,\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 =\n CreatedAfterOptions[\n createdAfter as keyof typeof CreatedAfterOptions\n ].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: string = t(TableTitleKeys.all, {\n count: totalCount ?? 0,\n });\n if (saved) {\n tableTitle = t(TableTitleKeys.saved, {\n count: totalCount ?? 0,\n });\n } else if (unreadOnly === true) {\n tableTitle = t(TableTitleKeys.unread, {\n count: totalCount ?? 0,\n });\n } else if (unreadOnly === false) {\n tableTitle = t(TableTitleKeys.read, {\n count: totalCount ?? 0,\n });\n }\n\n const pageContent = (\n <Content>\n <Grid.Root columns=\"12\" gap=\"6\">\n <Grid.Item colSpan=\"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.Item>\n <Grid.Item colSpan=\"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.Item>\n </Grid.Root>\n </Content>\n );\n\n if (headerVariant === 'bui') {\n return pageContent;\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 {pageContent}\n </PageWithHeader>\n );\n}\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => (\n <NotificationsPageContent {...(props ?? {})} headerVariant=\"legacy\" />\n);\n\nexport const NfsNotificationsPage = (props?: NotificationsPageProps) => (\n <NotificationsPageContent {...(props ?? {})} headerVariant=\"bui\" />\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAM,cAAA,GAAiB;AAAA,EACrB,GAAA,EAAK,kCAAA;AAAA,EACL,KAAA,EAAO,oCAAA;AAAA,EACP,MAAA,EAAQ,qCAAA;AAAA,EACR,IAAA,EAAM;AACR,CAAA;AAoBA,MAAM,eAAA,GAAkB,GAAA;AAcxB,SAAS,yBACP,KAAA,EACA;AACA,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,C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cAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,QAAA;AAAA,MACA,IAAA;AAAA,MACA,QAAA;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ;AAEO,MAAM,iBAAA,GAAoB,CAAC,KAAA,qBAChC,GAAA,CAAC,wBAAA,EAAA,EAA0B,GAAI,KAAA,IAAS,EAAC,EAAI,aAAA,EAAc,QAAA,EAAS;AAG/D,MAAM,oBAAA,GAAuB,CAAC,KAAA,qBACnC,GAAA,CAAC,wBAAA,EAAA,EAA0B,GAAI,KAAA,IAAS,EAAC,EAAI,aAAA,EAAc,KAAA,EAAM;;;;"}
@@ -1,2 +1,6 @@
1
- export { NfsNotificationsPage, NotificationsPage } from './NotificationsPage.esm.js';
1
+ import { NotificationsPage, NfsNotificationsPage } from './NotificationsPage.esm.js';
2
+
3
+
4
+
5
+ export { NfsNotificationsPage, NotificationsPage };
2
6
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}