@backstage/plugin-notifications 0.5.1 → 0.5.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @backstage/plugin-notifications
2
2
 
3
+ ## 0.5.2-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 438c36c: added topic filter for notifications
8
+ - Updated dependencies
9
+ - @backstage/core-components@0.16.3
10
+ - @backstage/core-plugin-api@1.10.3
11
+ - @backstage/errors@1.2.7
12
+ - @backstage/theme@0.6.3
13
+ - @backstage/types@1.2.1
14
+ - @backstage/plugin-notifications-common@0.0.8
15
+ - @backstage/plugin-signals-react@0.0.9
16
+
3
17
  ## 0.5.1
4
18
 
5
19
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsApi.esm.js","sources":["../../src/api/NotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationSettings,\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 getNotificationSettings(): Promise<NotificationSettings>;\n\n updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings>;\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA;AACN,CAAC;;;;"}
1
+ {"version":3,"file":"NotificationsApi.esm.js","sources":["../../src/api/NotificationsApi.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n Notification,\n NotificationSettings,\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 GetNotificationsCommonOptions = {\n search?: string;\n read?: boolean;\n saved?: boolean;\n createdAfter?: Date;\n minimumSeverity?: NotificationSeverity;\n};\n\n/** @public */\nexport type GetNotificationsOptions = GetNotificationsCommonOptions & {\n offset?: number;\n limit?: number;\n sort?: 'created' | 'topic' | 'origin';\n sortOrder?: 'asc' | 'desc';\n topic?: string;\n};\n\n/** @public */\nexport type GetTopicsOptions = GetNotificationsCommonOptions;\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 type GetTopicsResponse = {\n topics: string[];\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 getNotificationSettings(): Promise<NotificationSettings>;\n\n updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings>;\n\n getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse>;\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA;AACN,CAAC;;;;"}
@@ -21,20 +21,9 @@ class NotificationsClient {
21
21
  `${options.sort},${options?.sortOrder ?? "desc"}`
22
22
  );
23
23
  }
24
- if (options?.search) {
25
- queryString.append("search", options.search);
26
- }
27
- if (options?.read !== void 0) {
28
- queryString.append("read", options.read ? "true" : "false");
29
- }
30
- if (options?.saved !== void 0) {
31
- queryString.append("saved", options.saved ? "true" : "false");
32
- }
33
- if (options?.createdAfter !== void 0) {
34
- queryString.append("createdAfter", options.createdAfter.toISOString());
35
- }
36
- if (options?.minimumSeverity !== void 0) {
37
- queryString.append("minimumSeverity", options.minimumSeverity);
24
+ this.appendCommonQueryStrings(queryString, options);
25
+ if (options?.topic !== void 0) {
26
+ queryString.append("topic", options.topic);
38
27
  }
39
28
  return await this.request(
40
29
  `/notifications?${queryString}`
@@ -65,6 +54,28 @@ class NotificationsClient {
65
54
  headers: { "Content-Type": "application/json" }
66
55
  });
67
56
  }
