@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BulkActions.esm.js","sources":["../../../src/components/NotificationsTable/BulkActions.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport 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"],"names":[],"mappings":";;;;;;;;;AAyBO,MAAM,cAAc,CAAC;AAAA,EAC1B,qBAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AACF,CAKM,KAAA;AACJ,EAAM,MAAA,UAAA,GAAa,sBAAsB,IAAS,KAAA,CAAA,CAAA;AAClD,EAAA,MAAM,oBAAoB,aAAc,CAAA,MAAA;AAAA,IAAO,CAC7C,YAAA,KAAA,qBAAA,CAAsB,GAAI,CAAA,YAAA,CAAa,EAAE,CAAA;AAAA,GAC3C,CAAA;AAEA,EAAM,MAAA,SAAA,GAAY,CAAC,CAAC,iBA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CACb,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,QAAU,EAAA,UAAA;AAAA,MACV,SAAS,MAAM;AACb,QAAA,kBAAA,CAAmB,CAAC,GAAG,qBAAqB,CAAA,EAAG,CAAC,SAAS,CAAA,CAAA;AAAA,OAC3D;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,YAAA,EAAY,cAAgB,EAAA,CAAA;AAAA,GAE/C,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,177 @@
1
+ import React from 'react';
2
+ import throttle from 'lodash/throttle';
3
+ import RelativeTime from 'react-relative-time';
4
+ import Box from '@material-ui/core/Box';
5
+ import Grid from '@material-ui/core/Grid';
6
+ import Checkbox from '@material-ui/core/Checkbox';
7
+ import Typography from '@material-ui/core/Typography';
8
+ import { makeStyles } from '@material-ui/core/styles';
9
+ import { notificationsApiRef } from '../../api/NotificationsApi.esm.js';
10
+ import '@backstage/errors';
11
+ import { useApi } from '@backstage/core-plugin-api';
12
+ import { Link, Table } from '@backstage/core-components';
13
+ import { SeverityIcon } from './SeverityIcon.esm.js';
14
+ import { SelectAll } from './SelectAll.esm.js';
15
+ import { BulkActions } from './BulkActions.esm.js';
16
+
17
+ const ThrottleDelayMs = 1e3;
18
+ const useStyles = makeStyles({
19
+ description: {
20
+ maxHeight: "5rem",
21
+ overflow: "scroll"
22
+ },
23
+ severityItem: {
24
+ alignContent: "center"
25
+ }
26
+ });
27
+ const NotificationsTable = ({
28
+ isLoading,
29
+ notifications = [],
30
+ onUpdate,
31
+ setContainsText,
32
+ onPageChange,
33
+ onRowsPerPageChange,
34
+ page,
35
+ pageSize,
36
+ totalCount
37
+ }) => {
38
+ const classes = useStyles();
39
+ const notificationsApi = useApi(notificationsApiRef);
40
+ const [selectedNotifications, setSelectedNotifications] = React.useState(
41
+ /* @__PURE__ */ new Set()
42
+ );
43
+ const onNotificationsSelectChange = React.useCallback(
44
+ (ids, checked) => {
45
+ let newSelect;
46
+ if (checked) {
47
+ newSelect = /* @__PURE__ */ new Set([...selectedNotifications, ...ids]);
48
+ } else {
49
+ newSelect = new Set(selectedNotifications);
50
+ ids.forEach((id) => newSelect.delete(id));
51
+ }
52
+ setSelectedNotifications(newSelect);
53
+ },
54
+ [selectedNotifications, setSelectedNotifications]
55
+ );
56
+ const onSwitchReadStatus = React.useCallback(
57
+ (ids, newStatus) => {
58
+ notificationsApi.updateNotifications({
59
+ ids,
60
+ read: newStatus
61
+ }).then(onUpdate);
62
+ },
63
+ [notificationsApi, onUpdate]
64
+ );
65
+ const onSwitchSavedStatus = React.useCallback(
66
+ (ids, newStatus) => {
67
+ notificationsApi.updateNotifications({
68
+ ids,
69
+ saved: newStatus
70
+ }).then(onUpdate);
71
+ },
72
+ [notificationsApi, onUpdate]
73
+ );
74
+ const throttledContainsTextHandler = React.useMemo(
75
+ () => throttle(setContainsText, ThrottleDelayMs),
76
+ [setContainsText]
77
+ );
78
+ React.useEffect(() => {
79
+ const allShownIds = new Set(notifications.map((n) => n.id));
80
+ const intersect = [...selectedNotifications].filter(
81
+ (id) => allShownIds.has(id)
82
+ );
83
+ if (selectedNotifications.size !== intersect.length) {
84
+ setSelectedNotifications(new Set(intersect));
85
+ }
86
+ }, [notifications, selectedNotifications]);
87
+ const compactColumns = React.useMemo(
88
+ () => [
89
+ {
90
+ /* selection column */
91
+ width: "1rem",
92
+ title: /* @__PURE__ */ React.createElement(
93
+ SelectAll,
94
+ {
95
+ count: selectedNotifications.size,
96
+ totalCount: notifications.length,
97
+ onSelectAll: () => onNotificationsSelectChange(
98
+ notifications.map((notification) => notification.id),
99
+ selectedNotifications.size !== notifications.length
100
+ )
101
+ }
102
+ ),
103
+ render: (notification) => /* @__PURE__ */ React.createElement(
104
+ Checkbox,
105
+ {
106
+ color: "primary",
107
+ checked: selectedNotifications.has(notification.id),
108
+ onChange: (_, checked) => onNotificationsSelectChange([notification.id], checked)
109
+ }
110
+ )
111
+ },
112
+ {
113
+ /* compact-data column */
114
+ customFilterAndSearch: () => true,
115
+ render: (notification) => {
116
+ var _a;
117
+ return /* @__PURE__ */ React.createElement(Grid, { container: true }, /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.severityItem }, /* @__PURE__ */ React.createElement(SeverityIcon, { severity: (_a = notification.payload) == null ? void 0 : _a.severity })), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 11 }, /* @__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), notification.payload.description ? /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.description }, notification.payload.description) : null, /* @__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 })))));
118
+ }
119
+ },
120
+ {
121
+ /* actions column */
122
+ width: "1rem",
123
+ title: /* @__PURE__ */ React.createElement(
124
+ BulkActions,
125
+ {
126
+ notifications,
127
+ selectedNotifications,
128
+ onSwitchReadStatus,
129
+ onSwitchSavedStatus
130
+ }
131
+ ),
132
+ render: (notification) => /* @__PURE__ */ React.createElement(
133
+ BulkActions,
134
+ {
135
+ notifications: [notification],
136
+ selectedNotifications: /* @__PURE__ */ new Set([notification.id]),
137
+ onSwitchReadStatus,
138
+ onSwitchSavedStatus
139
+ }
140
+ )
141
+ }
142
+ ],
143
+ [
144
+ selectedNotifications,
145
+ notifications,
146
+ onSwitchReadStatus,
147
+ onSwitchSavedStatus,
148
+ onNotificationsSelectChange,
149
+ classes.severityItem,
150
+ classes.description
151
+ ]
152
+ );
153
+ return /* @__PURE__ */ React.createElement(
154
+ Table,
155
+ {
156
+ isLoading,
157
+ options: {
158
+ padding: "dense",
159
+ search: true,
160
+ paging: true,
161
+ pageSize,
162
+ header: true,
163
+ sorting: false
164
+ },
165
+ onPageChange,
166
+ onRowsPerPageChange,
167
+ page,
168
+ totalCount,
169
+ onSearchChange: throttledContainsTextHandler,
170
+ data: notifications,
171
+ columns: compactColumns
172
+ }
173
+ );
174
+ };
175
+
176
+ export { NotificationsTable };
177
+ //# sourceMappingURL=NotificationsTable.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationsTable.esm.js","sources":["../../../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport 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 { makeStyles } from '@material-ui/core/styles';\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\nconst useStyles = makeStyles({\n description: {\n maxHeight: '5rem',\n overflow: 'scroll',\n },\n severityItem: {\n alignContent: 'center',\n },\n});\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 classes = useStyles();\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 className={classes.severityItem}>\n <SeverityIcon severity={notification.payload?.severity} />\n </Grid>\n <Grid item xs={11}>\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 {notification.payload.description ? (\n <Typography variant=\"body2\" className={classes.description}>\n {notification.payload.description}\n </Typography>\n ) : null}\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 selectedNotifications,\n notifications,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onNotificationsSelectChange,\n classes.severityItem,\n classes.description,\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":";;;;;;;;;;;;;;;;AAuCA,MAAM,eAAkB,GAAA,GAAA,CAAA;AAExB,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,WAAa,EAAA;AAAA,IACX,SAAW,EAAA,MAAA;AAAA,IACX,QAAU,EAAA,QAAA;AAAA,GACZ;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,YAAc,EAAA,QAAA;AAAA,GAChB;AACF,CAAC,CAAA,CAAA;AAeM,MAAM,qBAAqB,CAAC;AAAA,EACjC,SAAA;AAAA,EACA,gBAAgB,EAAC;AAAA,EACjB,QAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AACF,CAA+B,KAAA;AAC7B,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA,CAAA;AACnD,EAAA,MAAM,CAAC,qBAAA,EAAuB,wBAAwB,CAAA,GAAI,KAAM,CAAA,QAAA;AAAA,wBAC1D,GAAwB,EAAA;AAAA,GAC9B,CAAA;AAEA,EAAA,MAAM,8BAA8B,KAAM,CAAA,WAAA;AAAA,IACxC,CAAC,KAA2B,OAAqB,KAAA;AAC/C,MAAI,IAAA,SAAA,CAAA;AACJ,MAAA,IAAI,OAAS,EAAA;AACX,QAAA,SAAA,uBAAgB,GAAI,CAAA,CAAC,GAAG,qBAAuB,EAAA,GAAG,GAAG,CAAC,CAAA,CAAA;AAAA,OACjD,MAAA;AACL,QAAY,SAAA,GAAA,IAAI,IAA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ControlLabel from '@material-ui/core/FormControlLabel';
4
+ import { makeStyles } from '@material-ui/core/styles';
5
+
6
+ const useStyles = makeStyles({
7
+ label: {
8
+ marginLeft: "0px",
9
+ maxWidth: "2rem",
10
+ "& span": {
11
+ paddingRight: "0px"
12
+ }
13
+ }
14
+ });
15
+ const SelectAll = ({
16
+ count,
17
+ totalCount,
18
+ onSelectAll
19
+ }) => {
20
+ const classes = useStyles();
21
+ return /* @__PURE__ */ React.createElement(
22
+ FormControlLabel,
23
+ {
24
+ label: count > 0 ? `(${count})` : void 0,
25
+ className: classes.label,
26
+ control: /* @__PURE__ */ React.createElement(
27
+ Checkbox,
28
+ {
29
+ color: "primary",
30
+ disabled: !totalCount,
31
+ checked: count > 0,
32
+ indeterminate: count > 0 && totalCount !== count,
33
+ onChange: onSelectAll
34
+ }
35
+ )
36
+ }
37
+ );
38
+ };
39
+
40
+ export { SelectAll };
41
+ //# sourceMappingURL=SelectAll.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectAll.esm.js","sources":["../../../src/components/NotificationsTable/SelectAll.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport 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"],"names":[],"mappings":";;;;;AAoBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,KAAO,EAAA;AAAA,IACL,UAAY,EAAA,KAAA;AAAA,IACZ,QAAU,EAAA,MAAA;AAAA,IACV,QAAU,EAAA;AAAA,MACR,YAAc,EAAA,KAAA;AAAA,KAChB;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AAEM,MAAM,YAAY,CAAC;AAAA,EACxB,KAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,KAAA,GAAQ,CAAI,GAAA,CAAA,CAAA,EAAI,KAAK,CAAM,CAAA,CAAA,GAAA,KAAA,CAAA;AAAA,MAClC,WAAW,OAAQ,CAAA,KAAA;AAAA,MACnB,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,KAAM,EAAA,SAAA;AAAA,UACN,UAAU,CAAC,UAAA;AAAA,UACX,SAAS,KAAQ,GAAA,CAAA;AAAA,UACjB,aAAA,EAAe,KAAQ,GAAA,CAAA,IAAK,UAAe,KAAA,KAAA;AAAA,UAC3C,QAAU,EAAA,WAAA;AAAA,SAAA;AAAA,OACZ;AAAA,KAAA;AAAA,GAEJ,CAAA;AAEJ;;;;"}
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import NormalIcon from '@material-ui/icons/CheckOutlined';
3
+ import CriticalIcon from '@material-ui/icons/ErrorOutline';
4
+ import HighIcon from '@material-ui/icons/WarningOutlined';
5
+ import LowIcon from '@material-ui/icons/InfoOutlined';
6
+ import { makeStyles } from '@material-ui/core/styles';
7
+
8
+ const useStyles = makeStyles((theme) => ({
9
+ critical: {
10
+ color: theme.palette.status.error
11
+ },
12
+ high: {
13
+ color: theme.palette.status.warning
14
+ },
15
+ normal: {
16
+ color: theme.palette.status.ok
17
+ },
18
+ low: {
19
+ color: theme.palette.status.running
20
+ }
21
+ }));
22
+ const SeverityIcon = ({
23
+ severity
24
+ }) => {
25
+ const classes = useStyles();
26
+ switch (severity) {
27
+ case "critical":
28
+ return /* @__PURE__ */ React.createElement(CriticalIcon, { className: classes.critical });
29
+ case "high":
30
+ return /* @__PURE__ */ React.createElement(HighIcon, { className: classes.high });
31
+ case "low":
32
+ return /* @__PURE__ */ React.createElement(LowIcon, { className: classes.low });
33
+ case "normal":
34
+ default:
35
+ return /* @__PURE__ */ React.createElement(NormalIcon, { className: classes.normal });
36
+ }
37
+ };
38
+
39
+ export { SeverityIcon };
40
+ //# sourceMappingURL=SeverityIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SeverityIcon.esm.js","sources":["../../../src/components/NotificationsTable/SeverityIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport 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';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(theme => ({\n critical: {\n color: theme.palette.status.error,\n },\n high: {\n color: theme.palette.status.warning,\n },\n normal: {\n color: theme.palette.status.ok,\n },\n low: {\n color: theme.palette.status.running,\n },\n}));\n\nexport const SeverityIcon = ({\n severity,\n}: {\n severity?: NotificationSeverity;\n}) => {\n const classes = useStyles();\n\n switch (severity) {\n case 'critical':\n return <CriticalIcon className={classes.critical} />;\n case 'high':\n return <HighIcon className={classes.high} />;\n case 'low':\n return <LowIcon className={classes.low} />;\n case 'normal':\n default:\n return <NormalIcon className={classes.normal} />;\n }\n};\n"],"names":[],"mappings":";;;;;;;AAuBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,QAAU,EAAA;AAAA,IACR,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,GAC9B;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,OAAA;AAAA,GAC9B;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,EAAA;AAAA,GAC9B;AAAA,EACA,GAAK,EAAA;AAAA,IACH,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,OAAA;AAAA,GAC9B;AACF,CAAE,CAAA,CAAA,CAAA;AAEK,MAAM,eAAe,CAAC;AAAA,EAC3B,QAAA;AACF,CAEM,KAAA;AACJ,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EAAA,QAAQ,QAAU;AAAA,IAChB,KAAK,UAAA;AACH,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,SAAW,EAAA,OAAA,CAAQ,QAAU,EAAA,CAAA,CAAA;AAAA,IACpD,KAAK,MAAA;AACH,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,SAAW,EAAA,OAAA,CAAQ,IAAM,EAAA,CAAA,CAAA;AAAA,IAC5C,KAAK,KAAA;AACH,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,SAAW,EAAA,OAAA,CAAQ,GAAK,EAAA,CAAA,CAAA;AAAA,IAC1C,KAAK,QAAA,CAAA;AAAA,IACL;AACE,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAW,EAAA,OAAA,CAAQ,MAAQ,EAAA,CAAA,CAAA;AAAA,GAClD;AACF;;;;"}
@@ -0,0 +1,14 @@
1
+ import { notificationsApiRef } from '../api/NotificationsApi.esm.js';
2
+ import '@backstage/errors';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+
6
+ function useNotificationsApi(f, deps = []) {
7
+ const notificationsApi = useApi(notificationsApiRef);
8
+ return useAsyncRetry(async () => {
9
+ return await f(notificationsApi);
10
+ }, deps);
11
+ }
12
+
13
+ export { useNotificationsApi };
14
+ //# sourceMappingURL=useNotificationsApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationsApi.esm.js","sources":["../../src/hooks/useNotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NotificationsApi, notificationsApiRef } from '../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\n/** @public */\nexport function useNotificationsApi<T>(\n f: (api: NotificationsApi) => Promise<T>,\n deps: any[] = [],\n) {\n const notificationsApi = useApi(notificationsApiRef);\n\n return useAsyncRetry(async () => {\n return await f(notificationsApi);\n }, deps);\n}\n"],"names":[],"mappings":";;;;;AAqBO,SAAS,mBACd,CAAA,CAAA,EACA,IAAc,GAAA,EACd,EAAA;AACA,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA,CAAA;AAEnD,EAAA,OAAO,cAAc,YAAY;AAC/B,IAAO,OAAA,MAAM,EAAE,gBAAgB,CAAA,CAAA;AAAA,KAC9B,IAAI,CAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,57 @@
1
+ import { useState, useRef, useEffect, useCallback } from 'react';
2
+
3
+ function useTitleCounter() {
4
+ const [title, setTitle] = useState(document.title);
5
+ const [count, setCount] = useState(0);
6
+ const titleTimer = useRef(void 0);
7
+ const getPrefix = (value) => {
8
+ return value === 0 ? "" : `(${value}) `;
9
+ };
10
+ const cleanTitle = (currentTitle) => {
11
+ return currentTitle.replace(/^\(\d+\)\s/, "");
12
+ };
13
+ useEffect(() => {
14
+ const baseTitle = cleanTitle(title);
15
+ const shownTitle = `${getPrefix(count)}${baseTitle}`;
16
+ if (document.title !== shownTitle) {
17
+ window.clearTimeout(titleTimer.current);
18
+ document.title = shownTitle;
19
+ titleTimer.current = window.setTimeout(() => {
20
+ document.title = shownTitle;
21
+ }, 50);
22
+ }
23
+ return () => {
24
+ window.clearTimeout(titleTimer.current);
25
+ document.title = cleanTitle(title);
26
+ };
27
+ }, [title, count]);
28
+ useEffect(() => {
29
+ const titleElement = document.querySelector("title");
30
+ let observer;
31
+ if (titleElement) {
32
+ observer = new MutationObserver((mutations) => {
33
+ var _a, _b;
34
+ if ((_b = (_a = mutations == null ? void 0 : mutations[0]) == null ? void 0 : _a.target) == null ? void 0 : _b.textContent) {
35
+ setTitle(mutations[0].target.textContent);
36
+ }
37
+ });
38
+ observer.observe(titleElement, {
39
+ characterData: true,
40
+ childList: true
41
+ });
42
+ }
43
+ return () => {
44
+ if (observer) {
45
+ observer.disconnect();
46
+ }
47
+ };
48
+ }, []);
49
+ const setNotificationCount = useCallback(
50
+ (newCount) => setCount(newCount),
51
+ []
52
+ );
53
+ return { setNotificationCount };
54
+ }
55
+
56
+ export { useTitleCounter };
57
+ //# sourceMappingURL=useTitleCounter.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTitleCounter.esm.js","sources":["../../src/hooks/useTitleCounter.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/** @public */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n const titleTimer = useRef<undefined | number>(undefined);\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 const baseTitle = cleanTitle(title);\n const shownTitle = `${getPrefix(count)}${baseTitle}`;\n if (document.title !== shownTitle) {\n window.clearTimeout(titleTimer.current);\n document.title = shownTitle;\n // Need to do this in timeout as the React Helmet overrides the title after this effect\n titleTimer.current = window.setTimeout(() => {\n document.title = shownTitle;\n }, 50);\n }\n return () => {\n window.clearTimeout(titleTimer.current);\n document.title = cleanTitle(title);\n };\n }, [title, count]);\n\n useEffect(() => {\n const titleElement = document.querySelector('title');\n let observer: MutationObserver | undefined;\n if (titleElement) {\n observer = new MutationObserver(mutations => {\n if (mutations?.[0]?.target?.textContent) {\n setTitle(mutations[0].target.textContent);\n }\n });\n observer.observe(titleElement, {\n characterData: true,\n childList: true,\n });\n }\n return () => {\n if (observer) {\n observer.disconnect();\n }\n };\n }, []);\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n"],"names":[],"mappings":";;AAkBO,SAAS,eAAkB,GAAA;AAChC,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,QAAA,CAAS,SAAS,KAAK,CAAA,CAAA;AACjD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,CAAC,CAAA,CAAA;AACpC,EAAM,MAAA,UAAA,GAAa,OAA2B,KAAS,CAAA,CAAA,CAAA;AAEvD,EAAM,MAAA,SAAA,GAAY,CAAC,KAAkB,KAAA;AACnC,IAAA,OAAO,KAAU,KAAA,CAAA,GAAI,EAAK,GAAA,CAAA,CAAA,EAAI,KAAK,CAAA,EAAA,CAAA,CAAA;AAAA,GACrC,CAAA;AAEA,EAAM,MAAA,UAAA,GAAa,CAAC,YAAyB,KAAA;AAC3C,IAAO,OAAA,YAAA,CAAa,OAAQ,CAAA,YAAA,EAAc,EAAE,CAAA,CAAA;AAAA,GAC9C,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,SAAA,GAAY,WAAW,KAAK,CAAA,CAAA;AAClC,IAAA,MAAM,aAAa,CAAG,EAAA,SAAA,CAAU,KAAK,CAAC,GAAG,SAAS,CAAA,CAAA,CAAA;AAClD,IAAI,IAAA,QAAA,CAAS,UAAU,UAAY,EAAA;AACjC,MAAO,MAAA,CAAA,YAAA,CAAa,WAAW,OAAO,CAAA,CAAA;AACtC,MAAA,QAAA,CAAS,KAAQ,GAAA,UAAA,CAAA;AAEjB,MAAW,UAAA,CAAA,OAAA,GAAU,MAAO,CAAA,UAAA,CAAW,MAAM;AAC3C,QAAA,QAAA,CAAS,KA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,KAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,IACvC,EAAC;AAAA,GACH,CAAA;AAEA,EAAA,OAAO,EAAE,oBAAqB,EAAA,CAAA;AAChC;;;;"}
@@ -0,0 +1,44 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+ import { rootRouteRef } from '../routes.esm.js';
3
+ import { useRouteRef } from '@backstage/core-plugin-api';
4
+ import { useNavigate } from 'react-router-dom';
5
+
6
+ function useWebNotifications(enabled) {
7
+ const [webNotificationPermission, setWebNotificationPermission] = useState("default");
8
+ const notificationsRoute = useRouteRef(rootRouteRef);
9
+ const navigate = useNavigate();
10
+ useEffect(() => {
11
+ if (enabled && "Notification" in window && webNotificationPermission === "default") {
12
+ window.Notification.requestPermission().then((permission) => {
13
+ setWebNotificationPermission(permission);
14
+ });
15
+ }
16
+ }, [enabled, webNotificationPermission]);
17
+ const sendWebNotification = useCallback(
18
+ (options) => {
19
+ if (webNotificationPermission !== "granted") {
20
+ return null;
21
+ }
22
+ const notification = new Notification(options.title, {
23
+ body: options.description,
24
+ tag: options.id
25
+ // Prevent duplicates from multiple tabs
26
+ });
27
+ notification.onclick = (event) => {
28
+ event.preventDefault();
29
+ if (options.link) {
30
+ window.open(options.link, "_blank");
31
+ } else {
32
+ navigate(notificationsRoute());
33
+ }
34
+ notification.close();
35
+ };
36
+ return notification;
37
+ },
38
+ [webNotificationPermission, navigate, notificationsRoute]
39
+ );
40
+ return { sendWebNotification };
41
+ }
42
+
43
+ export { useWebNotifications };
44
+ //# sourceMappingURL=useWebNotifications.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWebNotifications.esm.js","sources":["../../src/hooks/useWebNotifications.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport { rootRouteRef } from '../routes';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { useNavigate } from 'react-router-dom';\n\n/** @public */\nexport function useWebNotifications(enabled: boolean) {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const notificationsRoute = useRouteRef(rootRouteRef);\n const navigate = useNavigate();\n\n useEffect(() => {\n if (\n enabled &&\n 'Notification' in window &&\n webNotificationPermission === 'default'\n ) {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [enabled, webNotificationPermission]);\n\n const sendWebNotification = useCallback(\n (options: {\n id: string;\n title: string;\n description: string;\n link?: string;\n }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n tag: options.id, // Prevent duplicates from multiple tabs\n });\n\n notification.onclick = event => {\n event.preventDefault();\n if (options.link) {\n window.open(options.link, '_blank');\n } else {\n navigate(notificationsRoute());\n }\n notification.close();\n };\n\n return notification;\n },\n [webNotificationPermission, navigate, notificationsRoute],\n );\n\n return { sendWebNotification };\n}\n"],"names":[],"mappings":";;;;;AAqBO,SAAS,oBAAoB,OAAkB,EAAA;AACpD,EAAA,MAAM,CAAC,yBAAA,EAA2B,4BAA4B,CAAA,GAC5D,SAAS,SAAS,CAAA,CAAA;AACpB,EAAM,MAAA,kBAAA,GAAqB,YAAY,YAAY,CAAA,CAAA;AACnD,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAE7B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IACE,OACA,IAAA,cAAA,IAAkB,MAClB,IAAA,yBAAA,KAA8B,SAC9B,EAAA;AACA,MAAA,MAAA,CAAO,YAAa,CAAA,iBAAA,EAAoB,CAAA,IAAA,CAAK,CAAc,UAAA,KAAA;AACzD,QAAA,4BAAA,CAA6B,UAAU,CAAA,CAAA;AAAA,OACxC,CAAA,CAAA;AAAA,KACH;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,yBAAyB,CAAC,CAAA,CAAA;AAEvC,EAAA,MAAM,mBAAsB,GAAA,WAAA;AAAA,IAC1B,CAAC,OAKK,KAAA;AACJ,MAAA,IAAI,8BAA8B,SAAW,EAAA;AAC3C,QAAO,OAAA,IAAA,CAAA;AAAA,OACT;AAEA,MAAA,MAAM,YAAe,GAAA,IAAI,YAAa,CAAA,OAAA,CAAQ,KAAO,EAAA;AAAA,QACnD,MAAM,OAAQ,CAAA,WAAA;AAAA,QACd,KAAK,OAAQ,CAAA,EAAA;AAAA;AAAA,OACd,CAAA,CAAA;AAED,MAAA,YAAA,CAAa,UAAU,CAAS,KAAA,KAAA;AAC9B,QAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AACrB,QAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,UAAO,MAAA,CAAA,IAAA,CAAK,OAAQ,CAAA,IAAA,EAAM,QAAQ,CAAA,CAAA;AAAA,SAC7B,MAAA;AACL,UAAA,QAAA,CAAS,oBAAoB,CAAA,CAAA;AAAA,SAC/B;AACA,QAAA,YAAA,CAAa,KAAM,EAAA,CAAA;AAAA,OACrB,CAAA;AAEA,MAAO,OAAA,YAAA,CAAA;AAAA,KACT;AAAA,IACA,CAAC,yBAA2B,EAAA,QAAA,EAAU,kBAAkB,CAAA;AAAA,GAC1D,CAAA;AAEA,EAAA,OAAO,EAAE,mBAAoB,EAAA,CAAA;AAC/B;;;;"}
package/dist/index.d.ts CHANGED
@@ -2,16 +2,26 @@
2
2
  import * as React from 'react';
