@backstage-community/plugin-ilert 0.3.0 → 0.3.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/ILertIcon.esm.js +61 -0
  3. package/dist/ILertIcon.esm.js.map +1 -0
  4. package/dist/api/client.esm.js +395 -0
  5. package/dist/api/client.esm.js.map +1 -0
  6. package/dist/components/Alert/AlertActionsMenu.esm.js +142 -0
  7. package/dist/components/Alert/AlertActionsMenu.esm.js.map +1 -0
  8. package/dist/components/Alert/AlertAssignModal.esm.js +147 -0
  9. package/dist/components/Alert/AlertAssignModal.esm.js.map +1 -0
  10. package/dist/components/Alert/AlertLink.esm.js +15 -0
  11. package/dist/components/Alert/AlertLink.esm.js.map +1 -0
  12. package/dist/components/Alert/AlertNewModal.esm.js +192 -0
  13. package/dist/components/Alert/AlertNewModal.esm.js.map +1 -0
  14. package/dist/components/AlertSource/AlertSourceLink.esm.js +49 -0
  15. package/dist/components/AlertSource/AlertSourceLink.esm.js.map +1 -0
  16. package/dist/components/AlertsPage/AlertsPage.esm.js +67 -0
  17. package/dist/components/AlertsPage/AlertsPage.esm.js.map +1 -0
  18. package/dist/components/AlertsPage/AlertsTable.esm.js +185 -0
  19. package/dist/components/AlertsPage/AlertsTable.esm.js.map +1 -0
  20. package/dist/components/AlertsPage/StatusChip.esm.js +47 -0
  21. package/dist/components/AlertsPage/StatusChip.esm.js.map +1 -0
  22. package/dist/components/AlertsPage/TableTitle.esm.js +74 -0
  23. package/dist/components/AlertsPage/TableTitle.esm.js.map +1 -0
  24. package/dist/components/Errors/MissingAuthorizationHeaderError.esm.js +24 -0
  25. package/dist/components/Errors/MissingAuthorizationHeaderError.esm.js.map +1 -0
  26. package/dist/components/ILertCard/ILertCard.esm.js +113 -0
  27. package/dist/components/ILertCard/ILertCard.esm.js.map +1 -0
  28. package/dist/components/ILertCard/ILertCardActionsHeader.esm.js +138 -0
  29. package/dist/components/ILertCard/ILertCardActionsHeader.esm.js.map +1 -0
  30. package/dist/components/ILertCard/ILertCardEmptyState.esm.js +57 -0
  31. package/dist/components/ILertCard/ILertCardEmptyState.esm.js.map +1 -0
  32. package/dist/components/ILertCard/ILertCardHeaderStatus.esm.js +29 -0
  33. package/dist/components/ILertCard/ILertCardHeaderStatus.esm.js.map +1 -0
  34. package/dist/components/ILertCard/ILertCardMaintenanceModal.esm.js +101 -0
  35. package/dist/components/ILertCard/ILertCardMaintenanceModal.esm.js.map +1 -0
  36. package/dist/components/ILertCard/ILertCardOnCall.esm.js +78 -0
  37. package/dist/components/ILertCard/ILertCardOnCall.esm.js.map +1 -0
  38. package/dist/components/ILertCard/ILertCardOnCallEmptyState.esm.js +26 -0
  39. package/dist/components/ILertCard/ILertCardOnCallEmptyState.esm.js.map +1 -0
  40. package/dist/components/ILertCard/ILertCardOnCallItem.esm.js +109 -0
  41. package/dist/components/ILertCard/ILertCardOnCallItem.esm.js.map +1 -0
  42. package/dist/components/ILertCard/index.esm.js +2 -0
  43. package/dist/components/ILertCard/index.esm.js.map +1 -0
  44. package/dist/components/ILertPage/ILertPage.esm.js +48 -0
  45. package/dist/components/ILertPage/ILertPage.esm.js.map +1 -0
  46. package/dist/components/OnCallSchedulesPage/OnCallSchedulesGrid.esm.js +135 -0
  47. package/dist/components/OnCallSchedulesPage/OnCallSchedulesGrid.esm.js.map +1 -0
  48. package/dist/components/OnCallSchedulesPage/OnCallSchedulesPage.esm.js +27 -0
  49. package/dist/components/OnCallSchedulesPage/OnCallSchedulesPage.esm.js.map +1 -0
  50. package/dist/components/OnCallSchedulesPage/OnCallShiftItem.esm.js +63 -0
  51. package/dist/components/OnCallSchedulesPage/OnCallShiftItem.esm.js.map +1 -0
  52. package/dist/components/Service/ServiceActionsMenu.esm.js +47 -0
  53. package/dist/components/Service/ServiceActionsMenu.esm.js.map +1 -0
  54. package/dist/components/Service/ServiceLink.esm.js +15 -0
  55. package/dist/components/Service/ServiceLink.esm.js.map +1 -0
  56. package/dist/components/ServicesPage/ServicesPage.esm.js +32 -0
  57. package/dist/components/ServicesPage/ServicesPage.esm.js.map +1 -0
  58. package/dist/components/ServicesPage/ServicesTable.esm.js +99 -0
  59. package/dist/components/ServicesPage/ServicesTable.esm.js.map +1 -0
  60. package/dist/components/ServicesPage/StatusChip.esm.js +67 -0
  61. package/dist/components/ServicesPage/StatusChip.esm.js.map +1 -0
  62. package/dist/components/Shift/ShiftOverrideModal.esm.js +171 -0
  63. package/dist/components/Shift/ShiftOverrideModal.esm.js.map +1 -0
  64. package/dist/components/StatusPage/StatusPageActionsMenu.esm.js +50 -0
  65. package/dist/components/StatusPage/StatusPageActionsMenu.esm.js.map +1 -0
  66. package/dist/components/StatusPage/StatusPageLink.esm.js +17 -0
  67. package/dist/components/StatusPage/StatusPageLink.esm.js.map +1 -0
  68. package/dist/components/StatusPage/StatusPageURL.esm.js +18 -0
  69. package/dist/components/StatusPage/StatusPageURL.esm.js.map +1 -0
  70. package/dist/components/StatusPagePage/StatusChip.esm.js +67 -0
  71. package/dist/components/StatusPagePage/StatusChip.esm.js.map +1 -0
  72. package/dist/components/StatusPagePage/StatusPagesPage.esm.js +32 -0
  73. package/dist/components/StatusPagePage/StatusPagesPage.esm.js.map +1 -0
  74. package/dist/components/StatusPagePage/StatusPagesTable.esm.js +115 -0
  75. package/dist/components/StatusPagePage/StatusPagesTable.esm.js.map +1 -0
  76. package/dist/components/StatusPagePage/VisibilityChip.esm.js +37 -0
  77. package/dist/components/StatusPagePage/VisibilityChip.esm.js.map +1 -0
  78. package/dist/components/index.esm.js +3 -0
  79. package/dist/components/index.esm.js.map +1 -0
  80. package/dist/constants.esm.js +4 -0
  81. package/dist/constants.esm.js.map +1 -0
  82. package/dist/hooks/index.esm.js +13 -0
  83. package/dist/hooks/index.esm.js.map +1 -0
  84. package/dist/hooks/useAlertActions.esm.js +43 -0
  85. package/dist/hooks/useAlertActions.esm.js.map +1 -0
  86. package/dist/hooks/useAlertSource.esm.js +52 -0
  87. package/dist/hooks/useAlertSource.esm.js.map +1 -0
  88. package/dist/hooks/useAlertSourceOnCalls.esm.js +47 -0
  89. package/dist/hooks/useAlertSourceOnCalls.esm.js.map +1 -0
  90. package/dist/hooks/useAlerts.esm.js +128 -0
  91. package/dist/hooks/useAlerts.esm.js.map +1 -0
  92. package/dist/hooks/useAssignAlert.esm.js +53 -0
  93. package/dist/hooks/useAssignAlert.esm.js.map +1 -0
  94. package/dist/hooks/useNewAlert.esm.js +58 -0
  95. package/dist/hooks/useNewAlert.esm.js.map +1 -0
  96. package/dist/hooks/useOnCallSchedules.esm.js +42 -0
  97. package/dist/hooks/useOnCallSchedules.esm.js.map +1 -0
  98. package/dist/hooks/useServices.esm.js +70 -0
  99. package/dist/hooks/useServices.esm.js.map +1 -0
  100. package/dist/hooks/useShiftOverride.esm.js +60 -0
  101. package/dist/hooks/useShiftOverride.esm.js.map +1 -0
  102. package/dist/hooks/useStatusPages.esm.js +72 -0
  103. package/dist/hooks/useStatusPages.esm.js.map +1 -0
  104. package/dist/index.esm.js +7 -3346
  105. package/dist/index.esm.js.map +1 -1
  106. package/dist/plugin.esm.js +39 -0
  107. package/dist/plugin.esm.js.map +1 -0
  108. package/dist/route-refs.esm.js +8 -0
  109. package/dist/route-refs.esm.js.map +1 -0
  110. package/dist/types.esm.js +13 -0
  111. package/dist/types.esm.js.map +1 -0
  112. package/package.json +12 -8
  113. package/dist/esm/index-D2_Gjvjx.esm.js +0 -58
  114. package/dist/esm/index-D2_Gjvjx.esm.js.map +0 -1
  115. package/dist/esm/index-aory7UQN.esm.js +0 -58
  116. package/dist/esm/index-aory7UQN.esm.js.map +0 -1