57
+ async getTopics(options) {
58
+ const queryString = new URLSearchParams();
59
+ this.appendCommonQueryStrings(queryString, options);
60
+ return await this.request(`/topics?${queryString}`);
61
+ }
62
+ appendCommonQueryStrings(queryString, options) {
63
+ if (options?.search) {
64
+ queryString.append("search", options.search);
65
+ }
66
+ if (options?.read !== void 0) {
67
+ queryString.append("read", options.read ? "true" : "false");
68
+ }
69
+ if (options?.saved !== void 0) {
70
+ queryString.append("saved", options.saved ? "true" : "false");
71
+ }
72
+ if (options?.createdAfter !== void 0) {
73
+ queryString.append("createdAfter", options.createdAfter.toISOString());
74
+ }
75
+ if (options?.minimumSeverity !== void 0) {
76
+ queryString.append("minimumSeverity", options.minimumSeverity);
77
+ }
78
+ }
68
79
  async request(path, init) {
69
80
  const baseUrl = await this.discoveryApi.getBaseUrl("notifications");
70
81
  const res = await this.fetchApi.fetch(`${baseUrl}${path}`, init);
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationsClient.esm.js","sources":["../../src/api/NotificationsClient.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n 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 NotificationSettings,\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('minimumSeverity', options.minimumSeverity);\n }\n\n return await this.request<GetNotificationsResponse>(\n `/notifications?${queryString}`,\n );\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(\n `/notifications/${encodeURIComponent(id)}`,\n );\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[]>('/notifications/update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getNotificationSettings(): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings');\n }\n\n async updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings', {\n method: 'POST',\n body: JSON.stringify(settings),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private async request<T>(path: string, init?: RequestInit): Promise<T> {\n const baseUrl = await this.discoveryApi.getBaseUrl('notifications');\n const res = await this.fetchApi.fetch(`${baseUrl}${path}`,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,EAAA,MAAA;AAAA,MACR,IAAA,EAAM,IAAK,CAAA,SAAA,CAAU,QAAQ,CAAA;AAAA,MAC7B,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAmB;AAAA,KAC/C,CAAA;AAAA;AACH,EAEA,MAAc,OAAW,CAAA,IAAA,EAAc,IAAgC,EAAA;AACrE,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,eAAe,CAAA;AAClE,IAAM,MAAA,GAAA,GAAM,MAAM,IAAA,CAAK,QAAS,CAAA,KAAA,CAAM,GAAG,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA;AAE/D,IAAI,IAAA,CAAC,IAAI,EAAI,EAAA;AACX,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,GAAG,CAAA;AAAA;AAG5C,IAAA,OAAO,IAAI,IAAK,EAAA;AAAA;AAEpB;;;;"}
1
+ {"version":3,"file":"NotificationsClient.esm.js","sources":["../../src/api/NotificationsClient.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n GetNotificationsCommonOptions,\n GetNotificationsOptions,\n GetNotificationsResponse,\n GetTopicsOptions,\n GetTopicsResponse,\n NotificationsApi,\n UpdateNotificationsOptions,\n} from './NotificationsApi';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n Notification,\n NotificationSettings,\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\n this.appendCommonQueryStrings(queryString, options);\n\n if (options?.topic !== undefined) {\n queryString.append('topic', options.topic);\n }\n\n return await this.request<GetNotificationsResponse>(\n `/notifications?${queryString}`,\n );\n }\n\n async getNotification(id: string): Promise<Notification> {\n return await this.request<Notification>(\n `/notifications/${encodeURIComponent(id)}`,\n );\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[]>('/notifications/update', {\n method: 'POST',\n body: JSON.stringify(options),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getNotificationSettings(): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings');\n }\n\n async updateNotificationSettings(\n settings: NotificationSettings,\n ): Promise<NotificationSettings> {\n return await this.request<NotificationSettings>('/settings', {\n method: 'POST',\n body: JSON.stringify(settings),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n async getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse> {\n const queryString = new URLSearchParams();\n this.appendCommonQueryStrings(queryString, options);\n\n return await this.request<GetTopicsResponse>(`/topics?${queryString}`);\n }\n\n private appendCommonQueryStrings(\n queryString: URLSearchParams,\n options?: GetNotificationsCommonOptions,\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('minimumSeverity', options.minimumSeverity);\n }\n }\n\n private async request<T>(path: string, init?: RequestInit): Promise<T> {\n const baseUrl = await this.discoveryApi.getBaseUrl('notifications');\n const res = await this.fetchApi.fetch(`${baseUrl}${path}`, init);\n\n if (!res.ok) {\n throw await ResponseError.fromResponse(res);\n }\n\n return res.json() as Promise<T>;\n }\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EAEV,YAAY,OAGhB,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AAAA;AAC1B,EAEA,MAAM,iBACJ,OACmC,EAAA;AACnC,IAAM,MAAA,WAAA,GAAc,IAAI,eAAgB,EAAA;AACxC,IAAI,IAAA,OAAA,EAAS,UAAU,KAAW,CAAA,EAAA;AAChC,MAAA,WAAA,CAAY,OAAO,OAAS,EAAA,OAAA,CAAQ,KAAM,CAAA,QAAA,CAAS,EAAE,CAAC,CAAA;AAAA;AAExD,IAAI,IAAA,OAAA,EAAS,WAAW,KAAW,CAAA,EAAA;AACjC,MAAA,WAAA,CAAY,OAAO,QAAU,EAAA,OAAA,CAAQ,MAAO,CAAA,QAAA,CAAS,EAAE,CAAC,CAAA;AAAA;AAE1D,IAAI,IAAA,OAAA,EAAS,SAAS,KAAW,CAAA,EAAA;AAC/B,MAAY,WAAA,CAAA,MAAA;AAAA,QACV,YAAA;AAAA,QACA,GAAG,OAAQ,CAAA,IAAI,CAAI,CAAA,EAAA,OAAA,EAAS,aAAa,MAAM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,EAAI,IAAI,CAAA;AAE/D,IAAI,IAAA,CAAC,IAAI,EAAI,EAAA;AACX,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,GAAG,CAAA;AAAA;AAG5C,IAAA,OAAO,IAAI,IAAK,EAAA;AAAA;AAEpB;;;;"}
@@ -7,6 +7,7 @@ import MenuItem from '@material-ui/core/MenuItem';
7
7
  import Select from '@material-ui/core/Select';
8
8
  import Typography from '@material-ui/core/Typography';
9
9
 
10
+ const ALL = "___all___";
10
11
  const CreatedAfterOptions = {
11
12
  last24h: {
12
13
  label: "Last 24h",
@@ -79,7 +80,10 @@ const NotificationsFilters = ({
79
80
  saved,
80
81
  onSavedChanged,
81
82
  severity,
82
- onSeverityChanged
83
+ onSeverityChanged,
84
+ topic,
85
+ onTopicChanged,
86
+ allTopics
83
87
  }) => {
84
88
  const sortByText = getSortByText(sorting);
85
89
  const handleOnCreatedAfterChanged = (event) => {
@@ -117,6 +121,11 @@ const NotificationsFilters = ({
117
121
  const value = event.target.value || "normal";
118
122
  onSeverityChanged(value);
119
123
  };
124
+ const handleOnTopicChanged = (event) => {
125
+ const value = event.target.value;
126
+ onTopicChanged(value === ALL ? void 0 : value);
127
+ };
128
+ const sortedAllTopics = (allTopics || []).sort((a, b) => a.localeCompare(b));
120
129
  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(
121
130
  Select,
122
131
  {
@@ -158,6 +167,16 @@ const NotificationsFilters = ({
158
167
  onChange: handleOnSeverityChanged
159
168
  },
160
169
  Object.keys(AllSeverityOptions).map((key) => /* @__PURE__ */ React.createElement(MenuItem, { value: key, key }, AllSeverityOptions[key]))
170
+ ))), /* @__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-topic" }, "Topic"), /* @__PURE__ */ React.createElement(
171
+ Select,
172
+ {
173
+ label: "Topic",
174
+ labelId: "notifications-filter-topic",
175
+ value: topic ?? ALL,
176
+ onChange: handleOnTopicChanged
177
+ },
178
+ /* @__PURE__ */ React.createElement(MenuItem, { value: ALL, key: ALL }, "Any topic"),
179
+ sortedAllTopics.map((item) => /* @__PURE__ */ React.createElement(MenuItem, { value: item, key: item }, item))
161
180
  )))));
162
181
  };
163
182
 
@@ -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 React 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};\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\">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 </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA4CO,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;AAAA,GACvD;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,WAAA;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,IAAK,CAA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,GAEL,CACF,CACF,CACF,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 React 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: 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 const handleOnTopicChanged = (\n event: React.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,GAAM,GAAA,WAAA;AAEL,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;AAAA,GACvD;AAAA,EACA,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;AAEJ;;;;"}
@@ -36,6 +36,7 @@ const NotificationsPage = (props) => {
36
36
  SortByOptions.newest.sortBy
37
37
  );
