@backstage/plugin-notifications 0.5.6-next.0 → 0.5.6-next.2

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,37 @@
1
1
  # @backstage/plugin-notifications
2
2
 
3
+ ## 0.5.6-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - b00c160: Remove React import form notification and scaffolder plugin
8
+ - Updated dependencies
9
+ - @backstage/core-components@0.17.3-next.0
10
+ - @backstage/frontend-plugin-api@0.10.3-next.1
11
+ - @backstage/core-compat-api@0.4.3-next.2
12
+ - @backstage/core-plugin-api@1.10.7
13
+ - @backstage/errors@1.2.7
14
+ - @backstage/theme@0.6.6
15
+ - @backstage/types@1.2.1
16
+ - @backstage/plugin-notifications-common@0.0.9-next.0
17
+ - @backstage/plugin-signals-react@0.0.13
18
+
19
+ ## 0.5.6-next.1
20
+
21
+ ### Patch Changes
22
+
23
+ - 1fb5f06: Adds ability for user to turn on/off notifications for specific topics within an origin.
24
+ - Updated dependencies
25
+ - @backstage/plugin-notifications-common@0.0.9-next.0
26
+ - @backstage/core-compat-api@0.4.3-next.1
27
+ - @backstage/core-components@0.17.2
28
+ - @backstage/core-plugin-api@1.10.7
29
+ - @backstage/errors@1.2.7
30
+ - @backstage/frontend-plugin-api@0.10.3-next.0
31
+ - @backstage/theme@0.6.6
32
+ - @backstage/types@1.2.1
33
+ - @backstage/plugin-signals-react@0.0.13
34
+
3
35
  ## 0.5.6-next.0
4
36
 
5
37
  ### Patch Changes
