@backstage/plugin-notifications 0.5.11 → 0.5.12
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.
- package/CHANGELOG.md +31 -0
- package/dist/alpha.d.ts +2 -1
- package/dist/alpha.esm.js +4 -7
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/NotificationsFilters/NotificationsFilters.esm.js +0 -6
- package/dist/components/NotificationsFilters/NotificationsFilters.esm.js.map +1 -1
- package/dist/components/NotificationsPage/NotificationsPage.esm.js +7 -4
- package/dist/components/NotificationsPage/NotificationsPage.esm.js.map +1 -1
- package/dist/components/NotificationsTable/NotificationDescription.esm.js +50 -0
- package/dist/components/NotificationsTable/NotificationDescription.esm.js.map +1 -0
- package/dist/components/NotificationsTable/NotificationsTable.esm.js +11 -8
- package/dist/components/NotificationsTable/NotificationsTable.esm.js.map +1 -1
- package/dist/components/NotificationsTable/SelectAll.esm.js +5 -3
- package/dist/components/NotificationsTable/SelectAll.esm.js.map +1 -1
- package/dist/index.d.ts +75 -73
- package/dist/package.json.esm.js +4 -5
- package/dist/package.json.esm.js.map +1 -1
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @backstage/plugin-notifications
|
|
2
2
|
|
|
3
|
+
## 0.5.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d02db50: Remove unnecessary use of `compatWrapper` and `convertLegacyRouteRef`(s) for the new frontend system.
|
|
8
|
+
- 53347cc: Move long notification descriptions behind `Show more/less` button.
|
|
9
|
+
|
|
10
|
+
This improves readability of the notifications list by preventing long descriptions from taking up too much space
|
|
11
|
+
or rendering very small scrollable areas.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/frontend-plugin-api@0.13.2
|
|
15
|
+
- @backstage/core-components@0.18.4
|
|
16
|
+
- @backstage/core-plugin-api@1.12.1
|
|
17
|
+
- @backstage/theme@0.7.1
|
|
18
|
+
- @backstage/plugin-signals-react@0.0.18
|
|
19
|
+
|
|
20
|
+
## 0.5.12-next.0
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- d02db50: Remove unnecessary use of `compatWrapper` and `convertLegacyRouteRef`(s) for the new frontend system.
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/frontend-plugin-api@0.13.2-next.0
|
|
27
|
+
- @backstage/core-plugin-api@1.12.1-next.0
|
|
28
|
+
- @backstage/theme@0.7.1-next.0
|
|
29
|
+
- @backstage/core-components@0.18.4-next.0
|
|
30
|
+
- @backstage/plugin-signals-react@0.0.18-next.0
|
|
31
|
+
- @backstage/errors@1.2.7
|
|
32
|
+
- @backstage/plugin-notifications-common@0.2.0
|
|
33
|
+
|
|
3
34
|
## 0.5.11
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
3
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
4
|
|
|
4
5
|
/** @alpha */
|
|
5
6
|
declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin<{
|
|
6
|
-
root:
|
|
7
|
+
root: _backstage_core_plugin_api.RouteRef<undefined>;
|
|
7
8
|
}, {}, {
|
|
8
9
|
"api:notifications": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
|
|
9
10
|
kind: "api";
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { PageBlueprint, ApiBlueprint, fetchApiRef, discoveryApiRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { rootRouteRef } from './routes.esm.js';
|
|
4
|
-
import { convertLegacyRouteRef, compatWrapper, convertLegacyRouteRefs } from '@backstage/core-compat-api';
|
|
5
4
|
import { notificationsApiRef } from './api/NotificationsApi.esm.js';
|
|
6
5
|
import { NotificationsClient } from './api/NotificationsClient.esm.js';
|
|
7
6
|
|
|
8
7
|
const page = PageBlueprint.make({
|
|
9
8
|
params: {
|
|
10
9
|
path: "/notifications",
|
|
11
|
-
routeRef:
|
|
12
|
-
loader: () => import('./components/NotificationsPage/index.esm.js').then(
|
|
13
|
-
(m) => compatWrapper(/* @__PURE__ */ jsx(m.NotificationsPage, {}))
|
|
14
|
-
)
|
|
10
|
+
routeRef: rootRouteRef,
|
|
11
|
+
loader: () => import('./components/NotificationsPage/index.esm.js').then((m) => /* @__PURE__ */ jsx(m.NotificationsPage, {}))
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
14
|
const api = ApiBlueprint.make({
|
|
@@ -24,9 +21,9 @@ const api = ApiBlueprint.make({
|
|
|
24
21
|
var alpha = createFrontendPlugin({
|
|
25
22
|
pluginId: "notifications",
|
|
26
23
|
info: { packageJson: () => import('./package.json.esm.js') },
|
|
27
|
-
routes:
|
|
24
|
+
routes: {
|
|
28
25
|
root: rootRouteRef
|
|
29
|
-
}
|
|
26
|
+
},
|
|
30
27
|
// TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually
|
|
31
28
|
extensions: [page, api]
|
|
32
29
|
});
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n PageBlueprint,\n createFrontendPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { rootRouteRef } from './routes';\nimport {
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n PageBlueprint,\n createFrontendPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { rootRouteRef } from './routes';\nimport { NotificationsClient, notificationsApiRef } from './api';\n\nconst page = PageBlueprint.make({\n params: {\n path: '/notifications',\n routeRef: rootRouteRef,\n loader: () =>\n import('./components/NotificationsPage').then(m => (\n <m.NotificationsPage />\n )),\n },\n});\n\nconst api = ApiBlueprint.make({\n params: defineParams =>\n defineParams({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'notifications',\n info: { packageJson: () => import('../package.json') },\n routes: {\n root: rootRouteRef,\n },\n // TODO(Rugvip): Nav item (i.e. NotificationsSidebarItem) currently needs to be installed manually\n extensions: [page, api],\n});\n"],"names":[],"mappings":";;;;;;AA0BA,MAAM,IAAA,GAAO,cAAc,IAAA,CAAK;AAAA,EAC9B,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,gBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,6CAAgC,CAAA,CAAE,IAAA,CAAK,CAAA,CAAA,qBAC5C,GAAA,CAAC,CAAA,CAAE,iBAAA,EAAF,EAAoB,CACtB;AAAA;AAEP,CAAC,CAAA;AAED,MAAM,GAAA,GAAM,aAAa,IAAA,CAAK;AAAA,EAC5B,MAAA,EAAQ,kBACN,YAAA,CAAa;AAAA,IACX,GAAA,EAAK,mBAAA;AAAA,IACL,IAAA,EAAM,EAAE,YAAA,EAAc,eAAA,EAAiB,UAAU,WAAA,EAAY;AAAA,IAC7D,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,QAAA,EAAS,KACjC,IAAI,mBAAA,CAAoB,EAAE,YAAA,EAAc,QAAA,EAAU;AAAA,GACrD;AACL,CAAC,CAAA;AAGD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,eAAA;AAAA,EACV,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAA,EAAE;AAAA,EACrD,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA;AAAA,EAEA,UAAA,EAAY,CAAC,IAAA,EAAM,GAAG;AACxB,CAAC,CAAA;;;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import Divider from '@material-ui/core/Divider';
|
|
3
2
|
import FormControl from '@material-ui/core/FormControl';
|
|
4
3
|
import Grid from '@material-ui/core/Grid';
|
|
5
4
|
import InputLabel from '@material-ui/core/InputLabel';
|
|
6
5
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
7
6
|
import Select from '@material-ui/core/Select';
|
|
8
|
-
import Typography from '@material-ui/core/Typography';
|
|
9
7
|
|
|
10
8
|
const ALL = "___all___";
|
|
11
9
|
const CreatedAfterOptions = {
|
|
@@ -127,10 +125,6 @@ const NotificationsFilters = ({
|
|
|
127
125
|
};
|
|
128
126
|
const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));
|
|
129
127
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Grid, { container: true, children: [
|
|
130
|
-
/* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
|
|
131
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h6", children: "Filters" }),
|
|
132
|
-
/* @__PURE__ */ jsx(Divider, { variant: "fullWidth" })
|
|
133
|
-
] }),
|
|
134
128
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, variant: "outlined", size: "small", children: [
|
|
135
129
|
/* @__PURE__ */ jsx(InputLabel, { id: "notifications-filter-view", children: "View" }),
|
|
136
130
|
/* @__PURE__ */ jsxs(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsFilters.esm.js","sources":["../../../src/components/NotificationsFilters/NotificationsFilters.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ChangeEvent } from 'react';\n\nimport Divider from '@material-ui/core/Divider';\nimport FormControl from '@material-ui/core/FormControl';\nimport Grid from '@material-ui/core/Grid';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport Typography from '@material-ui/core/Typography';\nimport { GetNotificationsOptions } from '../../api';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\n\nexport type SortBy = Required<\n Pick<GetNotificationsOptions, 'sort' | 'sortOrder'>\n>;\n\nexport type NotificationsFiltersProps = {\n unreadOnly?: boolean;\n onUnreadOnlyChanged: (checked: boolean | undefined) => void;\n createdAfter?: string;\n onCreatedAfterChanged: (value: string) => void;\n sorting: SortBy;\n onSortingChanged: (sortBy: SortBy) => void;\n saved?: boolean;\n onSavedChanged: (checked: boolean | undefined) => void;\n severity: NotificationSeverity;\n onSeverityChanged: (severity: NotificationSeverity) => void;\n topic?: string;\n onTopicChanged: (value: string | undefined) => void;\n allTopics?: string[];\n};\n\nconst ALL = '___all___';\n\nexport const CreatedAfterOptions: {\n [key: string]: { label: string; getDate: () => Date };\n} = {\n last24h: {\n label: 'Last 24h',\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n label: 'Last week',\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n label: 'Any time',\n getDate: () => new Date(0),\n },\n};\n\nexport const SortByOptions: {\n [key: string]: {\n label: string;\n sortBy: SortBy;\n };\n} = {\n newest: {\n label: 'Newest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'desc',\n },\n },\n oldest: {\n label: 'Oldest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'asc',\n },\n },\n topic: {\n label: 'Topic',\n sortBy: {\n sort: 'topic',\n sortOrder: 'asc',\n },\n },\n origin: {\n label: 'Origin',\n sortBy: {\n sort: 'origin',\n sortOrder: 'asc',\n },\n },\n};\n\nconst getSortByText = (sortBy?: SortBy): string => {\n if (sortBy?.sort === 'created' && sortBy?.sortOrder === 'asc') {\n return 'oldest';\n }\n if (sortBy?.sort === 'topic') {\n return 'topic';\n }\n if (sortBy?.sort === 'origin') {\n return 'origin';\n }\n\n return 'newest';\n};\n\nconst AllSeverityOptions: { [key in NotificationSeverity]: string } = {\n critical: 'Critical',\n high: 'High',\n normal: 'Normal',\n low: 'Low',\n};\n\nexport const NotificationsFilters = ({\n sorting,\n onSortingChanged,\n unreadOnly,\n onUnreadOnlyChanged,\n createdAfter,\n onCreatedAfterChanged,\n saved,\n onSavedChanged,\n severity,\n onSeverityChanged,\n topic,\n onTopicChanged,\n allTopics,\n}: NotificationsFiltersProps) => {\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnViewChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n if (event.target.value === 'unread') {\n onUnreadOnlyChanged(true);\n onSavedChanged(undefined);\n } else if (event.target.value === 'read') {\n onUnreadOnlyChanged(false);\n onSavedChanged(undefined);\n } else if (event.target.value === 'saved') {\n onUnreadOnlyChanged(undefined);\n onSavedChanged(true);\n } else {\n // All\n onUnreadOnlyChanged(undefined);\n onSavedChanged(undefined);\n }\n };\n\n const handleOnSortByChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const idx = (event.target.value as string) || 'newest';\n const option = SortByOptions[idx];\n onSortingChanged({ ...option.sortBy });\n };\n\n let viewValue = 'all';\n if (saved) {\n viewValue = 'saved';\n } else if (unreadOnly) {\n viewValue = 'unread';\n } else if (unreadOnly === false) {\n viewValue = 'read';\n }\n\n const handleOnSeverityChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value: NotificationSeverity =\n (event.target.value as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\n\n const handleOnTopicChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value = event.target.value as string;\n onTopicChanged(value === ALL ? undefined : value);\n };\n\n const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));\n\n return (\n <>\n <Grid container>\n <Grid item xs={12}>\n <Typography variant=\"h6\">Filters</Typography>\n <Divider variant=\"fullWidth\" />\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-view\">View</InputLabel>\n <Select\n labelId=\"notifications-filter-view\"\n label=\"View\"\n value={viewValue}\n onChange={handleOnViewChanged}\n >\n <MenuItem value=\"unread\">Unread notifications</MenuItem>\n <MenuItem value=\"read\">Read notifications</MenuItem>\n <MenuItem value=\"saved\">Saved</MenuItem>\n <MenuItem value=\"all\">All</MenuItem>\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-created\">Sent out</InputLabel>\n\n <Select\n label=\"Sent out\"\n labelId=\"notifications-filter-created\"\n placeholder=\"Notifications since\"\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n >\n {Object.keys(CreatedAfterOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {CreatedAfterOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-sort\">Sort by</InputLabel>\n\n <Select\n label=\"Sort by\"\n labelId=\"notifications-filter-sort\"\n placeholder=\"Field to sort by\"\n value={sortByText}\n onChange={handleOnSortByChanged}\n >\n {Object.keys(SortByOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {SortByOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-severity\">\n Min severity\n </InputLabel>\n\n <Select\n label=\"Min severity\"\n labelId=\"notifications-filter-severity\"\n value={severity}\n onChange={handleOnSeverityChanged}\n >\n {Object.keys(AllSeverityOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {AllSeverityOptions[key as NotificationSeverity]}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-topic\">Topic</InputLabel>\n\n <Select\n label=\"Topic\"\n labelId=\"notifications-filter-topic\"\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n >\n <MenuItem value={ALL} key={ALL}>\n Any topic\n </MenuItem>\n\n {sortedAllTopics.map((item: string) => (\n <MenuItem value={item} key={item}>\n {item}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA+CA,MAAM,GAAA,GAAM,WAAA;AAEL,MAAM,mBAAA,GAET;AAAA,EACF,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,UAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GACvD;AAAA,EACA,QAAA,EAAU;AAAA,IACR,KAAA,EAAO,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,IAAA,CAAK,KAAI,GAAI,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GAC3D;AAAA,EACA,GAAA,EAAK;AAAA,IACH,KAAA,EAAO,UAAA;AAAA,IACP,OAAA,EAAS,sBAAM,IAAI,IAAA,CAAK,CAAC;AAAA;AAE7B;AAEO,MAAM,aAAA,GAKT;AAAA,EACF,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,SAAA;AAAA,MACN,SAAA,EAAW;AAAA;AACb,GACF;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,SAAA;AAAA,MACN,SAAA,EAAW;AAAA;AACb,GACF;AAAA,EACA,KAAA,EAAO;AAAA,IACL,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,OAAA;AAAA,MACN,SAAA,EAAW;AAA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A,EAAA,MAAA,CAAO,IAAA,CAAK,kBAAkB,CAAA,CAAE,IAAI,CAAC,GAAA,qBACpC,GAAA,CAAC,QAAA,EAAA,EAAS,OAAO,GAAA,EACd,QAAA,EAAA,kBAAA,CAAmB,GAA2B,CAAA,EAAA,EADtB,GAE3B,CACD;AAAA;AAAA;AACH,KAAA,EACF,CAAA,EACF,CAAA;AAAA,oBAEA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,EAAA,EACb,QAAA,kBAAA,IAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAS,IAAA,EAAC,OAAA,EAAQ,UAAA,EAAW,MAAK,OAAA,EAC7C,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,EAAA,EAAG,4BAAA,EAA6B,QAAA,EAAA,OAAA,EAAK,CAAA;AAAA,sBAEjD,IAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,OAAA;AAAA,UACN,OAAA,EAAQ,4BAAA;AAAA,UACR,OAAO,KAAA,IAAS,GAAA;AAAA,UAChB,QAAA,EAAU,oBAAA;AAAA,UAEV,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAO,GAAA,EAAe,QAAA,EAAA,WAAA,EAAA,EAAL,GAE3B,CAAA;AAAA,YAEC,eAAA,CAAgB,GAAA,CAAI,CAAC,IAAA,qBACpB,GAAA,CAAC,YAAS,KAAA,EAAO,IAAA,EACd,QAAA,EAAA,IAAA,EAAA,EADyB,IAE5B,CACD;AAAA;AAAA;AAAA;AACH,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationsFilters.esm.js","sources":["../../../src/components/NotificationsFilters/NotificationsFilters.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ChangeEvent } from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport Grid from '@material-ui/core/Grid';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { GetNotificationsOptions } from '../../api';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\n\nexport type SortBy = Required<\n Pick<GetNotificationsOptions, 'sort' | 'sortOrder'>\n>;\n\nexport type NotificationsFiltersProps = {\n unreadOnly?: boolean;\n onUnreadOnlyChanged: (checked: boolean | undefined) => void;\n createdAfter?: string;\n onCreatedAfterChanged: (value: string) => void;\n sorting: SortBy;\n onSortingChanged: (sortBy: SortBy) => void;\n saved?: boolean;\n onSavedChanged: (checked: boolean | undefined) => void;\n severity: NotificationSeverity;\n onSeverityChanged: (severity: NotificationSeverity) => void;\n topic?: string;\n onTopicChanged: (value: string | undefined) => void;\n allTopics?: string[];\n};\n\nconst ALL = '___all___';\n\nexport const CreatedAfterOptions: {\n [key: string]: { label: string; getDate: () => Date };\n} = {\n last24h: {\n label: 'Last 24h',\n getDate: () => new Date(Date.now() - 24 * 3600 * 1000),\n },\n lastWeek: {\n label: 'Last week',\n getDate: () => new Date(Date.now() - 7 * 24 * 3600 * 1000),\n },\n all: {\n label: 'Any time',\n getDate: () => new Date(0),\n },\n};\n\nexport const SortByOptions: {\n [key: string]: {\n label: string;\n sortBy: SortBy;\n };\n} = {\n newest: {\n label: 'Newest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'desc',\n },\n },\n oldest: {\n label: 'Oldest on top',\n sortBy: {\n sort: 'created',\n sortOrder: 'asc',\n },\n },\n topic: {\n label: 'Topic',\n sortBy: {\n sort: 'topic',\n sortOrder: 'asc',\n },\n },\n origin: {\n label: 'Origin',\n sortBy: {\n sort: 'origin',\n sortOrder: 'asc',\n },\n },\n};\n\nconst getSortByText = (sortBy?: SortBy): string => {\n if (sortBy?.sort === 'created' && sortBy?.sortOrder === 'asc') {\n return 'oldest';\n }\n if (sortBy?.sort === 'topic') {\n return 'topic';\n }\n if (sortBy?.sort === 'origin') {\n return 'origin';\n }\n\n return 'newest';\n};\n\nconst AllSeverityOptions: { [key in NotificationSeverity]: string } = {\n critical: 'Critical',\n high: 'High',\n normal: 'Normal',\n low: 'Low',\n};\n\nexport const NotificationsFilters = ({\n sorting,\n onSortingChanged,\n unreadOnly,\n onUnreadOnlyChanged,\n createdAfter,\n onCreatedAfterChanged,\n saved,\n onSavedChanged,\n severity,\n onSeverityChanged,\n topic,\n onTopicChanged,\n allTopics,\n}: NotificationsFiltersProps) => {\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnViewChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n if (event.target.value === 'unread') {\n onUnreadOnlyChanged(true);\n onSavedChanged(undefined);\n } else if (event.target.value === 'read') {\n onUnreadOnlyChanged(false);\n onSavedChanged(undefined);\n } else if (event.target.value === 'saved') {\n onUnreadOnlyChanged(undefined);\n onSavedChanged(true);\n } else {\n // All\n onUnreadOnlyChanged(undefined);\n onSavedChanged(undefined);\n }\n };\n\n const handleOnSortByChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const idx = (event.target.value as string) || 'newest';\n const option = SortByOptions[idx];\n onSortingChanged({ ...option.sortBy });\n };\n\n let viewValue = 'all';\n if (saved) {\n viewValue = 'saved';\n } else if (unreadOnly) {\n viewValue = 'unread';\n } else if (unreadOnly === false) {\n viewValue = 'read';\n }\n\n const handleOnSeverityChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value: NotificationSeverity =\n (event.target.value as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\n\n const handleOnTopicChanged = (\n event: ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value = event.target.value as string;\n onTopicChanged(value === ALL ? undefined : value);\n };\n\n const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));\n\n return (\n <>\n <Grid container>\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-view\">View</InputLabel>\n <Select\n labelId=\"notifications-filter-view\"\n label=\"View\"\n value={viewValue}\n onChange={handleOnViewChanged}\n >\n <MenuItem value=\"unread\">Unread notifications</MenuItem>\n <MenuItem value=\"read\">Read notifications</MenuItem>\n <MenuItem value=\"saved\">Saved</MenuItem>\n <MenuItem value=\"all\">All</MenuItem>\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-created\">Sent out</InputLabel>\n\n <Select\n label=\"Sent out\"\n labelId=\"notifications-filter-created\"\n placeholder=\"Notifications since\"\n value={createdAfter}\n onChange={handleOnCreatedAfterChanged}\n >\n {Object.keys(CreatedAfterOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {CreatedAfterOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-sort\">Sort by</InputLabel>\n\n <Select\n label=\"Sort by\"\n labelId=\"notifications-filter-sort\"\n placeholder=\"Field to sort by\"\n value={sortByText}\n onChange={handleOnSortByChanged}\n >\n {Object.keys(SortByOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {SortByOptions[key].label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-severity\">\n Min severity\n </InputLabel>\n\n <Select\n label=\"Min severity\"\n labelId=\"notifications-filter-severity\"\n value={severity}\n onChange={handleOnSeverityChanged}\n >\n {Object.keys(AllSeverityOptions).map((key: string) => (\n <MenuItem value={key} key={key}>\n {AllSeverityOptions[key as NotificationSeverity]}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-topic\">Topic</InputLabel>\n\n <Select\n label=\"Topic\"\n labelId=\"notifications-filter-topic\"\n value={topic ?? ALL}\n onChange={handleOnTopicChanged}\n >\n <MenuItem value={ALL} key={ALL}>\n Any topic\n </MenuItem>\n\n {sortedAllTopics.map((item: string) => (\n <MenuItem value={item} key={item}>\n {item}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA4CA,MAAM,GAAA,GAAM,WAAA;AAEL,MAAM,mBAAA,GAET;AAAA,EACF,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,UAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAA,EAAI,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GACvD;AAAA,EACA,QAAA,EAAU;AAAA,IACR,KAAA,EAAO,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,IAAA,CAAK,KAAI,GAAI,CAAA,GAAI,EAAA,GAAK,IAAA,GAAO,GAAI;AAAA,GAC3D;AAAA,EACA,GAAA,EAAK;AAAA,IACH,KAAA,EAAO,UAAA;AAAA,IACP,OAAA,EAAS,sBAAM,IAAI,IAAA,CAAK,CAAC;AAAA;AAE7B;AAEO,MAAM,aAAA,GAKT;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,13 +101,16 @@ const NotificationsPage = (props) => {
|
|
|
101
101
|
const totalCount = value?.[0]?.totalCount;
|
|
102
102
|
const isUnread = !!value?.[1]?.unread;
|
|
103
103
|
const allTopics = value?.[2]?.topics;
|
|
104
|
-
let tableTitle = `All notifications
|
|
104
|
+
let tableTitle = `All notifications `;
|
|
105
105
|
if (saved) {
|
|
106
|
-
tableTitle = `Saved notifications
|
|
106
|
+
tableTitle = `Saved notifications`;
|
|
107
107
|
} else if (unreadOnly === true) {
|
|
108
|
-
tableTitle = `Unread notifications
|
|
108
|
+
tableTitle = `Unread notifications`;
|
|
109
109
|
} else if (unreadOnly === false) {
|
|
110
|
-
tableTitle = `Read notifications
|
|
110
|
+
tableTitle = `Read notifications`;
|
|
111
|
+
}
|
|
112
|
+
if (totalCount) {
|
|
113
|
+
tableTitle += ` (${totalCount})`;
|
|
111
114
|
}
|
|
112
115
|
return /* @__PURE__ */ jsx(
|
|
113
116
|
PageWithHeader,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsPage.esm.js","sources":["../../../src/components/NotificationsPage/NotificationsPage.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport { ConfirmProvider } from 'material-ui-confirm';\nimport { useSignal } from '@backstage/plugin-signals-react';\n\nimport { NotificationsTable } from '../NotificationsTable';\nimport { useNotificationsApi } from '../../hooks';\nimport {\n CreatedAfterOptions,\n NotificationsFilters,\n SortBy,\n SortByOptions,\n} from '../NotificationsFilters';\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsResponse,\n} from '../../api';\nimport {\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\nconst ThrottleDelayMs = 2000;\n\n/** @public */\nexport type NotificationsPageProps = {\n /** Mark notification as read when opening the link it contains, defaults to false */\n markAsReadOnLinkOpen?: boolean;\n title?: string;\n themeId?: string;\n subtitle?: string;\n tooltip?: string;\n type?: string;\n typeLink?: string;\n};\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => {\n const {\n title = 'Notifications',\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n } = props ?? {};\n\n const [refresh, setRefresh] = useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = useState<boolean | undefined>(true);\n const [saved, setSaved] = useState<boolean | undefined>(undefined);\n const [pageNumber, setPageNumber] = useState(0);\n const [pageSize, setPageSize] = useState(5);\n const [containsText, setContainsText] = useState<string>();\n const [createdAfter, setCreatedAfter] = useState<string>('all');\n const [sorting, setSorting] = useState<SortBy>(SortByOptions.newest.sortBy);\n const [severity, setSeverity] = useState<NotificationSeverity>('low');\n const [topic, setTopic] = useState<string>();\n\n const { error, value, retry, loading } = useNotificationsApi<\n [GetNotificationsResponse, NotificationStatus, GetTopicsResponse]\n >(\n api => {\n const options: GetNotificationsOptions = {\n search: containsText,\n limit: pageSize,\n offset: pageNumber * pageSize,\n minimumSeverity: severity,\n ...(sorting || {}),\n };\n if (unreadOnly !== undefined) {\n options.read = !unreadOnly;\n }\n if (saved !== undefined) {\n options.saved = saved;\n }\n if (topic !== undefined) {\n options.topic = topic;\n }\n\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return Promise.all([\n api.getNotifications(options),\n api.getStatus(),\n api.getTopics(options),\n ]);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n topic,\n ],\n );\n\n const throttledSetRefresh = useMemo(\n () => throttle(setRefresh, ThrottleDelayMs),\n [setRefresh],\n );\n\n useEffect(() => {\n if (refresh && !loading) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry, loading]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n throttledSetRefresh(true);\n }\n }, [lastSignal, throttledSetRefresh]);\n\n const onUpdate = () => {\n throttledSetRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const notifications = value?.[0]?.notifications;\n const totalCount = value?.[0]?.totalCount;\n const isUnread = !!value?.[1]?.unread;\n const allTopics = value?.[2]?.topics;\n\n let tableTitle = `All notifications (${totalCount})`;\n if (saved) {\n tableTitle = `Saved notifications (${totalCount})`;\n } else if (unreadOnly === true) {\n tableTitle = `Unread notifications (${totalCount})`;\n } else if (unreadOnly === false) {\n tableTitle = `Read notifications (${totalCount})`;\n }\n\n return (\n <PageWithHeader\n title={title}\n themeId={themeId}\n tooltip={tooltip}\n subtitle={subtitle}\n type={type}\n typeLink={typeLink}\n >\n <Content>\n <ConfirmProvider>\n <Grid container>\n <Grid item xs={2}>\n <NotificationsFilters\n unreadOnly={unreadOnly}\n onUnreadOnlyChanged={setUnreadOnly}\n createdAfter={createdAfter}\n onCreatedAfterChanged={setCreatedAfter}\n onSortingChanged={setSorting}\n sorting={sorting}\n saved={saved}\n onSavedChanged={setSaved}\n severity={severity}\n onSeverityChanged={setSeverity}\n topic={topic}\n onTopicChanged={setTopic}\n allTopics={allTopics}\n />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n title={tableTitle}\n isLoading={loading}\n isUnread={isUnread}\n markAsReadOnLinkOpen={markAsReadOnLinkOpen}\n notifications={notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={totalCount}\n />\n </Grid>\n </Grid>\n </ConfirmProvider>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,eAAA,GAAkB,GAAA;AAcjB,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAmC;AACnE,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,eAAA;AAAA,IACR,OAAA,GAAU,MAAA;AAAA,IACV,QAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,SAAS,EAAC;AAEd,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,EAAE,UAAA,EAAW,GAAI,SAAA,CAAU,eAAe,CAAA;AAChD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAA8B,IAAI,CAAA;AACtE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAA8B,MAAS,CAAA;AACjE,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,CAAC,CAAA;AAC9C,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,CAAC,CAAA;AAC1C,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAA,EAAiB;AACzD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAiB,KAAK,CAAA;AAC9D,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,IAAI,QAAA,CAAiB,aAAA,CAAc,OAAO,MAAM,CAAA;AAC1E,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAA+B,KAAK,CAAA;AACpE,EAAA,MAAM,CAAC,KAA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,UAAA;AAAA,YACN,QAAA;AAAA,YACA;AAAA;AAAA,SACF,EACF;AAAA,OAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationsPage.esm.js","sources":["../../../src/components/NotificationsPage/NotificationsPage.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useState } from 'react';\nimport throttle from 'lodash/throttle';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport { ConfirmProvider } from 'material-ui-confirm';\nimport { useSignal } from '@backstage/plugin-signals-react';\n\nimport { NotificationsTable } from '../NotificationsTable';\nimport { useNotificationsApi } from '../../hooks';\nimport {\n CreatedAfterOptions,\n NotificationsFilters,\n SortBy,\n SortByOptions,\n} from '../NotificationsFilters';\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsResponse,\n} from '../../api';\nimport {\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\nconst ThrottleDelayMs = 2000;\n\n/** @public */\nexport type NotificationsPageProps = {\n /** Mark notification as read when opening the link it contains, defaults to false */\n markAsReadOnLinkOpen?: boolean;\n title?: string;\n themeId?: string;\n subtitle?: string;\n tooltip?: string;\n type?: string;\n typeLink?: string;\n};\n\nexport const NotificationsPage = (props?: NotificationsPageProps) => {\n const {\n title = 'Notifications',\n themeId = 'tool',\n subtitle,\n tooltip,\n type,\n typeLink,\n markAsReadOnLinkOpen,\n } = props ?? {};\n\n const [refresh, setRefresh] = useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = useState<boolean | undefined>(true);\n const [saved, setSaved] = useState<boolean | undefined>(undefined);\n const [pageNumber, setPageNumber] = useState(0);\n const [pageSize, setPageSize] = useState(5);\n const [containsText, setContainsText] = useState<string>();\n const [createdAfter, setCreatedAfter] = useState<string>('all');\n const [sorting, setSorting] = useState<SortBy>(SortByOptions.newest.sortBy);\n const [severity, setSeverity] = useState<NotificationSeverity>('low');\n const [topic, setTopic] = useState<string>();\n\n const { error, value, retry, loading } = useNotificationsApi<\n [GetNotificationsResponse, NotificationStatus, GetTopicsResponse]\n >(\n api => {\n const options: GetNotificationsOptions = {\n search: containsText,\n limit: pageSize,\n offset: pageNumber * pageSize,\n minimumSeverity: severity,\n ...(sorting || {}),\n };\n if (unreadOnly !== undefined) {\n options.read = !unreadOnly;\n }\n if (saved !== undefined) {\n options.saved = saved;\n }\n if (topic !== undefined) {\n options.topic = topic;\n }\n\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return Promise.all([\n api.getNotifications(options),\n api.getStatus(),\n api.getTopics(options),\n ]);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n topic,\n ],\n );\n\n const throttledSetRefresh = useMemo(\n () => throttle(setRefresh, ThrottleDelayMs),\n [setRefresh],\n );\n\n useEffect(() => {\n if (refresh && !loading) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry, loading]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n throttledSetRefresh(true);\n }\n }, [lastSignal, throttledSetRefresh]);\n\n const onUpdate = () => {\n throttledSetRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n const notifications = value?.[0]?.notifications;\n const totalCount = value?.[0]?.totalCount;\n const isUnread = !!value?.[1]?.unread;\n const allTopics = value?.[2]?.topics;\n\n let tableTitle = `All notifications `;\n if (saved) {\n tableTitle = `Saved notifications`;\n } else if (unreadOnly === true) {\n tableTitle = `Unread notifications`;\n } else if (unreadOnly === false) {\n tableTitle = `Read notifications`;\n }\n\n if (totalCount) {\n tableTitle += ` (${totalCount})`;\n }\n\n return (\n <PageWithHeader\n title={title}\n themeId={themeId}\n tooltip={tooltip}\n subtitle={subtitle}\n type={type}\n typeLink={typeLink}\n >\n <Content>\n <ConfirmProvider>\n <Grid container>\n <Grid item xs={2}>\n <NotificationsFilters\n unreadOnly={unreadOnly}\n onUnreadOnlyChanged={setUnreadOnly}\n createdAfter={createdAfter}\n onCreatedAfterChanged={setCreatedAfter}\n onSortingChanged={setSorting}\n sorting={sorting}\n saved={saved}\n onSavedChanged={setSaved}\n severity={severity}\n onSeverityChanged={setSeverity}\n topic={topic}\n onTopicChanged={setTopic}\n allTopics={allTopics}\n />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n title={tableTitle}\n isLoading={loading}\n isUnread={isUnread}\n markAsReadOnLinkOpen={markAsReadOnLinkOpen}\n notifications={notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={totalCount}\n />\n </Grid>\n </Grid>\n </ConfirmProvider>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,eAAA,GAAkB,GAAA;AAcjB,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAmC;AACnE,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,eAAA;AAAA,IACR,OAAA,GAAU,MAAA;AAAA,IACV,QAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,SAAS,EAAC;AAEd,EAAA,MAAM,CAAC,OAAA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AI,IAAA,EAAC,EAAA,EAAI,CAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,oBAAA;AAAA,UAAA;AAAA,YACC,UAAA;AAAA,YACA,mBAAA,EAAqB,aAAA;AAAA,YACrB,YAAA;AAAA,YACA,qBAAA,EAAuB,eAAA;AAAA,YACvB,gBAAA,EAAkB,UAAA;AAAA,YAClB,OAAA;AAAA,YACA,KAAA;AAAA,YACA,cAAA,EAAgB,QAAA;AAAA,YAChB,QAAA;AAAA,YACA,iBAAA,EAAmB,WAAA;AAAA,YACnB,KAAA;AAAA,YACA,cAAA,EAAgB,QAAA;AAAA,YAChB;AAAA;AAAA,SACF,EACF,CAAA;AAAA,wBACA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,kBAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,UAAA;AAAA,YACP,SAAA,EAAW,OAAA;AAAA,YACX,QAAA;AAAA,YACA,oBAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YACA,eAAA;AAAA,YACA,YAAA,EAAc,aAAA;AAAA,YACd,mBAAA,EAAqB,WAAA;AAAA,YACrB,IAAA,EAAM,UAAA;AAAA,YACN,QAAA;AAAA,YACA;AAAA;AAAA,SACF,EACF;AAAA,OAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import Typography from '@material-ui/core/Typography';
|
|
3
|
+
import Button from '@material-ui/core/Button';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const MAX_LENGTH = 100;
|
|
7
|
+
const NotificationDescription = (props) => {
|
|
8
|
+
const { description } = props;
|
|
9
|
+
const [shown, setShown] = useState(false);
|
|
10
|
+
const isLong = description.length > MAX_LENGTH;
|
|
11
|
+
if (!isLong) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "body2", children: description });
|
|
13
|
+
}
|
|
14
|
+
if (shown) {
|
|
15
|
+
return /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
|
|
16
|
+
description,
|
|
17
|
+
" ",
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
Button,
|
|
20
|
+
{
|
|
21
|
+
variant: "text",
|
|
22
|
+
size: "small",
|
|
23
|
+
onClick: () => {
|
|
24
|
+
setShown(false);
|
|
25
|
+
},
|
|
26
|
+
children: "Show less"
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
|
|
32
|
+
description.substring(0, MAX_LENGTH),
|
|
33
|
+
"...",
|
|
34
|
+
" ",
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Button,
|
|
37
|
+
{
|
|
38
|
+
variant: "text",
|
|
39
|
+
size: "small",
|
|
40
|
+
onClick: () => {
|
|
41
|
+
setShown(true);
|
|
42
|
+
},
|
|
43
|
+
children: "Show more"
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { NotificationDescription };
|
|
50
|
+
//# sourceMappingURL=NotificationDescription.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationDescription.esm.js","sources":["../../../src/components/NotificationsTable/NotificationDescription.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Typography from '@material-ui/core/Typography';\nimport Button from '@material-ui/core/Button';\nimport { useState } from 'react';\n\nconst MAX_LENGTH = 100;\n\nexport const NotificationDescription = (props: { description: string }) => {\n const { description } = props;\n const [shown, setShown] = useState(false);\n const isLong = description.length > MAX_LENGTH;\n\n if (!isLong) {\n return <Typography variant=\"body2\">{description}</Typography>;\n }\n\n if (shown) {\n return (\n <Typography variant=\"body2\">\n {description}{' '}\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={() => {\n setShown(false);\n }}\n >\n Show less\n </Button>\n </Typography>\n );\n }\n return (\n <Typography variant=\"body2\">\n {description.substring(0, MAX_LENGTH)}...{' '}\n <Button\n variant=\"text\"\n size=\"small\"\n onClick={() => {\n setShown(true);\n }}\n >\n Show more\n </Button>\n </Typography>\n );\n};\n"],"names":[],"mappings":";;;;;AAmBA,MAAM,UAAA,GAAa,GAAA;AAEZ,MAAM,uBAAA,GAA0B,CAAC,KAAA,KAAmC;AACzE,EAAA,MAAM,EAAE,aAAY,GAAI,KAAA;AACxB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA;AACxC,EAAA,MAAM,MAAA,GAAS,YAAY,MAAA,GAAS,UAAA;AAEpC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,uBAAO,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAAS,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,EAClD;AAEA,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,uBACE,IAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EACjB,QAAA,EAAA;AAAA,MAAA,WAAA;AAAA,MAAa,GAAA;AAAA,sBACd,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAA,EAAQ,MAAA;AAAA,UACR,IAAA,EAAK,OAAA;AAAA,UACL,SAAS,MAAM;AACb,YAAA,QAAA,CAAS,KAAK,CAAA;AAAA,UAChB,CAAA;AAAA,UACD,QAAA,EAAA;AAAA;AAAA;AAED,KAAA,EACF,CAAA;AAAA,EAEJ;AACA,EAAA,uBACE,IAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EACjB,QAAA,EAAA;AAAA,IAAA,WAAA,CAAY,SAAA,CAAU,GAAG,UAAU,CAAA;AAAA,IAAE,KAAA;AAAA,IAAI,GAAA;AAAA,oBAC1C,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAQ,MAAA;AAAA,QACR,IAAA,EAAK,OAAA;AAAA,QACL,SAAS,MAAM;AACb,UAAA,QAAA,CAAS,IAAI,CAAA;AAAA,QACf,CAAA;AAAA,QACD,QAAA,EAAA;AAAA;AAAA;AAED,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -16,13 +16,10 @@ import '@backstage/errors';
|
|
|
16
16
|
import { SelectAll } from './SelectAll.esm.js';
|
|
17
17
|
import { BulkActions } from './BulkActions.esm.js';
|
|
18
18
|
import { NotificationIcon } from './NotificationIcon.esm.js';
|
|
19
|
+
import { NotificationDescription } from './NotificationDescription.esm.js';
|
|
19
20
|
|
|
20
21
|
const ThrottleDelayMs = 1e3;
|
|
21
22
|
const useStyles = makeStyles((theme) => ({
|
|
22
|
-
description: {
|
|
23
|
-
maxHeight: "5rem",
|
|
24
|
-
overflow: "auto"
|
|
25
|
-
},
|
|
26
23
|
severityItem: {
|
|
27
24
|
alignContent: "center"
|
|
28
25
|
},
|
|
@@ -31,8 +28,10 @@ const useStyles = makeStyles((theme) => ({
|
|
|
31
28
|
verticalAlign: "text-bottom"
|
|
32
29
|
},
|
|
33
30
|
notificationInfoRow: {
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
marginRight: theme.spacing(0.5),
|
|
32
|
+
"&:not(:first-child)": {
|
|
33
|
+
marginLeft: theme.spacing(0.5)
|
|
34
|
+
}
|
|
36
35
|
}
|
|
37
36
|
}));
|
|
38
37
|
const NotificationsTable = ({
|
|
@@ -171,7 +170,12 @@ const NotificationsTable = ({
|
|
|
171
170
|
children: notification.payload.title
|
|
172
171
|
}
|
|
173
172
|
) : notification.payload.title }),
|
|
174
|
-
notification.payload.description ? /* @__PURE__ */ jsx(
|
|
173
|
+
notification.payload.description ? /* @__PURE__ */ jsx(
|
|
174
|
+
NotificationDescription,
|
|
175
|
+
{
|
|
176
|
+
description: notification.payload.description
|
|
177
|
+
}
|
|
178
|
+
) : null,
|
|
175
179
|
/* @__PURE__ */ jsxs(Typography, { variant: "caption", children: [
|
|
176
180
|
!notification.user && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(BroadcastIcon, { className: classes.broadcastIcon }) }),
|
|
177
181
|
notification.origin && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -242,7 +246,6 @@ const NotificationsTable = ({
|
|
|
242
246
|
onMarkAllRead,
|
|
243
247
|
onNotificationsSelectChange,
|
|
244
248
|
classes.severityItem,
|
|
245
|
-
classes.description,
|
|
246
249
|
classes.broadcastIcon,
|
|
247
250
|
classes.notificationInfoRow,
|
|
248
251
|
markAsReadOnLinkOpen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsTable.esm.js","sources":["../../../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useCallback, useMemo, useEffect } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport CheckBox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { useConfirm } from 'material-ui-confirm';\nimport BroadcastIcon from '@material-ui/icons/RssFeed';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n Link,\n Table,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\n\nimport { notificationsApiRef } from '../../api';\nimport { SelectAll } from './SelectAll';\nimport { BulkActions } from './BulkActions';\nimport { NotificationIcon } from './NotificationIcon';\n\nconst ThrottleDelayMs = 1000;\n\nconst useStyles = makeStyles(theme => ({\n description: {\n maxHeight: '5rem',\n overflow: 'auto',\n },\n severityItem: {\n alignContent: 'center',\n },\n broadcastIcon: {\n fontSize: '1rem',\n verticalAlign: 'text-bottom',\n },\n notificationInfoRow: {\n marginLeft: theme.spacing(0.5),\n marginRight: theme.spacing(0.5),\n },\n}));\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'\n> & {\n markAsReadOnLinkOpen?: boolean;\n isLoading?: boolean;\n isUnread: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n title,\n markAsReadOnLinkOpen,\n isLoading,\n notifications = [],\n isUnread,\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const classes = useStyles();\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const confirm = useConfirm();\n\n const [selectedNotifications, setSelectedNotifications] = useState(\n new Set<Notification['id']>(),\n );\n\n const onNotificationsSelectChange = useCallback(\n (ids: Notification['id'][], checked: boolean) => {\n let newSelect: Set<Notification['id']>;\n if (checked) {\n newSelect = new Set([...selectedNotifications, ...ids]);\n } else {\n newSelect = new Set(selectedNotifications);\n ids.forEach(id => newSelect.delete(id));\n }\n setSelectedNotifications(newSelect);\n },\n [selectedNotifications, setSelectedNotifications],\n );\n\n const onSwitchReadStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n read: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onSwitchSavedStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n saved: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onMarkAllRead = useCallback(() => {\n confirm({\n title: 'Are you sure?',\n description: (\n <>\n Mark <b>all</b> notifications as <b>read</b>.\n </>\n ),\n confirmationText: 'Mark All',\n })\n .then(async () => {\n const ids = (\n await notificationsApi.getNotifications({ read: false })\n ).notifications?.map(notification => notification.id);\n\n return notificationsApi\n .updateNotifications({\n ids,\n read: true,\n })\n .then(onUpdate);\n })\n .catch(e => {\n if (e) {\n // if e === undefined, the Cancel button has been hit\n alertApi.post({\n message: 'Failed to mark all notifications as read',\n severity: 'error',\n });\n }\n });\n }, [alertApi, confirm, notificationsApi, onUpdate]);\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n useEffect(() => {\n const allShownIds = new Set(notifications.map(n => n.id));\n const intersect = [...selectedNotifications].filter(id =>\n allShownIds.has(id),\n );\n if (selectedNotifications.size !== intersect.length) {\n setSelectedNotifications(new Set(intersect));\n }\n }, [notifications, selectedNotifications]);\n\n const compactColumns = useMemo((): TableColumn<Notification>[] => {\n const showToolbar = notifications.length > 0;\n return [\n {\n /* selection column */\n width: '1rem',\n title: showToolbar ? (\n <SelectAll\n count={selectedNotifications.size}\n totalCount={notifications.length}\n onSelectAll={() =>\n onNotificationsSelectChange(\n notifications.map(notification => notification.id),\n selectedNotifications.size !== notifications.length,\n )\n }\n />\n ) : undefined,\n render: (notification: Notification) => (\n <CheckBox\n color=\"primary\"\n checked={selectedNotifications.has(notification.id)}\n onChange={(_, checked) =>\n onNotificationsSelectChange([notification.id], checked)\n }\n />\n ),\n },\n {\n /* compact-data column */\n customFilterAndSearch: () =>\n true /* Keep sorting&filtering on backend due to pagination. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <Grid container>\n <Grid item className={classes.severityItem}>\n <NotificationIcon notification={notification} />\n </Grid>\n <Grid item xs={11}>\n <Box>\n <Typography variant=\"subtitle1\">\n {notification.payload.link ? (\n <Link\n to={notification.payload.link}\n onClick={() => {\n if (markAsReadOnLinkOpen && !notification.read) {\n onSwitchReadStatus([notification.id], true);\n }\n }}\n >\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n {notification.payload.description ? (\n <Typography variant=\"body2\" className={classes.description}>\n {notification.payload.description}\n </Typography>\n ) : null}\n\n <Typography variant=\"caption\">\n {!notification.user && (\n <>\n <BroadcastIcon className={classes.broadcastIcon} />\n </>\n )}\n {notification.origin && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.origin}\n </Typography>\n •\n </>\n )}\n {notification.payload.topic && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.payload.topic}\n </Typography>\n •\n </>\n )}\n {notification.created && (\n <RelativeTime\n value={notification.created}\n className={classes.notificationInfoRow}\n />\n )}\n </Typography>\n </Box>\n </Grid>\n </Grid>\n );\n },\n },\n {\n /* actions column */\n width: '1rem',\n title: showToolbar ? (\n <BulkActions\n notifications={notifications}\n selectedNotifications={selectedNotifications}\n isUnread={isUnread}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n onMarkAllRead={onMarkAllRead}\n />\n ) : undefined,\n render: (notification: Notification) => (\n <BulkActions\n notifications={[notification]}\n selectedNotifications={new Set([notification.id])}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n />\n ),\n },\n ];\n }, [\n notifications,\n selectedNotifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n onNotificationsSelectChange,\n classes.severityItem,\n classes.description,\n classes.broadcastIcon,\n classes.notificationInfoRow,\n markAsReadOnLinkOpen,\n ]);\n\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n padding: 'dense',\n search: true,\n paging: true,\n pageSize,\n header: true,\n sorting: false,\n }}\n title={title}\n onPageChange={onPageChange}\n onRowsPerPageChange={onRowsPerPageChange}\n page={page}\n totalCount={totalCount}\n onSearchChange={throttledContainsTextHandler}\n data={notifications}\n columns={compactColumns}\n />\n );\n};\n"],"names":["CheckBox"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,eAAA,GAAkB,GAAA;AAExB,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,WAAA,EAAa;AAAA,IACX,SAAA,EAAW,MAAA;AAAA,IACX,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,aAAA,EAAe;AAAA,IACb,QAAA,EAAU,MAAA;AAAA,IACV,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,mBAAA,EAAqB;AAAA,IACnB,UAAA,EAAY,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AAAA,IAC7B,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,GAAG;AAAA;AAElC,CAAA,CAAE,CAAA;AAiBK,MAAM,qBAAqB,CAAC;AAAA,EACjC,KAAA;AAAA,EACA,oBAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAgB,EAAC;AAAA,EACjB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,mB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A,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,aAAA;AAAA,YACA,qBAAA;AAAA,YACA,QAAA;AAAA,YACA,kBAAA;AAAA,YACA,mBAAA;AAAA,YACA;AAAA;AAAA,SACF,GACE,MAAA;AAAA,QACJ,MAAA,EAAQ,CAAC,YAAA,qBACP,GAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,aAAA,EAAe,CAAC,YAAY,CAAA;AAAA,YAC5B,uCAAuB,IAAI,GAAA,CAAI,CAAC,YAAA,CAAa,EAAE,CAAC,CAAA;AAAA,YAChD,kBAAA;AAAA,YACA;AAAA;AAAA;AACF;AAEJ,KACF;AAAA,EACF,CAAA,EAAG;AAAA,IACD,aAAA;AAAA,IACA,qBAAA;AAAA,IACA,QAAA;AAAA,IACA,kBAAA;AAAA,IACA,mBAAA;AAAA,IACA,aAAA;AAAA,IACA,2BAAA;AAAA,IACA,OAAA,CAAQ,YAAA;AAAA,IACR,OAAA,CAAQ,WAAA;AAAA,IACR,OAAA,CAAQ,aAAA;AAAA,IACR,OAAA,CAAQ,mBAAA;AAAA,IACR;AAAA,GACD,CAAA;AAED,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,OAAA;AAAA,QACT,MAAA,EAAQ,IAAA;AAAA,QACR,MAAA,EAAQ,IAAA;AAAA,QACR,QAAA;AAAA,QACA,MAAA,EAAQ,IAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACX;AAAA,MACA,KAAA;AAAA,MACA,YAAA;AAAA,MACA,mBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAA,EAAgB,4BAAA;AAAA,MAChB,IAAA,EAAM,aAAA;AAAA,MACN,OAAA,EAAS;AAAA;AAAA,GACX;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"NotificationsTable.esm.js","sources":["../../../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport Box from '@material-ui/core/Box';\nimport Grid from '@material-ui/core/Grid';\nimport CheckBox from '@material-ui/core/Checkbox';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Notification } from '@backstage/plugin-notifications-common';\nimport { useConfirm } from 'material-ui-confirm';\nimport BroadcastIcon from '@material-ui/icons/RssFeed';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n Link,\n Table,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\n\nimport { notificationsApiRef } from '../../api';\nimport { SelectAll } from './SelectAll';\nimport { BulkActions } from './BulkActions';\nimport { NotificationIcon } from './NotificationIcon';\nimport { NotificationDescription } from './NotificationDescription';\n\nconst ThrottleDelayMs = 1000;\n\nconst useStyles = makeStyles(theme => ({\n severityItem: {\n alignContent: 'center',\n },\n broadcastIcon: {\n fontSize: '1rem',\n verticalAlign: 'text-bottom',\n },\n notificationInfoRow: {\n marginRight: theme.spacing(0.5),\n '&:not(:first-child)': {\n marginLeft: theme.spacing(0.5),\n },\n },\n}));\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'\n> & {\n markAsReadOnLinkOpen?: boolean;\n isLoading?: boolean;\n isUnread: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n title,\n markAsReadOnLinkOpen,\n isLoading,\n notifications = [],\n isUnread,\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const classes = useStyles();\n const notificationsApi = useApi(notificationsApiRef);\n const alertApi = useApi(alertApiRef);\n const confirm = useConfirm();\n\n const [selectedNotifications, setSelectedNotifications] = useState(\n new Set<Notification['id']>(),\n );\n\n const onNotificationsSelectChange = useCallback(\n (ids: Notification['id'][], checked: boolean) => {\n let newSelect: Set<Notification['id']>;\n if (checked) {\n newSelect = new Set([...selectedNotifications, ...ids]);\n } else {\n newSelect = new Set(selectedNotifications);\n ids.forEach(id => newSelect.delete(id));\n }\n setSelectedNotifications(newSelect);\n },\n [selectedNotifications, setSelectedNotifications],\n );\n\n const onSwitchReadStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n read: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onSwitchSavedStatus = useCallback(\n (ids: Notification['id'][], newStatus: boolean) => {\n notificationsApi\n .updateNotifications({\n ids,\n saved: newStatus,\n })\n .then(onUpdate);\n },\n [notificationsApi, onUpdate],\n );\n\n const onMarkAllRead = useCallback(() => {\n confirm({\n title: 'Are you sure?',\n description: (\n <>\n Mark <b>all</b> notifications as <b>read</b>.\n </>\n ),\n confirmationText: 'Mark All',\n })\n .then(async () => {\n const ids = (\n await notificationsApi.getNotifications({ read: false })\n ).notifications?.map(notification => notification.id);\n\n return notificationsApi\n .updateNotifications({\n ids,\n read: true,\n })\n .then(onUpdate);\n })\n .catch(e => {\n if (e) {\n // if e === undefined, the Cancel button has been hit\n alertApi.post({\n message: 'Failed to mark all notifications as read',\n severity: 'error',\n });\n }\n });\n }, [alertApi, confirm, notificationsApi, onUpdate]);\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n useEffect(() => {\n const allShownIds = new Set(notifications.map(n => n.id));\n const intersect = [...selectedNotifications].filter(id =>\n allShownIds.has(id),\n );\n if (selectedNotifications.size !== intersect.length) {\n setSelectedNotifications(new Set(intersect));\n }\n }, [notifications, selectedNotifications]);\n\n const compactColumns = useMemo((): TableColumn<Notification>[] => {\n const showToolbar = notifications.length > 0;\n return [\n {\n /* selection column */\n width: '1rem',\n title: showToolbar ? (\n <SelectAll\n count={selectedNotifications.size}\n totalCount={notifications.length}\n onSelectAll={() =>\n onNotificationsSelectChange(\n notifications.map(notification => notification.id),\n selectedNotifications.size !== notifications.length,\n )\n }\n />\n ) : undefined,\n render: (notification: Notification) => (\n <CheckBox\n color=\"primary\"\n checked={selectedNotifications.has(notification.id)}\n onChange={(_, checked) =>\n onNotificationsSelectChange([notification.id], checked)\n }\n />\n ),\n },\n {\n /* compact-data column */\n customFilterAndSearch: () =>\n true /* Keep sorting&filtering on backend due to pagination. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <Grid container>\n <Grid item className={classes.severityItem}>\n <NotificationIcon notification={notification} />\n </Grid>\n <Grid item xs={11}>\n <Box>\n <Typography variant=\"subtitle1\">\n {notification.payload.link ? (\n <Link\n to={notification.payload.link}\n onClick={() => {\n if (markAsReadOnLinkOpen && !notification.read) {\n onSwitchReadStatus([notification.id], true);\n }\n }}\n >\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n {notification.payload.description ? (\n <NotificationDescription\n description={notification.payload.description}\n />\n ) : null}\n\n <Typography variant=\"caption\">\n {!notification.user && (\n <>\n <BroadcastIcon className={classes.broadcastIcon} />\n </>\n )}\n {notification.origin && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.origin}\n </Typography>\n •\n </>\n )}\n {notification.payload.topic && (\n <>\n <Typography\n variant=\"inherit\"\n className={classes.notificationInfoRow}\n >\n {notification.payload.topic}\n </Typography>\n •\n </>\n )}\n {notification.created && (\n <RelativeTime\n value={notification.created}\n className={classes.notificationInfoRow}\n />\n )}\n </Typography>\n </Box>\n </Grid>\n </Grid>\n );\n },\n },\n {\n /* actions column */\n width: '1rem',\n title: showToolbar ? (\n <BulkActions\n notifications={notifications}\n selectedNotifications={selectedNotifications}\n isUnread={isUnread}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n onMarkAllRead={onMarkAllRead}\n />\n ) : undefined,\n render: (notification: Notification) => (\n <BulkActions\n notifications={[notification]}\n selectedNotifications={new Set([notification.id])}\n onSwitchReadStatus={onSwitchReadStatus}\n onSwitchSavedStatus={onSwitchSavedStatus}\n />\n ),\n },\n ];\n }, [\n notifications,\n selectedNotifications,\n isUnread,\n onSwitchReadStatus,\n onSwitchSavedStatus,\n onMarkAllRead,\n onNotificationsSelectChange,\n classes.severityItem,\n classes.broadcastIcon,\n classes.notificationInfoRow,\n markAsReadOnLinkOpen,\n ]);\n\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n padding: 'dense',\n search: true,\n paging: true,\n pageSize,\n header: true,\n sorting: false,\n }}\n title={title}\n onPageChange={onPageChange}\n onRowsPerPageChange={onRowsPerPageChange}\n page={page}\n totalCount={totalCount}\n onSearchChange={throttledContainsTextHandler}\n data={notifications}\n columns={compactColumns}\n />\n );\n};\n"],"names":["CheckBox"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,eAAA,GAAkB,GAAA;AAExB,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,YAAA,EAAc;AAAA,IACZ,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,aAAA,EAAe;AAAA,IACb,QAAA,EAAU,MAAA;AAAA,IACV,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,mBAAA,EAAqB;AAAA,IACnB,WAAA,EAAa,KAAA,CAAM,OAAA,C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AA,MACA,YAAA;AAAA,MACA,mBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAA,EAAgB,4BAAA;AAAA,MAChB,IAAA,EAAM,aAAA;AAAA,MACN,OAAA,EAAS;AAAA;AAAA,GACX;AAEJ;;;;"}
|
|
@@ -2,13 +2,15 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import Checkbox from '@material-ui/core/Checkbox';
|
|
3
3
|
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
4
4
|
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
import Tooltip from '@material-ui/core/Tooltip';
|
|
5
6
|
|
|
6
7
|
const useStyles = makeStyles({
|
|
7
8
|
label: {
|
|
8
9
|
marginLeft: "0px",
|
|
9
10
|
maxWidth: "2rem",
|
|
10
11
|
"& span": {
|
|
11
|
-
paddingRight: "0px"
|
|
12
|
+
paddingRight: "0px",
|
|
13
|
+
marginRight: "2px"
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
});
|
|
@@ -23,7 +25,7 @@ const SelectAll = ({
|
|
|
23
25
|
{
|
|
24
26
|
label: count > 0 ? `(${count})` : void 0,
|
|
25
27
|
className: classes.label,
|
|
26
|
-
control: /* @__PURE__ */ jsx(
|
|
28
|
+
control: /* @__PURE__ */ jsx(Tooltip, { title: "Select all", children: /* @__PURE__ */ jsx(
|
|
27
29
|
Checkbox,
|
|
28
30
|
{
|
|
29
31
|
color: "primary",
|
|
@@ -32,7 +34,7 @@ const SelectAll = ({
|
|
|
32
34
|
indeterminate: count > 0 && totalCount !== count,
|
|
33
35
|
onChange: onSelectAll
|
|
34
36
|
}
|
|
35
|
-
)
|
|
37
|
+
) })
|
|
36
38
|
}
|
|
37
39
|
);
|
|
38
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectAll.esm.js","sources":["../../../src/components/NotificationsTable/SelectAll.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles({\n label: {\n marginLeft: '0px',\n maxWidth: '2rem',\n '& span': {\n paddingRight: '0px',\n },\n },\n});\n\nexport const SelectAll = ({\n count,\n totalCount,\n onSelectAll,\n}: {\n count: number;\n totalCount: number;\n onSelectAll: () => void;\n}) => {\n const classes = useStyles();\n\n return (\n <FormControlLabel\n label={count > 0 ? `(${count})` : undefined}\n className={classes.label}\n control={\n <Checkbox\n
|
|
1
|
+
{"version":3,"file":"SelectAll.esm.js","sources":["../../../src/components/NotificationsTable/SelectAll.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nconst useStyles = makeStyles({\n label: {\n marginLeft: '0px',\n maxWidth: '2rem',\n '& span': {\n paddingRight: '0px',\n marginRight: '2px',\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 <Tooltip title=\"Select all\">\n <Checkbox\n color=\"primary\"\n disabled={!totalCount}\n checked={count > 0}\n indeterminate={count > 0 && totalCount !== count}\n onChange={onSelectAll}\n />\n </Tooltip>\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAoBA,MAAM,YAAY,UAAA,CAAW;AAAA,EAC3B,KAAA,EAAO;AAAA,IACL,UAAA,EAAY,KAAA;AAAA,IACZ,QAAA,EAAU,MAAA;AAAA,IACV,QAAA,EAAU;AAAA,MACR,YAAA,EAAc,KAAA;AAAA,MACd,WAAA,EAAa;AAAA;AACf;AAEJ,CAAC,CAAA;AAEM,MAAM,YAAY,CAAC;AAAA,EACxB,KAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAIM;AACJ,EAAA,MAAM,UAAU,SAAA,EAAU;AAE1B,EAAA,uBACE,GAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,KAAA,GAAQ,CAAA,GAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,CAAA,GAAM,MAAA;AAAA,MAClC,WAAW,OAAA,CAAQ,KAAA;AAAA,MACnB,OAAA,kBACE,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAM,YAAA,EACb,QAAA,kBAAA,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAM,SAAA;AAAA,UACN,UAAU,CAAC,UAAA;AAAA,UACX,SAAS,KAAA,GAAQ,CAAA;AAAA,UACjB,aAAA,EAAe,KAAA,GAAQ,CAAA,IAAK,UAAA,KAAe,KAAA;AAAA,UAC3C,QAAA,EAAU;AAAA;AAAA,OACZ,EACF;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,80 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
|
-
import { DiscoveryApi, FetchApi
|
|
4
|
+
import { IconComponent, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
|
|
4
5
|
import { NotificationSeverity, Notification, NotificationStatus, NotificationSettings } from '@backstage/plugin-notifications-common';
|
|
5
|
-
import * as
|
|
6
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
6
7
|
import { TableProps } from '@backstage/core-components';
|
|
7
8
|
|
|
9
|
+
declare module 'notistack' {
|
|
10
|
+
interface VariantOverrides {
|
|
11
|
+
low: true;
|
|
12
|
+
normal: true;
|
|
13
|
+
high: true;
|
|
14
|
+
critical: true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
type NotificationSnackbarProperties = {
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
autoHideDuration?: number | null;
|
|
23
|
+
anchorOrigin?: {
|
|
24
|
+
vertical: 'top' | 'bottom';
|
|
25
|
+
horizontal: 'left' | 'center' | 'right';
|
|
26
|
+
};
|
|
27
|
+
dense?: boolean;
|
|
28
|
+
maxSnack?: number;
|
|
29
|
+
snackStyle?: React.CSSProperties;
|
|
30
|
+
iconVariant?: Partial<Record<NotificationSeverity, React.ReactNode>>;
|
|
31
|
+
Components?: {
|
|
32
|
+
[key in NotificationSeverity]: React.JSXElementConstructor<any>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
type NotificationsSideBarItemProps = {
|
|
39
|
+
webNotificationsEnabled?: boolean;
|
|
40
|
+
titleCounterEnabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `snackbarProps` instead.
|
|
43
|
+
*/
|
|
44
|
+
snackbarEnabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `snackbarProps` instead.
|
|
47
|
+
*/
|
|
48
|
+
snackbarAutoHideDuration?: number | null;
|
|
49
|
+
snackbarProps?: NotificationSnackbarProperties;
|
|
50
|
+
className?: string;
|
|
51
|
+
icon?: IconComponent;
|
|
52
|
+
text?: string;
|
|
53
|
+
disableHighlight?: boolean;
|
|
54
|
+
noTrack?: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** @public */
|
|
57
|
+
declare const NotificationsSidebarItem: (props?: NotificationsSideBarItemProps) => react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
/** @public */
|
|
60
|
+
type NotificationsTableProps = Pick<TableProps, 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'> & {
|
|
61
|
+
markAsReadOnLinkOpen?: boolean;
|
|
62
|
+
isLoading?: boolean;
|
|
63
|
+
isUnread: boolean;
|
|
64
|
+
notifications?: Notification[];
|
|
65
|
+
onUpdate: () => void;
|
|
66
|
+
setContainsText: (search: string) => void;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
};
|
|
69
|
+
/** @public */
|
|
70
|
+
declare const NotificationsTable: ({ title, markAsReadOnLinkOpen, isLoading, notifications, isUnread, onUpdate, setContainsText, onPageChange, onRowsPerPageChange, page, pageSize, totalCount, }: NotificationsTableProps) => react_jsx_runtime.JSX.Element;
|
|
71
|
+
|
|
72
|
+
/** @public */
|
|
73
|
+
declare const UserNotificationSettingsCard: (props: {
|
|
74
|
+
originNames?: Record<string, string>;
|
|
75
|
+
topicNames?: Record<string, string>;
|
|
76
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
8
78
|
/** @public */
|
|
9
79
|
type NotificationsPageProps = {
|
|
10
80
|
/** Mark notification as read when opening the link it contains, defaults to false */
|
|
@@ -25,7 +95,7 @@ declare const notificationsPlugin: _backstage_core_plugin_api.BackstagePlugin<{
|
|
|
25
95
|
declare const NotificationsPage: (props?: NotificationsPageProps) => react_jsx_runtime.JSX.Element;
|
|
26
96
|
|
|
27
97
|
/** @public */
|
|
28
|
-
declare const notificationsApiRef:
|
|
98
|
+
declare const notificationsApiRef: _backstage_frontend_plugin_api.ApiRef<NotificationsApi>;
|
|
29
99
|
/** @public */
|
|
30
100
|
type GetNotificationsCommonOptions = {
|
|
31
101
|
search?: string;
|
|
@@ -112,73 +182,5 @@ declare function useNotificationsApi<T>(f: (api: NotificationsApi) => Promise<T>
|
|
|
112
182
|
value: T;
|
|
113
183
|
};
|
|
114
184
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
low: true;
|
|
118
|
-
normal: true;
|
|
119
|
-
high: true;
|
|
120
|
-
critical: true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
type NotificationSnackbarProperties = {
|
|
127
|
-
enabled?: boolean;
|
|
128
|
-
autoHideDuration?: number | null;
|
|
129
|
-
anchorOrigin?: {
|
|
130
|
-
vertical: 'top' | 'bottom';
|
|
131
|
-
horizontal: 'left' | 'center' | 'right';
|
|
132
|
-
};
|
|
133
|
-
dense?: boolean;
|
|
134
|
-
maxSnack?: number;
|
|
135
|
-
snackStyle?: React.CSSProperties;
|
|
136
|
-
iconVariant?: Partial<Record<NotificationSeverity, React.ReactNode>>;
|
|
137
|
-
Components?: {
|
|
138
|
-
[key in NotificationSeverity]: React.JSXElementConstructor<any>;
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* @public
|
|
143
|
-
*/
|
|
144
|
-
type NotificationsSideBarItemProps = {
|
|
145
|
-
webNotificationsEnabled?: boolean;
|
|
146
|
-
titleCounterEnabled?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated Use `snackbarProps` instead.
|
|
149
|
-
*/
|
|
150
|
-
snackbarEnabled?: boolean;
|
|
151
|
-
/**
|
|
152
|
-
* @deprecated Use `snackbarProps` instead.
|
|
153
|
-
*/
|
|
154
|
-
snackbarAutoHideDuration?: number | null;
|
|
155
|
-
snackbarProps?: NotificationSnackbarProperties;
|
|
156
|
-
className?: string;
|
|
157
|
-
icon?: IconComponent;
|
|
158
|
-
text?: string;
|
|
159
|
-
disableHighlight?: boolean;
|
|
160
|
-
noTrack?: boolean;
|
|
161
|
-
};
|
|
162
|
-
/** @public */
|
|
163
|
-
declare const NotificationsSidebarItem: (props?: NotificationsSideBarItemProps) => react_jsx_runtime.JSX.Element;
|
|
164
|
-
|
|
165
|
-
/** @public */
|
|
166
|
-
type NotificationsTableProps = Pick<TableProps, 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount' | 'title'> & {
|
|
167
|
-
markAsReadOnLinkOpen?: boolean;
|
|
168
|
-
isLoading?: boolean;
|
|
169
|
-
isUnread: boolean;
|
|
170
|
-
notifications?: Notification[];
|
|
171
|
-
onUpdate: () => void;
|
|
172
|
-
setContainsText: (search: string) => void;
|
|
173
|
-
pageSize: number;
|
|
174
|
-
};
|
|
175
|
-
/** @public */
|
|
176
|
-
declare const NotificationsTable: ({ title, markAsReadOnLinkOpen, isLoading, notifications, isUnread, onUpdate, setContainsText, onPageChange, onRowsPerPageChange, page, pageSize, totalCount, }: NotificationsTableProps) => react_jsx_runtime.JSX.Element;
|
|
177
|
-
|
|
178
|
-
/** @public */
|
|
179
|
-
declare const UserNotificationSettingsCard: (props: {
|
|
180
|
-
originNames?: Record<string, string>;
|
|
181
|
-
topicNames?: Record<string, string>;
|
|
182
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
183
|
-
|
|
184
|
-
export { type GetNotificationsCommonOptions, type GetNotificationsOptions, type GetNotificationsResponse, type GetTopicsOptions, type GetTopicsResponse, type NotificationSnackbarProperties, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, type NotificationsSideBarItemProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
|
|
185
|
+
export { NotificationsClient, NotificationsPage, NotificationsSidebarItem, NotificationsTable, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
|
|
186
|
+
export type { GetNotificationsCommonOptions, GetNotificationsOptions, GetNotificationsResponse, GetTopicsOptions, GetTopicsResponse, NotificationSnackbarProperties, NotificationsApi, NotificationsPageProps, NotificationsSideBarItemProps, NotificationsTableProps, UpdateNotificationsOptions };
|
package/dist/package.json.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@backstage/plugin-notifications";
|
|
2
|
-
var version = "0.5.
|
|
2
|
+
var version = "0.5.12";
|
|
3
3
|
var backstage = {
|
|
4
4
|
role: "frontend-plugin",
|
|
5
5
|
pluginId: "notifications",
|
|
@@ -20,7 +20,7 @@ var repository = {
|
|
|
20
20
|
};
|
|
21
21
|
var license = "Apache-2.0";
|
|
22
22
|
var sideEffects = false;
|
|
23
|
-
var exports = {
|
|
23
|
+
var exports$1 = {
|
|
24
24
|
".": "./src/index.ts",
|
|
25
25
|
"./alpha": "./src/alpha.tsx",
|
|
26
26
|
"./package.json": "./package.json"
|
|
@@ -50,7 +50,6 @@ var scripts = {
|
|
|
50
50
|
test: "backstage-cli package test"
|
|
51
51
|
};
|
|
52
52
|
var dependencies = {
|
|
53
|
-
"@backstage/core-compat-api": "workspace:^",
|
|
54
53
|
"@backstage/core-components": "workspace:^",
|
|
55
54
|
"@backstage/core-plugin-api": "workspace:^",
|
|
56
55
|
"@backstage/errors": "workspace:^",
|
|
@@ -98,7 +97,7 @@ var _package = {
|
|
|
98
97
|
repository: repository,
|
|
99
98
|
license: license,
|
|
100
99
|
sideEffects: sideEffects,
|
|
101
|
-
exports: exports,
|
|
100
|
+
exports: exports$1,
|
|
102
101
|
main: main,
|
|
103
102
|
types: types,
|
|
104
103
|
typesVersions: typesVersions,
|
|
@@ -110,5 +109,5 @@ var _package = {
|
|
|
110
109
|
peerDependenciesMeta: peerDependenciesMeta
|
|
111
110
|
};
|
|
112
111
|
|
|
113
|
-
export { backstage, _package as default, dependencies, devDependencies, exports, files, license, main, name, peerDependencies, peerDependenciesMeta, publishConfig, repository, scripts, sideEffects, types, typesVersions, version };
|
|
112
|
+
export { backstage, _package as default, dependencies, devDependencies, exports$1 as exports, files, license, main, name, peerDependencies, peerDependenciesMeta, publishConfig, repository, scripts, sideEffects, types, typesVersions, version };
|
|
114
113
|
//# sourceMappingURL=package.json.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "notifications",
|
|
@@ -63,14 +63,13 @@
|
|
|
63
63
|
"test": "backstage-cli package test"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@backstage/core-
|
|
67
|
-
"@backstage/core-
|
|
68
|
-
"@backstage/core-plugin-api": "^1.12.0",
|
|
66
|
+
"@backstage/core-components": "^0.18.4",
|
|
67
|
+
"@backstage/core-plugin-api": "^1.12.1",
|
|
69
68
|
"@backstage/errors": "^1.2.7",
|
|
70
|
-
"@backstage/frontend-plugin-api": "^0.13.
|
|
69
|
+
"@backstage/frontend-plugin-api": "^0.13.2",
|
|
71
70
|
"@backstage/plugin-notifications-common": "^0.2.0",
|
|
72
|
-
"@backstage/plugin-signals-react": "^0.0.
|
|
73
|
-
"@backstage/theme": "^0.7.
|
|
71
|
+
"@backstage/plugin-signals-react": "^0.0.18",
|
|
72
|
+
"@backstage/theme": "^0.7.1",
|
|
74
73
|
"@material-ui/core": "^4.9.13",
|
|
75
74
|
"@material-ui/icons": "^4.9.1",
|
|
76
75
|
"lodash": "^4.17.21",
|
|
@@ -80,10 +79,10 @@
|
|
|
80
79
|
"react-use": "^17.2.4"
|
|
81
80
|
},
|
|
82
81
|
"devDependencies": {
|
|
83
|
-
"@backstage/cli": "^0.
|
|
84
|
-
"@backstage/dev-utils": "^1.1.
|
|
85
|
-
"@backstage/plugin-signals": "^0.0.
|
|
86
|
-
"@backstage/test-utils": "^1.7.
|
|
82
|
+
"@backstage/cli": "^0.35.0",
|
|
83
|
+
"@backstage/dev-utils": "^1.1.18",
|
|
84
|
+
"@backstage/plugin-signals": "^0.0.26",
|
|
85
|
+
"@backstage/test-utils": "^1.7.14",
|
|
87
86
|
"@testing-library/jest-dom": "^6.0.0",
|
|
88
87
|
"@testing-library/react": "^16.0.0",
|
|
89
88
|
"@types/react": "^18.0.0",
|