@backstage/plugin-notifications 0.2.0-next.1 → 0.2.1-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 (36) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/api/NotificationsApi.esm.js +8 -0
  3. package/dist/api/NotificationsApi.esm.js.map +1 -0
  4. package/dist/api/NotificationsClient.esm.js +74 -0
  5. package/dist/api/NotificationsClient.esm.js.map +1 -0
  6. package/dist/{esm/index-ijQzv-25.esm.js → components/NotificationsFilters/NotificationsFilters.esm.js} +4 -124
  7. package/dist/components/NotificationsFilters/NotificationsFilters.esm.js.map +1 -0
  8. package/dist/components/NotificationsPage/NotificationsPage.esm.js +130 -0
  9. package/dist/components/NotificationsPage/NotificationsPage.esm.js.map +1 -0
  10. package/dist/components/NotificationsPage/index.esm.js +2 -0
  11. package/dist/components/NotificationsPage/index.esm.js.map +1 -0
  12. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js +88 -0
  13. package/dist/components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js.map +1 -0
  14. package/dist/components/NotificationsTable/BulkActions.esm.js +52 -0
  15. package/dist/components/NotificationsTable/BulkActions.esm.js.map +1 -0
  16. package/dist/components/NotificationsTable/NotificationsTable.esm.js +177 -0
  17. package/dist/components/NotificationsTable/NotificationsTable.esm.js.map +1 -0
  18. package/dist/components/NotificationsTable/SelectAll.esm.js +41 -0
  19. package/dist/components/NotificationsTable/SelectAll.esm.js.map +1 -0
  20. package/dist/components/NotificationsTable/SeverityIcon.esm.js +40 -0
  21. package/dist/components/NotificationsTable/SeverityIcon.esm.js.map +1 -0
  22. package/dist/hooks/useNotificationsApi.esm.js +14 -0
  23. package/dist/hooks/useNotificationsApi.esm.js.map +1 -0
  24. package/dist/hooks/useTitleCounter.esm.js +57 -0
  25. package/dist/hooks/useTitleCounter.esm.js.map +1 -0
  26. package/dist/hooks/useWebNotifications.esm.js +44 -0
  27. package/dist/hooks/useWebNotifications.esm.js.map +1 -0
  28. package/dist/index.d.ts +20 -4
  29. package/dist/index.esm.js +8 -509
  30. package/dist/index.esm.js.map +1 -1
  31. package/dist/plugin.esm.js +28 -0
  32. package/dist/plugin.esm.js.map +1 -0
  33. package/dist/routes.esm.js +8 -0
  34. package/dist/routes.esm.js.map +1 -0
  35. package/package.json +12 -11
  36. package/dist/esm/index-ijQzv-25.esm.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,510 +1,9 @@