@@ -0,0 +1,11 @@
1
+ import { withStyles } from '@material-ui/core/styles';
2
+ import MuiTableCell from '@material-ui/core/TableCell';
3
+
4
+ const NoBorderTableCell = withStyles({
5
+ root: {
6
+ borderBottom: "none"
7
+ }
8
+ })(MuiTableCell);
9
+
10
+ export { NoBorderTableCell };
11
+ //# sourceMappingURL=NoBorderTableCell.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NoBorderTableCell.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/NoBorderTableCell.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 */\n\nimport { withStyles } from '@material-ui/core/styles';\nimport MuiTableCell from '@material-ui/core/TableCell';\n\nexport const NoBorderTableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n"],"names":[],"mappings":";;;AAmBO,MAAM,oBAAoB,UAAW,CAAA;AAAA,EAC1C,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA;AAAA;AAElB,CAAC,EAAE,YAAY;;;;"}
@@ -0,0 +1,59 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { isNotificationsEnabledFor } from '@backstage/plugin-notifications-common';
3
+ import IconButton from '@material-ui/core/IconButton';
4
+ import Switch from '@material-ui/core/Switch';
5
+ import TableRow from '@material-ui/core/TableRow';
6
+ import Tooltip from '@material-ui/core/Tooltip';
7
+ import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
8
+ import KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';
9
+ import { NoBorderTableCell } from './NoBorderTableCell.esm.js';
10
+ import { useNotificationFormat } from './UserNotificationSettingsCard.esm.js';
11
+
12
+ const OriginRow = (props) => {
13
+ const { channel, origin, settings, handleChange, open, handleRowToggle } = props;
14
+ const { formatOriginName } = useNotificationFormat();
15
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
16
+ /* @__PURE__ */ jsx(NoBorderTableCell, { children: origin.topics && origin.topics.length > 0 && /* @__PURE__ */ jsx(
17
+ Tooltip,
18
+ {
19
+ title: `Show Topics for the ${formatOriginName(origin.id)} origin`,
20
+ children: /* @__PURE__ */ jsx(
21
+ IconButton,
22
+ {
23
+ "aria-label": "expand row",
24
+ size: "small",
25
+ onClick: () => handleRowToggle(origin.id),
26
+ children: open ? /* @__PURE__ */ jsx(KeyboardArrowUpIcon, {}) : /* @__PURE__ */ jsx(KeyboardArrowDownIcon, {})
27
+ }
28
+ )
29
+ }
30
+ ) }),
31
+ /* @__PURE__ */ jsx(NoBorderTableCell, { children: formatOriginName(origin.id) }),
32
+ /* @__PURE__ */ jsx(NoBorderTableCell, { children: "all" }),
33
+ settings.channels.map((ch) => /* @__PURE__ */ jsx(NoBorderTableCell, { align: "center", children: /* @__PURE__ */ jsx(
34
+ Tooltip,
35
+ {
36
+ title: `Enable or disable ${channel.id.toLocaleLowerCase(
37
+ "en-US"
38
+ )} notifications from ${formatOriginName(origin.id)}`,
39
+ children: /* @__PURE__ */ jsx(
40
+ Switch,
41
+ {
42
+ checked: isNotificationsEnabledFor(
43
+ settings,
44
+ ch.id,
45
+ origin.id,
46
+ null
47
+ ),
48
+ onChange: (event) => {
49
+ handleChange(ch.id, origin.id, null, event.target.checked);
50
+ }
51
+ }
52
+ )
53
+ }
54
+ ) }, ch.id))
55
+ ] });
56
+ };
57
+
58
+ export { OriginRow };
59
+ //# sourceMappingURL=OriginRow.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OriginRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/OriginRow.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 */\n\nimport {\n ChannelSetting,\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport IconButton from '@material-ui/core/IconButton';\nimport Switch from '@material-ui/core/Switch';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';\nimport KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nexport const OriginRow = (props: {\n channel: ChannelSetting;\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n open: boolean;\n handleRowToggle: (originId: string) => void;\n}) => {\n const { channel, origin, settings, handleChange, open, handleRowToggle } =\n props;\n const { formatOriginName } = useNotificationFormat();\n return (\n <TableRow>\n <NoBorderTableCell>\n {origin.topics && origin.topics.length > 0 && (\n <Tooltip\n title={`Show Topics for the ${formatOriginName(origin.id)} origin`}\n >\n <IconButton\n aria-label=\"expand row\"\n size=\"small\"\n onClick={() => handleRowToggle(origin.id)}\n >\n {open ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}\n </IconButton>\n </Tooltip>\n )}\n </NoBorderTableCell>\n <NoBorderTableCell>{formatOriginName(origin.id)}</NoBorderTableCell>\n <NoBorderTableCell>all</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={ch.id} align=\"center\">\n <Tooltip\n title={`Enable or disable ${channel.id.toLocaleLowerCase(\n 'en-US',\n )} notifications from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n null,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, null, event.target.checked);\n }}\n />\n </Tooltip>\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A,EAAO,CAAqB,kBAAA,EAAA,OAAA,CAAQ,EAAG,CAAA,iBAAA;AAAA,UACrC;AAAA,SACD,CAAA,oBAAA,EAAuB,gBAAiB,CAAA,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA;AAAA,QAEnD,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,yBAAA;AAAA,cACP,QAAA;AAAA,cACA,EAAG,CAAA,EAAA;AAAA,cACH,MAAO,CAAA,EAAA;AAAA,cACP;AAAA,aACF;AAAA,YACA,QAAA,EAAU,CAAC,KAA+C,KAAA;AACxD,cAAA,YAAA,CAAa,GAAG,EAAI,EAAA,MAAA,CAAO,IAAI,IAAM,EAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAC3D;AAAA;AACF;AAAA,KACF,EAAA,EAjBsB,EAAG,CAAA,EAkB3B,CACD;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,50 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { isNotificationsEnabledFor } from '@backstage/plugin-notifications-common';
3
+ import TableRow from '@material-ui/core/TableRow';
4
+ import Tooltip from '@material-ui/core/Tooltip';
5
+ import Switch from '@material-ui/core/Switch';
6
+ import { withStyles } from '@material-ui/core/styles';
7
+ import { NoBorderTableCell } from './NoBorderTableCell.esm.js';
8
+ import { useNotificationFormat } from './UserNotificationSettingsCard.esm.js';
9
+
10
+ const TopicTableRow = withStyles({
11
+ root: {
12
+ paddingLeft: "4px"
13
+ }
14
+ })(TableRow);
15
+ const TopicRow = (props) => {
16
+ const { topic, origin, settings, handleChange } = props;
17
+ const { formatOriginName, formatTopicName } = useNotificationFormat();
18
+ return /* @__PURE__ */ jsxs(TopicTableRow, { children: [
19
+ /* @__PURE__ */ jsx(NoBorderTableCell, {}),
20
+ /* @__PURE__ */ jsx(NoBorderTableCell, {}),
21
+ /* @__PURE__ */ jsx(NoBorderTableCell, { children: formatTopicName(topic.id) }),
22
+ settings.channels.map((ch) => /* @__PURE__ */ jsx(NoBorderTableCell, { align: "center", children: /* @__PURE__ */ jsx(
23
+ Tooltip,
24
+ {
25
+ title: `Enable or disable ${ch.id.toLocaleLowerCase(
26
+ "en-US"
27
+ )} notifications for the ${formatTopicName(
28
+ topic.id
29
+ )} topic from ${formatOriginName(origin.id)}`,
30
+ children: /* @__PURE__ */ jsx(
31
+ Switch,
32
+ {
33
+ checked: isNotificationsEnabledFor(
34
+ settings,
35
+ ch.id,
36
+ origin.id,
37
+ topic.id
38
+ ),
39
+ onChange: (event) => {
40
+ handleChange(ch.id, origin.id, topic.id, event.target.checked);
41
+ }
42
+ }
43
+ )
44
+ }
45
+ ) }, `${ch.id}-${topic}`))
46
+ ] });
47
+ };
48
+
49
+ export { TopicRow };
50
+ //# sourceMappingURL=TopicRow.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TopicRow.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/TopicRow.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 */\n\nimport {\n isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n TopicSetting,\n} from '@backstage/plugin-notifications-common';\nimport TableRow from '@material-ui/core/TableRow';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Switch from '@material-ui/core/Switch';\nimport { withStyles } from '@material-ui/core/styles';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './UserNotificationSettingsCard';\n\nconst TopicTableRow = withStyles({\n root: {\n paddingLeft: '4px',\n },\n})(TableRow);\n\nexport const TopicRow = (props: {\n topic: TopicSetting;\n origin: OriginSetting;\n settings: NotificationSettings;\n handleChange: (\n channel: string,\n origin: string,\n topic: string | null,\n enabled: boolean,\n ) => void;\n}) => {\n const { topic, origin, settings, handleChange } = props;\n const { formatOriginName, formatTopicName } = useNotificationFormat();\n return (\n <TopicTableRow>\n <NoBorderTableCell />\n <NoBorderTableCell />\n <NoBorderTableCell>{formatTopicName(topic.id)}</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={`${ch.id}-${topic}`} align=\"center\">\n <Tooltip\n title={`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications for the ${formatTopicName(\n topic.id,\n )} topic from ${formatOriginName(origin.id)}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n topic.id,\n )}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n handleChange(ch.id, origin.id, topic.id, event.target.checked);\n }}\n />\n </Tooltip>\n </NoBorderTableCell>\n ))}\n </TopicTableRow>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA6BA,MAAM,gBAAgB,UAAW,CAAA;AAAA,EAC/B,IAAM,EAAA;AAAA,IACJ,WAAa,EAAA;AAAA;AAEjB,CAAC,EAAE,QAAQ,CAAA;AAEE,MAAA,QAAA,GAAW,CAAC,KAUnB,KAAA;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,MAAQ,EAAA,QAAA,EAAU,cAAiB,GAAA,KAAA;AAClD,EAAA,MAAM,EAAE,gBAAA,EAAkB,eAAgB,EAAA,GAAI,qBAAsB,EAAA;AACpE,EAAA,4BACG,aACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAkB,EAAA,EAAA,CAAA;AAAA,wBAClB,iBAAkB,EAAA,EAAA,CAAA;AAAA,oBAClB,GAAA,CAAA,iBAAA,EAAA,EAAmB,QAAgB,EAAA,eAAA,CAAA,KAAA,CAAM,EAAE,CAAE,EAAA,CAAA;AAAA,IAC7C,SAAS,QAAS,CAAA,GAAA,CAAI,wBACpB,GAAA,CAAA,iBAAA,EAAA,EAA4C,OAAM,QACjD,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAO,CAAqB,kBAAA,EAAA,EAAA,CAAG,EAAG,CAAA,iBAAA;AAAA,UAChC;AAAA,SACD,CAA0B,uBAAA,EAAA,eAAA;AAAA,UACzB,KAAM,CAAA;AAAA,SACP,CAAA,YAAA,EAAe,gBAAiB,CAAA,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA;AAAA,QAE3C,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,yBAAA;AAAA,cACP,QAAA;AAAA,cACA,EAAG,CAAA,EAAA;AAAA,cACH,MAAO,CAAA,EAAA;AAAA,cACP,KAAM,CAAA;AAAA,aACR;AAAA,YACA,QAAA,EAAU,CAAC,KAA+C,KAAA;AACxD,cAAa,YAAA,CAAA,EAAA,CAAG,IAAI,MAAO,CAAA,EAAA,EAAI,MAAM,EAAI,EAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAC/D;AAAA;AACF;AAAA,SAlBoB,CAAG,EAAA,EAAA,CAAG,EAAE,CAAI,CAAA,EAAA,KAAK,EAoBzC,CACD;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useState, useEffect } from 'react';
2
+ import { createContext, useState, useEffect, useContext } from 'react';
3
3
  import { InfoCard, Progress, ErrorPanel } from '@backstage/core-components';
