@backstage/plugin-notifications 0.1.0-next.1 → 0.1.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.
- package/CHANGELOG.md +40 -0
- package/dist/esm/{index-40cfd0ed.esm.js → index-9328bf59.esm.js} +146 -22
- package/dist/esm/index-9328bf59.esm.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +67 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +11 -11
- package/dist/esm/index-40cfd0ed.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @backstage/plugin-notifications
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6e6d096: notifications can be newly sorted by list of predefined options
|
|
8
|
+
- cd96173: Notifications-backend URL query parameters changed from `sort/sortOrder` to `orderField` and `created_after` to `createdAfter` to unify with other plugins.
|
|
9
|
+
- 07abfe1: The NotificationsPage newly uses pagination implemented on the backend layer to avoid large dataset transfers
|
|
10
|
+
- 758f2a4: The Notifications frontend has been redesigned towards list view with condensed row details. The 'done' attribute has been removed to keep the Notifications aligned with the idea of a messaging system instead of a task manager.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- dff7a7e: All notifications can be marked and filtered by severity critical, high, normal or low, the default is 'normal'
|
|
15
|
+
- 75f2d84: the user can newly mark notifications as "Saved" for their better visibility in the future
|
|
16
|
+
- 5d9c5ba: The Notifications can be newly filtered based on the Created Date.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/plugin-notifications-common@0.0.2
|
|
19
|
+
- @backstage/core-components@0.14.1
|
|
20
|
+
- @backstage/errors@1.2.4
|
|
21
|
+
- @backstage/theme@0.5.2
|
|
22
|
+
- @backstage/core-plugin-api@1.9.1
|
|
23
|
+
- @backstage/types@1.1.1
|
|
24
|
+
- @backstage/plugin-signals-react@0.0.2
|
|
25
|
+
|
|
26
|
+
## 0.1.0-next.2
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- 6e6d096: notifications can be newly sorted by list of predefined options
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies
|
|
35
|
+
- @backstage/core-components@0.14.1-next.2
|
|
36
|
+
- @backstage/core-plugin-api@1.9.1-next.1
|
|
37
|
+
- @backstage/errors@1.2.4-next.0
|
|
38
|
+
- @backstage/theme@0.5.2-next.0
|
|
39
|
+
- @backstage/types@1.1.1
|
|
40
|
+
- @backstage/plugin-notifications-common@0.0.2-next.1
|
|
41
|
+
- @backstage/plugin-signals-react@0.0.2-next.1
|
|
42
|
+
|
|
3
43
|
## 0.1.0-next.1
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
|
@@ -11,6 +11,12 @@ import 'lodash/throttle';
|
|
|
11
11
|
import 'react-relative-time';
|
|
12
12
|
import '@material-ui/icons/Markunread';
|
|
13
13
|
import '@material-ui/icons/CheckCircle';
|
|
14
|
+
import '@material-ui/icons/LabelOff';
|
|
15
|
+
import '@material-ui/icons/Label';
|
|
16
|
+
import '@material-ui/icons/CheckOutlined';
|
|
17
|
+
import '@material-ui/icons/ErrorOutline';
|
|
18
|
+
import '@material-ui/icons/WarningOutlined';
|
|
19
|
+
import '@material-ui/icons/InfoOutlined';
|
|
14
20
|
|
|
15
21
|
const CreatedAfterOptions = {
|
|
16
22
|
last24h: {
|
|
@@ -26,50 +32,143 @@ const CreatedAfterOptions = {
|
|
|
26
32
|
getDate: () => /* @__PURE__ */ new Date(0)
|
|
27
33
|
}
|
|
28
34
|
};
|
|
35
|
+
const SortByOptions = {
|
|
36
|
+
newest: {
|
|
37
|
+
label: "Newest on top",
|
|
38
|
+
sortBy: {
|
|
39
|
+
sort: "created",
|
|
40
|
+
sortOrder: "desc"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
oldest: {
|
|
44
|
+
label: "Oldest on top",
|
|
45
|
+
sortBy: {
|
|
46
|
+
sort: "created",
|
|
47
|
+
sortOrder: "asc"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
topic: {
|
|
51
|
+
label: "Topic",
|
|
52
|
+
sortBy: {
|
|
53
|
+
sort: "topic",
|
|
54
|
+
sortOrder: "asc"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
origin: {
|
|
58
|
+
label: "Origin",
|
|
59
|
+
sortBy: {
|
|
60
|
+
sort: "origin",
|
|
61
|
+
sortOrder: "asc"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const getSortByText = (sortBy) => {
|
|
66
|
+
if ((sortBy == null ? void 0 : sortBy.sort) === "created" && (sortBy == null ? void 0 : sortBy.sortOrder) === "asc") {
|
|
67
|
+
return "oldest";
|
|
68
|
+
}
|
|
69
|
+
if ((sortBy == null ? void 0 : sortBy.sort) === "topic") {
|
|
70
|
+
return "topic";
|
|
71
|
+
}
|
|
72
|
+
if ((sortBy == null ? void 0 : sortBy.sort) === "origin") {
|
|
73
|
+
return "origin";
|
|
74
|
+
}
|
|
75
|
+
return "newest";
|
|
76
|
+
};
|
|
77
|
+
const AllSeverityOptions = {
|
|
78
|
+
critical: "Critical",
|
|
79
|
+
high: "High",
|
|
80
|
+
normal: "Normal",
|
|
81
|
+
low: "Low"
|
|
82
|
+
};
|
|
29
83
|
const NotificationsFilters = ({
|
|
30
|
-
|
|
31
|
-
|
|
84
|
+
sorting,
|
|
85
|
+
onSortingChanged,
|
|
32
86
|
unreadOnly,
|
|
33
87
|
onUnreadOnlyChanged,
|
|
34
88
|
createdAfter,
|
|
35
|
-
onCreatedAfterChanged
|
|
89
|
+
onCreatedAfterChanged,
|
|
90
|
+
saved,
|
|
91
|
+
onSavedChanged,
|
|
92
|
+
severity,
|
|
93
|
+
onSeverityChanged
|
|
36
94
|
}) => {
|
|
95
|
+
const sortByText = getSortByText(sorting);
|
|
37
96
|
const handleOnCreatedAfterChanged = (event) => {
|
|
38
97
|
onCreatedAfterChanged(event.target.value);
|
|
39
98
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (event.target.value === "read")
|
|
45
|
-
|
|
46
|
-
|
|
99
|
+
const handleOnViewChanged = (event) => {
|
|
100
|
+
if (event.target.value === "unread") {
|
|
101
|
+
onUnreadOnlyChanged(true);
|
|
102
|
+
onSavedChanged(void 0);
|
|
103
|
+
} else if (event.target.value === "read") {
|
|
104
|
+
onUnreadOnlyChanged(false);
|
|
105
|
+
onSavedChanged(void 0);
|
|
106
|
+
} else if (event.target.value === "saved") {
|
|
107
|
+
onUnreadOnlyChanged(void 0);
|
|
108
|
+
onSavedChanged(true);
|
|
109
|
+
} else {
|
|
110
|
+
onUnreadOnlyChanged(void 0);
|
|
111
|
+
onSavedChanged(void 0);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const handleOnSortByChanged = (event) => {
|
|
115
|
+
const idx = event.target.value || "newest";
|
|
116
|
+
const option = SortByOptions[idx];
|
|
117
|
+
onSortingChanged({ ...option.sortBy });
|
|
118
|
+
};
|
|
119
|
+
let viewValue = "all";
|
|
120
|
+
if (saved) {
|
|
121
|
+
viewValue = "saved";
|
|
122
|
+
} else if (unreadOnly) {
|
|
123
|
+
viewValue = "unread";
|
|
124
|
+
} else if (unreadOnly === false) {
|
|
125
|
+
viewValue = "read";
|
|
126
|
+
}
|
|
127
|
+
const handleOnSeverityChanged = (event) => {
|
|
128
|
+
const value = event.target.value || "normal";
|
|
129
|
+
onSeverityChanged(value);
|
|
47
130
|
};
|
|
48
|
-
let unreadOnlyValue = "all";
|
|
49
|
-
if (unreadOnly)
|
|
50
|
-
unreadOnlyValue = "unread";
|
|
51
|
-
if (unreadOnly === false)
|
|
52
|
-
unreadOnlyValue = "read";
|
|
53
131
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Grid, { container: true }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, "Filters"), /* @__PURE__ */ React.createElement(Divider, { variant: "fullWidth" })), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true, variant: "outlined", size: "small" }, /* @__PURE__ */ React.createElement(InputLabel, { id: "notifications-filter-view" }, "View"), /* @__PURE__ */ React.createElement(
|
|
54
132
|
Select,
|
|
55
133
|
{
|
|
56
134
|
labelId: "notifications-filter-view",
|
|
57
135
|
label: "View",
|
|
58
|
-
value:
|
|
59
|
-
onChange:
|
|
136
|
+
value: viewValue,
|
|
137
|
+
onChange: handleOnViewChanged
|
|
60
138
|
},
|
|
61
139
|
/* @__PURE__ */ React.createElement(MenuItem, { value: "unread" }, "New only"),
|
|
140
|
+
/* @__PURE__ */ React.createElement(MenuItem, { value: "saved" }, "Saved"),
|
|
62
141
|
/* @__PURE__ */ React.createElement(MenuItem, { value: "read" }, "Marked as read"),
|
|
63
142
|
/* @__PURE__ */ React.createElement(MenuItem, { value: "all" }, "All")
|
|
64
|
-
))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true, variant: "outlined", size: "small" }, /* @__PURE__ */ React.createElement(InputLabel, { id: "notifications-filter-
|
|
143
|
+
))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true, variant: "outlined", size: "small" }, /* @__PURE__ */ React.createElement(InputLabel, { id: "notifications-filter-created" }, "Created after"), /* @__PURE__ */ React.createElement(
|
|
65
144
|
Select,
|
|
66
145
|
{
|
|
67
146
|
label: "Created after",
|
|
147
|
+
labelId: "notifications-filter-created",
|
|
68
148
|
placeholder: "Notifications since",
|
|
69
149
|
value: createdAfter,
|
|
70
150
|
onChange: handleOnCreatedAfterChanged
|
|
71
151
|
},
|
|
72
152
|
Object.keys(CreatedAfterOptions).map((key) => /* @__PURE__ */ React.createElement(MenuItem, { value: key, key }, CreatedAfterOptions[key].label))
|
|
153
|
+
))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true, variant: "outlined", size: "small" }, /* @__PURE__ */ React.createElement(InputLabel, { id: "notifications-filter-sort" }, "Sort by"), /* @__PURE__ */ React.createElement(
|
|
154
|
+
Select,
|
|
155
|
+
{
|
|
156
|
+
label: "Sort by",
|
|
157
|
+
labelId: "notifications-filter-sort",
|
|
158
|
+
placeholder: "Field to sort by",
|
|
159
|
+
value: sortByText,
|
|
160
|
+
onChange: handleOnSortByChanged
|
|
161
|
+
},
|
|
162
|
+
Object.keys(SortByOptions).map((key) => /* @__PURE__ */ React.createElement(MenuItem, { value: key, key }, SortByOptions[key].label))
|
|
163
|
+
))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true, variant: "outlined", size: "small" }, /* @__PURE__ */ React.createElement(InputLabel, { id: "notifications-filter-severity" }, "Severity"), /* @__PURE__ */ React.createElement(
|
|
164
|
+
Select,
|
|
165
|
+
{
|
|
166
|
+
label: "Severity",
|
|
167
|
+
labelId: "notifications-filter-severity",
|
|
168
|
+
value: severity,
|
|
169
|
+
onChange: handleOnSeverityChanged
|
|
170
|
+
},
|
|
171
|
+
Object.keys(AllSeverityOptions).map((key) => /* @__PURE__ */ React.createElement(MenuItem, { value: key, key }, AllSeverityOptions[key]))
|
|
73
172
|
)))));
|
|
74
173
|
};
|
|
75
174
|
|
|
@@ -77,27 +176,46 @@ const NotificationsPage = () => {
|
|
|
77
176
|
const [refresh, setRefresh] = React.useState(false);
|
|
78
177
|
const { lastSignal } = useSignal("notifications");
|
|
79
178
|
const [unreadOnly, setUnreadOnly] = React.useState(true);
|
|
179
|
+
const [saved, setSaved] = React.useState(void 0);
|
|
80
180
|
const [pageNumber, setPageNumber] = React.useState(0);
|
|
81
181
|
const [pageSize, setPageSize] = React.useState(5);
|
|
82
182
|
const [containsText, setContainsText] = React.useState();
|
|
83
183
|
const [createdAfter, setCreatedAfter] = React.useState("lastWeek");
|
|
184
|
+
const [sorting, setSorting] = React.useState(
|
|
185
|
+
SortByOptions.newest.sortBy
|
|
186
|
+
);
|
|
187
|
+
const [severity, setSeverity] = React.useState("low");
|
|
84
188
|
const { error, value, retry, loading } = useNotificationsApi(
|
|
85
189
|
(api) => {
|
|
86
190
|
const options = {
|
|
87
191
|
search: containsText,
|
|
88
192
|
limit: pageSize,
|
|
89
|
-
offset: pageNumber * pageSize
|
|
193
|
+
offset: pageNumber * pageSize,
|
|
194
|
+
minimumSeverity: severity,
|
|
195
|
+
...sorting || {}
|
|
90
196
|
};
|
|
91
197
|
if (unreadOnly !== void 0) {
|
|
92
198
|
options.read = !unreadOnly;
|
|
93
199
|
}
|
|
200
|
+
if (saved !== void 0) {
|
|
201
|
+
options.saved = saved;
|
|
202
|
+
}
|
|
94
203
|
const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();
|
|
95
204
|
if (createdAfterDate.valueOf() > 0) {
|
|
96
205
|
options.createdAfter = createdAfterDate;
|
|
97
206
|
}
|
|
98
207
|
return api.getNotifications(options);
|
|
99
208
|
},
|
|
100
|
-
[
|
|
209
|
+
[
|
|
210
|
+
containsText,
|
|
211
|
+
unreadOnly,
|
|
212
|
+
createdAfter,
|
|
213
|
+
pageNumber,
|
|
214
|
+
pageSize,
|
|
215
|
+
sorting,
|
|
216
|
+
saved,
|
|
217
|
+
severity
|
|
218
|
+
]
|
|
101
219
|
);
|
|
102
220
|
useEffect(() => {
|
|
103
221
|
if (refresh) {
|
|
@@ -122,7 +240,13 @@ const NotificationsPage = () => {
|
|
|
122
240
|
unreadOnly,
|
|
123
241
|
onUnreadOnlyChanged: setUnreadOnly,
|
|
124
242
|
createdAfter,
|
|
125
|
-
onCreatedAfterChanged: setCreatedAfter
|
|
243
|
+
onCreatedAfterChanged: setCreatedAfter,
|
|
244
|
+
onSortingChanged: setSorting,
|
|
245
|
+
sorting,
|
|
246
|
+
saved,
|
|
247
|
+
onSavedChanged: setSaved,
|
|
248
|
+
severity,
|
|
249
|
+
onSeverityChanged: setSeverity
|
|
126
250
|
}
|
|
127
251
|
)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 10 }, /* @__PURE__ */ React.createElement(
|
|
128
252
|
NotificationsTable,
|
|
@@ -141,4 +265,4 @@ const NotificationsPage = () => {
|
|
|
141
265
|
};
|
|
142
266
|
|
|
143
267
|
export { NotificationsPage };
|
|
144
|
-
//# sourceMappingURL=index-
|
|
268
|
+
//# sourceMappingURL=index-9328bf59.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-9328bf59.esm.js","sources":["../../src/components/NotificationsFilters/NotificationsFilters.tsx","../../src/components/NotificationsPage/NotificationsPage.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';\n\nimport {\n Divider,\n FormControl,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n Typography,\n} from '@material-ui/core';\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};\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}: NotificationsFiltersProps) => {\n const sortByText = getSortByText(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: React.ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnViewChanged = (\n event: React.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: React.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: React.ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n const value: NotificationSeverity =\n (event.target.value as NotificationSeverity) || 'normal';\n onSeverityChanged(value);\n };\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\">New only</MenuItem>\n <MenuItem value=\"saved\">Saved</MenuItem>\n <MenuItem value=\"read\">Marked as read</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\">\n Created after\n </InputLabel>\n\n <Select\n label=\"Created after\"\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\">Severity</InputLabel>\n\n <Select\n label=\"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 </Grid>\n </>\n );\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect } from 'react';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { Grid } from '@material-ui/core';\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 { GetNotificationsOptions } from '../../api';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\n\nexport const NotificationsPage = () => {\n const [refresh, setRefresh] = React.useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = React.useState<boolean | undefined>(true);\n const [saved, setSaved] = React.useState<boolean | undefined>(undefined);\n const [pageNumber, setPageNumber] = React.useState(0);\n const [pageSize, setPageSize] = React.useState(5);\n const [containsText, setContainsText] = React.useState<string>();\n const [createdAfter, setCreatedAfter] = React.useState<string>('lastWeek');\n const [sorting, setSorting] = React.useState<SortBy>(\n SortByOptions.newest.sortBy,\n );\n const [severity, setSeverity] = React.useState<NotificationSeverity>('low');\n\n const { error, value, retry, loading } = useNotificationsApi(\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\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return api.getNotifications(options);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n ],\n );\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n setRefresh(true);\n }\n }, [lastSignal]);\n\n const onUpdate = () => {\n setRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n return (\n <PageWithHeader title=\"Notifications\" themeId=\"tool\">\n <Content>\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 />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n isLoading={loading}\n notifications={value?.notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={value?.totalCount}\n />\n </Grid>\n </Grid>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CO,MAAM,mBAET,GAAA;AAAA,EACF,OAAS,EAAA;AAAA,IACP,KAAO,EAAA,UAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAI,EAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI,CAAA;AAAA,GACvD;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAK,CAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI,CAAA;AAAA,GAC3D;AAAA,EACA,GAAK,EAAA;AAAA,IACH,KAAO,EAAA,UAAA;AAAA,IACP,OAAS,EAAA,sBAAU,IAAA,IAAA,CAAK,CAAC,CAAA;AAAA,GAC3B;AACF,CAAA,CAAA;AAEO,MAAM,aAKT,GAAA;AAAA,EACF,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,eAAA;AAAA,IACP,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,SAAA;AAAA,MACN,SAAW,EAAA,MAAA;AAAA,KACb;AAAA,GACF;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,eAAA;AAAA,IAC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AAA,UAAA;AAAA,KAAA;AAAA,GAEvB,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
5
|
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
|
|
6
|
-
import { Notification as Notification$1, NotificationStatus } from '@backstage/plugin-notifications-common';
|
|
6
|
+
import { NotificationSeverity, Notification as Notification$1, NotificationStatus } from '@backstage/plugin-notifications-common';
|
|
7
7
|
import { TableProps } from '@backstage/core-components';
|
|
8
8
|
|
|
9
9
|
/** @public */
|
|
@@ -21,7 +21,11 @@ type GetNotificationsOptions = {
|
|
|
21
21
|
limit?: number;
|
|
22
22
|
search?: string;
|
|
23
23
|
read?: boolean;
|
|
24
|
+
saved?: boolean;
|
|
24
25
|
createdAfter?: Date;
|
|
26
|
+
sort?: 'created' | 'topic' | 'origin';
|
|
27
|
+
sortOrder?: 'asc' | 'desc';
|
|
28
|
+
minimumSeverity?: NotificationSeverity;
|
|
25
29
|
};
|
|
26
30
|
/** @public */
|
|
27
31
|
type UpdateNotificationsOptions = {
|
package/dist/index.esm.js
CHANGED
|
@@ -7,9 +7,15 @@ import NotificationsIcon from '@material-ui/icons/Notifications';
|
|
|
7
7
|
import { useSignal } from '@backstage/plugin-signals-react';
|
|
8
8
|
import throttle from 'lodash/throttle';
|
|
9
9
|
import RelativeTime from 'react-relative-time';
|
|
10
|
-
import { Box, Typography, Tooltip, IconButton } from '@material-ui/core';
|
|
10
|
+
import { Box, Typography, Grid, Tooltip, IconButton } from '@material-ui/core';
|
|
11
11
|
import MarkAsUnreadIcon from '@material-ui/icons/Markunread';
|
|
12
12
|
import MarkAsReadIcon from '@material-ui/icons/CheckCircle';
|
|
13
|
+
import MarkAsUnsavedIcon from '@material-ui/icons/LabelOff';
|
|
14
|
+
import MarkAsSavedIcon from '@material-ui/icons/Label';
|
|
15
|
+
import NormalIcon from '@material-ui/icons/CheckOutlined';
|
|
16
|
+
import CriticalIcon from '@material-ui/icons/ErrorOutline';
|
|
17
|
+
import HighIcon from '@material-ui/icons/WarningOutlined';
|
|
18
|
+
import LowIcon from '@material-ui/icons/InfoOutlined';
|
|
13
19
|
|
|
14
20
|
const rootRouteRef = createRouteRef({
|
|
15
21
|
id: "notifications"
|
|
@@ -33,6 +39,7 @@ class NotificationsClient {
|
|
|
33
39
|
this.fetchApi = options.fetchApi;
|
|
34
40
|
}
|
|
35
41
|
async getNotifications(options) {
|
|
42
|
+
var _a;
|
|
36
43
|
const queryString = new URLSearchParams();
|
|
37
44
|
if ((options == null ? void 0 : options.limit) !== void 0) {
|
|
38
45
|
queryString.append("limit", options.limit.toString(10));
|
|
@@ -40,14 +47,26 @@ class NotificationsClient {
|
|
|
40
47
|
if ((options == null ? void 0 : options.offset) !== void 0) {
|
|
41
48
|
queryString.append("offset", options.offset.toString(10));
|
|
42
49
|
}
|
|
50
|
+
if ((options == null ? void 0 : options.sort) !== void 0) {
|
|
51
|
+
queryString.append(
|
|
52
|
+
"orderField",
|
|
53
|
+
`${options.sort},${(_a = options == null ? void 0 : options.sortOrder) != null ? _a : "desc"}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
43
56
|
if (options == null ? void 0 : options.search) {
|
|
44
57
|
queryString.append("search", options.search);
|
|
45
58
|
}
|
|
46
59
|
if ((options == null ? void 0 : options.read) !== void 0) {
|
|
47
60
|
queryString.append("read", options.read ? "true" : "false");
|
|
48
61
|
}
|
|
62
|
+
if ((options == null ? void 0 : options.saved) !== void 0) {
|
|
63
|
+
queryString.append("saved", options.saved ? "true" : "false");
|
|
64
|
+
}
|
|
49
65
|
if ((options == null ? void 0 : options.createdAfter) !== void 0) {
|
|
50
|
-
queryString.append("
|
|
66
|
+
queryString.append("createdAfter", options.createdAfter.toISOString());
|
|
67
|
+
}
|
|
68
|
+
if ((options == null ? void 0 : options.minimumSeverity) !== void 0) {
|
|
69
|
+
queryString.append("minimal_severity", options.minimumSeverity);
|
|
51
70
|
}
|
|
52
71
|
const urlSegment = `?${queryString}`;
|
|
53
72
|
return await this.request(urlSegment);
|
|
@@ -92,7 +111,7 @@ const notificationsPlugin = createPlugin({
|
|
|
92
111
|
const NotificationsPage = notificationsPlugin.provide(
|
|
93
112
|
createRoutableExtension({
|
|
94
113
|
name: "NotificationsPage",
|
|
95
|
-
component: () => import('./esm/index-
|
|
114
|
+
component: () => import('./esm/index-9328bf59.esm.js').then((m) => m.NotificationsPage),
|
|
96
115
|
mountPoint: rootRouteRef
|
|
97
116
|
})
|
|
98
117
|
);
|
|
@@ -242,6 +261,22 @@ const NotificationsSidebarItem = (props) => {
|
|
|
242
261
|
);
|
|
243
262
|
};
|
|
244
263
|
|
|
264
|
+
const SeverityIcon = ({
|
|
265
|
+
severity
|
|
266
|
+
}) => {
|
|
267
|
+
switch (severity) {
|
|
268
|
+
case "critical":
|
|
269
|
+
return /* @__PURE__ */ React.createElement(CriticalIcon, { htmlColor: "#C9190B" });
|
|
270
|
+
case "high":
|
|
271
|
+
return /* @__PURE__ */ React.createElement(HighIcon, { htmlColor: "#F0AB00" });
|
|
272
|
+
case "low":
|
|
273
|
+
return /* @__PURE__ */ React.createElement(LowIcon, { htmlColor: "#2B9AF3" });
|
|
274
|
+
case "normal":
|
|
275
|
+
default:
|
|
276
|
+
return /* @__PURE__ */ React.createElement(NormalIcon, { htmlColor: "#5BA352" });
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
245
280
|
const ThrottleDelayMs = 1e3;
|
|
246
281
|
const NotificationsTable = ({
|
|
247
282
|
isLoading,
|
|
@@ -264,12 +299,28 @@ const NotificationsTable = ({
|
|
|
264
299
|
},
|
|
265
300
|
[notificationsApi, onUpdate]
|
|
266
301
|
);
|
|
302
|
+
const onSwitchSavedStatus = React.useCallback(
|
|
303
|
+
(notification) => {
|
|
304
|
+
notificationsApi.updateNotifications({
|
|
305
|
+
ids: [notification.id],
|
|
306
|
+
saved: !notification.saved
|
|
307
|
+
}).then(() => onUpdate());
|
|
308
|
+
},
|
|
309
|
+
[notificationsApi, onUpdate]
|
|
310
|
+
);
|
|
267
311
|
const throttledContainsTextHandler = useMemo(
|
|
268
312
|
() => throttle(setContainsText, ThrottleDelayMs),
|
|
269
313
|
[setContainsText]
|
|
270
314
|
);
|
|
271
315
|
const compactColumns = React.useMemo(
|
|
272
316
|
() => [
|
|
317
|
+
{
|
|
318
|
+
width: "1rem",
|
|
319
|
+
render: (notification) => {
|
|
320
|
+
var _a;
|
|
321
|
+
return /* @__PURE__ */ React.createElement(SeverityIcon, { severity: (_a = notification.payload) == null ? void 0 : _a.severity });
|
|
322
|
+
}
|
|
323
|
+
},
|
|
273
324
|
{
|
|
274
325
|
customFilterAndSearch: () => true,
|
|
275
326
|
render: (notification) => {
|
|
@@ -298,13 +349,22 @@ const NotificationsTable = ({
|
|
|
298
349
|
// },
|
|
299
350
|
// },
|
|
300
351
|
{
|
|
301
|
-
// TODO: action for saving notifications
|
|
302
352
|
// actions
|
|
303
353
|
width: "1rem",
|
|
304
354
|
render: (notification) => {
|
|
305
355
|
const markAsReadText = !!notification.read ? "Return among unread" : "Mark as read";
|
|
306
356
|
const IconComponent = !!notification.read ? MarkAsUnreadIcon : MarkAsReadIcon;
|
|
307
|
-
|
|
357
|
+
const markAsSavedText = !!notification.saved ? "Undo save" : "Save for later";
|
|
358
|
+
const SavedIconComponent = !!notification.saved ? MarkAsUnsavedIcon : MarkAsSavedIcon;
|
|
359
|
+
return /* @__PURE__ */ React.createElement(Grid, { container: true, wrap: "nowrap" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Tooltip, { title: markAsSavedText }, /* @__PURE__ */ React.createElement(
|
|
360
|
+
IconButton,
|
|
361
|
+
{
|
|
362
|
+
onClick: () => {
|
|
363
|
+
onSwitchSavedStatus(notification);
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
/* @__PURE__ */ React.createElement(SavedIconComponent, { "aria-label": markAsSavedText })
|
|
367
|
+
))), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Tooltip, { title: markAsReadText }, /* @__PURE__ */ React.createElement(
|
|
308
368
|
IconButton,
|
|
309
369
|
{
|
|
310
370
|
onClick: () => {
|
|
@@ -312,11 +372,11 @@ const NotificationsTable = ({
|
|
|
312
372
|
}
|
|
313
373
|
},
|
|
314
374
|
/* @__PURE__ */ React.createElement(IconComponent, { "aria-label": markAsReadText })
|
|
315
|
-
));
|
|
375
|
+
))));
|
|
316
376
|
}
|
|
317
377
|
}
|
|
318
378
|
],
|
|
319
|
-
[onSwitchReadStatus]
|
|
379
|
+
[onSwitchReadStatus, onSwitchSavedStatus]
|
|
320
380
|
);
|
|
321
381
|
return /* @__PURE__ */ React.createElement(
|
|
322
382
|
Table,
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/routes.ts","../src/api/NotificationsApi.ts","../src/api/NotificationsClient.ts","../src/plugin.ts","../src/hooks/useNotificationsApi.ts","../src/hooks/useWebNotifications.ts","../src/hooks/useTitleCounter.ts","../src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx","../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'notifications',\n});\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport const notificationsApiRef = createApiRef<NotificationsApi>({\n id: 'plugin.notifications.service',\n});\n\n/** @public */\nexport type GetNotificationsOptions = {\n offset?: number;\n limit?: number;\n search?: string;\n read?: boolean;\n createdAfter?: Date;\n};\n\n/** @public */\nexport type UpdateNotificationsOptions = {\n ids: string[];\n read?: boolean;\n saved?: boolean;\n};\n\n/** @public */\nexport type GetNotificationsResponse = {\n notifications: Notification[];\n totalCount: number;\n};\n\n/** @public */\nexport interface NotificationsApi {\n getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse>;\n\n getNotification(id: string): Promise<Notification>;\n\n getStatus(): Promise<NotificationStatus>;\n\n updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]>;\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport class NotificationsClient implements NotificationsApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n public constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse> {\n const queryString = new URLSearchParams();\n if (options?.limit !== undefined) {\n queryString.append('limit', options.limit.toString(10));\n }\n if (options?.offset !== undefined) {\n queryString.append('offset', options.offset.toString(10));\n }\n if (options?.search) {\n queryString.append('search', options.search);\n }\n if (options?.read !== undefined) {\n queryString.append('read', options.read ? 'true' : 'false');\n }\n if (options?.createdAfter !== undefined) {\n queryString.append('created_after', options.createdAfter.toISOString());\n }\n const urlSegment = `?${queryString}`;\n\n return await this.request<GetNotificationsResponse>(urlSegment);\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(`${id}`);\n }\n\n async getStatus(): Promise<NotificationStatus> {\n return await this.request<NotificationStatus>('status');\n }\n\n async updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]> {\n return await this.request<Notification[]>('update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private async request<T>(path: string, init?: any): Promise<T> {\n const baseUrl = `${await this.discoveryApi.getBaseUrl('notifications')}/`;\n const url = new URL(path, baseUrl);\n\n const response = await this.fetchApi.fetch(url.toString(), init);\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json() as Promise<T>;\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { notificationsApiRef } from './api/NotificationsApi';\nimport { NotificationsClient } from './api';\n\n/** @public */\nexport const notificationsPlugin = createPlugin({\n id: 'notifications',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/** @public */\nexport const NotificationsPage = notificationsPlugin.provide(\n createRoutableExtension({\n name: 'NotificationsPage',\n component: () =>\n import('./components/NotificationsPage').then(m => m.NotificationsPage),\n mountPoint: rootRouteRef,\n }),\n);\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NotificationsApi, notificationsApiRef } from '../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/lib/useAsyncRetry';\n\n/** @public */\nexport function useNotificationsApi<T>(\n f: (api: NotificationsApi) => Promise<T>,\n deps: any[] = [],\n) {\n const notificationsApi = useApi(notificationsApiRef);\n\n return useAsyncRetry(async () => {\n return await f(notificationsApi);\n }, deps);\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\n/** @public */\nexport function useWebNotifications() {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const [webNotifications, setWebNotifications] = useState<Notification[]>([]);\n\n useEffect(() => {\n if ('Notification' in window && webNotificationPermission === 'default') {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [webNotificationPermission]);\n\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n webNotifications.forEach(n => n.close());\n setWebNotifications([]);\n }\n });\n\n const sendWebNotification = useCallback(\n (options: { title: string; description: string; link?: string }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n });\n\n notification.onclick = event => {\n event.preventDefault();\n notification.close();\n if (options.link) {\n window.open(options.link, '_blank');\n }\n };\n\n return notification;\n },\n [webNotificationPermission],\n );\n\n return { sendWebNotification };\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\n/** @public */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n\n const getPrefix = (value: number) => {\n return value === 0 ? '' : `(${value}) `;\n };\n\n const cleanTitle = (currentTitle: string) => {\n return currentTitle.replace(/^\\(\\d+\\)\\s/, '');\n };\n\n useEffect(() => {\n document.title = title;\n }, [title]);\n\n useEffect(() => {\n const baseTitle = cleanTitle(title);\n setTitle(`${getPrefix(count)}${baseTitle}`);\n return () => {\n document.title = cleanTitle(title);\n };\n }, [title, count]);\n\n const titleElement = document.querySelector('title');\n if (titleElement) {\n new MutationObserver(() => {\n setTitle(document.title);\n }).observe(titleElement, {\n subtree: true,\n characterData: true,\n childList: true,\n });\n }\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useEffect } from 'react';\nimport { useNotificationsApi } from '../../hooks';\nimport { SidebarItem } from '@backstage/core-components';\nimport NotificationsIcon from '@material-ui/icons/Notifications';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../routes';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport { NotificationSignal } from '@backstage/plugin-notifications-common';\nimport { useWebNotifications } from '../../hooks/useWebNotifications';\nimport { useTitleCounter } from '../../hooks/useTitleCounter';\nimport { notificationsApiRef } from '../../api';\n\n/** @public */\nexport const NotificationsSidebarItem = (props?: {\n webNotificationsEnabled?: boolean;\n titleCounterEnabled?: boolean;\n}) => {\n const { webNotificationsEnabled = false, titleCounterEnabled = true } =\n props ?? { webNotificationsEnabled: false, titleCounterEnabled: true };\n\n const { loading, error, value, retry } = useNotificationsApi(api =>\n api.getStatus(),\n );\n const notificationsApi = useApi(notificationsApiRef);\n const [unreadCount, setUnreadCount] = React.useState(0);\n const notificationsRoute = useRouteRef(rootRouteRef);\n // TODO: Do we want to add long polling in case signals are not available\n const { lastSignal } = useSignal<NotificationSignal>('notifications');\n const { sendWebNotification } = useWebNotifications();\n const [refresh, setRefresh] = React.useState(false);\n const { setNotificationCount } = useTitleCounter();\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, retry]);\n\n useEffect(() => {\n const handleWebNotification = (signal: NotificationSignal) => {\n if (!webNotificationsEnabled || signal.action !== 'new_notification') {\n return;\n }\n\n notificationsApi\n .getNotification(signal.notification_id)\n .then(notification => {\n if (!notification) {\n return;\n }\n sendWebNotification({\n title: notification.payload.title,\n description: notification.payload.description ?? '',\n link: notification.payload.link,\n });\n });\n };\n\n if (lastSignal && lastSignal.action) {\n handleWebNotification(lastSignal);\n setRefresh(true);\n }\n }, [\n lastSignal,\n sendWebNotification,\n webNotificationsEnabled,\n notificationsApi,\n ]);\n\n useEffect(() => {\n if (!loading && !error && value) {\n setUnreadCount(value.unread);\n if (titleCounterEnabled) {\n setNotificationCount(value.unread);\n }\n }\n }, [loading, error, value, titleCounterEnabled, setNotificationCount]);\n\n // TODO: Figure out if the count can be added to hasNotifications\n return (\n <SidebarItem\n icon={NotificationsIcon}\n to={notificationsRoute()}\n text=\"Notifications\"\n hasNotifications={!error && !!unreadCount}\n />\n );\n};\n","/*\n * Copyright 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, { useMemo } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport { Box, IconButton, Tooltip, Typography } from '@material-ui/core';\nimport { Notification } from '@backstage/plugin-notifications-common';\n\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport MarkAsUnreadIcon from '@material-ui/icons/Markunread';\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport {\n Link,\n Table,\n TableProps,\n TableColumn,\n} from '@backstage/core-components';\n\nconst ThrottleDelayMs = 1000;\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount'\n> & {\n isLoading?: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n isLoading,\n notifications = [],\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const notificationsApi = useApi(notificationsApiRef);\n\n const onSwitchReadStatus = React.useCallback(\n (notification: Notification) => {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: !notification.read,\n })\n .then(() => onUpdate());\n },\n [notificationsApi, onUpdate],\n );\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n const compactColumns = React.useMemo(\n (): TableColumn<Notification>[] => [\n {\n customFilterAndSearch: () =>\n true /* Keep it on backend due to pagination. If recent flickering is an issue, implement search here as well. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <>\n <Box>\n <Typography variant=\"subtitle2\">\n {notification.payload.link ? (\n <Link to={notification.payload.link}>\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n <Typography variant=\"body2\">\n {notification.payload.description}\n </Typography>\n <Typography variant=\"caption\">\n {notification.origin && (\n <>{notification.origin} • </>\n )}\n {notification.payload.topic && (\n <>{notification.payload.topic} • </>\n )}\n {notification.created && (\n <RelativeTime value={notification.created} />\n )}\n </Typography>\n </Box>\n </>\n );\n },\n },\n // {\n // // TODO: additional action links\n // width: '25%',\n // render: (notification: Notification) => {\n // return (\n // notification.payload.link && (\n // <Grid container>\n // {/* TODO: render additionalLinks of different titles */}\n // <Grid item>\n // <Link\n // key={notification.payload.link}\n // to={notification.payload.link}\n // >\n // More info\n // </Link>\n // </Grid>\n // </Grid>\n // )\n // );\n // },\n // },\n {\n // TODO: action for saving notifications\n // actions\n width: '1rem',\n render: (notification: Notification) => {\n const markAsReadText = !!notification.read\n ? 'Return among unread'\n : 'Mark as read';\n const IconComponent = !!notification.read\n ? MarkAsUnreadIcon\n : MarkAsReadIcon;\n\n return (\n <Tooltip title={markAsReadText}>\n <IconButton\n onClick={() => {\n onSwitchReadStatus(notification);\n }}\n >\n <IconComponent aria-label={markAsReadText} />\n </IconButton>\n </Tooltip>\n );\n },\n },\n ],\n [onSwitchReadStatus],\n );\n\n // TODO: render \"Saved notifications\" as \"Pinned\"\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n search: true,\n paging: true,\n pageSize,\n header: false,\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":[],"mappings":";;;;;;;;;;;;;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA,eAAA;AACN,CAAC,CAAA;;ACGM,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA,8BAAA;AACN,CAAC;;;;;;;;ACKM,MAAM,mBAAgD,CAAA;AAAA,EAIpD,YAAY,OAGhB,EAAA;AANH,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AACjB,IAAiB,aAAA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;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/routes.ts","../src/api/NotificationsApi.ts","../src/api/NotificationsClient.ts","../src/plugin.ts","../src/hooks/useNotificationsApi.ts","../src/hooks/useWebNotifications.ts","../src/hooks/useTitleCounter.ts","../src/components/NotificationsSideBarItem/NotificationsSideBarItem.tsx","../src/components/NotificationsTable/SeverityIcon.tsx","../src/components/NotificationsTable/NotificationsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'notifications',\n});\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationSeverity,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport const notificationsApiRef = createApiRef<NotificationsApi>({\n id: 'plugin.notifications.service',\n});\n\n/** @public */\nexport type GetNotificationsOptions = {\n offset?: number;\n limit?: number;\n search?: string;\n read?: boolean;\n saved?: boolean;\n createdAfter?: Date;\n sort?: 'created' | 'topic' | 'origin';\n sortOrder?: 'asc' | 'desc';\n minimumSeverity?: NotificationSeverity;\n};\n\n/** @public */\nexport type UpdateNotificationsOptions = {\n ids: string[];\n read?: boolean;\n saved?: boolean;\n};\n\n/** @public */\nexport type GetNotificationsResponse = {\n notifications: Notification[];\n totalCount: number;\n};\n\n/** @public */\nexport interface NotificationsApi {\n getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse>;\n\n getNotification(id: string): Promise<Notification>;\n\n getStatus(): Promise<NotificationStatus>;\n\n updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]>;\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n GetNotificationsOptions,\n GetNotificationsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\n NotificationStatus,\n} from '@backstage/plugin-notifications-common';\n\n/** @public */\nexport class NotificationsClient implements NotificationsApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n public constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async getNotifications(\n options?: GetNotificationsOptions,\n ): Promise<GetNotificationsResponse> {\n const queryString = new URLSearchParams();\n if (options?.limit !== undefined) {\n queryString.append('limit', options.limit.toString(10));\n }\n if (options?.offset !== undefined) {\n queryString.append('offset', options.offset.toString(10));\n }\n if (options?.sort !== undefined) {\n queryString.append(\n 'orderField',\n `${options.sort},${options?.sortOrder ?? 'desc'}`,\n );\n }\n if (options?.search) {\n queryString.append('search', options.search);\n }\n if (options?.read !== undefined) {\n queryString.append('read', options.read ? 'true' : 'false');\n }\n if (options?.saved !== undefined) {\n queryString.append('saved', options.saved ? 'true' : 'false');\n }\n if (options?.createdAfter !== undefined) {\n queryString.append('createdAfter', options.createdAfter.toISOString());\n }\n if (options?.minimumSeverity !== undefined) {\n queryString.append('minimal_severity', options.minimumSeverity);\n }\n const urlSegment = `?${queryString}`;\n\n return await this.request<GetNotificationsResponse>(urlSegment);\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(`${id}`);\n }\n\n async getStatus(): Promise<NotificationStatus> {\n return await this.request<NotificationStatus>('status');\n }\n\n async updateNotifications(\n options: UpdateNotificationsOptions,\n ): Promise<Notification[]> {\n return await this.request<Notification[]>('update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private async request<T>(path: string, init?: any): Promise<T> {\n const baseUrl = `${await this.discoveryApi.getBaseUrl('notifications')}/`;\n const url = new URL(path, baseUrl);\n\n const response = await this.fetchApi.fetch(url.toString(), init);\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json() as Promise<T>;\n }\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { notificationsApiRef } from './api/NotificationsApi';\nimport { NotificationsClient } from './api';\n\n/** @public */\nexport const notificationsPlugin = createPlugin({\n id: 'notifications',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: notificationsApiRef,\n deps: { discoveryApi: discoveryApiRef, fetchApi: fetchApiRef },\n factory: ({ discoveryApi, fetchApi }) =>\n new NotificationsClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/** @public */\nexport const NotificationsPage = notificationsPlugin.provide(\n createRoutableExtension({\n name: 'NotificationsPage',\n component: () =>\n import('./components/NotificationsPage').then(m => m.NotificationsPage),\n mountPoint: rootRouteRef,\n }),\n);\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NotificationsApi, notificationsApiRef } from '../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsyncRetry from 'react-use/lib/useAsyncRetry';\n\n/** @public */\nexport function useNotificationsApi<T>(\n f: (api: NotificationsApi) => Promise<T>,\n deps: any[] = [],\n) {\n const notificationsApi = useApi(notificationsApiRef);\n\n return useAsyncRetry(async () => {\n return await f(notificationsApi);\n }, deps);\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\n/** @public */\nexport function useWebNotifications() {\n const [webNotificationPermission, setWebNotificationPermission] =\n useState('default');\n const [webNotifications, setWebNotifications] = useState<Notification[]>([]);\n\n useEffect(() => {\n if ('Notification' in window && webNotificationPermission === 'default') {\n window.Notification.requestPermission().then(permission => {\n setWebNotificationPermission(permission);\n });\n }\n }, [webNotificationPermission]);\n\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n webNotifications.forEach(n => n.close());\n setWebNotifications([]);\n }\n });\n\n const sendWebNotification = useCallback(\n (options: { title: string; description: string; link?: string }) => {\n if (webNotificationPermission !== 'granted') {\n return null;\n }\n\n const notification = new Notification(options.title, {\n body: options.description,\n });\n\n notification.onclick = event => {\n event.preventDefault();\n notification.close();\n if (options.link) {\n window.open(options.link, '_blank');\n }\n };\n\n return notification;\n },\n [webNotificationPermission],\n );\n\n return { sendWebNotification };\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\n/** @public */\nexport function useTitleCounter() {\n const [title, setTitle] = useState(document.title);\n const [count, setCount] = useState(0);\n\n const getPrefix = (value: number) => {\n return value === 0 ? '' : `(${value}) `;\n };\n\n const cleanTitle = (currentTitle: string) => {\n return currentTitle.replace(/^\\(\\d+\\)\\s/, '');\n };\n\n useEffect(() => {\n document.title = title;\n }, [title]);\n\n useEffect(() => {\n const baseTitle = cleanTitle(title);\n setTitle(`${getPrefix(count)}${baseTitle}`);\n return () => {\n document.title = cleanTitle(title);\n };\n }, [title, count]);\n\n const titleElement = document.querySelector('title');\n if (titleElement) {\n new MutationObserver(() => {\n setTitle(document.title);\n }).observe(titleElement, {\n subtree: true,\n characterData: true,\n childList: true,\n });\n }\n\n const setNotificationCount = useCallback(\n (newCount: number) => setCount(newCount),\n [],\n );\n\n return { setNotificationCount };\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useEffect } from 'react';\nimport { useNotificationsApi } from '../../hooks';\nimport { SidebarItem } from '@backstage/core-components';\nimport NotificationsIcon from '@material-ui/icons/Notifications';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { rootRouteRef } from '../../routes';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport { NotificationSignal } from '@backstage/plugin-notifications-common';\nimport { useWebNotifications } from '../../hooks/useWebNotifications';\nimport { useTitleCounter } from '../../hooks/useTitleCounter';\nimport { notificationsApiRef } from '../../api';\n\n/** @public */\nexport const NotificationsSidebarItem = (props?: {\n webNotificationsEnabled?: boolean;\n titleCounterEnabled?: boolean;\n}) => {\n const { webNotificationsEnabled = false, titleCounterEnabled = true } =\n props ?? { webNotificationsEnabled: false, titleCounterEnabled: true };\n\n const { loading, error, value, retry } = useNotificationsApi(api =>\n api.getStatus(),\n );\n const notificationsApi = useApi(notificationsApiRef);\n const [unreadCount, setUnreadCount] = React.useState(0);\n const notificationsRoute = useRouteRef(rootRouteRef);\n // TODO: Do we want to add long polling in case signals are not available\n const { lastSignal } = useSignal<NotificationSignal>('notifications');\n const { sendWebNotification } = useWebNotifications();\n const [refresh, setRefresh] = React.useState(false);\n const { setNotificationCount } = useTitleCounter();\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, retry]);\n\n useEffect(() => {\n const handleWebNotification = (signal: NotificationSignal) => {\n if (!webNotificationsEnabled || signal.action !== 'new_notification') {\n return;\n }\n\n notificationsApi\n .getNotification(signal.notification_id)\n .then(notification => {\n if (!notification) {\n return;\n }\n sendWebNotification({\n title: notification.payload.title,\n description: notification.payload.description ?? '',\n link: notification.payload.link,\n });\n });\n };\n\n if (lastSignal && lastSignal.action) {\n handleWebNotification(lastSignal);\n setRefresh(true);\n }\n }, [\n lastSignal,\n sendWebNotification,\n webNotificationsEnabled,\n notificationsApi,\n ]);\n\n useEffect(() => {\n if (!loading && !error && value) {\n setUnreadCount(value.unread);\n if (titleCounterEnabled) {\n setNotificationCount(value.unread);\n }\n }\n }, [loading, error, value, titleCounterEnabled, setNotificationCount]);\n\n // TODO: Figure out if the count can be added to hasNotifications\n return (\n <SidebarItem\n icon={NotificationsIcon}\n to={notificationsRoute()}\n text=\"Notifications\"\n hasNotifications={!error && !!unreadCount}\n />\n );\n};\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { NotificationSeverity } from '@backstage/plugin-notifications-common';\nimport NormalIcon from '@material-ui/icons/CheckOutlined';\nimport CriticalIcon from '@material-ui/icons/ErrorOutline';\nimport HighIcon from '@material-ui/icons/WarningOutlined';\nimport LowIcon from '@material-ui/icons/InfoOutlined';\n\nexport const SeverityIcon = ({\n severity,\n}: {\n severity?: NotificationSeverity;\n}) => {\n switch (severity) {\n case 'critical':\n return <CriticalIcon htmlColor=\"#C9190B\" />;\n case 'high':\n return <HighIcon htmlColor=\"#F0AB00\" />;\n case 'low':\n return <LowIcon htmlColor=\"#2B9AF3\" />;\n case 'normal':\n default:\n return <NormalIcon htmlColor=\"#5BA352\" />;\n }\n};\n","/*\n * Copyright 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, { useMemo } from 'react';\nimport throttle from 'lodash/throttle';\n// @ts-ignore\nimport RelativeTime from 'react-relative-time';\nimport { Box, Grid, IconButton, Tooltip, Typography } from '@material-ui/core';\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 MarkAsUnreadIcon from '@material-ui/icons/Markunread' /* TODO: use Drafts and MarkAsUnread once we have mui 5 icons */;\nimport MarkAsReadIcon from '@material-ui/icons/CheckCircle';\nimport MarkAsUnsavedIcon from '@material-ui/icons/LabelOff' /* TODO: use BookmarkRemove and BookmarkAdd once we have mui 5 icons */;\nimport MarkAsSavedIcon from '@material-ui/icons/Label';\nimport { SeverityIcon } from './SeverityIcon';\n\nconst ThrottleDelayMs = 1000;\n\n/** @public */\nexport type NotificationsTableProps = Pick<\n TableProps,\n 'onPageChange' | 'onRowsPerPageChange' | 'page' | 'totalCount'\n> & {\n isLoading?: boolean;\n notifications?: Notification[];\n onUpdate: () => void;\n setContainsText: (search: string) => void;\n pageSize: number;\n};\n\n/** @public */\nexport const NotificationsTable = ({\n isLoading,\n notifications = [],\n onUpdate,\n setContainsText,\n onPageChange,\n onRowsPerPageChange,\n page,\n pageSize,\n totalCount,\n}: NotificationsTableProps) => {\n const notificationsApi = useApi(notificationsApiRef);\n\n const onSwitchReadStatus = React.useCallback(\n (notification: Notification) => {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n read: !notification.read,\n })\n .then(() => onUpdate());\n },\n [notificationsApi, onUpdate],\n );\n\n const onSwitchSavedStatus = React.useCallback(\n (notification: Notification) => {\n notificationsApi\n .updateNotifications({\n ids: [notification.id],\n saved: !notification.saved,\n })\n .then(() => onUpdate());\n },\n [notificationsApi, onUpdate],\n );\n\n const throttledContainsTextHandler = useMemo(\n () => throttle(setContainsText, ThrottleDelayMs),\n [setContainsText],\n );\n\n const compactColumns = React.useMemo(\n (): TableColumn<Notification>[] => [\n {\n width: '1rem',\n render: (notification: Notification) => (\n <SeverityIcon severity={notification.payload?.severity} />\n ),\n },\n {\n customFilterAndSearch: () =>\n true /* Keep it on backend due to pagination. If recent flickering is an issue, implement search here as well. */,\n render: (notification: Notification) => {\n // Compact content\n return (\n <>\n <Box>\n <Typography variant=\"subtitle2\">\n {notification.payload.link ? (\n <Link to={notification.payload.link}>\n {notification.payload.title}\n </Link>\n ) : (\n notification.payload.title\n )}\n </Typography>\n <Typography variant=\"body2\">\n {notification.payload.description}\n </Typography>\n <Typography variant=\"caption\">\n {notification.origin && (\n <>{notification.origin} • </>\n )}\n {notification.payload.topic && (\n <>{notification.payload.topic} • </>\n )}\n {notification.created && (\n <RelativeTime value={notification.created} />\n )}\n </Typography>\n </Box>\n </>\n );\n },\n },\n // {\n // // TODO: additional action links\n // width: '25%',\n // render: (notification: Notification) => {\n // return (\n // notification.payload.link && (\n // <Grid container>\n // {/* TODO: render additionalLinks of different titles */}\n // <Grid item>\n // <Link\n // key={notification.payload.link}\n // to={notification.payload.link}\n // >\n // More info\n // </Link>\n // </Grid>\n // </Grid>\n // )\n // );\n // },\n // },\n {\n // actions\n width: '1rem',\n render: (notification: Notification) => {\n const markAsReadText = !!notification.read\n ? 'Return among unread'\n : 'Mark as read';\n const IconComponent = !!notification.read\n ? MarkAsUnreadIcon\n : MarkAsReadIcon;\n\n const markAsSavedText = !!notification.saved\n ? 'Undo save'\n : 'Save for later';\n\n const SavedIconComponent = !!notification.saved\n ? MarkAsUnsavedIcon\n : MarkAsSavedIcon;\n\n return (\n <Grid container wrap=\"nowrap\">\n <Grid item>\n <Tooltip title={markAsSavedText}>\n <IconButton\n onClick={() => {\n onSwitchSavedStatus(notification);\n }}\n >\n <SavedIconComponent aria-label={markAsSavedText} />\n </IconButton>\n </Tooltip>\n </Grid>\n\n <Grid item>\n <Tooltip title={markAsReadText}>\n <IconButton\n onClick={() => {\n onSwitchReadStatus(notification);\n }}\n >\n <IconComponent aria-label={markAsReadText} />\n </IconButton>\n </Tooltip>\n </Grid>\n </Grid>\n );\n },\n },\n ],\n [onSwitchReadStatus, onSwitchSavedStatus],\n );\n\n return (\n <Table<Notification>\n isLoading={isLoading}\n options={{\n search: true,\n paging: true,\n pageSize,\n header: false,\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":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA,eAAA;AACN,CAAC,CAAA;;ACIM,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA,8BAAA;AACN,CAAC;;;;;;;;ACIM,MAAM,mBAAgD,CAAA;AAAA,EAIpD,YAAY,OAGhB,EAAA;AANH,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AAMf,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,WA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AA;AAAA,MACA,mBAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAgB,EAAA,4BAAA;AAAA,MAChB,IAAM,EAAA,aAAA;AAAA,MACN,OAAS,EAAA,cAAA;AAAA,KAAA;AAAA,GACX,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"postpack": "backstage-cli package postpack"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@backstage/core-components": "^0.14.1
|
|
32
|
-
"@backstage/core-plugin-api": "^1.9.1
|
|
33
|
-
"@backstage/errors": "^1.2.4
|
|
34
|
-
"@backstage/plugin-notifications-common": "^0.0.2
|
|
35
|
-
"@backstage/plugin-signals-react": "^0.0.2
|
|
36
|
-
"@backstage/theme": "^0.5.2
|
|
31
|
+
"@backstage/core-components": "^0.14.1",
|
|
32
|
+
"@backstage/core-plugin-api": "^1.9.1",
|
|
33
|
+
"@backstage/errors": "^1.2.4",
|
|
34
|
+
"@backstage/plugin-notifications-common": "^0.0.2",
|
|
35
|
+
"@backstage/plugin-signals-react": "^0.0.2",
|
|
36
|
+
"@backstage/theme": "^0.5.2",
|
|
37
37
|
"@backstage/types": "^1.1.1",
|
|
38
38
|
"@material-ui/core": "^4.9.13",
|
|
39
39
|
"@material-ui/icons": "^4.9.1",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/cli": "^0.
|
|
52
|
-
"@backstage/core-app-api": "^1.12.1
|
|
53
|
-
"@backstage/dev-utils": "^1.0.28
|
|
54
|
-
"@backstage/test-utils": "^1.5.1
|
|
51
|
+
"@backstage/cli": "^0.26.0",
|
|
52
|
+
"@backstage/core-app-api": "^1.12.1",
|
|
53
|
+
"@backstage/dev-utils": "^1.0.28",
|
|
54
|
+
"@backstage/test-utils": "^1.5.1",
|
|
55
55
|
"@testing-library/jest-dom": "^6.0.0",
|
|
56
56
|
"@testing-library/react": "^14.0.0",
|
|
57
57
|
"@testing-library/user-event": "^14.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-40cfd0ed.esm.js","sources":["../../src/components/NotificationsFilters/NotificationsFilters.tsx","../../src/components/NotificationsPage/NotificationsPage.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';\n\nimport {\n Divider,\n FormControl,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n Typography,\n} from '@material-ui/core';\n\nexport type NotificationsFiltersProps = {\n unreadOnly?: boolean;\n onUnreadOnlyChanged: (checked: boolean | undefined) => void;\n createdAfter?: string;\n onCreatedAfterChanged: (value: string) => void;\n\n // sorting?: {\n // orderBy: GetNotificationsOrderByEnum;\n // orderByDirec: GetNotificationsOrderByDirecEnum;\n // };\n // setSorting: ({\n // orderBy,\n // orderByDirec,\n // }: {\n // orderBy: GetNotificationsOrderByEnum;\n // orderByDirec: GetNotificationsOrderByDirecEnum;\n // }) => void;\n};\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\n// export const SortByOptions: {\n// [key: string]: {\n// label: string;\n// orderBy: GetNotificationsOrderByEnum;\n// orderByDirec: GetNotificationsOrderByDirecEnum;\n// };\n// } = {\n// newest: {\n// label: 'Newest on top',\n// orderBy: GetNotificationsOrderByEnum.Created,\n// orderByDirec: GetNotificationsOrderByDirecEnum.Asc,\n// },\n// oldest: {\n// label: 'Oldest on top',\n// orderBy: GetNotificationsOrderByEnum.Created,\n// orderByDirec: GetNotificationsOrderByDirecEnum.Desc,\n// },\n// topic: {\n// label: 'Topic',\n// orderBy: GetNotificationsOrderByEnum.Topic,\n// orderByDirec: GetNotificationsOrderByDirecEnum.Asc,\n// },\n// origin: {\n// label: 'Origin',\n// orderBy: GetNotificationsOrderByEnum.Origin,\n// orderByDirec: GetNotificationsOrderByDirecEnum.Asc,\n// },\n// };\n\n// TODO: Implement sorting on server (to work with pagination)\n// const getSortBy = (sorting: NotificationsFiltersProps['sorting']): string => {\n// if (\n// sorting?.orderBy === GetNotificationsOrderByEnum.Created &&\n// sorting.orderByDirec === GetNotificationsOrderByDirecEnum.Desc\n// ) {\n// return 'oldest';\n// }\n// if (sorting?.orderBy === GetNotificationsOrderByEnum.Topic) {\n// return 'topic';\n// }\n// if (sorting?.orderBy === GetNotificationsOrderByEnum.Origin) {\n// return 'origin';\n// }\n\n// return 'newest';\n// };\n\nexport const NotificationsFilters = ({\n // sorting,\n // setSorting,\n unreadOnly,\n onUnreadOnlyChanged,\n createdAfter,\n onCreatedAfterChanged,\n}: NotificationsFiltersProps) => {\n // const sortBy = getSortBy(sorting);\n\n const handleOnCreatedAfterChanged = (\n event: React.ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n onCreatedAfterChanged(event.target.value as string);\n };\n\n const handleOnUnreadOnlyChanged = (\n event: React.ChangeEvent<{ name?: string; value: unknown }>,\n ) => {\n let value = undefined;\n if (event.target.value === 'unread') value = true;\n if (event.target.value === 'read') value = false;\n onUnreadOnlyChanged(value);\n };\n\n // const handleOnSortByChanged = (\n // event: React.ChangeEvent<{ name?: string; value: unknown }>,\n // ) => {\n // const idx = (event.target.value as string) || 'newest';\n // const option = SortByOptions[idx];\n // setSorting({\n // orderBy: option.orderBy,\n // orderByDirec: option.orderByDirec,\n // });\n // };\n\n let unreadOnlyValue = 'all';\n if (unreadOnly) unreadOnlyValue = 'unread';\n if (unreadOnly === false) unreadOnlyValue = 'read';\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 <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={unreadOnlyValue}\n onChange={handleOnUnreadOnlyChanged}\n >\n <MenuItem value=\"unread\">New only</MenuItem>\n <MenuItem value=\"read\">Marked as read</MenuItem>\n <MenuItem value=\"all\">All</MenuItem>\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={12}>\n <FormControl fullWidth variant=\"outlined\" size=\"small\">\n <InputLabel id=\"notifications-filter-view\">\n Created after\n </InputLabel>\n\n <Select\n label=\"Created after\"\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 {/*\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 placeholder=\"Field to sort by\"\n value={sortBy}\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 </Grid>\n </>\n );\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect } from 'react';\nimport {\n Content,\n PageWithHeader,\n ResponseErrorPanel,\n} from '@backstage/core-components';\nimport { Grid } from '@material-ui/core';\nimport { useSignal } from '@backstage/plugin-signals-react';\n\nimport { NotificationsTable } from '../NotificationsTable';\nimport { useNotificationsApi } from '../../hooks';\nimport {\n CreatedAfterOptions,\n NotificationsFilters,\n} from '../NotificationsFilters';\nimport { GetNotificationsOptions } from '../../api';\n\nexport const NotificationsPage = () => {\n const [refresh, setRefresh] = React.useState(false);\n const { lastSignal } = useSignal('notifications');\n const [unreadOnly, setUnreadOnly] = React.useState<boolean | undefined>(true);\n const [pageNumber, setPageNumber] = React.useState(0);\n const [pageSize, setPageSize] = React.useState(5);\n const [containsText, setContainsText] = React.useState<string>();\n const [createdAfter, setCreatedAfter] = React.useState<string>('lastWeek');\n\n const { error, value, retry, loading } = useNotificationsApi(\n api => {\n const options: GetNotificationsOptions = {\n search: containsText,\n limit: pageSize,\n offset: pageNumber * pageSize,\n };\n if (unreadOnly !== undefined) {\n options.read = !unreadOnly;\n }\n\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return api.getNotifications(options);\n },\n [containsText, unreadOnly, createdAfter, pageNumber, pageSize],\n );\n\n useEffect(() => {\n if (refresh) {\n retry();\n setRefresh(false);\n }\n }, [refresh, setRefresh, retry]);\n\n useEffect(() => {\n if (lastSignal && lastSignal.action) {\n setRefresh(true);\n }\n }, [lastSignal]);\n\n const onUpdate = () => {\n setRefresh(true);\n };\n\n if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n\n return (\n <PageWithHeader title=\"Notifications\" themeId=\"tool\">\n <Content>\n <Grid container>\n <Grid item xs={2}>\n <NotificationsFilters\n unreadOnly={unreadOnly}\n onUnreadOnlyChanged={setUnreadOnly}\n createdAfter={createdAfter}\n onCreatedAfterChanged={setCreatedAfter}\n // setSorting={setSorting}\n // sorting={sorting}\n />\n </Grid>\n <Grid item xs={10}>\n <NotificationsTable\n isLoading={loading}\n notifications={value?.notifications}\n onUpdate={onUpdate}\n setContainsText={setContainsText}\n onPageChange={setPageNumber}\n onRowsPerPageChange={setPageSize}\n page={pageNumber}\n pageSize={pageSize}\n totalCount={value?.totalCount}\n />\n </Grid>\n </Grid>\n </Content>\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8CO,MAAM,mBAET,GAAA;AAAA,EACF,OAAS,EAAA;AAAA,IACP,KAAO,EAAA,UAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAA,CAAK,KAAK,GAAI,EAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI,CAAA;AAAA,GACvD;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAK,CAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,GAAI,EAAK,GAAA,IAAA,GAAO,GAAI,CAAA;AAAA,GAC3D;AAAA,EACA,GAAK,EAAA;AAAA,IACH,KAAO,EAAA,UAAA;AAAA,IACP,OAAS,EAAA,sBAAU,IAAA,IAAA,CAAK,CAAC,CAAA;AAAA,GAC3B;AACF,CAAA,CAAA;AAi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