1
- import { createRouteRef, createApiRef, createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createRoutableExtension, useApi, useRouteRef } from '@backstage/core-plugin-api';
2
- import { ResponseError } from '@backstage/errors';
3
- import useAsyncRetry from 'react-use/esm/useAsyncRetry';
4
- import React, { useState, useEffect, useCallback } from 'react';
5
- import { SidebarItem, Link, Table } from '@backstage/core-components';
6
- import NotificationsIcon from '@material-ui/icons/Notifications';
7
- import { useSignal } from '@backstage/plugin-signals-react';
8
- import throttle from 'lodash/throttle';
9
- import RelativeTime from 'react-relative-time';
10
- import Box from '@material-ui/core/Box';
11
- import Grid from '@material-ui/core/Grid';
12
- import Checkbox from '@material-ui/core/Checkbox';
13
- import Typography from '@material-ui/core/Typography';
14
- import NormalIcon from '@material-ui/icons/CheckOutlined';
15
- import CriticalIcon from '@material-ui/icons/ErrorOutline';
16
- import HighIcon from '@material-ui/icons/WarningOutlined';
17
- import LowIcon from '@material-ui/icons/InfoOutlined';
18
- import FormControlLabel from '@material-ui/core/FormControlLabel';
19
- import { makeStyles } from '@material-ui/core/styles';
20
- import IconButton from '@material-ui/core/IconButton';
21
- import Tooltip from '@material-ui/core/Tooltip';
22
- import MarkAsUnreadIcon from '@material-ui/icons/Markunread';
23
- import MarkAsReadIcon from '@material-ui/icons/CheckCircle';
24
- import MarkAsUnsavedIcon from '@material-ui/icons/LabelOff';
25
- import MarkAsSavedIcon from '@material-ui/icons/Label';
26
-
27
- const rootRouteRef = createRouteRef({
28
- id: "notifications"
29
- });
30
-
31
- const notificationsApiRef = createApiRef({
32
- id: "plugin.notifications.service"
33
- });
34
-
35
- var __defProp = Object.defineProperty;
36
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
37
- var __publicField = (obj, key, value) => {
38
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
39
- return value;
40
- };
41
- class NotificationsClient {
42
- constructor(options) {
43
- __publicField(this, "discoveryApi");
44
- __publicField(this, "fetchApi");
45
- this.discoveryApi = options.discoveryApi;
46
- this.fetchApi = options.fetchApi;
47
- }
48
- async getNotifications(options) {
49
- var _a;
50
- const queryString = new URLSearchParams();
51
- if ((options == null ? void 0 : options.limit) !== void 0) {
52
- queryString.append("limit", options.limit.toString(10));
53
- }
54
- if ((options == null ? void 0 : options.offset) !== void 0) {
55
- queryString.append("offset", options.offset.toString(10));
56
- }
57
- if ((options == null ? void 0 : options.sort) !== void 0) {
58
- queryString.append(
59
- "orderField",
60
- `${options.sort},${(_a = options == null ? void 0 : options.sortOrder) != null ? _a : "desc"}`
61
- );
62
- }
63
- if (options == null ? void 0 : options.search) {
64
- queryString.append("search", options.search);
65
- }
66
- if ((options == null ? void 0 : options.read) !== void 0) {
67
- queryString.append("read", options.read ? "true" : "false");
68
- }
69
- if ((options == null ? void 0 : options.saved) !== void 0) {
70
- queryString.append("saved", options.saved ? "true" : "false");
71
- }
72
- if ((options == null ? void 0 : options.createdAfter) !== void 0) {
73
- queryString.append("createdAfter", options.createdAfter.toISOString());
74
- }
75
- if ((options == null ? void 0 : options.minimumSeverity) !== void 0) {
76
- queryString.append("minimal_severity", options.minimumSeverity);
77
- }
78
- const urlSegment = `?${queryString}`;
79
- return await this.request(urlSegment);
80
- }
81
- async getNotification(id) {
82
- return await this.request(`${id}`);
83
- }
84
- async getStatus() {
85
- return await this.request("status");
86
- }
87
- async updateNotifications(options) {
88
- return await this.request("update", {
89
- method: "POST",
90
- body: JSON.stringify(options),
91
- headers: { "Content-Type": "application/json" }
92
- });
93
- }
94
- async request(path, init) {
95
- const baseUrl = `${await this.discoveryApi.getBaseUrl("notifications")}/`;
96
- const url = new URL(path, baseUrl);
97
- const response = await this.fetchApi.fetch(url.toString(), init);
98
- if (!response.ok) {
99
- throw await ResponseError.fromResponse(response);
100
- }
101
- return response.json();
102
- }
103
- }
104
-
105
- const notificationsPlugin = createPlugin({
106
- id: "notifications",
107
- routes: {
108
- root: rootRouteRef
109
- },
110
- apis: [
111
- createApiFactory({
112
- api: notificationsApiRef,
113
- deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },
114
- factory: ({ discoveryApi, fetchApi }) => new NotificationsClient({ discoveryApi, fetchApi })
115
- })
116
- ]
117
- });
118
- const NotificationsPage = notificationsPlugin.provide(
119
- createRoutableExtension({
120
- name: "NotificationsPage",
121
- component: () => import('./esm/index-ijQzv-25.esm.js').then((m) => m.NotificationsPage),
122
- mountPoint: rootRouteRef
123
- })
124
- );
125
-
126
- function useNotificationsApi(f, deps = []) {
127
- const notificationsApi = useApi(notificationsApiRef);
128
- return useAsyncRetry(async () => {
129
- return await f(notificationsApi);
130
- }, deps);
131
- }
132
-
133
- function useWebNotifications() {
134
- const [webNotificationPermission, setWebNotificationPermission] = useState("default");
135
- const [webNotifications, setWebNotifications] = useState([]);
136
- useEffect(() => {
137
- if ("Notification" in window && webNotificationPermission === "default") {
138
- window.Notification.requestPermission().then((permission) => {
139
- setWebNotificationPermission(permission);
140
- });
141
- }
142
- }, [webNotificationPermission]);
143
- document.addEventListener("visibilitychange", () => {
144
- if (document.visibilityState === "visible") {
145
- webNotifications.forEach((n) => n.close());
146
- setWebNotifications([]);
147
- }
148
- });
149
- const sendWebNotification = useCallback(
150
- (options) => {
151
- if (webNotificationPermission !== "granted") {
152
- return null;
153
- }
154
- const notification = new Notification(options.title, {
155
- body: options.description
156
- });
157
- notification.onclick = (event) => {
158
- event.preventDefault();
159
- notification.close();
160
- if (options.link) {
161
- window.open(options.link, "_blank");
162
- }
163
- };
164
- return notification;
165
- },
166
- [webNotificationPermission]
167
- );
168
- return { sendWebNotification };
169
- }
170
-
171
- function useTitleCounter() {
172
- const [title, setTitle] = useState(document.title);
173
- const [count, setCount] = useState(0);
174
- const getPrefix = (value) => {
175
- return value === 0 ? "" : `(${value}) `;
176
- };
177
- const cleanTitle = (currentTitle) => {
178
- return currentTitle.replace(/^\(\d+\)\s/, "");
179
- };
180
- useEffect(() => {
181
- document.title = title;
182
- }, [title]);
183
- useEffect(() => {
184
- const baseTitle = cleanTitle(title);
185
- setTitle(`${getPrefix(count)}${baseTitle}`);
186
- return () => {
187
- document.title = cleanTitle(title);
188
- };
189
- }, [title, count]);
190
- const titleElement = document.querySelector("title");
191
- if (titleElement) {
192
- new MutationObserver(() => {
193
- setTitle(document.title);
194
- }).observe(titleElement, {
195
- subtree: true,
196
- characterData: true,
197
- childList: true
198
- });
199
- }
200
- const setNotificationCount = useCallback(
201
- (newCount) => setCount(newCount),
202
- []
203
- );
204
- return { setNotificationCount };
205
- }
206
-
207
- const NotificationsSidebarItem = (props) => {
208
- const { webNotificationsEnabled = false, titleCounterEnabled = true } = props != null ? props : { webNotificationsEnabled: false, titleCounterEnabled: true };
209
- const { loading, error, value, retry } = useNotificationsApi(
210
- (api) => api.getStatus()
211
- );
212
- const notificationsApi = useApi(notificationsApiRef);
213
- const [unreadCount, setUnreadCount] = React.useState(0);
214
- const notificationsRoute = useRouteRef(rootRouteRef);
215
- const { lastSignal } = useSignal("notifications");
216
- const { sendWebNotification } = useWebNotifications();
217
- const [refresh, setRefresh] = React.useState(false);
218
- const { setNotificationCount } = useTitleCounter();
219
- useEffect(() => {
220
- if (refresh) {
221
- retry();
222
- setRefresh(false);
223
- }
224
- }, [refresh, retry]);
225
- useEffect(() => {
226
- const handleWebNotification = (signal) => {
227
- if (!webNotificationsEnabled || signal.action !== "new_notification") {
228
- return;
229
- }
230
- notificationsApi.getNotification(signal.notification_id).then((notification) => {
231
- var _a;
232
- if (!notification) {
233
- return;
234
- }
235
- sendWebNotification({
236
- title: notification.payload.title,
237
- description: (_a = notification.payload.description) != null ? _a : "",
238
- link: notification.payload.link
239
- });
240
- });
241
- };
242
- if (lastSignal && lastSignal.action) {
243
- handleWebNotification(lastSignal);
244
- setRefresh(true);
245
- }
246
- }, [
247
- lastSignal,
248
- sendWebNotification,
249
- webNotificationsEnabled,
250
- notificationsApi
251
- ]);
252
- useEffect(() => {
253
- if (!loading && !error && value) {
254
- setUnreadCount(value.unread);
255
- if (titleCounterEnabled) {
256
- setNotificationCount(value.unread);
257
- }
258
- }
259
- }, [loading, error, value, titleCounterEnabled, setNotificationCount]);
260
- return /* @__PURE__ */ React.createElement(
261
- SidebarItem,
262
- {
263
- icon: NotificationsIcon,
264
- to: notificationsRoute(),
265
- text: "Notifications",
266
- hasNotifications: !error && !!unreadCount
267
- }
268
- );
269
- };
270
-
271
- const SeverityIcon = ({
272
- severity
273
- }) => {
274
- switch (severity) {
275
- case "critical":
276
- return /* @__PURE__ */ React.createElement(CriticalIcon, { htmlColor: "#C9190B" });
277
- case "high":
278
- return /* @__PURE__ */ React.createElement(HighIcon, { htmlColor: "#F0AB00" });
279
- case "low":
280
- return /* @__PURE__ */ React.createElement(LowIcon, { htmlColor: "#2B9AF3" });
281
- case "normal":
282
- default:
283
- return /* @__PURE__ */ React.createElement(NormalIcon, { htmlColor: "#5BA352" });
284
- }
285
- };
286
-
287
- const useStyles = makeStyles({
288
- label: {
289
- marginLeft: "0px",
290
- maxWidth: "2rem",
291
- "& span": {
292
- paddingRight: "0px"
293
- }
294
- }
295
- });
296
- const SelectAll = ({
297
- count,
298
- totalCount,
299
- onSelectAll
300
- }) => {
301
- const classes = useStyles();
302
- return /* @__PURE__ */ React.createElement(
303
- FormControlLabel,
304
- {
305
- label: count > 0 ? `(${count})` : void 0,
306
- className: classes.label,
307
- control: /* @__PURE__ */ React.createElement(
308
- Checkbox,
309
- {
310
- color: "primary",
311
- disabled: !totalCount,
312
- checked: count > 0,
313
- indeterminate: count > 0 && totalCount !== count,
314
- onChange: onSelectAll
315
- }
316
- )
317
- }
318
- );
319
- };
320
-
321
- const BulkActions = ({
322
- selectedNotifications,
323
- notifications,
324
- onSwitchReadStatus,
325
- onSwitchSavedStatus
326
- }) => {
327
- const isDisabled = selectedNotifications.size === 0;
328
- const bulkNotifications = notifications.filter(
329
- (notification) => selectedNotifications.has(notification.id)
330
- );
331
- const isOneRead = !!bulkNotifications.find(
332
- (notification) => !!notification.read
333
- );
334
- const isOneSaved = !!bulkNotifications.find(
335
- (notification) => !!notification.saved
336
- );
337
- const markAsReadText = isOneRead ? "Return selected among unread" : "Mark selected as read";
338
- const IconComponent = isOneRead ? MarkAsUnreadIcon : MarkAsReadIcon;
339
- const markAsSavedText = isOneSaved ? "Undo save for selected" : "Save selected for later";
340
- const SavedIconComponent = isOneSaved ? MarkAsUnsavedIcon : MarkAsSavedIcon;
341
- return /* @__PURE__ */ React.createElement(Grid, { container: true, wrap: "nowrap" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Tooltip, { title: markAsSavedText }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
342
- IconButton,
343
- {
344
- disabled: isDisabled,
345
- onClick: () => {
346
- onSwitchSavedStatus([...selectedNotifications], !isOneSaved);
347
- }
348
- },
349
- /* @__PURE__ */ React.createElement(SavedIconComponent, { "aria-label": markAsSavedText })
350
- )))), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Tooltip, { title: markAsReadText }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
351
- IconButton,
352
- {
353
- disabled: isDisabled,
354
- onClick: () => {
355
- onSwitchReadStatus([...selectedNotifications], !isOneRead);
356
- }
357
- },
358
- /* @__PURE__ */ React.createElement(IconComponent, { "aria-label": markAsReadText })
359
- )))));
360
- };
361
-
362
- const ThrottleDelayMs = 1e3;
363
- const NotificationsTable = ({
364
- isLoading,
365
- notifications = [],
366
- onUpdate,
367
- setContainsText,
368
- onPageChange,
369
- onRowsPerPageChange,
370
- page,
371
- pageSize,
372
- totalCount
373
- }) => {
374
- const notificationsApi = useApi(notificationsApiRef);
375
- const [selectedNotifications, setSelectedNotifications] = React.useState(
376
- /* @__PURE__ */ new Set()
377
- );
378
- const onNotificationsSelectChange = React.useCallback(
379
- (ids, checked) => {
380
- let newSelect;
381
- if (checked) {
382
- newSelect = /* @__PURE__ */ new Set([...selectedNotifications, ...ids]);
383
- } else {
384
- newSelect = new Set(selectedNotifications);
385
- ids.forEach((id) => newSelect.delete(id));
386
- }
387
- setSelectedNotifications(newSelect);
388
- },
389
- [selectedNotifications, setSelectedNotifications]
390
- );
391
- const onSwitchReadStatus = React.useCallback(
392
- (ids, newStatus) => {
393
- notificationsApi.updateNotifications({
394
- ids,
395
- read: newStatus
396
- }).then(onUpdate);
397
- },
398
- [notificationsApi, onUpdate]
399
- );
400
- const onSwitchSavedStatus = React.useCallback(
401
- (ids, newStatus) => {
402
- notificationsApi.updateNotifications({
403
- ids,
404
- saved: newStatus
405
- }).then(onUpdate);
406
- },
407
- [notificationsApi, onUpdate]
408
- );
409
- const throttledContainsTextHandler = React.useMemo(
410
- () => throttle(setContainsText, ThrottleDelayMs),
411
- [setContainsText]
412
- );
413
- React.useEffect(() => {
414
- const allShownIds = new Set(notifications.map((n) => n.id));
415
- const intersect = [...selectedNotifications].filter(
416
- (id) => allShownIds.has(id)
417
- );
418
- if (selectedNotifications.size !== intersect.length) {
419
- setSelectedNotifications(new Set(intersect));
420
- }
421
- }, [notifications, selectedNotifications]);
422
- const compactColumns = React.useMemo(
423
- () => [
424
- {
425
- /* selection column */
426
- width: "1rem",
427
- title: /* @__PURE__ */ React.createElement(
428
- SelectAll,
429
- {
430
- count: selectedNotifications.size,
431
- totalCount: notifications.length,
432
- onSelectAll: () => onNotificationsSelectChange(
433
- notifications.map((notification) => notification.id),
434
- selectedNotifications.size !== notifications.length
435
- )
436
- }
437
- ),
438
- render: (notification) => /* @__PURE__ */ React.createElement(
439
- Checkbox,
440
- {
441
- color: "primary",
442
- checked: selectedNotifications.has(notification.id),
443
- onChange: (_, checked) => onNotificationsSelectChange([notification.id], checked)
444
- }
445
- )
446
- },
447
- {
448
- /* compact-data column */
449
- customFilterAndSearch: () => true,
450
- render: (notification) => {
451
- var _a;
452
- return /* @__PURE__ */ React.createElement(Grid, { container: true }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(SeverityIcon, { severity: (_a = notification.payload) == null ? void 0 : _a.severity })), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Typography, { variant: "subtitle2" }, notification.payload.link ? /* @__PURE__ */ React.createElement(Link, { to: notification.payload.link }, notification.payload.title) : notification.payload.title), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, notification.payload.description), /* @__PURE__ */ React.createElement(Typography, { variant: "caption" }, notification.origin && /* @__PURE__ */ React.createElement(React.Fragment, null, notification.origin, "\xA0\u2022\xA0"), notification.payload.topic && /* @__PURE__ */ React.createElement(React.Fragment, null, notification.payload.topic, "\xA0\u2022\xA0"), notification.created && /* @__PURE__ */ React.createElement(RelativeTime, { value: notification.created })))));
453
- }
454
- },
455
- {
456
- /* actions column */
457
- width: "1rem",
458
- title: /* @__PURE__ */ React.createElement(
459
- BulkActions,
460
- {
461
- notifications,
462
- selectedNotifications,
463
- onSwitchReadStatus,
464
- onSwitchSavedStatus
465
- }
466
- ),
467
- render: (notification) => /* @__PURE__ */ React.createElement(
468
- BulkActions,
469
- {
470
- notifications: [notification],
471
- selectedNotifications: /* @__PURE__ */ new Set([notification.id]),
472
- onSwitchReadStatus,
473
- onSwitchSavedStatus
474
- }
475
- )
476
- }
477
- ],
478
- [
479
- onSwitchReadStatus,
480
- onSwitchSavedStatus,
481
- selectedNotifications,
482
- onNotificationsSelectChange,
483
- notifications
484
- ]
485
- );
486
- return /* @__PURE__ */ React.createElement(
487
- Table,
488
- {
489
- isLoading,
490
- options: {
491
- padding: "dense",
492
- search: true,
493
- paging: true,
494
- pageSize,
495
- header: true,
496
- sorting: false
497
- },
498
- onPageChange,
499
- onRowsPerPageChange,
500
- page,
501
- totalCount,
502
- onSearchChange: throttledContainsTextHandler,
503
- data: notifications,
504
- columns: compactColumns
505
- }
506
- );
507
- };
508
-
509
- export { NotificationsClient, NotificationsPage, NotificationsSidebarItem, NotificationsTable, notificationsApiRef, notificationsPlugin, useNotificationsApi, useTitleCounter, useWebNotifications };
1
+ export { NotificationsPage, notificationsPlugin } from './plugin.esm.js';
2
+ export { notificationsApiRef } from './api/NotificationsApi.esm.js';
3
+ export { NotificationsClient } from './api/NotificationsClient.esm.js';
4
+ export { useNotificationsApi } from './hooks/useNotificationsApi.esm.js';
5
+ export { useWebNotifications } from './hooks/useWebNotifications.esm.js';
6
+ export { useTitleCounter } from './hooks/useTitleCounter.esm.js';
7
+ export { NotificationsSidebarItem } from './components/NotificationsSideBarItem/NotificationsSideBarItem.esm.js';
8
+ export { NotificationsTable } from './components/NotificationsTable/NotificationsTable.esm.js';
510
9
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/routes.ts","../src/api/NotificationsApi.ts","../src/api/NotificationsClient.ts","../src/plugin.ts","../src/hooks/useNotificationsApi.ts","../src/hooks/useWebNotifications.ts","../src/hooks/useTitleCounter.ts","../src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx","../src/components/NotificationsTable/SeverityIcon.tsx","../src/components/NotificationsTable/SelectAll.tsx","../src/components/NotificationsTable/BulkActions.tsx","../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 { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'notifications',\n});\n","/*\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 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 GetNotificationsOptions = {\n offset?: number;\n limit?: number;\n search?: string;\n read?: boolean;\n saved?: boolean;\n createdAfter?: Date;\n sort?: 'created' | 'topic' | 'origin';\n sortOrder?: 'asc' | 'desc';\n minimumSeverity?: NotificationSeverity;\n};\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 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","/*\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 GetNotificationsOptions,\n GetNotificationsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\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 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('minimal_severity', options.minimumSeverity);\n }\n const urlSegment = `?${queryString}`;\n\n return await this.request<GetNotificationsResponse>(urlSegment);\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(`${id}`);\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[]>('update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private async request<T>(path: string, init?: any): Promise<T> {\n const baseUrl = `${await this.discoveryApi.getBaseUrl('notifications')}/`;\n const url = new URL(path, baseUrl);\n\n const response = await this.fetchApi.fetch(url.toString(), init);\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json() as Promise<T>;\n }\n}\n","/*\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","/*\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","/*\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';\n\n/** @public */\nexport function useWebNotifications() {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const [webNotifications, setWebNotifications] = useState<Notification[]>([]);\n\n useEffect(() => {\n if ('Notification' in window && webNotificationPermission === 'default') {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [webNotificationPermission]);\n\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n webNotifications.forEach(n => n.close());\n setWebNotifications([]);\n }\n });\n\n const sendWebNotification = useCallback(\n (options: { title: string; description: string; link?: string }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n });\n\n notification.onclick = event => {\n event.preventDefault();\n notification.close();\n if (options.link) {\n window.open(options.link, '_blank');\n }\n };\n\n return notification;\n },\n [webNotificationPermission],\n );\n\n return { sendWebNotification };\n}\n","/*\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';\n\n/** @public */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n\n const getPrefix = (value: number) => {\n return value === 0 ? '' : `(${value}) `;\n };\n\n const cleanTitle = (currentTitle: string) => {\n return currentTitle.replace(/^\\(\\d+\\)\\s/, '');\n };\n\n useEffect(() => {\n document.title = title;\n }, [title]);\n\n useEffect(() => {\n const baseTitle = cleanTitle(title);\n setTitle(`${getPrefix(count)}${baseTitle}`);\n return () => {\n document.title = cleanTitle(title);\n };\n }, [title, count]);\n\n const titleElement = document.querySelector('title');\n if (titleElement) {\n new MutationObserver(() => {\n setTitle(document.title);\n }).observe(titleElement, {\n subtree: true,\n characterData: true,\n childList: true,\n });\n }\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n","/*\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 React, { useEffect } from 'react';\nimport { useNotificationsApi } from '../../hooks';\nimport { SidebarItem } from '@backstage/core-components';\nimport NotificationsIcon from '@material-ui/icons/Notifications';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../routes';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport { NotificationSignal } from '@backstage/plugin-notifications-common';\nimport { useWebNotifications } from '../../hooks/useWebNotifications';\nimport { useTitleCounter } from '../../hooks/useTitleCounter';\nimport { notificationsApiRef } from '../../api';\n\n/** @public */\nexport const NotificationsSidebarItem = (props?: {\n webNotificationsEnabled?: boolean;\n titleCounterEnabled?: boolean;\n}) => {\n const { webNotificationsEnabled = false, titleCounterEnabled = true } =\n props ?? { webNotificationsEnabled: false, titleCounterEnabled: true };\n\n const { loading, error, value, retry } = useNotificationsApi(api =>\n api.getStatus(),\n );\n const notificationsApi = useApi(notificationsApiRef);\n const [unreadCount, setUnreadCount] = React.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 } = useWebNotifications();\n const [refresh, setRefresh] = React.useState(false);\n const { setNotificationCount } = useTitleCounter();\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, retry]);\n\n useEffect(() => {\n const handleWebNotification = (signal: NotificationSignal) => {\n if (!webNotificationsEnabled || signal.action !== 'new_notification') {\n return;\n }\n\n notificationsApi\n .getNotification(signal.notification_id)\n .then(notification => {\n if (!notification) {\n return;\n }\n sendWebNotification({\n title: notification.payload.title,\n description: notification.payload.description ?? '',\n link: notification.payload.link,\n });\n });\n };\n\n if (lastSignal && lastSignal.action) {\n handleWebNotification(lastSignal);\n setRefresh(true);\n }\n }, [\n lastSignal,\n sendWebNotification,\n webNotificationsEnabled,\n notificationsApi,\n ]);\n\n useEffect(() => {\n if (!loading && !error && value) {\n setUnreadCount(value.unread);\n if (titleCounterEnabled) {\n setNotificationCount(value.unread);\n }\n }\n }, [loading, error, value, titleCounterEnabled, setNotificationCount]);\n\n // TODO: Figure out if the count can be added to hasNotifications\n return (\n <SidebarItem\n icon={NotificationsIcon}\n to={notificationsRoute()}\n text=\"Notifications\"\n hasNotifications={!error && !!unreadCount}\n />\n );\n};\n","/*\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 React from 'react';\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';\n\nexport const SeverityIcon = ({\n severity,\n}: {\n severity?: NotificationSeverity;\n}) => {\n switch (severity) {\n case 'critical':\n return <CriticalIcon htmlColor=\"#C9190B\" />;\n case 'high':\n return <HighIcon htmlColor=\"#F0AB00\" />;\n case 'low':\n return <LowIcon htmlColor=\"#2B9AF3\" />;\n case 'normal':\n default:\n return <NormalIcon htmlColor=\"#5BA352\" />;\n }\n};\n","/*\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 React from 'react';\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","/*\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 React from 'react';\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';\n\nexport const BulkActions = ({\n selectedNotifications,\n notifications,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n}: {\n selectedNotifications: Set<Notification['id']>;\n notifications: Notification[];\n onSwitchReadStatus: (ids: Notification['id'][], newStatus: boolean) => void;\n onSwitchSavedStatus: (ids: Notification['id'][], newStatus: boolean) => 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>\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>\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","/*\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 React 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 { Notification } from '@backstage/plugin-notifications-common';\n\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n Link,\n Table,\n TableProps,\n TableColumn,\n} from '@backstage/core-components';\n\nimport { SeverityIcon } from './SeverityIcon';\nimport { SelectAll } from './SelectAll';\nimport { BulkActions } from './BulkActions';\n\nconst ThrottleDelayMs = 1000;\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount'\n> & {\n isLoading?: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n isLoading,\n notifications = [],\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const notificationsApi = useApi(notificationsApiRef);\n const [selectedNotifications, setSelectedNotifications] = React.useState(\n new Set<Notification['id']>(),\n );\n\n const onNotificationsSelectChange = React.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 = React.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 = React.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 throttledContainsTextHandler = React.useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n React.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 = React.useMemo(\n (): TableColumn<Notification>[] => [\n {\n /* selection column */\n width: '1rem',\n title: (\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 ),\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>\n <SeverityIcon severity={notification.payload?.severity} />\n </Grid>\n <Grid item>\n <Box>\n <Typography variant=\"subtitle2\">\n {notification.payload.link ? (\n <Link to={notification.payload.link}>\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n <Typography variant=\"body2\">\n {notification.payload.description}\n </Typography>\n <Typography variant=\"caption\">\n {notification.origin && (\n <>{notification.origin}&nbsp;&bull;&nbsp;</>\n )}\n {notification.payload.topic && (\n <>{notification.payload.topic}&nbsp;&bull;&nbsp;</>\n )}\n {notification.created && (\n <RelativeTime value={notification.created} />\n )}\n </Typography>\n </Box>\n </Grid>\n </Grid>\n );\n },\n },\n {\n /* actions column */\n width: '1rem',\n title: (\n <BulkActions\n notifications={notifications}\n selectedNotifications={selectedNotifications}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n />\n ),\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 onSwitchReadStatus,\n onSwitchSavedStatus,\n selectedNotifications,\n onNotificationsSelectChange,\n notifications,\n ],\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA,eAAA;AACN,CAAC,CAAA;;ACIM,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA,8BAAA;AACN,CAAC;;;;;;;;ACIM,MAAM,mBAAgD,CAAA;AAAA,EAIpD,YAAY,OAGhB,EAAA;AANH,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AAMf,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,MAAM,iBACJ,OACmC,EAAA;AA3CvC,IAAA,IAAA,EAAA,CAAA;AA4CI,IAAM,MAAA,WAAA,GAAc,IAAI,eAAgB,EAAA,CAAA;AACxC,IAAI,IAAA,CAAA,OAAA,IAAA,IAAA,GAAA,KA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
1
+ import { createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
2
+ import { rootRouteRef } from './routes.esm.js';
3
+ import { notificationsApiRef } from './api/NotificationsApi.esm.js';
4
+ import { NotificationsClient } from './api/NotificationsClient.esm.js';
5
+
6
+ const notificationsPlugin = createPlugin({
7
+ id: "notifications",
8
+ routes: {
9
+ root: rootRouteRef
10
+ },
11
+ apis: [
12
+ createApiFactory({
13
+ api: notificationsApiRef,
14
+ deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },
15
+ factory: ({ discoveryApi, fetchApi }) => new NotificationsClient({ discoveryApi, fetchApi })
16
+ })
17
+ ]
18
+ });
19
+ const NotificationsPage = notificationsPlugin.provide(
20
+ createRoutableExtension({
21
+ name: "NotificationsPage",
22
+ component: () => import('./components/NotificationsPage/index.esm.js').then((m) => m.NotificationsPage),
23
+ mountPoint: rootRouteRef
24
+ })
25
+ );
26
+
27
+ export { NotificationsPage, notificationsPlugin };
28
+ //# sourceMappingURL=plugin.esm.js.map
@@ -0,0 +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,YAAA;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,CAAA;AAAA,KACrD,CAAA;AAAA,GACH;AACF,CAAC,EAAA;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,YAAA;AAAA,GACb,CAAA;AACH;;;;"}