3
3
  import React__default from 'react';
4
4
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
5
- import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
5
+ import { DiscoveryApi, FetchApi, IconComponent } from '@backstage/core-plugin-api';
6
6
  import { NotificationSeverity, Notification as Notification$1, NotificationStatus } from '@backstage/plugin-notifications-common';
7
7
  import { TableProps } from '@backstage/core-components';
8
8
 
9
+ /** @public */
10
+ type NotificationsPageProps = {
11
+ title?: string;
12
+ themeId?: string;
13
+ subtitle?: string;
14
+ tooltip?: string;
15
+ type?: string;
16
+ typeLink?: string;
17
+ };
18
+
9
19
  /** @public */
10
20
  declare const notificationsPlugin: _backstage_core_plugin_api.BackstagePlugin<{
11
21
  root: _backstage_core_plugin_api.RouteRef<undefined>;
12
22
  }, {}>;
13
23
  /** @public */
14
- declare const NotificationsPage: () => React.JSX.Element;
24
+ declare const NotificationsPage: (props?: NotificationsPageProps | undefined) => React.JSX.Element;
15
25
 
16
26
  /** @public */
17
27
  declare const notificationsApiRef: _backstage_core_plugin_api.ApiRef<NotificationsApi>;
@@ -85,8 +95,9 @@ declare function useNotificationsApi<T>(f: (api: NotificationsApi) => Promise<T>
85
95
  };
