@incident-io/backstage 0.0.15 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +35 -1
  2. package/config.d.ts +11 -5
  3. package/dist/alpha.d.ts +5 -0
  4. package/dist/alpha.esm.js +91 -0
  5. package/dist/alpha.esm.js.map +1 -0
  6. package/dist/api/client.esm.js +34 -0
  7. package/dist/api/client.esm.js.map +1 -0
  8. package/dist/components/AlertListItem/index.esm.js +68 -0
  9. package/dist/components/AlertListItem/index.esm.js.map +1 -0
  10. package/dist/components/EntityAlertCard/index.esm.js +113 -0
  11. package/dist/components/EntityAlertCard/index.esm.js.map +1 -0
  12. package/dist/components/EntityIncidentCard/index.esm.js +125 -0
  13. package/dist/components/EntityIncidentCard/index.esm.js.map +1 -0
  14. package/dist/components/EntityOnCallCard/index.esm.js +198 -0
  15. package/dist/components/EntityOnCallCard/index.esm.js.map +1 -0
  16. package/dist/components/HomePageAlertCard/Content.esm.js +76 -0
  17. package/dist/components/HomePageAlertCard/Content.esm.js.map +1 -0
  18. package/dist/components/HomePageAlertCard/index.esm.js +2 -0
  19. package/dist/components/HomePageAlertCard/index.esm.js.map +1 -0
  20. package/dist/components/HomePageIncidentCard/Content.esm.js +54 -0
  21. package/dist/components/HomePageIncidentCard/Content.esm.js.map +1 -0
  22. package/dist/components/HomePageIncidentCard/Context.esm.js +33 -0
  23. package/dist/components/HomePageIncidentCard/Context.esm.js.map +1 -0
  24. package/dist/components/HomePageIncidentCard/index.esm.js +3 -0
  25. package/dist/components/HomePageIncidentCard/index.esm.js.map +1 -0
  26. package/dist/components/HomePageOnCallCard/Content.esm.js +38 -0
  27. package/dist/components/HomePageOnCallCard/Content.esm.js.map +1 -0
  28. package/dist/components/HomePageOnCallCard/index.esm.js +6 -0
  29. package/dist/components/HomePageOnCallCard/index.esm.js.map +1 -0
  30. package/dist/components/IncidentListItem/index.esm.js +68 -0
  31. package/dist/components/IncidentListItem/index.esm.js.map +1 -0
  32. package/dist/components/styles.esm.js +34 -0
  33. package/dist/components/styles.esm.js.map +1 -0
  34. package/dist/components/utils.esm.js +19 -0
  35. package/dist/components/utils.esm.js.map +1 -0
  36. package/dist/hooks/useIncidentRequest.esm.js +65 -0
  37. package/dist/hooks/useIncidentRequest.esm.js.map +1 -0
  38. package/dist/hooks/useOnCallRequest.esm.js +116 -0
  39. package/dist/hooks/useOnCallRequest.esm.js.map +1 -0
  40. package/dist/index.d.ts +9 -6
  41. package/dist/index.esm.js +1 -3
  42. package/dist/index.esm.js.map +1 -1
  43. package/dist/plugin.esm.js +99 -0
  44. package/dist/plugin.esm.js.map +1 -0
  45. package/package.json +64 -31
  46. package/src/alpha.test.ts +9 -0
  47. package/src/alpha.tsx +111 -0
  48. package/src/api/client.test.ts +43 -0
  49. package/src/api/types.test.ts +15 -0
  50. package/src/api/types.ts +49796 -11325
  51. package/src/components/AlertListItem/index.tsx +82 -0
  52. package/src/components/EntityAlertCard/index.test.tsx +242 -0
  53. package/src/components/EntityAlertCard/index.tsx +168 -0
  54. package/src/components/EntityIncidentCard/index.test.tsx +135 -0
  55. package/src/components/EntityIncidentCard/index.tsx +3 -23
  56. package/src/components/EntityOnCallCard/index.test.tsx +134 -0
  57. package/src/components/EntityOnCallCard/index.tsx +301 -0
  58. package/src/components/HomePageAlertCard/Content.test.tsx +56 -0
  59. package/src/components/HomePageAlertCard/Content.tsx +85 -0
  60. package/src/components/HomePageAlertCard/index.tsx +1 -0
  61. package/src/components/HomePageIncidentCard/Content.test.tsx +4 -3
  62. package/src/components/HomePageIncidentCard/Content.tsx +2 -2
  63. package/src/components/HomePageIncidentCard/Context.tsx +2 -2
  64. package/src/components/HomePageOnCallCard/Content.test.tsx +90 -0
  65. package/src/components/HomePageOnCallCard/Content.tsx +58 -0
  66. package/src/components/HomePageOnCallCard/index.ts +3 -0
  67. package/src/components/IncidentListItem/index.tsx +3 -26
  68. package/src/components/styles.tsx +30 -0
  69. package/src/components/utils.tsx +24 -0
  70. package/src/hooks/useIncidentRequest.test.ts +189 -0
  71. package/src/hooks/useIncidentRequest.ts +56 -3
  72. package/src/hooks/useOnCallRequest.test.ts +52 -0
  73. package/src/hooks/useOnCallRequest.ts +141 -0
  74. package/src/index.ts +4 -0
  75. package/src/plugin.ts +45 -1
  76. package/src/setupTests.ts +2 -2
  77. package/dist/esm/index-3220e1e0.esm.js +0 -96
  78. package/dist/esm/index-3220e1e0.esm.js.map +0 -1
  79. package/dist/esm/index-5cb52808.esm.js +0 -73
  80. package/dist/esm/index-5cb52808.esm.js.map +0 -1
  81. package/dist/esm/index-632bbd58.esm.js +0 -117
  82. package/dist/esm/index-632bbd58.esm.js.map +0 -1
  83. package/dist/esm/index-8f5c4c5f.esm.js +0 -101
  84. package/dist/esm/index-8f5c4c5f.esm.js.map +0 -1