4
4
  import { useNotificationsApi } from '../../hooks/useNotificationsApi.esm.js';
5
5
  import { useApi } from '@backstage/core-plugin-api';
@@ -8,7 +8,44 @@ import '@backstage/errors';
8
8
  import '../../routes.esm.js';
9
9
  import '../../hooks/useTitleCounter.esm.js';
10
10
  import { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel.esm.js';
11
+ import { capitalize } from 'lodash';
11
12
 
13
+ const NotificationFormatContext = createContext(
14
+ void 0
15
+ );
16
+ const useNotificationFormat = () => {
17
+ const context = useContext(NotificationFormatContext);
18
+ if (!context)
19
+ throw new Error(
20
+ "useNotificationFormat must be used within a NotificationFormatProvider"
21
+ );
22
+ return context;
23
+ };
24
+ const NotificationFormatProvider = ({
25
+ children,
26
+ originMap,
27
+ topicMap
28
+ }) => {
29
+ const formatName = (id, nameMap) => {
30
+ if (nameMap && id in nameMap) {
31
+ return nameMap[id];
32
+ }
33
+ return capitalize(id.replaceAll(/[-_:]/g, " "));
34
+ };
35
+ const formatOriginName = (originId) => {
36
+ return formatName(originId, originMap);
37
+ };
38
+ const formatTopicName = (topicId) => {
39
+ return formatName(topicId, topicMap);
40
+ };
41
+ return /* @__PURE__ */ jsx(
42
+ NotificationFormatContext.Provider,
43
+ {
44
+ value: { formatOriginName, formatTopicName },
45
+ children
46
+ }
47
+ );
48
+ };
12
49
  const UserNotificationSettingsCard = (props) => {
13
50
  const [settings, setNotificationSettings] = useState(void 0);
14
51
  const client = useApi(notificationsApiRef);
@@ -27,15 +64,21 @@ const UserNotificationSettingsCard = (props) => {
27
64
  loading && /* @__PURE__ */ jsx(Progress, {}),
28
65
  error && /* @__PURE__ */ jsx(ErrorPanel, { title: "Failed to load settings", error }),
29
66
  settings && /* @__PURE__ */ jsx(
30
- UserNotificationSettingsPanel,
67
+ NotificationFormatProvider,
31
68
  {
32
- settings,
33
- onChange: onUpdate,
34
- originNames: props.originNames
69
+ originMap: props.originNames,
70
+ topicMap: props.topicNames,
71
+ children: /* @__PURE__ */ jsx(
72
+ UserNotificationSettingsPanel,
73
+ {
74
+ settings,
75
+ onChange: onUpdate
76
+ }
77
+ )
35
78
  }
36
79
  )
37
80
  ] });
