@backstage/plugin-notifications 0.5.21-next.0 → 0.5.21-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 +23 -0
- package/dist/components/UserNotificationSettingsCard/NotificationFormatContext.esm.js +43 -0
- package/dist/components/UserNotificationSettingsCard/NotificationFormatContext.esm.js.map +1 -0
- package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js +1 -1
- package/dist/components/UserNotificationSettingsCard/OriginRow.esm.js.map +1 -1
- package/dist/components/UserNotificationSettingsCard/TopicRow.esm.js +1 -1
- package/dist/components/UserNotificationSettingsCard/TopicRow.esm.js.map +1 -1
- package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsCard.esm.js +3 -37
- package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsCard.esm.js.map +1 -1
- package/dist/plugins/notifications/package.json.esm.js +2 -1
- package/dist/plugins/notifications/package.json.esm.js.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @backstage/plugin-notifications
|
|
2
2
|
|
|
3
|
+
## 0.5.21-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/ui@0.18.0-next.2
|
|
9
|
+
- @backstage/core-components@0.18.14-next.2
|
|
10
|
+
- @backstage/core-plugin-api@1.12.10-next.1
|
|
11
|
+
- @backstage/frontend-plugin-api@0.18.1-next.1
|
|
12
|
+
- @backstage/plugin-notifications-common@0.2.4-next.0
|
|
13
|
+
|
|
14
|
+
## 0.5.21-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b31afcf: Fixed circular dependency warnings when building the notification settings UI.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/core-components@0.18.14-next.1
|
|
21
|
+
- @backstage/frontend-plugin-api@0.18.1-next.0
|
|
22
|
+
- @backstage/ui@0.18.0-next.1
|
|
23
|
+
- @backstage/core-plugin-api@1.12.10-next.0
|
|
24
|
+
- @backstage/plugin-signals-react@0.0.26-next.0
|
|
25
|
+
|
|
3
26
|
## 0.5.21-next.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { capitalize } from 'lodash';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
+
import { notificationsTranslationRef } from '../../translation.esm.js';
|
|
6
|
+
|
|
7
|
+
const NotificationFormatContext = createContext(
|
|
8
|
+
void 0
|
|
9
|
+
);
|
|
10
|
+
const useNotificationFormat = () => {
|
|
11
|
+
const { t } = useTranslationRef(notificationsTranslationRef);
|
|
12
|
+
const context = useContext(NotificationFormatContext);
|
|
13
|
+
if (!context) throw new Error(t("settings.errors.useNotificationFormat"));
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
const NotificationFormatProvider = ({
|
|
17
|
+
children,
|
|
18
|
+
originMap,
|
|
19
|
+
topicMap
|
|
20
|
+
}) => {
|
|
21
|
+
const formatName = (id, nameMap) => {
|
|
22
|
+
if (nameMap && id in nameMap) {
|
|
23
|
+
return nameMap[id];
|
|
24
|
+
}
|
|
25
|
+
return capitalize(id.replaceAll(/[-_:]/g, " "));
|
|
26
|
+
};
|
|
27
|
+
const formatOriginName = (originId) => {
|
|
28
|
+
return formatName(originId, originMap);
|
|
29
|
+
};
|
|
30
|
+
const formatTopicName = (topicId) => {
|
|
31
|
+
return formatName(topicId, topicMap);
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
NotificationFormatContext.Provider,
|
|
35
|
+
{
|
|
36
|
+
value: { formatOriginName, formatTopicName },
|
|
37
|
+
children
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { NotificationFormatProvider, useNotificationFormat };
|
|
43
|
+
//# sourceMappingURL=NotificationFormatContext.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationFormatContext.esm.js","sources":["../../../src/components/UserNotificationSettingsCard/NotificationFormatContext.tsx"],"sourcesContent":["/*\n * Copyright 2026 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, ReactNode, useContext } from 'react';\nimport { capitalize } from 'lodash';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\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 { t } = useTranslationRef(notificationsTranslationRef);\n const context = useContext(NotificationFormatContext);\n if (!context) throw new Error(t('settings.errors.useNotificationFormat'));\n return context;\n};\n\nexport const NotificationFormatProvider = ({\n children,\n originMap,\n topicMap,\n}: {\n children: ReactNode;\n originMap: Record<string, string> | undefined;\n topicMap: Record<string, string> | undefined;\n}) => {\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\n return (\n <NotificationFormatContext.Provider\n value={{ formatOriginName, formatTopicName }}\n >\n {children}\n </NotificationFormatContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;AA0BA,MAAM,yBAAA,GAA4B,aAAA;AAAA,EAChC;AACF,CAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,OAAA,GAAU,WAAW,yBAAyB,CAAA;AACpD,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,KAAA,CAAM,CAAA,CAAE,uCAAuC,CAAC,CAAA;AACxE,EAAA,OAAO,OAAA;AACT;AAEO,MAAM,6BAA6B,CAAC;AAAA,EACzC,QAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,KAIM;AACJ,EAAA,MAAM,UAAA,GAAa,CACjB,EAAA,EACA,OAAA,KACG;AACH,IAAA,IAAI,OAAA,IAAW,MAAM,OAAA,EAAS;AAC5B,MAAA,OAAO,QAAQ,EAAE,CAAA;AAAA,IACnB;AACA,IAAA,OAAO,UAAA,CAAW,EAAA,CAAG,UAAA,CAAW,QAAA,EAAU,GAAG,CAAC,CAAA;AAAA,EAChD,CAAA;AAEA,EAAA,MAAM,gBAAA,GAAmB,CAAC,QAAA,KAAqB;AAC7C,IAAA,OAAO,UAAA,CAAW,UAAU,SAAS,CAAA;AAAA,EACvC,CAAA;AAEA,EAAA,MAAM,eAAA,GAAkB,CAAC,OAAA,KAAoB;AAC3C,IAAA,OAAO,UAAA,CAAW,SAAS,QAAQ,CAAA;AAAA,EACrC,CAAA;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,yBAAA,CAA0B,QAAA;AAAA,IAA1B;AAAA,MACC,KAAA,EAAO,EAAE,gBAAA,EAAkB,eAAA,EAAgB;AAAA,MAE1C;AAAA;AAAA,GACH;AAEJ;;;;"}
|
|
@@ -3,7 +3,7 @@ import { isNotificationsEnabledFor } from '@backstage/plugin-notifications-commo
|
|
|
3
3
|
import { TooltipTrigger, ButtonIcon, Tooltip, Switch } from '@backstage/ui';
|
|
4
4
|
import { RiArrowUpSLine, RiArrowDownSLine } from '@remixicon/react';
|
|
5
5
|
import { NoBorderTableCell } from './NoBorderTableCell.esm.js';
|
|
6
|
-
import { useNotificationFormat } from './
|
|
6
|
+
import { useNotificationFormat } from './NotificationFormatContext.esm.js';
|
|
7
7
|
|
|
8
8
|
const OriginRow = (props) => {
|
|
9
9
|
const { origin, settings, handleChange, open, handleRowToggle } = props;
|
|
@@ -1 +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 isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport { ButtonIcon, Switch, Tooltip, TooltipTrigger } from '@backstage/ui';\nimport { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './
|
|
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 isNotificationsEnabledFor,\n NotificationSettings,\n OriginSetting,\n} from '@backstage/plugin-notifications-common';\nimport { ButtonIcon, Switch, Tooltip, TooltipTrigger } from '@backstage/ui';\nimport { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './NotificationFormatContext';\n\nexport const OriginRow = (props: {\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 { origin, settings, handleChange, open, handleRowToggle } = props;\n const { formatOriginName } = useNotificationFormat();\n return (\n <tr>\n <NoBorderTableCell>\n {origin.topics && origin.topics.length > 0 && (\n <TooltipTrigger>\n <ButtonIcon\n aria-label=\"expand row\"\n onPress={() => handleRowToggle(origin.id)}\n icon={\n open ? (\n <RiArrowUpSLine size={16} />\n ) : (\n <RiArrowDownSLine size={16} />\n )\n }\n variant=\"secondary\"\n />\n <Tooltip>{`Show Topics for the ${formatOriginName(\n origin.id,\n )} origin`}</Tooltip>\n </TooltipTrigger>\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 <TooltipTrigger>\n <Switch\n isSelected={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n null,\n )}\n onChange={(isSelected: boolean) => {\n handleChange(ch.id, origin.id, null, isSelected);\n }}\n />\n <Tooltip>{`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications from ${formatOriginName(origin.id)}`}</Tooltip>\n </TooltipTrigger>\n </NoBorderTableCell>\n ))}\n </tr>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA0BO,MAAM,SAAA,GAAY,CAAC,KAAA,KAWpB;AACJ,EAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAU,YAAA,EAAc,IAAA,EAAM,iBAAgB,GAAI,KAAA;AAClE,EAAA,MAAM,EAAE,gBAAA,EAAiB,GAAI,qBAAA,EAAsB;AACnD,EAAA,4BACG,IAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAA,EAAA,EACE,iBAAO,MAAA,IAAU,MAAA,CAAO,OAAO,MAAA,GAAS,CAAA,yBACtC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,YAAA,EAAW,YAAA;AAAA,UACX,OAAA,EAAS,MAAM,eAAA,CAAgB,MAAA,CAAO,EAAE,CAAA;AAAA,UACxC,IAAA,EACE,IAAA,mBACE,GAAA,CAAC,cAAA,EAAA,EAAe,IAAA,EAAM,IAAI,CAAA,mBAE1B,GAAA,CAAC,gBAAA,EAAA,EAAiB,IAAA,EAAM,EAAA,EAAI,CAAA;AAAA,UAGhC,OAAA,EAAQ;AAAA;AAAA,OACV;AAAA,sBACA,GAAA,CAAC,WAAS,QAAA,EAAA,CAAA,oBAAA,EAAuB,gBAAA;AAAA,QAC/B,MAAA,CAAO;AAAA,OACR,CAAA,OAAA,CAAA,EAAU;AAAA,KAAA,EACb,CAAA,EAEJ,CAAA;AAAA,oBACA,GAAA,CAAC,iBAAA,EAAA,EAAmB,QAAA,EAAA,gBAAA,CAAiB,MAAA,CAAO,EAAE,CAAA,EAAE,CAAA;AAAA,oBAChD,GAAA,CAAC,qBAAkB,QAAA,EAAA,KAAA,EAAG,CAAA;AAAA,IACrB,QAAA,CAAS,SAAS,GAAA,CAAI,CAAA,EAAA,yBACpB,iBAAA,EAAA,EAA8B,KAAA,EAAM,QAAA,EACnC,QAAA,kBAAA,IAAA,CAAC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,UAAA,EAAY,yBAAA;AAAA,YACV,QAAA;AAAA,YACA,EAAA,CAAG,EAAA;AAAA,YACH,MAAA,CAAO,EAAA;AAAA,YACP;AAAA,WACF;AAAA,UACA,QAAA,EAAU,CAAC,UAAA,KAAwB;AACjC,YAAA,YAAA,CAAa,EAAA,CAAG,EAAA,EAAI,MAAA,CAAO,EAAA,EAAI,MAAM,UAAU,CAAA;AAAA,UACjD;AAAA;AAAA,OACF;AAAA,sBACA,GAAA,CAAC,OAAA,EAAA,EAAS,QAAA,EAAA,CAAA,kBAAA,EAAqB,EAAA,CAAG,EAAA,CAAG,iBAAA;AAAA,QACnC;AAAA,OACD,CAAA,oBAAA,EAAuB,gBAAA,CAAiB,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAG;AAAA,KAAA,EACxD,CAAA,EAAA,EAhBsB,EAAA,CAAG,EAiB3B,CACD;AAAA,GAAA,EACH,CAAA;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { isNotificationsEnabledFor } from '@backstage/plugin-notifications-common';
|
|
3
3
|
import { TooltipTrigger, Switch, Tooltip } from '@backstage/ui';
|
|
4
4
|
import { NoBorderTableCell } from './NoBorderTableCell.esm.js';
|
|
5
|
-
import { useNotificationFormat } from './
|
|
5
|
+
import { useNotificationFormat } from './NotificationFormatContext.esm.js';
|
|
6
6
|
|
|
7
7
|
const TopicRow = (props) => {
|
|
8
8
|
const { topic, origin, settings, handleChange } = props;
|
|
@@ -1 +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 { Switch, Tooltip, TooltipTrigger } from '@backstage/ui';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './
|
|
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 { Switch, Tooltip, TooltipTrigger } from '@backstage/ui';\nimport { NoBorderTableCell } from './NoBorderTableCell';\nimport { useNotificationFormat } from './NotificationFormatContext';\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 <tr>\n <NoBorderTableCell />\n <NoBorderTableCell />\n <NoBorderTableCell>{formatTopicName(topic.id)}</NoBorderTableCell>\n {settings.channels.map(ch => (\n <NoBorderTableCell key={`${ch.id}-${topic.id}`} align=\"center\">\n <TooltipTrigger>\n <Switch\n isSelected={isNotificationsEnabledFor(\n settings,\n ch.id,\n origin.id,\n topic.id,\n )}\n onChange={(isSelected: boolean) => {\n handleChange(ch.id, origin.id, topic.id, isSelected);\n }}\n />\n <Tooltip>{`Enable or disable ${ch.id.toLocaleLowerCase(\n 'en-US',\n )} notifications for the ${formatTopicName(\n topic.id,\n )} topic from ${formatOriginName(origin.id)}`}</Tooltip>\n </TooltipTrigger>\n </NoBorderTableCell>\n ))}\n </tr>\n );\n};\n"],"names":[],"mappings":";;;;;;AA0BO,MAAM,QAAA,GAAW,CAAC,KAAA,KAUnB;AACJ,EAAA,MAAM,EAAE,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,cAAa,GAAI,KAAA;AAClD,EAAA,MAAM,EAAE,gBAAA,EAAkB,eAAA,EAAgB,GAAI,qBAAA,EAAsB;AACpE,EAAA,4BACG,IAAA,EAAA,EACC,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,CAAA;AAAA,wBAClB,iBAAA,EAAA,EAAkB,CAAA;AAAA,oBACnB,GAAA,CAAC,iBAAA,EAAA,EAAmB,QAAA,EAAA,eAAA,CAAgB,KAAA,CAAM,EAAE,CAAA,EAAE,CAAA;AAAA,IAC7C,QAAA,CAAS,SAAS,GAAA,CAAI,CAAA,EAAA,yBACpB,iBAAA,EAAA,EAA+C,KAAA,EAAM,QAAA,EACpD,QAAA,kBAAA,IAAA,CAAC,cAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,UAAA,EAAY,yBAAA;AAAA,YACV,QAAA;AAAA,YACA,EAAA,CAAG,EAAA;AAAA,YACH,MAAA,CAAO,EAAA;AAAA,YACP,KAAA,CAAM;AAAA,WACR;AAAA,UACA,QAAA,EAAU,CAAC,UAAA,KAAwB;AACjC,YAAA,YAAA,CAAa,GAAG,EAAA,EAAI,MAAA,CAAO,EAAA,EAAI,KAAA,CAAM,IAAI,UAAU,CAAA;AAAA,UACrD;AAAA;AAAA,OACF;AAAA,sBACA,GAAA,CAAC,OAAA,EAAA,EAAS,QAAA,EAAA,CAAA,kBAAA,EAAqB,EAAA,CAAG,EAAA,CAAG,iBAAA;AAAA,QACnC;AAAA,OACD,CAAA,uBAAA,EAA0B,eAAA;AAAA,QACzB,KAAA,CAAM;AAAA,OACP,CAAA,YAAA,EAAe,gBAAA,CAAiB,MAAA,CAAO,EAAE,CAAC,CAAA,CAAA,EAAG;AAAA,KAAA,EAChD,CAAA,EAAA,EAlBsB,GAAG,EAAA,CAAG,EAAE,IAAI,KAAA,CAAM,EAAE,EAmB5C,CACD;AAAA,GAAA,EACH,CAAA;AAEJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useEffect } 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';
|
|
@@ -10,42 +10,8 @@ import '../../hooks/useTitleCounter.esm.js';
|
|
|
10
10
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
11
11
|
import { notificationsTranslationRef } from '../../translation.esm.js';
|
|
12
12
|
import { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel.esm.js';
|
|
13
|
-
import {
|
|
13
|
+
import { NotificationFormatProvider } from './NotificationFormatContext.esm.js';
|
|
14
14
|
|
|
15
|
-
const NotificationFormatContext = createContext(
|
|
16
|
-
void 0
|
|
17
|
-
);
|
|
18
|
-
const useNotificationFormat = () => {
|
|
19
|
-
const { t } = useTranslationRef(notificationsTranslationRef);
|
|
20
|
-
const context = useContext(NotificationFormatContext);
|
|
21
|
-
if (!context) throw new Error(t("settings.errors.useNotificationFormat"));
|
|
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
|
-
};
|
|
49
15
|
const UserNotificationSettingsCard = (props) => {
|
|
50
16
|
const { t } = useTranslationRef(notificationsTranslationRef);
|
|
51
17
|
const [settings, setNotificationSettings] = useState(void 0);
|
|
@@ -81,5 +47,5 @@ const UserNotificationSettingsCard = (props) => {
|
|
|
81
47
|
] });
|
|
82
48
|
};
|
|
83
49
|
|
|
84
|
-
export {
|
|
50
|
+
export { UserNotificationSettingsCard };
|
|
85
51
|
//# sourceMappingURL=UserNotificationSettingsCard.esm.js.map
|
package/dist/components/UserNotificationSettingsCard/UserNotificationSettingsCard.esm.js.map
CHANGED
|
@@ -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 {
|
|
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 { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { notificationsTranslationRef } from '../../translation';\nimport { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel';\nimport { NotificationFormatProvider } from './NotificationFormatContext';\n\n/** @public */\nexport const UserNotificationSettingsCard = (props: {\n originNames?: Record<string, string>;\n topicNames?: Record<string, string>;\n}) => {\n const { t } = useTranslationRef(notificationsTranslationRef);\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={t('settings.title')} variant=\"gridItem\">\n {loading && <Progress />}\n {error && <ErrorPanel title={t('settings.errorTitle')} 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":";;;;;;;;;;;;;;AA4BO,MAAM,4BAAA,GAA+B,CAAC,KAAA,KAGvC;AACJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,2BAA2B,CAAA;AAC3D,EAAA,MAAM,CAAC,QAAA,EAAU,uBAAuB,CAAA,GAAI,SAE1C,MAAS,CAAA;AAEX,EAAA,MAAM,MAAA,GAAS,OAAO,mBAAmB,CAAA;AACzC,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAO,OAAA,EAAQ,GAAI,oBAAoB,CAAA,GAAA,KAAO;AAC3D,IAAA,OAAO,IAAI,uBAAA,EAAwB;AAAA,EACrC,CAAC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,OAAA,IAAW,CAAC,KAAA,EAAO;AACtB,MAAA,uBAAA,CAAwB,KAAK,CAAA;AAAA,IAC/B;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,EAAS,KAAA,EAAO,KAAK,CAAC,CAAA;AAE1B,EAAA,MAAM,QAAA,GAAW,CAAC,WAAA,KAAsC;AACtD,IAAA,MAAA,CACG,2BAA2B,WAAW,CAAA,CACtC,KAAK,CAAA,eAAA,KAAmB,uBAAA,CAAwB,eAAe,CAAC,CAAA;AAAA,EACrE,CAAA;AAEA,EAAA,4BACG,QAAA,EAAA,EAAS,KAAA,EAAO,EAAE,gBAAgB,CAAA,EAAG,SAAQ,UAAA,EAC3C,QAAA,EAAA;AAAA,IAAA,OAAA,wBAAY,QAAA,EAAA,EAAS,CAAA;AAAA,IACrB,yBAAS,GAAA,CAAC,UAAA,EAAA,EAAW,OAAO,CAAA,CAAE,qBAAqB,GAAG,KAAA,EAAc,CAAA;AAAA,IACpE,QAAA,oBACC,GAAA;AAAA,MAAC,0BAAA;AAAA,MAAA;AAAA,QACC,WAAW,KAAA,CAAM,WAAA;AAAA,QACjB,UAAU,KAAA,CAAM,UAAA;AAAA,QAEhB,QAAA,kBAAA,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,QAAA,EAAU;AAAA;AAAA;AACZ;AAAA;AACF,GAAA,EAEJ,CAAA;AAEJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@backstage/plugin-notifications";
|
|
2
|
-
var version = "0.5.21-next.
|
|
2
|
+
var version = "0.5.21-next.2";
|
|
3
3
|
var backstage = {
|
|
4
4
|
role: "frontend-plugin",
|
|
5
5
|
pluginId: "notifications",
|
|
@@ -70,6 +70,7 @@ var devDependencies = {
|
|
|
70
70
|
"@backstage/dev-utils": "workspace:^",
|
|
71
71
|
"@backstage/plugin-signals": "workspace:^",
|
|
72
72
|
"@backstage/test-utils": "workspace:^",
|
|
73
|
+
"@testing-library/dom": "^10.0.0",
|
|
73
74
|
"@testing-library/jest-dom": "^6.0.0",
|
|
74
75
|
"@testing-library/react": "^16.0.0",
|
|
75
76
|
"@types/react": "^18.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-notifications",
|
|
3
|
-
"version": "0.5.21-next.
|
|
3
|
+
"version": "0.5.21-next.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "notifications",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"test": "backstage-cli package test"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@backstage/core-components": "0.18.14-next.
|
|
67
|
-
"@backstage/core-plugin-api": "1.12.
|
|
66
|
+
"@backstage/core-components": "0.18.14-next.2",
|
|
67
|
+
"@backstage/core-plugin-api": "1.12.10-next.1",
|
|
68
68
|
"@backstage/errors": "1.3.1",
|
|
69
|
-
"@backstage/frontend-plugin-api": "0.18.
|
|
70
|
-
"@backstage/plugin-notifications-common": "0.2.
|
|
71
|
-
"@backstage/plugin-signals-react": "0.0.
|
|
69
|
+
"@backstage/frontend-plugin-api": "0.18.1-next.1",
|
|
70
|
+
"@backstage/plugin-notifications-common": "0.2.4-next.0",
|
|
71
|
+
"@backstage/plugin-signals-react": "0.0.26-next.0",
|
|
72
72
|
"@backstage/theme": "0.7.3",
|
|
73
|
-
"@backstage/ui": "0.
|
|
73
|
+
"@backstage/ui": "0.18.0-next.2",
|
|
74
74
|
"@remixicon/react": ">=4.6.0 <4.9.0",
|
|
75
75
|
"lodash": "^4.17.21",
|
|
76
76
|
"notistack": "^3.0.1",
|
|
@@ -79,10 +79,11 @@
|
|
|
79
79
|
"react-use": "^17.2.4"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@backstage/cli": "0.36.6-next.
|
|
83
|
-
"@backstage/dev-utils": "1.1.27-next.
|
|
84
|
-
"@backstage/plugin-signals": "0.0.35-next.
|
|
85
|
-
"@backstage/test-utils": "1.7.22-next.
|
|
82
|
+
"@backstage/cli": "0.36.6-next.1",
|
|
83
|
+
"@backstage/dev-utils": "1.1.27-next.1",
|
|
84
|
+
"@backstage/plugin-signals": "0.0.35-next.1",
|
|
85
|
+
"@backstage/test-utils": "1.7.22-next.2",
|
|
86
|
+
"@testing-library/dom": "^10.0.0",
|
|
86
87
|
"@testing-library/jest-dom": "^6.0.0",
|
|
87
88
|
"@testing-library/react": "^16.0.0",
|
|
88
89
|
"@types/react": "^18.0.0",
|