@@ -0,0 +1,198 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { Progress } from '@backstage/core-components';
3
+ import { useEntity } from '@backstage/plugin-catalog-react';
4
+ import { Card, CardHeader, IconButton, Divider, CardContent, Box, Typography, Tooltip, Collapse, Chip } from '@material-ui/core';
5
+ import CachedIcon from '@material-ui/icons/Cached';
6
+ import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
7
+ import { Alert } from '@material-ui/lab';
8
+ import { useState } from 'react';
9
+ import { useIdentity } from '../../hooks/useIncidentRequest.esm.js';
10
+ import { useOnCallData, useSchedule, useEscalationPath } from '../../hooks/useOnCallRequest.esm.js';
11
+
12
+ const intervalTypeToUnit = (type) => {
13
+ const map = { hourly: "hour", daily: "day", weekly: "week", monthly: "month" };
14
+ return map[type] ?? type;
15
+ };
16
+ const formatInterval = (rotation) => {
17
+ const h = rotation.handovers[0];
18
+ if (!h) return "";
19
+ const unit = intervalTypeToUnit(h.interval_type ?? "");
20
+ return `Rotate every ${h.interval} ${unit}${h.interval !== 1 ? "s" : ""}`;
21
+ };
22
+ const formatShiftEnd = (isoString) => new Date(isoString).toLocaleString("en-GB", {
23
+ weekday: "short",
24
+ day: "numeric",
25
+ month: "short",
26
+ hour: "2-digit",
27
+ minute: "2-digit"
28
+ });
29
+ const RotationDisplay = ({ rotation, currentUserId, currentShiftEnd }) => /* @__PURE__ */ jsxs(Box, { mt: 1, children: [
30
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "textSecondary", children: formatInterval(rotation) }),
31
+ /* @__PURE__ */ jsx(Box, { display: "flex", flexDirection: "column", mt: 0.5, style: { gap: 4 }, children: (() => {
32
+ let onCallBadgeShown = false;
33
+ return rotation.users.map((user) => {
34
+ const isCurrent = user.id === currentUserId;
35
+ const showBadge = isCurrent && !onCallBadgeShown;
36
+ if (showBadge) onCallBadgeShown = true;
37
+ return /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", style: { gap: 8 }, children: [
38
+ /* @__PURE__ */ jsx(Box, { width: 10, height: 10, borderRadius: "50%", bgcolor: showBadge ? "primary.main" : "grey.400", flexShrink: 0 }),
39
+ /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", style: { gap: 6 }, children: [
40
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", style: { fontWeight: showBadge ? 600 : 400 }, children: user.name }),
41
+ showBadge && /* @__PURE__ */ jsx(Chip, { label: "on call", size: "small", color: "primary" }),
42
+ showBadge && currentShiftEnd && /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "textSecondary", children: [
43
+ "until ",
44
+ formatShiftEnd(currentShiftEnd)
45
+ ] })
46
+ ] })
47
+ ] }, user.id);
48
+ });
49
+ })() })
50
+ ] });
51
+ const formatCondition = (cond) => {
52
+ const subject = cond.subject.label.replace(/^Escalation → /i, "");
53
+ const op = cond.operation.label;
54
+ const values = cond.param_bindings.flatMap((b) => b.array_value?.map((v) => v.label) ?? []);
55
+ return values.length > 0 ? `${subject} ${op} ${values.join(", ")}` : `${subject} ${op}`;
56
+ };
57
+ const targetLabel = (t, scheduleId, scheduleName, channelNames) => {
58
+ if (t.type === "schedule") return t.id === scheduleId && scheduleName ? scheduleName : "schedule";
59
+ if (t.type === "slack_channel") return `${channelNames[t.id] ?? t.id}`;
60
+ return "user";
61
+ };
62
+ const renderEscalationNodes = (nodes, scheduleId, scheduleName, channelNames, depth = 0) => nodes.map((node) => {
63
+ const indent = depth * 16;
64
+ if (node.type === "level" && node.level || node.type === "notify_channel" && node.notify_channel) {
65
+ const data = node.level ?? node.notify_channel;
66
+ const minutes = Math.floor((data.time_to_ack_seconds ?? 0) / 60);
67
+ const label = data.targets.map((t) => targetLabel(t, scheduleId, scheduleName, channelNames)).join(", ");
68
+ const prefix = node.type === "notify_channel" ? "Notify" : "Page";
69
+ return /* @__PURE__ */ jsxs(Box, { ml: `${indent}px`, display: "flex", alignItems: "center", style: { gap: 6 }, mt: 0.5, children: [
70
+ /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
71
+ "\u2514 ",
72
+ prefix,
73
+ ": ",
74
+ label
75
+ ] }),
76
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "textSecondary", children: [
77
+ "\xB7 ",
78
+ minutes,
79
+ " min to ack"
80
+ ] })
81
+ ] }, node.id);
82
+ }
83
+ if (node.type === "repeat" && node.repeat) {
84
+ return /* @__PURE__ */ jsx(Box, { ml: `${indent}px`, mt: 0.5, children: /* @__PURE__ */ jsxs(Typography, { variant: "body2", color: "textSecondary", children: [
85
+ "\u2514 Retry ",
86
+ node.repeat.repeat_times,
87
+ "x from start"
88
+ ] }) }, node.id);
89
+ }
90
+ if (node.type === "if_else" && node.if_else) {
91
+ const condLabel = node.if_else.conditions.map(formatCondition).join(", ");
92
+ return /* @__PURE__ */ jsxs(Box, { ml: `${indent}px`, mt: 0.5, children: [
93
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: /* @__PURE__ */ jsxs("strong", { children: [
94
+ "If ",
95
+ condLabel,
96
+ ":"
97
+ ] }) }),
98
+ node.if_else.then_path.length > 0 ? renderEscalationNodes(node.if_else.then_path, scheduleId, scheduleName, channelNames, depth + 1) : /* @__PURE__ */ jsx(Box, { ml: "16px", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", children: "\u2514 Do nothing" }) }),
99
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", style: { marginTop: 4 }, children: /* @__PURE__ */ jsx("strong", { children: "Otherwise:" }) }),
100
+ node.if_else.else_path.length > 0 ? renderEscalationNodes(node.if_else.else_path, scheduleId, scheduleName, channelNames, depth + 1) : /* @__PURE__ */ jsx(Box, { ml: "16px", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", children: "\u2514 Do nothing" }) })
101
+ ] }, node.id);
102
+ }
103
+ return null;
104
+ });
105
+ const EntityOnCallCard = () => {
106
+ const { entity } = useEntity();
107
+ const [reload, setReload] = useState(false);
108
+ const [showPath, setShowPath] = useState(false);
109
+ const entityExternalId = `${entity.metadata.namespace}/${entity.metadata.name}`;
110
+ const { value, loading, error } = useOnCallData(entityExternalId, [reload]);
111
+ const { value: schedule, loading: scheduleLoading, error: scheduleError } = useSchedule(
112
+ value?.schedule?.literal ?? null,
113
+ [value?.schedule?.literal, reload]
114
+ );
115
+ const { value: escalationPathResult, loading: escalationLoading, error: escalationError } = useEscalationPath(
116
+ value?.escalationPath?.literal ?? null,
117
+ [value?.escalationPath?.literal, reload]
118
+ );
119
+ const escalationPath = escalationPathResult?.ep ?? null;
120
+ const channelNames = escalationPathResult?.channelNames ?? {};
121
+ const { value: identity } = useIdentity();
122
+ const baseUrl = identity?.identity.dashboard_url ?? "app.incident.io";
123
+ const anyLoading = loading || scheduleLoading || escalationLoading;
124
+ const anyError = error || scheduleError || escalationError;
125
+ return /* @__PURE__ */ jsxs(Card, { children: [
126
+ /* @__PURE__ */ jsx(
127
+ CardHeader,
128
+ {
129
+ title: "On-call",
130
+ action: /* @__PURE__ */ jsx(IconButton, { "aria-label": "Refresh", title: "Refresh", onClick: () => setReload(!reload), children: /* @__PURE__ */ jsx(CachedIcon, {}) })
131
+ }
132
+ ),
133
+ /* @__PURE__ */ jsx(Divider, {}),
134
+ /* @__PURE__ */ jsxs(CardContent, { children: [
135
+ anyLoading && /* @__PURE__ */ jsx(Progress, {}),
136
+ anyError && /* @__PURE__ */ jsx(Alert, { severity: "error", children: anyError.message }),
137
+ !loading && !error && value && /* @__PURE__ */ jsxs(Fragment, { children: [
138
+ /* @__PURE__ */ jsxs(Box, { mb: 2, children: [
139
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: /* @__PURE__ */ jsx("strong", { children: "Escalation path" }) }),
140
+ value.escalationPathStatus === "no_field" && /* @__PURE__ */ jsx(Alert, { severity: "error", children: "No escalation path field on this catalog type \u2014 add one in incident.io." }),
141
+ value.escalationPathStatus === "empty" && /* @__PURE__ */ jsx(Alert, { severity: "warning", children: "Escalation path field is empty for this component." }),
142
+ value.escalationPathStatus === "ok" && escalationPath && /* @__PURE__ */ jsxs(Fragment, { children: [
143
+ /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [
144
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: escalationPath.name }),
145
+ /* @__PURE__ */ jsx(Tooltip, { title: "View in incident.io", placement: "top", children: /* @__PURE__ */ jsx(IconButton, { size: "small", href: `${baseUrl}/on-call/escalation-paths/${escalationPath.id}`, target: "_blank", rel: "noopener noreferrer", color: "primary", children: /* @__PURE__ */ jsx(OpenInBrowserIcon, { fontSize: "small" }) }) })
146
+ ] }),
147
+ escalationPath.current_responders && escalationPath.current_responders.length > 0 && /* @__PURE__ */ jsxs(Box, { mb: 1, children: [
148
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: /* @__PURE__ */ jsx("strong", { children: "Current responders:" }) }),
149
+ escalationPath.current_responders.map((r) => /* @__PURE__ */ jsx(Typography, { variant: "body2", children: r.name }, r.id))
150
+ ] }),
151
+ /* @__PURE__ */ jsx(
152
+ Box,
153
+ {
154
+ display: "inline-flex",
155
+ alignItems: "center",
156
+ style: { cursor: "pointer", gap: 4 },
157
+ onClick: () => setShowPath((p) => !p),
158
+ mt: 0.5,
159
+ mb: 0.5,
160
+ children: /* @__PURE__ */ jsx(Typography, { variant: "button", color: "primary", children: showPath ? "Hide path \u25B2" : "Show path \u25BC" })
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsx(Collapse, { in: showPath, children: renderEscalationNodes(
164
+ escalationPath.path,
165
+ value.schedule?.literal ?? null,
166
+ schedule?.name ?? null,
167
+ channelNames
168
+ ) })
169
+ ] })
170
+ ] }),
171
+ /* @__PURE__ */ jsx(Divider, {}),
172
+ /* @__PURE__ */ jsxs(Box, { mt: 2, children: [
173
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: /* @__PURE__ */ jsx("strong", { children: "Schedule" }) }),
174
+ value.scheduleStatus === "no_field" && /* @__PURE__ */ jsx(Alert, { severity: "error", children: "No schedule field on this catalog type \u2014 add one in incident.io." }),
175
+ value.scheduleStatus === "empty" && /* @__PURE__ */ jsx(Alert, { severity: "warning", children: "Schedule field is empty for this component." }),
176
+ value.scheduleStatus === "ok" && schedule && /* @__PURE__ */ jsxs(Fragment, { children: [
177
+ /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [
178
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: schedule.name }),
179
+ /* @__PURE__ */ jsx(Tooltip, { title: "View in incident.io", placement: "top", children: /* @__PURE__ */ jsx(IconButton, { size: "small", href: `${baseUrl}/on-call/schedules/${schedule.id}`, target: "_blank", rel: "noopener noreferrer", color: "primary", children: /* @__PURE__ */ jsx(OpenInBrowserIcon, { fontSize: "small" }) }) })
180
+ ] }),
181
+ schedule.config?.rotations.map((rotation) => /* @__PURE__ */ jsx(
182
+ RotationDisplay,
183
+ {
184
+ rotation,
185
+ currentUserId: schedule.current_shifts?.[0]?.user?.id ?? null,
186
+ currentShiftEnd: schedule.current_shifts?.[0]?.end_at ?? null
187
+ },
188
+ rotation.id
189
+ ))
190
+ ] })
191
+ ] })
192
+ ] })
193
+ ] })
194
+ ] });
195
+ };
196
+
197
+ export { EntityOnCallCard };
198
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/EntityOnCallCard/index.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Progress } from \"@backstage/core-components\";\nimport { useEntity } from \"@backstage/plugin-catalog-react\";\nimport {\n Box,\n Card,\n CardContent,\n CardHeader,\n Chip,\n Divider,\n IconButton,\n Tooltip,\n Typography,\n Collapse,\n} from \"@material-ui/core\";\nimport CachedIcon from \"@material-ui/icons/Cached\";\nimport OpenInBrowserIcon from \"@material-ui/icons/OpenInBrowser\";\nimport { Alert } from \"@material-ui/lab\";\nimport { useState } from \"react\";\nimport { useIdentity } from \"../../hooks/useIncidentRequest\";\nimport {\n useOnCallData,\n useSchedule,\n useEscalationPath,\n ScheduleRotation,\n EscalationPathNode,\n EscalationPathTarget,\n} from \"../../hooks/useOnCallRequest\";\n\n// ── Schedule helpers ──────────────────────────────────────────────────────────\n\nconst intervalTypeToUnit = (type: string): string => {\n const map: Record<string, string> = { hourly: \"hour\", daily: \"day\", weekly: \"week\", monthly: \"month\" };\n return map[type] ?? type;\n};\n\nconst formatInterval = (rotation: ScheduleRotation): string => {\n const h = rotation.handovers[0];\n if (!h) return \"\";\n const unit = intervalTypeToUnit(h.interval_type ?? '');\n return `Rotate every ${h.interval} ${unit}${h.interval !== 1 ? \"s\" : \"\"}`;\n};\n\nconst formatShiftEnd = (isoString: string): string =>\n new Date(isoString).toLocaleString(\"en-GB\", {\n weekday: \"short\", day: \"numeric\", month: \"short\", hour: \"2-digit\", minute: \"2-digit\",\n });\n\nconst RotationDisplay = ({ rotation, currentUserId, currentShiftEnd }: {\n rotation: ScheduleRotation;\n currentUserId: string | null;\n currentShiftEnd: string | null;\n}) => (\n <Box mt={1}>\n <Typography variant=\"caption\" color=\"textSecondary\">\n {formatInterval(rotation)}\n </Typography>\n <Box display=\"flex\" flexDirection=\"column\" mt={0.5} style={{ gap: 4 }}>\n {(() => {\n let onCallBadgeShown = false;\n return rotation.users.map((user) => {\n const isCurrent = user.id === currentUserId;\n const showBadge = isCurrent && !onCallBadgeShown;\n if (showBadge) onCallBadgeShown = true;\n return (\n <Box key={user.id} display=\"flex\" alignItems=\"center\" style={{ gap: 8 }}>\n <Box width={10} height={10} borderRadius=\"50%\" bgcolor={showBadge ? \"primary.main\" : \"grey.400\"} flexShrink={0} />\n <Box display=\"flex\" alignItems=\"center\" style={{ gap: 6 }}>\n <Typography variant=\"body2\" style={{ fontWeight: showBadge ? 600 : 400 }}>\n {user.name}\n </Typography>\n {showBadge && <Chip label=\"on call\" size=\"small\" color=\"primary\" />}\n {showBadge && currentShiftEnd && (\n <Typography variant=\"caption\" color=\"textSecondary\">\n until {formatShiftEnd(currentShiftEnd)}\n </Typography>\n )}\n </Box>\n </Box>\n );\n });\n })()}\n </Box>\n </Box>\n);\n\n// ── Escalation path helpers ───────────────────────────────────────────────────\n\nconst formatCondition = (cond: EscalationPathNode['if_else'] extends undefined ? never : NonNullable<EscalationPathNode['if_else']>['conditions'][0]): string => {\n const subject = cond.subject.label.replace(/^Escalation → /i, \"\");\n const op = cond.operation.label;\n const values = cond.param_bindings.flatMap(b => b.array_value?.map(v => v.label) ?? []);\n return values.length > 0 ? `${subject} ${op} ${values.join(\", \")}` : `${subject} ${op}`;\n};\n\nconst targetLabel = (t: EscalationPathTarget, scheduleId: string | null, scheduleName: string | null, channelNames: Record<string, string>): string => {\n if (t.type === \"schedule\") return t.id === scheduleId && scheduleName ? scheduleName : \"schedule\";\n if (t.type === \"slack_channel\") return `${channelNames[t.id] ?? t.id}`;\n return \"user\";\n};\n\nconst renderEscalationNodes = (\n nodes: EscalationPathNode[],\n scheduleId: string | null,\n scheduleName: string | null,\n channelNames: Record<string, string>,\n depth = 0,\n): React.ReactNode[] =>\n nodes.map((node) => {\n const indent = depth * 16;\n\n if ((node.type === \"level\" && node.level) || (node.type === \"notify_channel\" && node.notify_channel)) {\n const data = node.level ?? node.notify_channel!;\n const minutes = Math.floor((data.time_to_ack_seconds ?? 0) / 60);\n const label = data.targets.map(t => targetLabel(t, scheduleId, scheduleName, channelNames)).join(\", \");\n const prefix = node.type === \"notify_channel\" ? \"Notify\" : \"Page\";\n return (\n <Box key={node.id} ml={`${indent}px`} display=\"flex\" alignItems=\"center\" style={{ gap: 6 }} mt={0.5}>\n <Typography variant=\"body2\">└ {prefix}: {label}</Typography>\n <Typography variant=\"caption\" color=\"textSecondary\">· {minutes} min to ack</Typography>\n </Box>\n );\n }\n\n if (node.type === \"repeat\" && node.repeat) {\n return (\n <Box key={node.id} ml={`${indent}px`} mt={0.5}>\n <Typography variant=\"body2\" color=\"textSecondary\">\n └ Retry {node.repeat.repeat_times}x from start\n </Typography>\n </Box>\n );\n }\n\n if (node.type === \"if_else\" && node.if_else) {\n const condLabel = node.if_else.conditions.map(formatCondition).join(\", \");\n return (\n <Box key={node.id} ml={`${indent}px`} mt={0.5}>\n <Typography variant=\"body2\"><strong>If {condLabel}:</strong></Typography>\n {node.if_else.then_path.length > 0\n ? renderEscalationNodes(node.if_else.then_path, scheduleId, scheduleName, channelNames, depth + 1)\n : <Box ml=\"16px\"><Typography variant=\"body2\" color=\"textSecondary\">└ Do nothing</Typography></Box>\n }\n <Typography variant=\"body2\" style={{ marginTop: 4 }}><strong>Otherwise:</strong></Typography>\n {node.if_else.else_path.length > 0\n ? renderEscalationNodes(node.if_else.else_path, scheduleId, scheduleName, channelNames, depth + 1)\n : <Box ml=\"16px\"><Typography variant=\"body2\" color=\"textSecondary\">└ Do nothing</Typography></Box>\n }\n </Box>\n );\n }\n\n return null;\n });\n\n// ── Card ──────────────────────────────────────────────────────────────────────\n\nexport const EntityOnCallCard = () => {\n const { entity } = useEntity();\n const [reload, setReload] = useState(false);\n const [showPath, setShowPath] = useState(false);\n\n const entityExternalId = `${entity.metadata.namespace}/${entity.metadata.name}`;\n\n const { value, loading, error } = useOnCallData(entityExternalId, [reload]);\n const { value: schedule, loading: scheduleLoading, error: scheduleError } = useSchedule(\n value?.schedule?.literal ?? null,\n [value?.schedule?.literal, reload],\n );\n const { value: escalationPathResult, loading: escalationLoading, error: escalationError } = useEscalationPath(\n value?.escalationPath?.literal ?? null,\n [value?.escalationPath?.literal, reload],\n );\n const escalationPath = escalationPathResult?.ep ?? null;\n const channelNames = escalationPathResult?.channelNames ?? {};\n\n const { value: identity } = useIdentity();\n const baseUrl = identity?.identity.dashboard_url ?? \"app.incident.io\";\n\n const anyLoading = loading || scheduleLoading || escalationLoading;\n const anyError = error || scheduleError || escalationError;\n\n return (\n <Card>\n <CardHeader\n title=\"On-call\"\n action={\n <IconButton aria-label=\"Refresh\" title=\"Refresh\" onClick={() => setReload(!reload)}>\n <CachedIcon />\n </IconButton>\n }\n />\n <Divider />\n <CardContent>\n {anyLoading && <Progress />}\n {anyError && <Alert severity=\"error\">{anyError.message}</Alert>}\n {!loading && !error && value && (\n <>\n {/* Escalation path */}\n <Box mb={2}>\n <Typography variant=\"subtitle1\"><strong>Escalation path</strong></Typography>\n {value.escalationPathStatus === 'no_field' && (\n <Alert severity=\"error\">No escalation path field on this catalog type — add one in incident.io.</Alert>\n )}\n {value.escalationPathStatus === 'empty' && (\n <Alert severity=\"warning\">Escalation path field is empty for this component.</Alert>\n )}\n {value.escalationPathStatus === 'ok' && escalationPath && (\n <>\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Typography variant=\"subtitle1\">{escalationPath.name}</Typography>\n <Tooltip title=\"View in incident.io\" placement=\"top\">\n <IconButton size=\"small\" href={`${baseUrl}/on-call/escalation-paths/${escalationPath.id}`} target=\"_blank\" rel=\"noopener noreferrer\" color=\"primary\">\n <OpenInBrowserIcon fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n </Box>\n {escalationPath.current_responders && escalationPath.current_responders.length > 0 && (\n <Box mb={1}>\n <Typography variant=\"body2\"><strong>Current responders:</strong></Typography>\n {escalationPath.current_responders.map((r) => (\n <Typography key={r.id} variant=\"body2\">{r.name}</Typography>\n ))}\n </Box>\n )}\n <Box\n display=\"inline-flex\"\n alignItems=\"center\"\n style={{ cursor: \"pointer\", gap: 4 }}\n onClick={() => setShowPath(p => !p)}\n mt={0.5}\n mb={0.5}\n >\n <Typography variant=\"button\" color=\"primary\">\n {showPath ? \"Hide path ▲\" : \"Show path ▼\"}\n </Typography>\n </Box>\n <Collapse in={showPath}>\n {renderEscalationNodes(\n escalationPath.path,\n value.schedule?.literal ?? null,\n schedule?.name ?? null,\n channelNames,\n )}\n </Collapse>\n </>\n )}\n </Box>\n\n <Divider />\n\n {/* Schedule */}\n <Box mt={2}>\n <Typography variant=\"subtitle1\"><strong>Schedule</strong></Typography>\n {value.scheduleStatus === 'no_field' && (\n <Alert severity=\"error\">No schedule field on this catalog type — add one in incident.io.</Alert>\n )}\n {value.scheduleStatus === 'empty' && (\n <Alert severity=\"warning\">Schedule field is empty for this component.</Alert>\n )}\n {value.scheduleStatus === 'ok' && schedule && (\n <>\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\">\n <Typography variant=\"subtitle1\">{schedule.name}</Typography>\n <Tooltip title=\"View in incident.io\" placement=\"top\">\n <IconButton size=\"small\" href={`${baseUrl}/on-call/schedules/${schedule.id}`} target=\"_blank\" rel=\"noopener noreferrer\" color=\"primary\">\n <OpenInBrowserIcon fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n </Box>\n {schedule.config?.rotations.map((rotation) => (\n <RotationDisplay\n key={rotation.id}\n rotation={rotation}\n currentUserId={schedule.current_shifts?.[0]?.user?.id ?? null}\n currentShiftEnd={schedule.current_shifts?.[0]?.end_at ?? null}\n />\n ))}\n </>\n )}\n </Box>\n </>\n )}\n </CardContent>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA6CA,MAAM,kBAAA,GAAqB,CAAC,IAAA,KAAyB;AACnD,EAAA,MAAM,GAAA,GAA8B,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAO,KAAA,EAAO,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAQ;AACrG,EAAA,OAAO,GAAA,CAAI,IAAI,CAAA,IAAK,IAAA;AACtB,CAAA;AAEA,MAAM,cAAA,GAAiB,CAAC,QAAA,KAAuC;AAC7D,EAAA,MAAM,CAAA,GAAI,QAAA,CAAS,SAAA,CAAU,CAAC,CAAA;AAC9B,EAAA,IAAI,CAAC,GAAG,OAAO,EAAA;AACf,EAAA,MAAM,IAAA,GAAO,kBAAA,CAAmB,CAAA,CAAE,aAAA,IAAiB,EAAE,CAAA;AACrD,EAAA,OAAO,CAAA,aAAA,EAAgB,CAAA,CAAE,QAAQ,CAAA,CAAA,EAAI,IAAI,GAAG,CAAA,CAAE,QAAA,KAAa,CAAA,GAAI,GAAA,GAAM,EAAE,CAAA,CAAA;AACzE,CAAA;AAEA,MAAM,cAAA,GAAiB,CAAC,SAAA,KACtB,IAAI,KAAK,SAAS,CAAA,CAAE,eAAe,OAAA,EAAS;AAAA,EAC1C,OAAA,EAAS,OAAA;AAAA,EAAS,GAAA,EAAK,SAAA;AAAA,EAAW,KAAA,EAAO,OAAA;AAAA,EAAS,IAAA,EAAM,SAAA;AAAA,EAAW,MAAA,EAAQ;AAC7E,CAAC,CAAA;AAEH,MAAM,eAAA,GAAkB,CAAC,EAAE,QAAA,EAAU,aAAA,EAAe,iBAAgB,qBAKlE,IAAA,CAAC,GAAA,EAAA,EAAI,E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AAC,UAAA,EAAA,EAAW,OAAA,EAAQ,WAAA,EAAa,QAAA,EAAA,QAAA,CAAS,IAAA,EAAK,CAAA;AAAA,8BAC/C,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAM,qBAAA,EAAsB,SAAA,EAAU,KAAA,EAC7C,QAAA,kBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,IAAA,EAAK,OAAA,EAAQ,IAAA,EAAM,CAAA,EAAG,OAAO,CAAA,mBAAA,EAAsB,QAAA,CAAS,EAAE,CAAA,CAAA,EAAI,MAAA,EAAO,QAAA,EAAS,GAAA,EAAI,qBAAA,EAAsB,KAAA,EAAM,SAAA,EAC5H,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,QAAA,EAAS,OAAA,EAAQ,CAAA,EACtC,CAAA,EACF;AAAA,aAAA,EACF,CAAA;AAAA,YACC,QAAA,CAAS,MAAA,EAAQ,SAAA,CAAU,GAAA,CAAI,CAAC,QAAA,qBAC/B,GAAA;AAAA,cAAC,eAAA;AAAA,cAAA;AAAA,gBAEC,QAAA;AAAA,gBACA,eAAe,QAAA,CAAS,cAAA,GAAiB,CAAC,CAAA,EAAG,MAAM,EAAA,IAAM,IAAA;AAAA,gBACzD,eAAA,EAAiB,QAAA,CAAS,cAAA,GAAiB,CAAC,GAAG,MAAA,IAAU;AAAA,eAAA;AAAA,cAHpD,QAAA,CAAS;AAAA,aAKjB;AAAA,WAAA,EACH;AAAA,SAAA,EAEF;AAAA,OAAA,EACF;AAAA,KAAA,EAEJ;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,76 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Progress } from '@backstage/core-components';
4
+ import { useApi, configApiRef } from '@backstage/core-plugin-api';
5
+ import Link from '@material-ui/core/Link';
6
+ import { Alert } from '@material-ui/lab';
7
+ import { Tabs, Tab, Divider, Typography, Box, List } from '@material-ui/core';
8
+ import { useAlertList, useAlertSourceList } from '../../hooks/useIncidentRequest.esm.js';
9
+ import { AlertListItem } from '../AlertListItem/index.esm.js';
10
+
11
+ const STATUS_TABS = [
12
+ { label: "Firing", value: "firing" },
13
+ { label: "Resolved", value: "resolved" },
14
+ { label: "All", value: void 0 }
15
+ ];
16
+ const HomePageAlertCardContent = () => {
17
+ const [statusFilter, setStatusFilter] = useState("firing");
18
+ const config = useApi(configApiRef);
19
+ const baseUrl = config.getOptionalString("incident.baseUrl") || "https://app.incident.io";
20
+ const { loading, error, value } = useAlertList(statusFilter, [statusFilter]);
21
+ const { value: sourcesResponse } = useAlertSourceList();
22
+ const alerts = value?.alerts ?? [];
23
+ const sourceById = Object.fromEntries(
24
+ (sourcesResponse?.alert_sources ?? []).map((s) => [s.id, s])
25
+ );
26
+ const currentTabIndex = STATUS_TABS.findIndex((t) => t.value === statusFilter);
27
+ if (loading) return /* @__PURE__ */ jsx(Progress, {});
28
+ if (error) return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
29
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx(
31
+ Tabs,
32
+ {
33
+ value: currentTabIndex,
34
+ onChange: (_, idx) => setStatusFilter(STATUS_TABS[idx].value),
35
+ indicatorColor: "primary",
36
+ textColor: "primary",
37
+ style: { minHeight: "auto" },
38
+ children: STATUS_TABS.map((tab) => /* @__PURE__ */ jsx(Tab, { label: tab.label, style: { minHeight: "auto", padding: "0px 12px" } }, tab.label))
39
+ }
40
+ ),
41
+ /* @__PURE__ */ jsx(Divider, {}),
42
+ alerts.length > 0 && /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
43
+ "There are ",
44
+ /* @__PURE__ */ jsx("strong", { children: alerts.length }),
45
+ " ",
46
+ statusFilter ?? "",
47
+ " alerts."
48
+ ] }),
49
+ alerts.length === 0 && /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
50
+ "No ",
51
+ statusFilter ?? "",
52
+ " alerts."
53
+ ] }),
54
+ /* @__PURE__ */ jsx(Box, { style: { maxHeight: 400, overflowY: "auto" }, children: /* @__PURE__ */ jsx(List, { dense: true, children: alerts.map((alert) => /* @__PURE__ */ jsx(
55
+ AlertListItem,
56
+ {
57
+ alert,
58
+ baseUrl,
59
+ source: sourceById[alert.alert_source_id]?.name ?? "-",
60
+ priority: alert.attributes.find((a) => a.attribute.name === "Priority")?.value?.label
61
+ },
62
+ alert.id
63
+ )) }) }),
64
+ /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
65
+ "Click to",
66
+ " ",
67
+ /* @__PURE__ */ jsx(Link, { target: "_blank", href: `${baseUrl}/on-call/alerts`, children: "see more." })
68
+ ] })
69
+ ] });
70
+ };
71
+ const Content = () => {
72
+ return /* @__PURE__ */ jsx(HomePageAlertCardContent, {});
73
+ };
74
+
75
+ export { Content, HomePageAlertCardContent };
76
+ //# sourceMappingURL=Content.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.esm.js","sources":["../../../src/components/HomePageAlertCard/Content.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Progress } from \"@backstage/core-components\";\nimport { configApiRef, useApi } from \"@backstage/core-plugin-api\";\nimport Link from \"@material-ui/core/Link\";\nimport { Alert } from \"@material-ui/lab\";\nimport { Box, Divider, List, Tab, Tabs, Typography } from \"@material-ui/core\";\nimport { useAlertList, useAlertSourceList } from \"../../hooks/useIncidentRequest\";\nimport { AlertListItem } from \"../AlertListItem\";\n\ntype StatusFilter = \"firing\" | \"resolved\" | undefined;\n\nconst STATUS_TABS: { label: string; value: StatusFilter }[] = [\n { label: \"Firing\", value: \"firing\" },\n { label: \"Resolved\", value: \"resolved\" },\n { label: \"All\", value: undefined },\n];\n\nexport const HomePageAlertCardContent = () => {\n const [statusFilter, setStatusFilter] = useState<StatusFilter>(\"firing\");\n\n const config = useApi(configApiRef);\n const baseUrl =\n config.getOptionalString(\"incident.baseUrl\") || \"https://app.incident.io\";\n\n const { loading, error, value } = useAlertList(statusFilter, [statusFilter]);\n const { value: sourcesResponse } = useAlertSourceList();\n\n const alerts = value?.alerts ?? [];\n const sourceById = Object.fromEntries(\n (sourcesResponse?.alert_sources ?? []).map(s => [s.id, s]),\n );\n\n const currentTabIndex = STATUS_TABS.findIndex(t => t.value === statusFilter);\n\n if (loading) return <Progress />;\n if (error) return <Alert severity=\"error\">{error.message}</Alert>;\n\n return (\n <>\n <Tabs\n value={currentTabIndex}\n onChange={(_, idx) => setStatusFilter(STATUS_TABS[idx].value)}\n indicatorColor=\"primary\"\n textColor=\"primary\"\n style={{ minHeight: \"auto\" }}\n >\n {STATUS_TABS.map(tab => (\n <Tab key={tab.label} label={tab.label} style={{ minHeight: \"auto\", padding: \"0px 12px\" }} />\n ))}\n </Tabs>\n <Divider />\n {alerts.length > 0 && (\n <Typography variant=\"subtitle1\">\n There are <strong>{alerts.length}</strong> {statusFilter ?? \"\"} alerts.\n </Typography>\n )}\n {alerts.length === 0 && (\n <Typography variant=\"subtitle1\">No {statusFilter ?? \"\"} alerts.</Typography>\n )}\n <Box style={{ maxHeight: 400, overflowY: \"auto\" }}>\n <List dense>\n {alerts.map(alert => (\n <AlertListItem\n key={alert.id}\n alert={alert}\n baseUrl={baseUrl}\n source={sourceById[alert.alert_source_id]?.name ?? \"-\"}\n priority={alert.attributes.find(a => a.attribute.name === \"Priority\")?.value?.label}\n />\n ))}\n </List>\n </Box>\n <Typography variant=\"subtitle1\">\n Click to{\" \"}\n <Link target=\"_blank\" href={`${baseUrl}/on-call/alerts`}>\n see more.\n </Link>\n </Typography>\n </>\n );\n};\n\nexport const Content = () => {\n return <HomePageAlertCardContent />;\n};\n"],"names":[],"mappings":";;;;;;;;;;AAWA,MAAM,WAAA,GAAwD;AAAA,EAC5D,EAAE,KAAA,EAAO,QAAA,EAAU,KAAA,EAAO,QAAA,EAAS;AAAA,EACnC,EAAE,KAAA,EAAO,UAAA,EAAY,KAAA,EAAO,UAAA,EAAW;AAA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AA,CAAM,UAAA,CAAW,IAAA,CAAK,CAAA,CAAA,KAAK,EAAE,SAAA,CAAU,IAAA,KAAS,UAAU,CAAA,EAAG,KAAA,EAAO;AAAA,OAAA;AAAA,MAJzE,KAAA,CAAM;AAAA,KAMd,GACH,CAAA,EACF,CAAA;AAAA,oBACA,IAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,WAAA,EAAY,QAAA,EAAA;AAAA,MAAA,UAAA;AAAA,MACrB,GAAA;AAAA,sBACT,GAAA,CAAC,QAAK,MAAA,EAAO,QAAA,EAAS,MAAM,CAAA,EAAG,OAAO,mBAAmB,QAAA,EAAA,WAAA,EAEzD;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;AAEO,MAAM,UAAU,MAAM;AAC3B,EAAA,2BAAQ,wBAAA,EAAA,EAAyB,CAAA;AACnC;;;;"}
@@ -0,0 +1,2 @@
1
+ export { Content } from './Content.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import { Progress } from '@backstage/core-components';
4
+ import Link from '@material-ui/core/Link';
5
+ import { Alert } from '@material-ui/lab';
6
+ import { useIncidentList } from '../../hooks/useIncidentRequest.esm.js';
7
+ import { Typography, List } from '@material-ui/core';
8
+ import { IncidentListItem } from '../IncidentListItem/index.esm.js';
9
+ import { useApi, configApiRef } from '@backstage/core-plugin-api';
10
+ import { useHomePageIncidentCard } from './Context.esm.js';
11
+
12
+ const HomePageIncidentCardContent = () => {
13
+ const { filterType, filter } = useHomePageIncidentCard();
14
+ const config = useApi(configApiRef);
15
+ const baseUrl = config.getOptionalString("incident.baseUrl") || "https://app.incident.io";
16
+ const query = useMemo(() => {
17
+ const params = new URLSearchParams();
18
+ params.set(`${filterType}[one_of]`, filter);
19
+ return params;
20
+ }, [filterType, filter]);
21
+ const { loading, error, value } = useIncidentList(query, [query]);
22
+ const incidents = value?.incidents;
23
+ if (loading) return /* @__PURE__ */ jsx(Progress, {});
24
+ if (error) return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
25
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
26
+ incidents && incidents.length > 0 && /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
27
+ "There are ",
28
+ /* @__PURE__ */ jsx("strong", { children: incidents.length }),
29
+ " ongoing incidents."
30
+ ] }),
31
+ incidents && incidents.length === 0 && /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: "No ongoing incidents." }),
32
+ /* @__PURE__ */ jsx(List, { dense: true, children: incidents?.map((incident) => {
33
+ return /* @__PURE__ */ jsx(
34
+ IncidentListItem,
35
+ {
36
+ incident,
37
+ baseUrl
38
+ },
39
+ incident.id
40
+ );
41
+ }) }),
42
+ /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
43
+ "Click to",
44
+ " ",
45
+ /* @__PURE__ */ jsx(Link, { target: "_blank", href: `${baseUrl}/incidents?${query.toString()}`, children: "see more." })
46
+ ] })
47
+ ] });
48
+ };
49
+ const Content = () => {
50
+ return /* @__PURE__ */ jsx(HomePageIncidentCardContent, {});
51
+ };
52
+
53
+ export { Content, HomePageIncidentCardContent };
54
+ //# sourceMappingURL=Content.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.esm.js","sources":["../../../src/components/HomePageIncidentCard/Content.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { Progress } from \"@backstage/core-components\";\nimport Link from \"@material-ui/core/Link\";\nimport { Alert } from \"@material-ui/lab\";\nimport { useIncidentList } from \"../../hooks/useIncidentRequest\";\nimport { Typography, List } from \"@material-ui/core\";\nimport { IncidentListItem } from \"../IncidentListItem\";\nimport { configApiRef, useApi } from \"@backstage/core-plugin-api\";\nimport { useHomePageIncidentCard } from \"./Context\";\n\nexport const HomePageIncidentCardContent = () => {\n const { filterType, filter } = useHomePageIncidentCard();\n const config = useApi(configApiRef);\n const baseUrl =\n config.getOptionalString(\"incident.baseUrl\") || \"https://app.incident.io\";\n\n const query = useMemo(() => {\n const params = new URLSearchParams();\n params.set(`${filterType}[one_of]`, filter);\n return params;\n }, [filterType, filter]);\n\n const { loading, error, value } = useIncidentList(query, [query]);\n const incidents = value?.incidents;\n\n if (loading) return <Progress />;\n if (error) return <Alert severity=\"error\">{error.message}</Alert>;\n\n return (\n <>\n {incidents && incidents.length > 0 && (\n <Typography variant=\"subtitle1\">\n There are <strong>{incidents.length}</strong> ongoing incidents.\n </Typography>\n )}\n {incidents && incidents.length === 0 && (\n <Typography variant=\"subtitle1\">No ongoing incidents.</Typography>\n )}\n <List dense>\n {incidents?.map((incident) => {\n return (\n <IncidentListItem\n key={incident.id}\n incident={incident}\n baseUrl={baseUrl}\n />\n );\n })}\n </List>\n <Typography variant=\"subtitle1\">\n Click to{\" \"}\n <Link target=\"_blank\" href={`${baseUrl}/incidents?${query.toString()}`}>\n see more.\n </Link>\n </Typography>\n </>\n );\n};\n\nexport const Content = () => {\n return <HomePageIncidentCardContent />;\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAUO,MAAM,8BAA8B,MAAM;AAC/C,EAAA,MAAM,EAAE,UAAA,EAAY,MAAA,EAAO,GAAI,uBAAA,EAAwB;AACvD,EAAA,MAAM,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,EAAA,MAAM,OAAA,GACJ,MAAA,CAAO,iBAAA,CAAkB,kBAAkB,CAAA,IAAK,yBAAA;AAElD,EAAA,MAAM,KAAA,GAAQ,QAAQ,MAAM;AAC1B,IAAA,MAAM,MAAA,GAAS,IAAI,eAAA,EAAgB;AACnC,IAAA,MAAA,CAAO,GAAA,CAAI,CAAA,EAAG,UAAU,CAAA,QAAA,CAAA,EAAY,MAAM,CAAA;AAC1C,IAAA,OAAO,MAAA;AAAA,EACT,CAAA,EAA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AAK,MAAA,EAAO,QAAA,EAAS,IAAA,EAAM,CAAA,EAAG,OAAO,CAAA,WAAA,EAAc,KAAA,CAAM,QAAA,EAAU,CAAA,CAAA,EAAI,QAAA,EAAA,WAAA,EAExE;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;AAEO,MAAM,UAAU,MAAM;AAC3B,EAAA,2BAAQ,2BAAA,EAAA,EAA4B,CAAA;AACtC;;;;"}
@@ -0,0 +1,33 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useMemo, createContext, useContext } from 'react';
3
+
4
+ const Context = createContext(
5
+ void 0
6
+ );
7
+ const ContextProvider = (props) => {
8
+ const {
9
+ children,
10
+ filterType: defaultFilterType,
11
+ filter: defaultFilter
12
+ } = props;
13
+ const value = useMemo(
14
+ () => ({
15
+ filterType: defaultFilterType || "status_category",
16
+ filter: defaultFilter || "active"
17
+ }),
18
+ [defaultFilter, defaultFilterType]
19
+ );
20
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
21
+ };
22
+ const useHomePageIncidentCard = () => {
23
+ const value = useContext(Context);
24
+ if (value === void 0) {
25
+ throw new Error(
26
+ "useHomePageIncidentCard must be used within a HomePageIncidentCardContextProvider"
27
+ );
28
+ }
29
+ return value;
30
+ };
31
+
32
+ export { ContextProvider, useHomePageIncidentCard };
33
+ //# sourceMappingURL=Context.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.esm.js","sources":["../../../src/components/HomePageIncidentCard/Context.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\n\ntype HomePageIncidentCardContextValue = {\n filterType: \"status_category\" | \"status\";\n filter: string;\n};\n\nconst Context = createContext<HomePageIncidentCardContextValue | undefined>(\n undefined,\n);\n\nexport const ContextProvider = (props: {\n children: JSX.Element;\n filterType?: \"status_category\" | \"status\";\n filter?: string;\n}) => {\n const {\n children,\n filterType: defaultFilterType,\n filter: defaultFilter,\n } = props;\n\n const value = useMemo(\n () => ({\n filterType: defaultFilterType || \"status_category\",\n filter: defaultFilter || \"active\",\n }),\n [defaultFilter, defaultFilterType],\n );\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useHomePageIncidentCard = () => {\n const value = useContext(Context);\n\n if (value === undefined) {\n throw new Error(\n \"useHomePageIncidentCard must be used within a HomePageIncidentCardContextProvider\",\n );\n }\n\n return value;\n};\n\nexport default Context;\n"],"names":[],"mappings":";;;AAOA,MAAM,OAAA,GAAU,aAAA;AAAA,EACd;AACF,CAAA;AAEO,MAAM,eAAA,GAAkB,CAAC,KAAA,KAI1B;AACJ,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,UAAA,EAAY,iBAAA;AAAA,IACZ,MAAA,EAAQ;AAAA,GACV,GAAI,KAAA;AAEJ,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO;AAAA,MACL,YAAY,iBAAA,IAAqB,iBAAA;AAAA,MACjC,QAAQ,aAAA,IAAiB;AAAA,KAC3B,CAAA;AAAA,IACA,CAAC,eAAe,iBAAiB;AAAA,GACnC;AAEA,EAAA,uBAAO,GAAA,CAAC,OAAA,CAAQ,QAAA,EAAR,EAAiB,OAAe,QAAA,EAAS,CAAA;AACnD;AAEO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,MAAM,KAAA,GAAQ,WAAW,OAAO,CAAA;AAEhC,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,KAAA;AACT;;;;"}
@@ -0,0 +1,3 @@
1
+ export { Content } from './Content.esm.js';
2
+ export { ContextProvider } from './Context.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,38 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { Progress } from '@backstage/core-components';
3
+ import { useIdentity } from '../../hooks/useIncidentRequest.esm.js';
4
+ import { useAllEscalationPaths, useAllSchedules } from '../../hooks/useOnCallRequest.esm.js';
5
+ import { Alert } from '@material-ui/lab';
6
+ import { Typography, Divider, Box, Tooltip, IconButton } from '@material-ui/core';
7
+ import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
8
+
9
+ const Content = () => {
10
+ const { value: identity } = useIdentity();
11
+ const baseUrl = identity?.identity.dashboard_url ?? "app.incident.io";
12
+ const { value: eps, loading: epsLoading, error: epsError } = useAllEscalationPaths();
13
+ const { value: schedules, loading: schedulesLoading, error: schedulesError } = useAllSchedules();
14
+ if (epsLoading || schedulesLoading) return /* @__PURE__ */ jsx(Progress, {});
15
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
16
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: /* @__PURE__ */ jsx("strong", { children: "Escalation Paths" }) }),
17
+ /* @__PURE__ */ jsx(Divider, {}),
18
+ epsError && /* @__PURE__ */ jsx(Alert, { severity: "error", children: epsError.message }),
19
+ eps && eps.length === 0 && /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", children: "No escalation paths." }),
20
+ eps && eps.map((ep) => /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", py: 0.5, children: [
21
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: ep.name }),
22
+ /* @__PURE__ */ jsx(Tooltip, { title: "View in incident.io", placement: "top", children: /* @__PURE__ */ jsx(IconButton, { size: "small", href: `${baseUrl}/on-call/escalation-paths/${ep.id}`, target: "_blank", rel: "noopener noreferrer", color: "primary", children: /* @__PURE__ */ jsx(OpenInBrowserIcon, { fontSize: "small" }) }) })
23
+ ] }, ep.id)),
24
+ /* @__PURE__ */ jsxs(Box, { mt: 2, children: [
25
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: /* @__PURE__ */ jsx("strong", { children: "Schedules" }) }),
26
+ /* @__PURE__ */ jsx(Divider, {}),
27
+ schedulesError && /* @__PURE__ */ jsx(Alert, { severity: "error", children: schedulesError.message }),
28
+ schedules && schedules.length === 0 && /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "textSecondary", children: "No schedules." }),
29
+ schedules && schedules.map((schedule) => /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", py: 0.5, children: [
30
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: schedule.name }),
31
+ /* @__PURE__ */ jsx(Tooltip, { title: "View in incident.io", placement: "top", children: /* @__PURE__ */ jsx(IconButton, { size: "small", href: `${baseUrl}/on-call/schedules/${schedule.id}`, target: "_blank", rel: "noopener noreferrer", color: "primary", children: /* @__PURE__ */ jsx(OpenInBrowserIcon, { fontSize: "small" }) }) })
32
+ ] }, schedule.id))
33
+ ] })
34
+ ] });
35
+ };
36
+
37
+ export { Content };
38
+ //# sourceMappingURL=Content.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.esm.js","sources":["../../../src/components/HomePageOnCallCard/Content.tsx"],"sourcesContent":["import { Progress } from \"@backstage/core-components\";\nimport { useIdentity } from \"../../hooks/useIncidentRequest\";\nimport { useAllEscalationPaths, useAllSchedules } from \"../../hooks/useOnCallRequest\";\nimport { Alert } from \"@material-ui/lab\";\nimport {\n Box,\n Divider,\n IconButton,\n Tooltip,\n Typography,\n} from \"@material-ui/core\";\nimport OpenInBrowserIcon from \"@material-ui/icons/OpenInBrowser\";\n\nexport const Content = () => {\n const { value: identity } = useIdentity();\n const baseUrl = identity?.identity.dashboard_url ?? \"app.incident.io\";\n\n const { value: eps, loading: epsLoading, error: epsError } = useAllEscalationPaths();\n const { value: schedules, loading: schedulesLoading, error: schedulesError } = useAllSchedules();\n\n if (epsLoading || schedulesLoading) return <Progress />;\n\n return (\n <>\n <Typography variant=\"subtitle1\"><strong>Escalation Paths</strong></Typography>\n <Divider />\n {epsError && <Alert severity=\"error\">{epsError.message}</Alert>}\n {eps && eps.length === 0 && <Typography variant=\"body2\" color=\"textSecondary\">No escalation paths.</Typography>}\n {eps && eps.map(ep => (\n <Box key={ep.id} display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\" py={0.5}>\n <Typography variant=\"body2\">{ep.name}</Typography>\n <Tooltip title=\"View in incident.io\" placement=\"top\">\n <IconButton size=\"small\" href={`${baseUrl}/on-call/escalation-paths/${ep.id}`} target=\"_blank\" rel=\"noopener noreferrer\" color=\"primary\">\n <OpenInBrowserIcon fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n </Box>\n ))}\n\n <Box mt={2}>\n <Typography variant=\"subtitle1\"><strong>Schedules</strong></Typography>\n <Divider />\n {schedulesError && <Alert severity=\"error\">{schedulesError.message}</Alert>}\n {schedules && schedules.length === 0 && <Typography variant=\"body2\" color=\"textSecondary\">No schedules.</Typography>}\n {schedules && schedules.map(schedule => (\n <Box key={schedule.id} display=\"flex\" alignItems=\"center\" justifyContent=\"space-between\" py={0.5}>\n <Typography variant=\"body2\">{schedule.name}</Typography>\n <Tooltip title=\"View in incident.io\" placement=\"top\">\n <IconButton size=\"small\" href={`${baseUrl}/on-call/schedules/${schedule.id}`} target=\"_blank\" rel=\"noopener noreferrer\" color=\"primary\">\n <OpenInBrowserIcon fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n </Box>\n ))}\n </Box>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAaO,MAAM,UAAU,MAAM;AAC3B,EAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAS,GAAI,WAAA,EAAY;AACxC,EAAA,MAAM,OAAA,GAAU,QAAA,EAAU,QAAA,CAAS,aAAA,IAAiB,iBAAA;AAEpD,EAAA,MAAM,EAAE,OAAO,GAAA,EAAK,OAAA,EAAS,YAAY,KAAA,EAAO,QAAA,KAAa,qBAAA,EAAsB;AACnF,EAAA,MAAM,EAAE,OAAO,SAAA,EAAW,OAAA,EAAS,kBAAkB,KAAA,EAAO,cAA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AO,QAAA,EAAS,GAAA,EAAI,qBAAA,EAAsB,KAAA,EAAM,SAAA,EAC5H,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,QAAA,EAAS,OAAA,EAAQ,CAAA,EACtC,CAAA,EACF;AAAA,OAAA,EAAA,EANQ,QAAA,CAAS,EAOnB,CACD;AAAA,KAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,6 @@
1
+ export { Content } from './Content.esm.js';
2
+
3
+ const ContextProvider = ({ children }) => children;
4
+
5
+ export { ContextProvider };
6
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/HomePageOnCallCard/index.ts"],"sourcesContent":["export { Content } from \"./Content\";\n\nexport const ContextProvider = ({ children }: { children: JSX.Element }) => children;\n"],"names":[],"mappings":";;AAEO,MAAM,eAAA,GAAkB,CAAC,EAAE,QAAA,EAAS,KAAiC;;;;"}
@@ -0,0 +1,68 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { DateTime, Duration } from 'luxon';
3
+ import { ListItem, ListItemText, Typography, Chip, ListItemSecondaryAction, Tooltip, IconButton } from '@material-ui/core';
4
+ import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
5
+ import { useStyles } from '../styles.esm.js';
6
+
7
+ const IncidentListItem = ({
8
+ baseUrl,
9
+ incident
10
+ }) => {
11
+ const classes = useStyles();
12
+ const reportedAt = incident.incident_timestamp_values?.find(
13
+ (ts) => ts.incident_timestamp.name.match(/reported/i)
14
+ );
15
+ const reportedAtDate = reportedAt?.value?.value || incident.created_at;
16
+ const sinceReported = (/* @__PURE__ */ new Date()).getTime() - new Date(reportedAtDate).getTime();
17
+ const sinceReportedLabel = DateTime.local().minus(Duration.fromMillis(sinceReported)).toRelative({ locale: "en" });
18
+ const lead = incident.incident_role_assignments.find((roleAssignment) => {
19
+ return roleAssignment.role.role_type === "lead";
20
+ });
21
+ return /* @__PURE__ */ jsxs(ListItem, { dense: true, children: [
22
+ /* @__PURE__ */ jsx(
23
+ ListItemText,
24
+ {
25
+ primary: /* @__PURE__ */ jsxs(Fragment, { children: [
26
+ /* @__PURE__ */ jsx(
27
+ Chip,
28
+ {
29
+ "data-testid": `chip-${incident.incident_status.id}`,
30
+ label: incident.incident_status.name,
31
+ size: "small",
32
+ variant: "outlined",
33
+ className: ["active"].includes(incident.incident_status.category) ? classes.error : classes.warning
34
+ }
35
+ ),
36
+ incident.reference,
37
+ " ",
38
+ incident.name
39
+ ] }),
40
+ primaryTypographyProps: {
41
+ variant: "body1",
42
+ className: classes.listItemPrimary
43
+ },
44
+ secondary: /* @__PURE__ */ jsxs(Typography, { noWrap: true, variant: "body2", color: "textSecondary", children: [
45
+ "Reported ",
46
+ sinceReportedLabel,
47
+ " and",
48
+ " ",
49
+ lead?.assignee ? `${lead.assignee.name} is lead` : "the lead is unassigned",
50
+ "."
51
+ ] })
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(ListItemSecondaryAction, { children: /* @__PURE__ */ jsx(Tooltip, { title: "View in incident.io", placement: "top", children: /* @__PURE__ */ jsx(
55
+ IconButton,
56
+ {
57
+ href: `${baseUrl}/incidents/${incident.id}`,
58
+ target: "_blank",
59
+ rel: "noopener noreferrer",
60
+ color: "primary",
61
+ children: /* @__PURE__ */ jsx(OpenInBrowserIcon, {})
62
+ }
63
+ ) }) })
64
+ ] }, incident.id);
65
+ };
66
+
67
+ export { IncidentListItem };
68
+ //# sourceMappingURL=index.esm.js.map