38
81
  };
39
82
 
40
- export { UserNotificationSettingsCard };
83
+ export { NotificationFormatProvider, UserNotificationSettingsCard, useNotificationFormat };
41
84
  //# sourceMappingURL=UserNotificationSettingsCard.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserNotificationSettingsCard.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsCard.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 */\n\nimport { useState, useEffect } from 'react';\nimport { ErrorPanel, InfoCard, Progress } from '@backstage/core-components';\nimport { useNotificationsApi } from '../../hooks';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel';\n\n/** @public */\nexport const UserNotificationSettingsCard = (props: {\n originNames?: Record<string, string>;\n}) => {\n const [settings, setNotificationSettings] = useState<\n NotificationSettings | undefined\n >(undefined);\n\n const client = useApi(notificationsApiRef);\n const { error, value, loading } = useNotificationsApi(api => {\n return api.getNotificationSettings();\n });\n\n useEffect(() => {\n if (!loading && !error) {\n setNotificationSettings(value);\n }\n }, [loading, value, error]);\n\n const onUpdate = (newSettings: NotificationSettings) => {\n client\n .updateNotificationSettings(newSettings)\n .then(updatedSettings => setNotificationSettings(updatedSettings));\n };\n\n return (\n <InfoCard title=\"Notification settings\" variant=\"gridItem\">\n {loading && <Progress />}\n {error && <ErrorPanel title=\"Failed to load settings\" error={error} />}\n {settings && (\n <UserNotificationSettingsPanel\n settings={settings}\n onChange={onUpdate}\n originNames={props.originNames}\n />\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAyBa,MAAA,4BAAA,GAA+B,CAAC,KAEvC,KAAA;AACJ,EAAA,MAAM,CAAC,QAAA,EAAU,uBAAuB,CAAA,GAAI,SAE1C,KAAS,CAAA,CAAA;AAEX,EAAM,MAAA,MAAA,GAAS,OAAO,mBAAmB,CAAA;AACzC,EAAA,MAAM,EAAE,KAAO,EAAA,KAAA,EAAO,OAAQ,EAAA,GAAI,oBAAoB,CAAO,GAAA,KAAA;AAC3D,IAAA,OAAO,IAAI,uBAAwB,EAAA;AAAA,GACpC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,CAAC,OAAW,IAAA,CAAC,KAAO,EAAA;AACtB,MAAA,uBAAA,CAAwB,KAAK,CAAA;AAAA;AAC/B,GACC,EAAA,CAAC,OAAS,EAAA,KAAA,EAAO,KAAK,CAAC,CAAA;AAE1B,EAAM,MAAA,QAAA,GAAW,CAAC,WAAsC,KAAA;AACtD,IAAA,MAAA,CACG,2BAA2B,WAAW,CAAA,CACtC,KAAK,CAAmB,eAAA,KAAA,uBAAA,CAAwB,eAAe,CAAC,CAAA;AAAA,GACrE;AAEA,EAAA,uBACG,IAAA,CAAA,QAAA,EAAA,EAAS,KAAM,EAAA,uBAAA,EAAwB,SAAQ,UAC7C,EAAA,QAAA,EAAA;AAAA,IAAA,OAAA,wBAAY,QAAS,EAAA,EAAA,CAAA;AAAA,IACrB,KAAS,oBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,KAAA,EAAM,2BAA0B,KAAc,EAAA,CAAA;AAAA,IACnE,QACC,oBAAA,GAAA;AAAA,MAAC,6BAAA;AAAA,MAAA;AAAA,QACC,QAAA;AAAA,QACA,QAAU,EAAA,QAAA;AAAA,QACV,aAAa,KAAM,CAAA;AAAA;AAAA;AACrB,GAEJ,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"UserNotificationSettingsCard.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsCard.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 */\n\nimport { createContext, useState, useContext, useEffect } from 'react';\nimport { ErrorPanel, InfoCard, Progress } from '@backstage/core-components';\nimport { useNotificationsApi } from '../../hooks';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport { notificationsApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel';\nimport { capitalize } from 'lodash';\n\ntype FormatContextType = {\n formatOriginName: (id: string) => string;\n formatTopicName: (id: string) => string;\n};\n\nconst NotificationFormatContext = createContext<FormatContextType | undefined>(\n undefined,\n);\n\nexport const useNotificationFormat = () => {\n const context = useContext(NotificationFormatContext);\n if (!context)\n throw new Error(\n 'useNotificationFormat must be used within a NotificationFormatProvider',\n );\n return context;\n};\n\ntype Props = {\n children: React.ReactNode;\n originMap: Record<string, string> | undefined;\n topicMap: Record<string, string> | undefined;\n};\n\nexport const NotificationFormatProvider = ({\n children,\n originMap,\n topicMap,\n}: Props) => {\n const formatName = (\n id: string,\n nameMap: Record<string, string> | undefined,\n ) => {\n if (nameMap && id in nameMap) {\n return nameMap[id];\n }\n return capitalize(id.replaceAll(/[-_:]/g, ' '));\n };\n\n const formatOriginName = (originId: string) => {\n return formatName(originId, originMap);\n };\n\n const formatTopicName = (topicId: string) => {\n return formatName(topicId, topicMap);\n };\n return (\n <NotificationFormatContext.Provider\n value={{ formatOriginName, formatTopicName }}\n >\n {children}\n </NotificationFormatContext.Provider>\n );\n};\n\n/** @public */\nexport const UserNotificationSettingsCard = (props: {\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const [settings, setNotificationSettings] = useState<\n NotificationSettings | undefined\n >(undefined);\n\n const client = useApi(notificationsApiRef);\n const { error, value, loading } = useNotificationsApi(api => {\n return api.getNotificationSettings();\n });\n\n useEffect(() => {\n if (!loading && !error) {\n setNotificationSettings(value);\n }\n }, [loading, value, error]);\n\n const onUpdate = (newSettings: NotificationSettings) => {\n client\n .updateNotificationSettings(newSettings)\n .then(updatedSettings => setNotificationSettings(updatedSettings));\n };\n\n return (\n <InfoCard title=\"Notification settings\" variant=\"gridItem\">\n {loading && <Progress />}\n {error && <ErrorPanel title=\"Failed to load settings\" error={error} />}\n {settings && (\n <NotificationFormatProvider\n originMap={props.originNames}\n topicMap={props.topicNames}\n >\n <UserNotificationSettingsPanel\n settings={settings}\n onChange={onUpdate}\n />\n </NotificationFormatProvider>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,yBAA4B,GAAA,aAAA;AAAA,EAChC,KAAA;AACF,CAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAM,MAAA,OAAA,GAAU,WAAW,yBAAyB,CAAA;AACpD,EAAA,IAAI,CAAC,OAAA;AACH,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AACF,EAAO,OAAA,OAAA;AACT;AAQO,MAAM,6BAA6B,CAAC;AAAA,EACzC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,UAAA,GAAa,CACjB,EAAA,EACA,OACG,KAAA;AACH,IAAI,IAAA,OAAA,IAAW,MAAM,OAAS,EAAA;AAC5B,MAAA,OAAO,QAAQ,EAAE,CAAA;AAAA;AAEnB,IAAA,OAAO,UAAW,CAAA,EAAA,CAAG,UAAW,CAAA,QAAA,EAAU,GAAG,CAAC,CAAA;AAAA,GAChD;AAEA,EAAM,MAAA,gBAAA,GAAmB,CAAC,QAAqB,KAAA;A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,EAAA,KAAA,EAAM,2BAA0B,KAAc,EAAA,CAAA;AAAA,IACnE,QACC,oBAAA,GAAA;AAAA,MAAC,0BAAA;AAAA,MAAA;AAAA,QACC,WAAW,KAAM,CAAA,WAAA;AAAA,QACjB,UAAU,KAAM,CAAA,UAAA;AAAA,QAEhB,QAAA,kBAAA,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,QAAU,EAAA;AAAA;AAAA;AACZ;AAAA;AACF,GAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { isNotificationsEnabledFor } from '@backstage/plugin-notifications-common';