86
96
 
87
97
  /** @public */
88
- declare function useWebNotifications(): {
98
+ declare function useWebNotifications(enabled: boolean): {
89
99
  sendWebNotification: (options: {
100
+ id: string;
90
101
  title: string;
91
102
  description: string;
92
103
  link?: string;
@@ -102,6 +113,11 @@ declare function useTitleCounter(): {
102
113
  declare const NotificationsSidebarItem: (props?: {
103
114
  webNotificationsEnabled?: boolean;
104
115
  titleCounterEnabled?: boolean;
116
+ className?: string;
117
+ icon?: IconComponent;
118
+ text?: string;
119
+ disableHighlight?: boolean;
120
+ noTrack?: boolean;
105
121
  }) => React__default.JSX.Element;
106
122
 
107
123
  /** @public */
@@ -115,4 +131,4 @@ type NotificationsTableProps = Pick<TableProps, 'onPageChange' | 'onRowsPerPageC
115
131
  /** @public */
116
132
  declare const NotificationsTable: ({ isLoading, notifications, onUpdate, setContainsText, onPageChange, onRowsPerPageChange, page, pageSize, totalCount, }: NotificationsTableProps) => React__default.JSX.Element;
117
133
 
118
- export { type GetNotificationsOptions, type GetNotificationsResponse, type NotificationsApi, NotificationsClient, NotificationsPage, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, notificationsApiRef, notificationsPlugin, useNotificationsApi, useTitleCounter, useWebNotifications };
134
+ export { type GetNotificationsOptions, type GetNotificationsResponse, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, notificationsApiRef, notificationsPlugin, useNotificationsApi, useTitleCounter, useWebNotifications };