38
38
  const [severity, setSeverity] = React.useState("low");
39
+ const [topic, setTopic] = React.useState();
39
40
  const { error, value, retry, loading } = useNotificationsApi(
40
41
  (api) => {
41
42
  const options = {
@@ -51,11 +52,18 @@ const NotificationsPage = (props) => {
51
52
  if (saved !== void 0) {
52
53
  options.saved = saved;
53
54
  }
55
+ if (topic !== void 0) {
56
+ options.topic = topic;
57
+ }
54
58
  const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();
55
59
  if (createdAfterDate.valueOf() > 0) {
56
60
  options.createdAfter = createdAfterDate;
57
61
  }
58
- return Promise.all([api.getNotifications(options), api.getStatus()]);
62
+ return Promise.all([
63
+ api.getNotifications(options),
64
+ api.getStatus(),
65
+ api.getTopics(options)
66
+ ]);
59
67
  },
60
68
  [
61
69
  containsText,
@@ -65,7 +73,8 @@ const NotificationsPage = (props) => {
65
73
  pageSize,
66
74
  sorting,
67
75
  saved,
68
- severity
76
+ severity,
77
+ topic
69
78
  ]
70
79
  );
71
80
  const throttledSetRefresh = React.useMemo(
@@ -92,6 +101,7 @@ const NotificationsPage = (props) => {
92
101
  const notifications = value?.[0]?.notifications;
93
102
  const totalCount = value?.[0]?.totalCount;
94
103
  const isUnread = !!value?.[1]?.unread;
104
+ const allTopics = value?.[2]?.topics;
95
105
  let tableTitle = `All notifications (${totalCount})`;
96
106
  if (saved) {
97
107
  tableTitle = `Saved notifications (${totalCount})`;
@@ -122,7 +132,10 @@ const NotificationsPage = (props) => {
122
132
  saved,
123
133
  onSavedChanged: setSaved,
124
134
  severity,
125
- onSeverityChanged: setSeverity
135
+ onSeverityChanged: setSeverity,
136
+ topic,
137
+ onTopicChanged: setTopic,
138
+ allTopics
126
139
  }
127
140
  )), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 10 }, /* @__PURE__ */ React.createElement(
128
141
  NotificationsTable,
@@ -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 React, { 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 { GetNotificationsOptions, GetNotificationsResponse } 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] = 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>('all');\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 [GetNotificationsResponse, NotificationStatus]\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\n const createdAfterDate = CreatedAfterOptions[createdAfter].getDate();\n if (createdAfterDate.valueOf() > 0) {\n options.createdAfter = createdAfterDate;\n }\n\n return Promise.all([api.getNotifications(options), api.getStatus()]);\n },\n [\n containsText,\n unreadOnly,\n createdAfter,\n pageNumber,\n pageSize,\n sorting,\n saved,\n severity,\n ],\n );\n\n const throttledSetRefresh = React.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\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 />\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":";;;;;;;;;;;;;;;AAyCA,MAAM,eAAkB,GAAA,GAAA;AAcX,MAAA,iBAAA,GAAoB,CAAC,KAAmC,KAAA;AACnE,EAAM,MAAA;AAAA,IACJ,KAAQ,GAAA,eAAA;AAAA,IACR,OAAU,GAAA,MAAA;AAAA,IACV,QAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,SAAS,EAAC;AAEd,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA;AAClD,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAAU,eAAe,CAAA;AAChD,EAAA,MAAM,CAAC,UAAY,EAAA,aAAa,CAAI,GAAA,KAAA,CAAM,SAA8B,IAAI,CAAA;AAC5E,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,KAAA,CAAM,SAA8B,KAAS,CAAA,CAA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A,QACC,KAAO,EAAA,UAAA;AAAA,QACP,SAAW,EAAA,OAAA;AAAA,QACX,QAAA;AAAA,QACA,oBAAA;AAAA,QACA,aAAA;AAAA,QACA,QAAA;AAAA,QACA,eAAA;AAAA,QACA,YAAc,EAAA,aAAA;AAAA,QACd,mBAAqB,EAAA,WAAA;AAAA,QACrB,IAAM,EAAA,UAAA;AAAA,QACN,QAAA;AAAA,QACA;AAAA;AAAA,KAEJ,CACF,CACF,CACF;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 React, { 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] = 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>('all');\n const [sorting, setSorting] = React.useState<SortBy>(\n SortByOptions.newest.sortBy,\n );\n const [severity, setSeverity] = React.useState<NotificationSeverity>('low');\n const [topic, setTopic] = React.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 = React.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,eAAkB,GAAA,GAAA;AAcX,MAAA,iBAAA,GAAoB,CAAC,KAAmC,KAAA;AACnE,EAA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NotificationsPageProps | undefined) =>
28
28
  /** @public */
29
29
  declare const notificationsApiRef: _backstage_core_plugin_api.ApiRef<NotificationsApi>;
30
30
  /** @public */
31
- type GetNotificationsOptions = {
32
- offset?: number;
33
- limit?: number;
31
+ type GetNotificationsCommonOptions = {
34
32
  search?: string;
35
33
  read?: boolean;
36
34
  saved?: boolean;
37
35
  createdAfter?: Date;
36
+ minimumSeverity?: NotificationSeverity;
37
+ };
38
+ /** @public */
39
+ type GetNotificationsOptions = GetNotificationsCommonOptions & {
40
+ offset?: number;
41
+ limit?: number;
38
42
  sort?: 'created' | 'topic' | 'origin';
39
43
  sortOrder?: 'asc' | 'desc';
40
- minimumSeverity?: NotificationSeverity;
44
+ topic?: string;
41
45
  };
42
46
  /** @public */
47
+ type GetTopicsOptions = GetNotificationsCommonOptions;
48
+ /** @public */
43
49
  type UpdateNotificationsOptions = {
44
50
  ids: string[];
45
51
  read?: boolean;
@@ -51,6 +57,10 @@ type GetNotificationsResponse = {
51
57
  totalCount: number;
52
58
  };
53
59
  /** @public */
60
+ type GetTopicsResponse = {
61
+ topics: string[];
62
+ };
63
+ /** @public */
54
64
  interface NotificationsApi {
55
65
  getNotifications(options?: GetNotificationsOptions): Promise<GetNotificationsResponse>;
56
66
  getNotification(id: string): Promise<Notification>;
@@ -58,6 +68,7 @@ interface NotificationsApi {
58
68
  updateNotifications(options: UpdateNotificationsOptions): Promise<Notification[]>;
59
69
  getNotificationSettings(): Promise<NotificationSettings>;
60
70
  updateNotificationSettings(settings: NotificationSettings): Promise<NotificationSettings>;
71
+ getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse>;
61
72
  }
62
73
 
63
74
  /** @public */
@@ -74,6 +85,8 @@ declare class NotificationsClient implements NotificationsApi {
74
85
  updateNotifications(options: UpdateNotificationsOptions): Promise<Notification[]>;
75
86
  getNotificationSettings(): Promise<NotificationSettings>;
76
87
  updateNotificationSettings(settings: NotificationSettings): Promise<NotificationSettings>;
88
+ getTopics(options?: GetTopicsOptions): Promise<GetTopicsResponse>;
89
+ private appendCommonQueryStrings;
77
90
  private request;
78
91
  }
79
92
 
@@ -139,4 +152,4 @@ declare const UserNotificationSettingsCard: (props: {
139
152
  originNames?: Record<string, string>;
140
153
  }) => React__default.JSX.Element;
141
154
 
142
- export { type GetNotificationsOptions, type GetNotificationsResponse, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
155
+ export { type GetNotificationsCommonOptions, type GetNotificationsOptions, type GetNotificationsResponse, type GetTopicsOptions, type GetTopicsResponse, type NotificationsApi, NotificationsClient, NotificationsPage, type NotificationsPageProps, NotificationsSidebarItem, NotificationsTable, type NotificationsTableProps, type UpdateNotificationsOptions, UserNotificationSettingsCard, notificationsApiRef, notificationsPlugin, useNotificationsApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-next.0",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "notifications",
@@ -38,13 +38,13 @@
38
38
  "test": "backstage-cli package test"
39
39
  },
40
40
  "dependencies": {
41
- "@backstage/core-components": "^0.16.3",
42
- "@backstage/core-plugin-api": "^1.10.3",
43
- "@backstage/errors": "^1.2.7",
44
- "@backstage/plugin-notifications-common": "^0.0.8",
45
- "@backstage/plugin-signals-react": "^0.0.9",
46
- "@backstage/theme": "^0.6.3",
47
- "@backstage/types": "^1.2.1",
41
+ "@backstage/core-components": "0.16.3",
42
+ "@backstage/core-plugin-api": "1.10.3",
43
+ "@backstage/errors": "1.2.7",
44
+ "@backstage/plugin-notifications-common": "0.0.8",
45
+ "@backstage/plugin-signals-react": "0.0.9",
46
+ "@backstage/theme": "0.6.3",
47
+ "@backstage/types": "1.2.1",
48
48
  "@material-ui/core": "^4.9.13",
49
49
  "@material-ui/icons": "^4.9.1",
50
50
  "@material-ui/lab": "^4.0.0-alpha.61",
@@ -55,11 +55,11 @@
55
55
  "react-use": "^17.2.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@backstage/cli": "^0.29.5",
59
- "@backstage/core-app-api": "^1.15.4",
60
- "@backstage/dev-utils": "^1.1.6",
61
- "@backstage/plugin-signals": "^0.0.15",
62
- "@backstage/test-utils": "^1.7.4",
58
+ "@backstage/cli": "0.30.0-next.0",
59
+ "@backstage/core-app-api": "1.15.4",
60
+ "@backstage/dev-utils": "1.1.7-next.0",
61
+ "@backstage/plugin-signals": "0.0.15",
62
+ "@backstage/test-utils": "1.7.4",
63
63
  "@testing-library/jest-dom": "^6.0.0",
64
64
  "@testing-library/react": "^16.0.0",
65
65
  "@testing-library/user-event": "^14.0.0",