2
+ import { useState } from 'react';
3
3
  import Table from '@material-ui/core/Table';
4
4
  import MuiTableCell from '@material-ui/core/TableCell';
5
5
  import { withStyles } from '@material-ui/core/styles';
@@ -7,9 +7,8 @@ import TableHead from '@material-ui/core/TableHead';
7
7
  import Typography from '@material-ui/core/Typography';
8
8
  import TableBody from '@material-ui/core/TableBody';
9
9
  import TableRow from '@material-ui/core/TableRow';
10
- import Switch from '@material-ui/core/Switch';
11
- import { capitalize } from 'lodash';
12
- import Tooltip from '@material-ui/core/Tooltip';
10
+ import { TopicRow } from './TopicRow.esm.js';
11
+ import { OriginRow } from './OriginRow.esm.js';
13
12
 
14
13
  const TableCell = withStyles({
15
14
  root: {
@@ -18,14 +17,19 @@ const TableCell = withStyles({
18
17
  })(MuiTableCell);
19
18
  const UserNotificationSettingsPanel = (props) => {
20
19
  const { settings, onChange } = props;
21
- const allOrigins = [
22
- ...new Set(
23
- settings.channels.flatMap(
24
- (channel) => channel.origins.map((origin) => origin.id)
25
- )
26
- )
27
- ];
28
- const handleChange = (channelId, originId, enabled) => {
20
+ const [expandedRows, setExpandedRows] = useState(/* @__PURE__ */ new Set());
21
+ const handleRowToggle = (originId) => {
22
+ setExpandedRows((prevState) => {
23
+ const newExpandedRows = new Set(prevState);
24
+ if (newExpandedRows.has(originId)) {
25
+ newExpandedRows.delete(originId);
26
+ } else {
27
+ newExpandedRows.add(originId);
28
+ }
29
+ return newExpandedRows;
30
+ });
31
+ };
32
+ const handleChange = (channelId, originId, topicId, enabled) => {
29
33
  const updatedSettings = {
30
34
  channels: settings.channels.map((channel) => {
31
35
  if (channel.id !== channelId) {
@@ -37,9 +41,26 @@ const UserNotificationSettingsPanel = (props) => {
37
41
  if (origin.id !== originId) {
38
42
  return origin;
39
43
  }
44
+ if (topicId === null) {
45
+ return {
46
+ ...origin,
47
+ enabled,
48
+ topics: origin.topics?.map((topic) => {
49
+ return { ...topic, enabled };
50
+ }) ?? []
51
+ };
52
+ }
40
53
  return {
41
54
  ...origin,
42
- enabled
55
+ topics: origin.topics?.map((topic) => {
56
+ if (topic.id === topicId) {
57
+ return {
58
+ ...topic,
59
+ enabled: origin.enabled ? enabled : origin.enabled
60
+ };
61
+ }
62
+ return topic;
63
+ }) ?? []
43
64
  };
44
65
  })
45
66
  };
@@ -47,46 +68,42 @@ const UserNotificationSettingsPanel = (props) => {
47
68
  };
48
69
  onChange(updatedSettings);
49
70
  };
50
- const formatOriginName = (originId) => {
51
- if (props.originNames && originId in props.originNames) {
52
- return props.originNames[originId];
53
- }
54
- return capitalize(originId.replaceAll(/[_:]/g, " "));
55
- };
56
- if (settings.channels.length === 0 || allOrigins.length === 0) {
71
+ if (settings.channels.length === 0) {
57
72
  return /* @__PURE__ */ jsx(Typography, { variant: "body1", children: "No notification settings available, check back later" });
58
73
  }
59
74
  return /* @__PURE__ */ jsxs(Table, { children: [
60
75
  /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
76
+ /* @__PURE__ */ jsx(TableCell, {}),
61
77
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: "Origin" }) }),
62
- settings.channels.map((channel) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: channel.id }) }))
78
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: "Topic" }) }),
79
+ settings.channels.map((channel) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", align: "center", children: channel.id }) }, channel.id))
63
80
  ] }) }),