@@ -0,0 +1,37 @@
1
+ import Chip from '@material-ui/core/Chip';
2
+ import { withStyles } from '@material-ui/core/styles';
3
+ import React from 'react';
4
+ import { PUBLIC, PRIVATE } from '../../types.esm.js';
5
+
6
+ const PrivateChip = withStyles((theme) => ({
7
+ root: {
8
+ backgroundColor: "#4caf50",
9
+ color: theme.palette.common.white,
10
+ margin: 0
11
+ }
12
+ }))(Chip);
13
+ const PublicChip = withStyles((theme) => ({
14
+ root: {
15
+ backgroundColor: "#ffb74d",
16
+ color: theme.palette.common.white,
17
+ margin: 0
18
+ }
19
+ }))(Chip);
20
+ const statusPageVisibilityLabels = {
21
+ [PUBLIC]: "Public",
22
+ [PRIVATE]: "Private"
23
+ };
24
+ const VisibilityChip = ({ statusPage }) => {
25
+ const label = `${statusPageVisibilityLabels[statusPage.visibility]}`;
26
+ switch (statusPage.visibility) {
27
+ case PRIVATE:
28
+ return /* @__PURE__ */ React.createElement(PrivateChip, { label, size: "small" });
29
+ case PUBLIC:
30
+ return /* @__PURE__ */ React.createElement(PublicChip, { label, size: "small" });
31
+ default:
32
+ return /* @__PURE__ */ React.createElement(Chip, { label, size: "small" });
33
+ }
34
+ };
35
+
36
+ export { VisibilityChip };
37
+ //# sourceMappingURL=VisibilityChip.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VisibilityChip.esm.js","sources":["../../../src/components/StatusPagePage/VisibilityChip.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 Chip from '@material-ui/core/Chip';\nimport { withStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport { PRIVATE, PUBLIC, StatusPage } from '../../types';\n\nconst PrivateChip = withStyles(theme => ({\n root: {\n backgroundColor: '#4caf50',\n color: theme.palette.common.white,\n margin: 0,\n },\n}))(Chip);\n\nconst PublicChip = withStyles(theme => ({\n root: {\n backgroundColor: '#ffb74d',\n color: theme.palette.common.white,\n margin: 0,\n },\n}))(Chip);\n\nconst statusPageVisibilityLabels = {\n [PUBLIC]: 'Public',\n [PRIVATE]: 'Private',\n} as Record<string, string>;\n\nexport const VisibilityChip = ({ statusPage }: { statusPage: StatusPage }) => {\n const label = `${statusPageVisibilityLabels[statusPage.visibility]}`;\n\n switch (statusPage.visibility) {\n case PRIVATE:\n return <PrivateChip label={label} size=\"small\" />;\n case PUBLIC:\n return <PublicChip label={label} size=\"small\" />;\n default:\n return <Chip label={label} size=\"small\" />;\n }\n};\n"],"names":[],"mappings":";;;;;AAoBA,MAAM,WAAA,GAAc,WAAW,CAAU,KAAA,MAAA;AAAA,EACvC,IAAM,EAAA;AAAA,IACJ,eAAiB,EAAA,SAAA;AAAA,IACjB,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,IAC5B,MAAQ,EAAA,CAAA;AAAA,GACV;AACF,CAAA,CAAE,EAAE,IAAI,CAAA,CAAA;AAER,MAAM,UAAA,GAAa,WAAW,CAAU,KAAA,MAAA;AAAA,EACtC,IAAM,EAAA;AAAA,IACJ,eAAiB,EAAA,SAAA;AAAA,IACjB,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,IAC5B,MAAQ,EAAA,CAAA;AAAA,GACV;AACF,CAAA,CAAE,EAAE,IAAI,CAAA,CAAA;AAER,MAAM,0BAA6B,GAAA;AAAA,EACjC,CAAC,MAAM,GAAG,QAAA;AAAA,EACV,CAAC,OAAO,GAAG,SAAA;AACb,CAAA,CAAA;AAEO,MAAM,cAAiB,GAAA,CAAC,EAAE,UAAA,EAA6C,KAAA;AAC5E,EAAA,MAAM,KAAQ,GAAA,CAAA,EAAG,0BAA2B,CAAA,UAAA,CAAW,UAAU,CAAC,CAAA,CAAA,CAAA;AAElE,EAAA,QAAQ,WAAW,UAAY;AAAA,IAC7B,KAAK,OAAA;AACH,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,KAAc,EAAA,IAAA,EAAK,OAAQ,EAAA,CAAA,CAAA;AAAA,IACjD,KAAK,MAAA;AACH,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,KAAc,EAAA,IAAA,EAAK,OAAQ,EAAA,CAAA,CAAA;AAAA,IAChD;AACE,MAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,KAAc,EAAA,IAAA,EAAK,OAAQ,EAAA,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
@@ -0,0 +1,3 @@
1
+ export { ILertPage } from './ILertPage/ILertPage.esm.js';
2
+ export { ILertCard, isPluginApplicableToEntity } from './ILertCard/ILertCard.esm.js';
3
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,4 @@
1
+ const ILERT_INTEGRATION_KEY_ANNOTATION = "ilert.com/integration-key";
2
+
3
+ export { ILERT_INTEGRATION_KEY_ANNOTATION };
4
+ //# sourceMappingURL=constants.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.esm.js","sources":["../src/constants.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\nexport const ILERT_INTEGRATION_KEY_ANNOTATION = 'ilert.com/integration-key';\n"],"names":[],"mappings":"AAeO,MAAM,gCAAmC,GAAA;;;;"}
@@ -0,0 +1,13 @@
1
+ import { useEntity } from '@backstage/plugin-catalog-react';
2
+ import { ILERT_INTEGRATION_KEY_ANNOTATION } from '../constants.esm.js';
3
+
4
+ function useILertEntity() {
5
+ const { entity } = useEntity();
6
+ const integrationKey = entity.metadata.annotations?.[ILERT_INTEGRATION_KEY_ANNOTATION] || "";
7
+ const name = entity.metadata.name;
8
+ const identifier = `${entity.kind}:${entity.metadata.namespace || "default"}/${entity.metadata.name}`;
9
+ return { integrationKey, name, identifier };
10
+ }
11
+
12
+ export { useILertEntity };
13
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/hooks/index.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { useEntity } from '@backstage/plugin-catalog-react';\n\nimport { ILERT_INTEGRATION_KEY_ANNOTATION } from '../constants';\n\nexport function useILertEntity() {\n const { entity } = useEntity();\n const integrationKey =\n entity.metadata.annotations?.[ILERT_INTEGRATION_KEY_ANNOTATION] || '';\n const name = entity.metadata.name;\n const identifier = `${entity.kind}:${\n entity.metadata.namespace || 'default'\n }/${entity.metadata.name}`;\n\n return { integrationKey, name, identifier };\n}\n"],"names":[],"mappings":";;;AAoBO,SAAS,cAAiB,GAAA;AAC/B,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAA,MAAM,cACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,gCAAgC,CAAK,IAAA,EAAA,CAAA;AACrE,EAAM,MAAA,IAAA,GAAO,OAAO,QAAS,CAAA,IAAA,CAAA;AAC7B,EAAA,MAAM,UAAa,GAAA,CAAA,EAAG,MAAO,CAAA,IAAI,CAC/B,CAAA,EAAA,MAAA,CAAO,QAAS,CAAA,SAAA,IAAa,SAC/B,CAAA,CAAA,EAAI,MAAO,CAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA;AAExB,EAAO,OAAA,EAAE,cAAgB,EAAA,IAAA,EAAM,UAAW,EAAA,CAAA;AAC5C;;;;"}
@@ -0,0 +1,43 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+
7
+ const useAlertActions = (alert, open) => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [alertActionsList, setAlertActionsList] = React.useState(
11
+ []
12
+ );
13
+ const [isLoading, setIsLoading] = React.useState(false);
14
+ const { error, retry } = useAsyncRetry(async () => {
15
+ try {
16
+ if (!alert || !open) {
17
+ return;
18
+ }
19
+ const data = await ilertApi.fetchAlertActions(alert);
20
+ setAlertActionsList(data);
21
+ } catch (e) {
22
+ if (!(e instanceof AuthenticationError)) {
23
+ errorApi.post(e);
24
+ }
25
+ throw e;
26
+ }
27
+ }, [alert, open]);
28
+ return [
29
+ {
30
+ alertActions: alertActionsList,
31
+ error,
32
+ isLoading
33
+ },
34
+ {
35
+ setAlertActionsList,
36
+ setIsLoading,
37
+ retry
38
+ }
39
+ ];
40
+ };
41
+
42
+ export { useAlertActions };
43
+ //# sourceMappingURL=useAlertActions.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlertActions.esm.js","sources":["../../src/hooks/useAlertActions.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ilertApiRef } from '../api';\nimport { Alert, AlertAction } from '../types';\n\nexport const useAlertActions = (alert: Alert | null, open: boolean) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [alertActionsList, setAlertActionsList] = React.useState<AlertAction[]>(\n [],\n );\n const [isLoading, setIsLoading] = React.useState(false);\n\n const { error, retry } = useAsyncRetry(async () => {\n try {\n if (!alert || !open) {\n return;\n }\n const data = await ilertApi.fetchAlertActions(alert);\n setAlertActionsList(data);\n } catch (e) {\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n }, [alert, open]);\n\n return [\n {\n alertActions: alertActionsList,\n error,\n isLoading,\n },\n {\n setAlertActionsList,\n setIsLoading,\n retry,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,eAAA,GAAkB,CAAC,KAAA,EAAqB,IAAkB,KAAA;AACrE,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,KAAM,CAAA,QAAA;AAAA,IACpD,EAAC;AAAA,GACH,CAAA;AACA,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAEtD,EAAA,MAAM,EAAE,KAAA,EAAO,KAAM,EAAA,GAAI,cAAc,YAAY;AACjD,IAAI,IAAA;AACF,MAAI,IAAA,CAAC,KAAS,IAAA,CAAC,IAAM,EAAA;AACnB,QAAA,OAAA;AAAA,OACF;AACA,MAAA,MAAM,IAAO,GAAA,MAAM,QAAS,CAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AACnD,MAAA,mBAAA,CAAoB,IAAI,CAAA,CAAA;AAAA,aACjB,CAAG,EAAA;AACV,MAAI,IAAA,EAAE,aAAa,mBAAsB,CAAA,EAAA;AACvC,QAAA,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA;AAAA,OACjB;AACA,MAAM,MAAA,CAAA,CAAA;AAAA,KACR;AAAA,GACC,EAAA,CAAC,KAAO,EAAA,IAAI,CAAC,CAAA,CAAA;AAEhB,EAAO,OAAA;AAAA,IACL;AAAA,MACE,YAAc,EAAA,gBAAA;AAAA,MACd,KAAA;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACA;AAAA,MACE,mBAAA;AAAA,MACA,YAAA;AAAA,MACA,KAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,52 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+
7
+ const useAlertSource = (integrationKey) => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [alertSource, setAlertSource] = React.useState(
11
+ null
12
+ );
13
+ const [isAlertSourceLoading, setIsAlertSourceLoading] = React.useState(false);
14
+ const fetchAlertSourceCall = async () => {
15
+ try {
16
+ if (!integrationKey) {
17
+ return;
18
+ }
19
+ setIsAlertSourceLoading(true);
20
+ const data = await ilertApi.fetchAlertSource(integrationKey);
21
+ setAlertSource(data || null);
22
+ setIsAlertSourceLoading(false);
23
+ } catch (e) {
24
+ setIsAlertSourceLoading(false);
25
+ if (!(e instanceof AuthenticationError)) {
26
+ errorApi.post(e);
27
+ }
28
+ throw e;
29
+ }
30
+ };
31
+ const { error: alertSourceError, retry: alertSourceRetry } = useAsyncRetry(
32
+ fetchAlertSourceCall,
33
+ [integrationKey]
34
+ );
35
+ const retry = () => alertSourceRetry();
36
+ return [
37
+ {
38
+ alertSource,
39
+ error: alertSourceError,
40
+ isLoading: isAlertSourceLoading
41
+ },
42
+ {
43
+ retry,
44
+ setIsLoading: setIsAlertSourceLoading,
45
+ refetchAlertSource: fetchAlertSourceCall,
46
+ setAlertSource
47
+ }
48
+ ];
49
+ };
50
+
51
+ export { useAlertSource };
52
+ //# sourceMappingURL=useAlertSource.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlertSource.esm.js","sources":["../../src/hooks/useAlertSource.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ilertApiRef } from '../api';\nimport { AlertSource } from '../types';\n\nexport const useAlertSource = (integrationKey: string) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [alertSource, setAlertSource] = React.useState<AlertSource | null>(\n null,\n );\n const [isAlertSourceLoading, setIsAlertSourceLoading] = React.useState(false);\n\n const fetchAlertSourceCall = async () => {\n try {\n if (!integrationKey) {\n return;\n }\n setIsAlertSourceLoading(true);\n const data = await ilertApi.fetchAlertSource(integrationKey);\n setAlertSource(data || null);\n setIsAlertSourceLoading(false);\n } catch (e) {\n setIsAlertSourceLoading(false);\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n };\n\n const { error: alertSourceError, retry: alertSourceRetry } = useAsyncRetry(\n fetchAlertSourceCall,\n [integrationKey],\n );\n\n const retry = () => alertSourceRetry();\n\n return [\n {\n alertSource,\n error: alertSourceError,\n isLoading: isAlertSourceLoading,\n },\n {\n retry,\n setIsLoading: setIsAlertSourceLoading,\n refetchAlertSource: fetchAlertSourceCall,\n setAlertSource,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,cAAA,GAAiB,CAAC,cAA2B,KAAA;AACxD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,KAAM,CAAA,QAAA;AAAA,IAC1C,IAAA;AAAA,GACF,CAAA;AACA,EAAA,MAAM,CAAC,oBAAsB,EAAA,uBAAuB,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAE5E,EAAA,MAAM,uBAAuB,YAAY;AACvC,IAAI,IAAA;AACF,MAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,QAAA,OAAA;AAAA,OACF;AACA,MAAA,uBAAA,CAAwB,IAAI,CAAA,CAAA;AAC5B,MAAA,MAAM,IAAO,GAAA,MAAM,QAAS,CAAA,gBAAA,CAAiB,cAAc,CAAA,CAAA;AAC3D,MAAA,cAAA,CAAe,QAAQ,IAAI,CAAA,CAAA;AAC3B,MAAA,uBAAA,CAAwB,KAAK,CAAA,CAAA;AAAA,aACtB,CAAG,EAAA;AACV,MAAA,uBAAA,CAAwB,KAAK,CAAA,CAAA;AAC7B,MAAI,IAAA,EAAE,aAAa,mBAAsB,CAAA,EAAA;AACvC,QAAA,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA;AAAA,OACjB;AACA,MAAM,MAAA,CAAA,CAAA;AAAA,KACR;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,EAAE,KAAA,EAAO,gBAAkB,EAAA,KAAA,EAAO,kBAAqB,GAAA,aAAA;AAAA,IAC3D,oBAAA;AAAA,IACA,CAAC,cAAc,CAAA;AAAA,GACjB,CAAA;AAEA,EAAM,MAAA,KAAA,GAAQ,MAAM,gBAAiB,EAAA,CAAA;AAErC,EAAO,OAAA;AAAA,IACL;AAAA,MACE,WAAA;AAAA,MACA,KAAO,EAAA,gBAAA;AAAA,MACP,SAAW,EAAA,oBAAA;AAAA,KACb;AAAA,IACA;AAAA,MACE,KAAA;AAAA,MACA,YAAc,EAAA,uBAAA;AAAA,MACd,kBAAoB,EAAA,oBAAA;AAAA,MACpB,cAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,47 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+
7
+ const useAlertSourceOnCalls = (alertSource) => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [onCallsList, setOnCallsList] = React.useState([]);
11
+ const [isLoading, setIsLoading] = React.useState(false);
12
+ const fetchAlertSourceOnCallsCall = async () => {
13
+ try {
14
+ if (!alertSource) {
15
+ return;
16
+ }
17
+ setIsLoading(true);
18
+ const data = await ilertApi.fetchAlertSourceOnCalls(alertSource);
19
+ setOnCallsList(data || []);
20
+ setIsLoading(false);
21
+ } catch (e) {
22
+ setIsLoading(false);
23
+ if (!(e instanceof AuthenticationError)) {
24
+ errorApi.post(e);
25
+ }
26
+ throw e;
27
+ }
28
+ };
29
+ const { error, retry } = useAsyncRetry(fetchAlertSourceOnCallsCall, [
30
+ alertSource
31
+ ]);
32
+ return [
33
+ {
34
+ onCalls: onCallsList,
35
+ error,
36
+ isLoading
37
+ },
38
+ {
39
+ retry,
40
+ setIsLoading,
41
+ refetchAlertSourceOnCalls: fetchAlertSourceOnCallsCall
42
+ }
43
+ ];
44
+ };
45
+
46
+ export { useAlertSourceOnCalls };
47
+ //# sourceMappingURL=useAlertSourceOnCalls.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlertSourceOnCalls.esm.js","sources":["../../src/hooks/useAlertSourceOnCalls.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ilertApiRef } from '../api';\nimport { AlertSource, OnCall } from '../types';\n\nexport const useAlertSourceOnCalls = (alertSource?: AlertSource | null) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [onCallsList, setOnCallsList] = React.useState<OnCall[]>([]);\n const [isLoading, setIsLoading] = React.useState(false);\n\n const fetchAlertSourceOnCallsCall = async () => {\n try {\n if (!alertSource) {\n return;\n }\n setIsLoading(true);\n const data = await ilertApi.fetchAlertSourceOnCalls(alertSource);\n setOnCallsList(data || []);\n setIsLoading(false);\n } catch (e) {\n setIsLoading(false);\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n };\n\n const { error, retry } = useAsyncRetry(fetchAlertSourceOnCallsCall, [\n alertSource,\n ]);\n\n return [\n {\n onCalls: onCallsList,\n error,\n isLoading,\n },\n {\n retry,\n setIsLoading,\n refetchAlertSourceOnCalls: fetchAlertSourceOnCallsCall,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,qBAAA,GAAwB,CAAC,WAAqC,KAAA;AACzE,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAA,MAAM,CAAC,WAAa,EAAA,cAAc,IAAI,KAAM,CAAA,QAAA,CAAmB,EAAE,CAAA,CAAA;AACjE,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAS,KAAK,CAAA,CAAA;AAEtD,EAAA,MAAM,8BAA8B,YAAY;AAC9C,IAAI,IAAA;AACF,MAAA,IAAI,CAAC,WAAa,EAAA;AAChB,QAAA,OAAA;AAAA,OACF;AACA,MAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AACjB,MAAA,MAAM,IAAO,GAAA,MAAM,QAAS,CAAA,uBAAA,CAAwB,WAAW,CAAA,CAAA;AAC/D,MAAe,cAAA,CAAA,IAAA,IAAQ,EAAE,CAAA,CAAA;AACzB,MAAA,YAAA,CAAa,KAAK,CAAA,CAAA;AAAA,aACX,CAAG,EAAA;AACV,MAAA,YAAA,CAAa,KAAK,CAAA,CAAA;AAClB,MAAI,IAAA,EAAE,aAAa,mBAAsB,CAAA,EAAA;AACvC,QAAA,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA;AAAA,OACjB;AACA,MAAM,MAAA,CAAA,CAAA;AAAA,KACR;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,EAAE,KAAA,EAAO,KAAM,EAAA,GAAI,cAAc,2BAA6B,EAAA;AAAA,IAClE,WAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL;AAAA,MACE,OAAS,EAAA,WAAA;AAAA,MACT,KAAA;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACA;AAAA,MACE,KAAA;AAAA,MACA,YAAA;AAAA,MACA,yBAA2B,EAAA,2BAAA;AAAA,KAC7B;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,128 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+ import { ACCEPTED, PENDING } from '../types.esm.js';
7
+
8
+ const useAlerts = (paging, singleSource, alertSource) => {
9
+ const ilertApi = useApi(ilertApiRef);
10
+ const errorApi = useApi(errorApiRef);
11
+ const [tableState, setTableState] = React.useState({
12
+ page: 0,
13
+ pageSize: 10
14
+ });
15
+ const [states, setStates] = React.useState([
16
+ ACCEPTED,
17
+ PENDING
18
+ ]);
19
+ const [alertsList, setAlertsList] = React.useState([]);
20
+ const [alertsCount, setAlertsCount] = React.useState(0);
21
+ const [isLoading, setIsLoading] = React.useState(false);
22
+ const fetchAlertsCall = async () => {
23
+ try {
24
+ if (singleSource && !alertSource) {
25
+ return;
26
+ }
27
+ setIsLoading(true);
28
+ const opts = {
29
+ states,
30
+ alertSources: alertSource ? [alertSource.id] : []
31
+ };
32
+ if (paging) {
33
+ opts.maxResults = tableState.pageSize;
34
+ opts.startIndex = tableState.page * tableState.pageSize;
35
+ }
36
+ const data = await ilertApi.fetchAlerts(opts);
37
+ setAlertsList(data || []);
38
+ setIsLoading(false);
39
+ } catch (e) {
40
+ if (!(e instanceof AuthenticationError)) {
41
+ errorApi.post(e);
42
+ }
43
+ setIsLoading(false);
44
+ throw e;
45
+ }
46
+ };
47
+ const fetchAlertsCountCall = async () => {
48
+ try {
49
+ const count = await ilertApi.fetchAlertsCount({ states });
50
+ setAlertsCount(count || 0);
51
+ } catch (e) {
52
+ if (!(e instanceof AuthenticationError)) {
53
+ errorApi.post(e);
54
+ }
55
+ throw e;
56
+ }
57
+ };
58
+ const fetchAlerts = useAsyncRetry(fetchAlertsCall, [
59
+ tableState,
60
+ states,
61
+ singleSource,
62
+ alertSource
63
+ ]);
64
+ const refetchAlerts = () => {
65
+ setTableState({ ...tableState, page: 0 });
66
+ Promise.all([fetchAlertsCall(), fetchAlertsCountCall()]);
67
+ };
68
+ const fetchAlertsCount = useAsyncRetry(fetchAlertsCountCall, [states]);
69
+ const error = fetchAlerts.error || fetchAlertsCount.error;
70
+ const retry = () => {
71
+ fetchAlerts.retry();
72
+ fetchAlertsCount.retry();
73
+ };
74
+ const onAlertChanged = (newAlert) => {
75
+ let shouldRefetchAlerts = false;
76
+ setAlertsList(
77
+ alertsList.reduce((acc, alert) => {
78
+ if (newAlert.id === alert.id) {
79
+ if (states.includes(newAlert.status)) {
80
+ acc.push(newAlert);
81
+ } else {
82
+ shouldRefetchAlerts = true;
83
+ }
84
+ return acc;
85
+ }
86
+ acc.push(alert);
87
+ return acc;
88
+ }, [])
89
+ );
90
+ if (shouldRefetchAlerts) {
91
+ refetchAlerts();
92
+ }
93
+ };
94
+ const onChangePage = (page) => {
95
+ setTableState({ ...tableState, page });
96
+ };
97
+ const onChangeRowsPerPage = (p) => {
98
+ setTableState({ ...tableState, pageSize: p });
99
+ };
100
+ const onAlertStatesChange = (s) => {
101
+ setStates(s);
102
+ };
103
+ return [
104
+ {
105
+ tableState,
106
+ states,
107
+ alerts: alertsList,
108
+ alertsCount,
109
+ error,
110
+ isLoading
111
+ },
112
+ {
113
+ setTableState,
114
+ setStates,
115
+ setAlertsList,
116
+ setIsLoading,
117
+ retry,
118
+ onAlertChanged,
119
+ refetchAlerts,
120
+ onChangePage,
121
+ onChangeRowsPerPage,
122
+ onAlertStatesChange
123
+ }
124
+ ];
125
+ };
126
+
127
+ export { useAlerts };
128
+ //# sourceMappingURL=useAlerts.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlerts.esm.js","sources":["../../src/hooks/useAlerts.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { GetAlertsOpts, ilertApiRef, TableState } from '../api';\nimport { ACCEPTED, Alert, AlertSource, AlertStatus, PENDING } from '../types';\n\nexport const useAlerts = (\n paging: boolean,\n singleSource?: boolean,\n alertSource?: AlertSource | null,\n) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [tableState, setTableState] = React.useState<TableState>({\n page: 0,\n pageSize: 10,\n });\n const [states, setStates] = React.useState<AlertStatus[]>([\n ACCEPTED,\n PENDING,\n ]);\n const [alertsList, setAlertsList] = React.useState<Alert[]>([]);\n const [alertsCount, setAlertsCount] = React.useState(0);\n const [isLoading, setIsLoading] = React.useState(false);\n\n const fetchAlertsCall = async () => {\n try {\n if (singleSource && !alertSource) {\n return;\n }\n setIsLoading(true);\n const opts: GetAlertsOpts = {\n states,\n alertSources: alertSource ? [alertSource.id] : [],\n };\n if (paging) {\n opts.maxResults = tableState.pageSize;\n opts.startIndex = tableState.page * tableState.pageSize;\n }\n const data = await ilertApi.fetchAlerts(opts);\n setAlertsList(data || []);\n setIsLoading(false);\n } catch (e) {\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n setIsLoading(false);\n throw e;\n }\n };\n\n const fetchAlertsCountCall = async () => {\n try {\n const count = await ilertApi.fetchAlertsCount({ states });\n setAlertsCount(count || 0);\n } catch (e) {\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n };\n const fetchAlerts = useAsyncRetry(fetchAlertsCall, [\n tableState,\n states,\n singleSource,\n alertSource,\n ]);\n\n const refetchAlerts = () => {\n setTableState({ ...tableState, page: 0 });\n Promise.all([fetchAlertsCall(), fetchAlertsCountCall()]);\n };\n\n const fetchAlertsCount = useAsyncRetry(fetchAlertsCountCall, [states]);\n\n const error = fetchAlerts.error || fetchAlertsCount.error;\n const retry = () => {\n fetchAlerts.retry();\n fetchAlertsCount.retry();\n };\n\n const onAlertChanged = (newAlert: Alert) => {\n let shouldRefetchAlerts = false;\n setAlertsList(\n alertsList.reduce((acc: Alert[], alert: Alert) => {\n if (newAlert.id === alert.id) {\n if (states.includes(newAlert.status)) {\n acc.push(newAlert);\n } else {\n shouldRefetchAlerts = true;\n }\n return acc;\n }\n acc.push(alert);\n return acc;\n }, []),\n );\n if (shouldRefetchAlerts) {\n refetchAlerts();\n }\n };\n\n const onChangePage = (page: number) => {\n setTableState({ ...tableState, page });\n };\n const onChangeRowsPerPage = (p: number) => {\n setTableState({ ...tableState, pageSize: p });\n };\n const onAlertStatesChange = (s: AlertStatus[]) => {\n setStates(s);\n };\n\n return [\n {\n tableState,\n states,\n alerts: alertsList,\n alertsCount,\n error,\n isLoading,\n },\n {\n setTableState,\n setStates,\n setAlertsList,\n setIsLoading,\n retry,\n onAlertChanged,\n refetchAlerts,\n onChangePage,\n onChangeRowsPerPage,\n onAlertStatesChange,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;;AAsBO,MAAM,SAAY,GAAA,CACvB,MACA,EAAA,YAAA,EACA,WACG,KAAA;AACH,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AAEnC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,MAAM,QAAqB,CAAA;AAAA,IAC7D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AA;AAAA,MACA,YAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MACA,mBAAA;AAAA,MACA,mBAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,53 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+
7
+ const useAssignAlert = (alert, open) => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [alertRespondersList, setAlertRespondersList] = React.useState([]);
11
+ const [alertResponder, setAlertResponder] = React.useState(null);
12
+ const [isLoading, setIsLoading] = React.useState(false);
13
+ const { error, retry } = useAsyncRetry(async () => {
14
+ try {
15
+ if (!alert || !open) {
16
+ return;
17
+ }
18
+ const data = await ilertApi.fetchAlertResponders(alert);
19
+ if (data && Array.isArray(data)) {
20
+ const groups = [
21
+ "SUGGESTED",
22
+ "USER",
23
+ "ESCALATION_POLICY",
24
+ "ON_CALL_SCHEDULE"
25
+ ];
26
+ data.sort((a, b) => groups.indexOf(a.group) - groups.indexOf(b.group));
27
+ setAlertRespondersList(data);
28
+ }
29
+ } catch (e) {
30
+ if (!(e instanceof AuthenticationError)) {
31
+ errorApi.post(e);
32
+ }
33
+ throw e;
34
+ }
35
+ }, [alert, open]);
36
+ return [
37
+ {
38
+ alertRespondersList,
39
+ alertResponder,
40
+ error,
41
+ isLoading
42
+ },
43
+ {
44
+ setAlertRespondersList,
45
+ setAlertResponder,
46
+ setIsLoading,
47
+ retry
48
+ }
49
+ ];
50
+ };
51
+
52
+ export { useAssignAlert };
53
+ //# sourceMappingURL=useAssignAlert.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAssignAlert.esm.js","sources":["../../src/hooks/useAssignAlert.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ilertApiRef } from '../api';\nimport { Alert, AlertResponder } from '../types';\n\nexport const useAssignAlert = (alert: Alert | null, open: boolean) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [alertRespondersList, setAlertRespondersList] = React.useState<\n AlertResponder[]\n >([]);\n const [alertResponder, setAlertResponder] =\n React.useState<AlertResponder | null>(null);\n const [isLoading, setIsLoading] = React.useState(false);\n\n const { error, retry } = useAsyncRetry(async () => {\n try {\n if (!alert || !open) {\n return;\n }\n const data = await ilertApi.fetchAlertResponders(alert);\n if (data && Array.isArray(data)) {\n const groups = [\n 'SUGGESTED',\n 'USER',\n 'ESCALATION_POLICY',\n 'ON_CALL_SCHEDULE',\n ];\n data.sort((a, b) => groups.indexOf(a.group) - groups.indexOf(b.group));\n setAlertRespondersList(data);\n }\n } catch (e) {\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n }, [alert, open]);\n\n return [\n {\n alertRespondersList,\n alertResponder,\n error,\n isLoading,\n },\n {\n setAlertRespondersList,\n setAlertResponder,\n setIsLoading,\n retry,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,cAAA,GAAiB,CAAC,KAAA,EAAqB,IAAkB,KAAA;AACpE,EAAM,MAAA,QAAA,GAAW,OAAO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AAO,EAAA,IAAI,CAAC,CAAA,CAAA;AAEhB,EAAO,OAAA;AAAA,IACL;AAAA,MACE,mBAAA;AAAA,MACA,cAAA;AAAA,MACA,KAAA;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACA;AAAA,MACE,sBAAA;AAAA,MACA,iBAAA;AAAA,MACA,YAAA;AAAA,MACA,KAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,58 @@
1
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
2
+ import { AuthenticationError } from '@backstage/errors';
3
+ import React from 'react';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { ilertApiRef } from '../api/client.esm.js';
6
+
7
+ const useNewAlert = (open, initialAlertSource) => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [alertSourcesList, setAlertSourcesList] = React.useState(
11
+ []
12
+ );
13
+ const [alertSource, setAlertSource] = React.useState(
14
+ null
15
+ );
16
+ const [summary, setSummary] = React.useState("");
17
+ const [details, setDetails] = React.useState("");
18
+ const [isLoading, setIsLoading] = React.useState(false);
19
+ const fetchAlertSources = useAsyncRetry(async () => {
20
+ try {
21
+ if (!open || initialAlertSource) {
22
+ return;
23
+ }
24
+ const count = await ilertApi.fetchAlertSources();
25
+ setAlertSourcesList(count || 0);
26
+ } catch (e) {
27
+ if (!(e instanceof AuthenticationError)) {
28
+ errorApi.post(e);
29
+ }
30
+ throw e;
31
+ }
32
+ }, [open]);
33
+ const error = fetchAlertSources.error;
34
+ const retry = () => {
35
+ fetchAlertSources.retry();
36
+ };
37
+ return [
38
+ {
39
+ alertSources: alertSourcesList,
40
+ alertSource: initialAlertSource ? initialAlertSource : alertSource,
41
+ summary,
42
+ details,
43
+ error,
44
+ isLoading
45
+ },
46
+ {
47
+ setAlertSourcesList,
48
+ setAlertSource,
49
+ setSummary,
50
+ setDetails,
51
+ setIsLoading,
52
+ retry
53
+ }
54
+ ];
55
+ };
56
+
57
+ export { useNewAlert };
58
+ //# sourceMappingURL=useNewAlert.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNewAlert.esm.js","sources":["../../src/hooks/useNewAlert.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { AuthenticationError } from '@backstage/errors';\nimport React from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { ilertApiRef } from '../api';\nimport { AlertSource } from '../types';\n\nexport const useNewAlert = (\n open: boolean,\n initialAlertSource?: AlertSource | null,\n) => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [alertSourcesList, setAlertSourcesList] = React.useState<AlertSource[]>(\n [],\n );\n const [alertSource, setAlertSource] = React.useState<AlertSource | null>(\n null,\n );\n const [summary, setSummary] = React.useState('');\n const [details, setDetails] = React.useState('');\n const [isLoading, setIsLoading] = React.useState(false);\n\n const fetchAlertSources = useAsyncRetry(async () => {\n try {\n if (!open || initialAlertSource) {\n return;\n }\n const count = await ilertApi.fetchAlertSources();\n setAlertSourcesList(count || 0);\n } catch (e) {\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n }, [open]);\n\n const error = fetchAlertSources.error;\n const retry = () => {\n fetchAlertSources.retry();\n };\n\n return [\n {\n alertSources: alertSourcesList,\n alertSource: initialAlertSource ? initialAlertSource : alertSource,\n summary,\n details,\n error,\n isLoading,\n },\n {\n setAlertSourcesList,\n setAlertSource,\n setSumm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CAAA,KAAA,CAAA;AAChC,EAAA,MAAM,QAAQ,MAAM;AAClB,IAAA,iBAAA,CAAkB,KAAM,EAAA,CAAA;AAAA,GAC1B,CAAA;AAEA,EAAO,OAAA;AAAA,IACL;AAAA,MACE,YAAc,EAAA,gBAAA;AAAA,MACd,WAAA,EAAa,qBAAqB,kBAAqB,GAAA,WAAA;AAAA,MACvD,OAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACA;AAAA,MACE,mBAAA;AAAA,MACA,cAAA;AAAA,MACA,UAAA;AAAA,MACA,UAAA;AAAA,MACA,YAAA;AAAA,MACA,KAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { ilertApiRef } from '../api/client.esm.js';
3
+ import { AuthenticationError } from '@backstage/errors';
4
+ import useAsyncRetry from 'react-use/esm/useAsyncRetry';
5
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
6
+
7
+ const useOnCallSchedules = () => {
8
+ const ilertApi = useApi(ilertApiRef);
9
+ const errorApi = useApi(errorApiRef);
10
+ const [onCallSchedulesList, setOnCallSchedulesList] = React.useState([]);
11
+ const [isLoading, setIsLoading] = React.useState(false);
12
+ const fetchOnCallSchedulesCall = async () => {
13
+ try {
14
+ setIsLoading(true);
15
+ const data = await ilertApi.fetchOnCallSchedules();
16
+ setOnCallSchedulesList(data || []);
17
+ setIsLoading(false);
18
+ } catch (e) {
19
+ setIsLoading(false);
20
+ if (!(e instanceof AuthenticationError)) {
21
+ errorApi.post(e);
22
+ }
23
+ throw e;
24
+ }
25
+ };
26
+ const { error, retry } = useAsyncRetry(fetchOnCallSchedulesCall, []);
27
+ return [
28
+ {
29
+ onCallSchedules: onCallSchedulesList,
30
+ error,
31
+ isLoading
32
+ },
33
+ {
34
+ retry,
35
+ setIsLoading,
36
+ refetchOnCallSchedules: fetchOnCallSchedulesCall
37
+ }
38
+ ];
39
+ };
40
+
41
+ export { useOnCallSchedules };
42
+ //# sourceMappingURL=useOnCallSchedules.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnCallSchedules.esm.js","sources":["../../src/hooks/useOnCallSchedules.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { ilertApiRef } from '../api';\nimport { AuthenticationError } from '@backstage/errors';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { Schedule } from '../types';\nimport { useApi, errorApiRef } from '@backstage/core-plugin-api';\n\nexport const useOnCallSchedules = () => {\n const ilertApi = useApi(ilertApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [onCallSchedulesList, setOnCallSchedulesList] = React.useState<\n Schedule[]\n >([]);\n const [isLoading, setIsLoading] = React.useState(false);\n\n const fetchOnCallSchedulesCall = async () => {\n try {\n setIsLoading(true);\n const data = await ilertApi.fetchOnCallSchedules();\n setOnCallSchedulesList(data || []);\n setIsLoading(false);\n } catch (e) {\n setIsLoading(false);\n if (!(e instanceof AuthenticationError)) {\n errorApi.post(e);\n }\n throw e;\n }\n };\n\n const { error, retry } = useAsyncRetry(fetchOnCallSchedulesCall, []);\n\n return [\n {\n onCallSchedules: onCallSchedulesList,\n error,\n isLoading,\n },\n {\n retry,\n setIsLoading,\n refetchOnCallSchedules: fetchOnCallSchedulesCall,\n },\n ] as const;\n};\n"],"names":[],"mappings":";;;;;;AAsBO,MAAM,qBAAqB,MAAM;AACtC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC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