64
- /* @__PURE__ */ jsx(TableBody, { children: allOrigins.map((origin) => /* @__PURE__ */ jsxs(TableRow, { children: [
65
- /* @__PURE__ */ jsx(TableCell, { children: formatOriginName(origin) }),
66
- settings.channels.map((channel) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
67
- Tooltip,
68
- {
69
- title: `Enable or disable ${channel.id.toLocaleLowerCase(
70
- "en-US"
71
- )} notifications from ${formatOriginName(
72
- origin
73
- ).toLocaleLowerCase("en-US")}`,
74
- children: /* @__PURE__ */ jsx(
75
- Switch,
76
- {
77
- checked: isNotificationsEnabledFor(
78
- settings,
79
- channel.id,
80
- origin
81
- ),
82
- onChange: (event) => {
83
- handleChange(channel.id, origin, event.target.checked);
84
- }
85
- }
86
- )
87
- }
88
- ) }))
89
- ] })) })
81
+ /* @__PURE__ */ jsx(TableBody, { children: settings.channels.map(
82
+ (channel) => channel.origins.flatMap((origin) => [
83
+ /* @__PURE__ */ jsx(
84
+ OriginRow,
85
+ {
86
+ channel,
87
+ origin,
88
+ settings,
89
+ open: expandedRows.has(origin.id),
90
+ handleChange,
91
+ handleRowToggle
92
+ },
93
+ origin.id
94
+ ),
95
+ ...expandedRows.has(origin.id) ? origin.topics?.map((topic) => /* @__PURE__ */ jsx(
96
+ TopicRow,
97
+ {
98
+ topic,
99
+ origin,
100
+ settings,
101
+ handleChange
102
+ },
103
+ `${origin.id}-${topic.id}`
104
+ )) || [] : []
105
+ ])
106
+ ) })
90
107
  ] });
91
108
  };
92
109
 
@@ -1 +1 @@
1
- {"version":3,"file":"UserNotificationSettingsPanel.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.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 */\n\nimport { ChangeEvent } from 'react';\nimport {\n isNotificationsEnabledFor,\n NotificationSettings,\n} from '@backstage/plugin-notifications-common';\nimport Table from '@material-ui/core/Table';\nimport MuiTableCell from '@material-ui/core/TableCell';\nimport { withStyles } from '@material-ui/core/styles';\nimport TableHead from '@material-ui/core/TableHead';\nimport Typography from '@material-ui/core/Typography';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport Switch from '@material-ui/core/Switch';\nimport { capitalize } from 'lodash';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nconst TableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n\nexport const UserNotificationSettingsPanel = (props: {\n settings: NotificationSettings;\n onChange: (settings: NotificationSettings) => void;\n originNames?: Record<string, string>;\n}) => {\n const { settings, onChange } = props;\n const allOrigins = [\n ...new Set(\n settings.channels.flatMap(channel =>\n channel.origins.map(origin => origin.id),\n ),\n ),\n ];\n\n const handleChange = (\n channelId: string,\n originId: string,\n enabled: boolean,\n ) => {\n const updatedSettings = {\n channels: settings.channels.map(channel => {\n if (channel.id !== channelId) {\n return channel;\n }\n return {\n ...channel,\n origins: channel.origins.map(origin => {\n if (origin.id !== originId) {\n return origin;\n }\n return {\n ...origin,\n enabled,\n };\n }),\n };\n }),\n };\n onChange(updatedSettings);\n };\n\n const formatOriginName = (originId: string) => {\n if (props.originNames && originId in props.originNames) {\n return props.originNames[originId];\n }\n return capitalize(originId.replaceAll(/[_:]/g, ' '));\n };\n\n if (settings.channels.length === 0 || allOrigins.length === 0) {\n return (\n <Typography variant=\"body1\">\n No notification settings available, check back later\n </Typography>\n );\n }\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableCell>\n <Typography variant=\"subtitle1\">Origin</Typography>\n </TableCell>\n {settings.channels.map(channel => (\n <TableCell>\n <Typography variant=\"subtitle1\">{channel.id}</Typography>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {allOrigins.map(origin => (\n <TableRow>\n <TableCell>{formatOriginName(origin)}</TableCell>\n {settings.channels.map(channel => (\n <TableCell>\n <Tooltip\n title={`Enable or disable ${channel.id.toLocaleLowerCase(\n 'en-US',\n )} notifications from ${formatOriginName(\n origin,\n ).toLocaleLowerCase('en-US')}`}\n >\n <Switch\n checked={isNotificationsEnabledFor(\n settings,\n channel.id,\n origin,\n )}\n onChange={(event: ChangeEvent<HTMLInputElement>) => {\n handleChange(channel.id, origin, event.target.checked);\n }}\n />\n </Tooltip>\n </TableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA;AAAA;AAElB,CAAC,EAAE,YAAY,CAAA;AAEF,MAAA,6BAAA,GAAgC,CAAC,KAIxC,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA;AAC/B,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,GAAG,IAAI,GAAA;AAAA,MACL,SAAS,QAAS,CAAA,OAAA;AAAA,QAAQ,aACxB,OAAQ,CAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE;AAAA;AACzC;AACF,GACF;AAEA,EAAA,MAAM,YAAe,GAAA,CACnB,SACA,EAAA,QAAA,EACA,OACG,KAAA;A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;"}
1
+ {"version":3,"file":"UserNotificationSettingsPanel.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.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 */\n\nimport { useState } from 'react';\nimport { NotificationSettings } from '@backstage/plugin-notifications-common';\nimport Table from '@material-ui/core/Table';\nimport MuiTableCell from '@material-ui/core/TableCell';\nimport { withStyles } from '@material-ui/core/styles';\nimport TableHead from '@material-ui/core/TableHead';\nimport Typography from '@material-ui/core/Typography';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport { TopicRow } from './TopicRow';\nimport { OriginRow } from './OriginRow';\n\nconst TableCell = withStyles({\n root: {\n borderBottom: 'none',\n },\n})(MuiTableCell);\n\nexport const UserNotificationSettingsPanel = (props: {\n settings: NotificationSettings;\n onChange: (settings: NotificationSettings) => void;\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const { settings, onChange } = props;\n const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());\n\n const handleRowToggle = (originId: string) => {\n setExpandedRows(prevState => {\n const newExpandedRows = new Set(prevState);\n if (newExpandedRows.has(originId)) {\n newExpandedRows.delete(originId);\n } else {\n newExpandedRows.add(originId);\n }\n return newExpandedRows;\n });\n };\n const handleChange = (\n channelId: string,\n originId: string,\n topicId: string | null,\n enabled: boolean,\n ) => {\n const updatedSettings = {\n channels: settings.channels.map(channel => {\n if (channel.id !== channelId) {\n return channel;\n }\n return {\n ...channel,\n origins: channel.origins.map(origin => {\n if (origin.id !== originId) {\n return origin;\n }\n\n if (topicId === null) {\n return {\n ...origin,\n enabled,\n topics:\n origin.topics?.map(topic => {\n return { ...topic, enabled };\n }) ?? [],\n };\n }\n\n return {\n ...origin,\n topics:\n origin.topics?.map(topic => {\n if (topic.id === topicId) {\n return {\n ...topic,\n enabled: origin.enabled ? enabled : origin.enabled,\n };\n }\n return topic;\n }) ?? [],\n };\n }),\n };\n }),\n };\n onChange(updatedSettings);\n };\n\n if (settings.channels.length === 0) {\n return (\n <Typography variant=\"body1\">\n No notification settings available, check back later\n </Typography>\n );\n }\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableCell />\n <TableCell>\n <Typography variant=\"subtitle1\">Origin</Typography>\n </TableCell>\n <TableCell>\n <Typography variant=\"subtitle1\">Topic</Typography>\n </TableCell>\n {settings.channels.map(channel => (\n <TableCell key={channel.id}>\n <Typography variant=\"subtitle1\" align=\"center\">\n {channel.id}\n </Typography>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {settings.channels.map(channel =>\n channel.origins.flatMap(origin => [\n <OriginRow\n key={origin.id}\n channel={channel}\n origin={origin}\n settings={settings}\n open={expandedRows.has(origin.id)}\n handleChange={handleChange}\n handleRowToggle={handleRowToggle}\n />,\n ...(expandedRows.has(origin.id)\n ? origin.topics?.map(topic => (\n <TopicRow\n key={`${origin.id}-${topic.id}`}\n topic={topic}\n origin={origin}\n settings={settings}\n handleChange={handleChange}\n />\n )) || []\n : []),\n ]),\n )}\n </TableBody>\n </Table>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA;AAAA;AAElB,CAAC,EAAE,YAAY,CAAA;AAEF,MAAA,6BAAA,GAAgC,CAAC,KAKxC,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA;AAC/B,EAAA,MAAM,CAAC,YAAc,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AAA,oBACA,GAAA,CAAC,SACE,EAAA,EAAA,QAAA,EAAA,QAAA,CAAS,QAAS,CAAA,GAAA;AAAA,MAAI,CACrB,OAAA,KAAA,OAAA,CAAQ,OAAQ,CAAA,OAAA,CAAQ,CAAU,MAAA,KAAA;AAAA,wBAChC,GAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YAEC,OAAA;AAAA,YACA,MAAA;AAAA,YACA,QAAA;AAAA,YACA,IAAM,EAAA,YAAA,CAAa,GAAI,CAAA,MAAA,CAAO,EAAE,CAAA;AAAA,YAChC,YAAA;AAAA,YACA;AAAA,WAAA;AAAA,UANK,MAAO,CAAA;AAAA,SAOd;AAAA,QACA,GAAI,aAAa,GAAI,CAAA,MAAA,CAAO,EAAE,CAC1B,GAAA,MAAA,CAAO,MAAQ,EAAA,GAAA,CAAI,CACjB,KAAA,qBAAA,GAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YAEC,KAAA;AAAA,YACA,MAAA;AAAA,YACA,QAAA;AAAA,YACA;AAAA,WAAA;AAAA,UAJK,CAAG,EAAA,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,MAAM,EAAE,CAAA;AAAA,SAMhC,CAAA,IAAK,EAAC,GACP;AAAC,OACN;AAAA,KAEL,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -148,6 +148,7 @@ declare const NotificationsTable: ({ title, markAsReadOnLinkOpen, isLoading, not
148
148
  /** @public */
149
149
  declare const UserNotificationSettingsCard: (props: {
150
150
  originNames?: Record<string, string>;
151
+ topicNames?: Record<string, string>;
151
152
  }) => react_jsx_runtime.JSX.Element;
152
153
 
153
154
  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 };
@@ -1,5 +1,5 @@
1
1
  var name = "@backstage/plugin-notifications";
2
- var version = "0.5.6-next.0";
2
+ var version = "0.5.6-next.2";
3
3
  var backstage = {
4
4
  role: "frontend-plugin",
5
5
  pluginId: "notifications",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-notifications",
3
- "version": "0.5.6-next.0",
3
+ "version": "0.5.6-next.2",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "notifications",
@@ -63,12 +63,12 @@
63
63
  "test": "backstage-cli package test"
64
64
  },
65
65
  "dependencies": {
66
- "@backstage/core-compat-api": "0.4.3-next.0",
67
- "@backstage/core-components": "0.17.2",
66
+ "@backstage/core-compat-api": "0.4.3-next.2",
67
+ "@backstage/core-components": "0.17.3-next.0",
68
68
  "@backstage/core-plugin-api": "1.10.7",
69
69
  "@backstage/errors": "1.2.7",
70
- "@backstage/frontend-plugin-api": "0.10.3-next.0",
71
- "@backstage/plugin-notifications-common": "0.0.8",
70
+ "@backstage/frontend-plugin-api": "0.10.3-next.1",
71
+ "@backstage/plugin-notifications-common": "0.0.9-next.0",
72
72
  "@backstage/plugin-signals-react": "0.0.13",
73
73
  "@backstage/theme": "0.6.6",
74
74
  "@backstage/types": "1.2.1",
@@ -82,10 +82,10 @@
82
82
  "react-use": "^17.2.4"
83
83
  },
84
84
  "devDependencies": {
85
- "@backstage/cli": "0.32.1",
85
+ "@backstage/cli": "0.33.0-next.1",
86
86
  "@backstage/core-app-api": "1.17.0",
87
- "@backstage/dev-utils": "1.1.11-next.0",
88
- "@backstage/plugin-signals": "0.0.20-next.0",
87
+ "@backstage/dev-utils": "1.1.11-next.2",
88
+ "@backstage/plugin-signals": "0.0.20-next.1",
89
89
  "@backstage/test-utils": "1.7.8",
90
90
  "@testing-library/jest-dom": "^6.0.0",
91
91
  "@testing-library/react": "^16.0.0",