@pagerduty/backstage-plugin 0.12.1-next.9 → 0.12.1-next.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index-0909ce8b.esm.js +276 -0
- package/dist/esm/index-0909ce8b.esm.js.map +1 -0
- package/dist/esm/{index-af98e993.esm.js → index-0fb4de6c.esm.js} +2 -2
- package/dist/esm/{index-af98e993.esm.js.map → index-0fb4de6c.esm.js.map} +1 -1
- package/dist/esm/{index-d4b445d8.esm.js → index-53ae5dcf.esm.js} +23 -5
- package/dist/esm/index-53ae5dcf.esm.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.esm.js +1 -1
- package/package.json +9 -3
- package/dist/esm/index-c05cbebd.esm.js +0 -71
- package/dist/esm/index-c05cbebd.esm.js.map +0 -1
- package/dist/esm/index-d4b445d8.esm.js.map +0 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
|
+
import { Typography, Box, DialogTitle, DialogContent, Grid, DialogActions, Tooltip, IconButton } from '@material-ui/core';
|
|
3
|
+
import { Page, Header, Content } from '@backstage/core-components';
|
|
4
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
5
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
6
|
+
import { p as pagerDutyApiRef } from './index-53ae5dcf.esm.js';
|
|
7
|
+
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
8
|
+
import { useMaterialReactTable, MRT_EditActionButtons, MaterialReactTable } from 'material-react-table';
|
|
9
|
+
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
10
|
+
import { OpenInBrowser } from '@material-ui/icons';
|
|
11
|
+
import '@backstage/errors';
|
|
12
|
+
import '@backstage/plugin-home-react';
|
|
13
|
+
import 'luxon';
|
|
14
|
+
import '@material-ui/icons/OpenInBrowser';
|
|
15
|
+
import '../assets/emptystate.svg';
|
|
16
|
+
import 'react-use/lib/useAsyncFn';
|
|
17
|
+
import '@material-ui/lab';
|
|
18
|
+
import '../assets/forbiddenstate.svg';
|
|
19
|
+
import '@material-ui/core/Avatar';
|
|
20
|
+
import '@material-ui/icons/Notifications';
|
|
21
|
+
import 'react-use/lib/useAsync';
|
|
22
|
+
import '@material-ui/icons/Link';
|
|
23
|
+
import '../assets/PD-Green.svg';
|
|
24
|
+
import '../assets/PD-White.svg';
|
|
25
|
+
import 'validate-color';
|
|
26
|
+
import '@material-ui/icons/Info';
|
|
27
|
+
import '@material-ui/icons/CheckCircle';
|
|
28
|
+
import '@material-ui/icons/RadioButtonUnchecked';
|
|
29
|
+
import '@material-ui/core/styles';
|
|
30
|
+
import 'react-use';
|
|
31
|
+
import '@material-ui/lab/Alert/Alert';
|
|
32
|
+
import '@backstage/catalog-model';
|
|
33
|
+
import '@material-ui/icons/AddAlert';
|
|
34
|
+
import '@material-ui/icons/ExpandMore';
|
|
35
|
+
|
|
36
|
+
function getColorFromStatus(status) {
|
|
37
|
+
switch (status) {
|
|
38
|
+
case "InSync":
|
|
39
|
+
return "green";
|
|
40
|
+
case "OutOfSync":
|
|
41
|
+
return "red";
|
|
42
|
+
case "NotMapped":
|
|
43
|
+
return "orange";
|
|
44
|
+
default:
|
|
45
|
+
return "gray";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function makeReadable(status) {
|
|
49
|
+
switch (status) {
|
|
50
|
+
case "InSync":
|
|
51
|
+
return "In Sync";
|
|
52
|
+
case "OutOfSync":
|
|
53
|
+
return "Out of Sync";
|
|
54
|
+
case "NotMapped":
|
|
55
|
+
return "Not Mapped";
|
|
56
|
+
default:
|
|
57
|
+
return "Refresh to Update";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const ServiceMappingComponent = () => {
|
|
61
|
+
const [catalogEntities, setCatalogEntities] = useState([]);
|
|
62
|
+
const [entityOptions, setEntityOptions] = useState([]);
|
|
63
|
+
const pagerDutyApi = useApi(pagerDutyApiRef);
|
|
64
|
+
const catalogApi = useApi(catalogApiRef);
|
|
65
|
+
function useGetMappings() {
|
|
66
|
+
return useQuery({
|
|
67
|
+
queryKey: ["mappings"],
|
|
68
|
+
queryFn: async () => {
|
|
69
|
+
const { mappings: foundMappings } = await pagerDutyApi.getEntityMappings();
|
|
70
|
+
return foundMappings;
|
|
71
|
+
},
|
|
72
|
+
refetchOnWindowFocus: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function useUpdateMapping() {
|
|
76
|
+
const queryClient2 = useQueryClient();
|
|
77
|
+
return useMutation({
|
|
78
|
+
mutationFn: async (mapping) => {
|
|
79
|
+
return await pagerDutyApi.storeServiceMapping(
|
|
80
|
+
mapping.serviceId,
|
|
81
|
+
mapping.entityRef
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
// client side optimistic update
|
|
85
|
+
onMutate: (newMappingInfo) => {
|
|
86
|
+
queryClient2.setQueryData(
|
|
87
|
+
["updateMappings"],
|
|
88
|
+
(prevMappings) => prevMappings == null ? void 0 : prevMappings.map(
|
|
89
|
+
(prevMapping) => {
|
|
90
|
+
var _a;
|
|
91
|
+
if (prevMapping.serviceId === newMappingInfo.serviceId) {
|
|
92
|
+
newMappingInfo.entityName = ((_a = catalogEntities.find((entity) => entity.id === newMappingInfo.entityRef)) == null ? void 0 : _a.name) || "";
|
|
93
|
+
return newMappingInfo;
|
|
94
|
+
}
|
|
95
|
+
return prevMapping;
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function fetchCatalogEntities() {
|
|
103
|
+
catalogApi.getEntities({
|
|
104
|
+
filter: { kind: "Component" }
|
|
105
|
+
}).then(({ items }) => {
|
|
106
|
+
const entities = [];
|
|
107
|
+
items.forEach((entity) => {
|
|
108
|
+
var _a, _b, _c, _d, _e, _f;
|
|
109
|
+
entities.push({
|
|
110
|
+
name: (_a = entity.metadata) == null ? void 0 : _a.name,
|
|
111
|
+
id: (_c = (_b = entity.metadata) == null ? void 0 : _b.uid) != null ? _c : "",
|
|
112
|
+
system: JSON.stringify((_d = entity.spec) == null ? void 0 : _d.system) || "",
|
|
113
|
+
owner: JSON.stringify((_e = entity.spec) == null ? void 0 : _e.owner) || "",
|
|
114
|
+
lifecycle: JSON.stringify((_f = entity.spec) == null ? void 0 : _f.lifecycle) || ""
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
setCatalogEntities(entities);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function getCatalogEntityOptions() {
|
|
121
|
+
if (catalogEntities.length === 0) {
|
|
122
|
+
fetchCatalogEntities();
|
|
123
|
+
}
|
|
124
|
+
if (entityOptions.length === 0) {
|
|
125
|
+
const options = [];
|
|
126
|
+
options.push({ value: "", label: "None" });
|
|
127
|
+
catalogEntities.forEach((entity) => {
|
|
128
|
+
options.push({
|
|
129
|
+
value: entity.id,
|
|
130
|
+
label: entity.name
|
|
131
|
+
});
|
|
132
|
+
setEntityOptions(options);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return entityOptions;
|
|
136
|
+
}
|
|
137
|
+
const DenseTable = () => {
|
|
138
|
+
const [validationErrors, setValidationErrors] = useState({});
|
|
139
|
+
const columns = useMemo(
|
|
140
|
+
() => [
|
|
141
|
+
{
|
|
142
|
+
accessorKey: "serviceId",
|
|
143
|
+
header: "Service ID",
|
|
144
|
+
visibleInShowHideMenu: false,
|
|
145
|
+
enableEditing: false,
|
|
146
|
+
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(Typography, { variant: "body1", style: { fontWeight: 600 } }, cell.getValue())
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
accessorKey: "serviceName",
|
|
150
|
+
header: "PagerDuty Service",
|
|
151
|
+
enableEditing: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
accessorKey: "team",
|
|
155
|
+
header: "Team",
|
|
156
|
+
enableEditing: false
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
accessorKey: "escalationPolicy",
|
|
160
|
+
header: "Escalation Policy",
|
|
161
|
+
enableEditing: false
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
accessorKey: "entityRef",
|
|
165
|
+
header: "Mapping",
|
|
166
|
+
visibleInShowHideMenu: false,
|
|
167
|
+
editVariant: "select",
|
|
168
|
+
editSelectOptions: getCatalogEntityOptions(),
|
|
169
|
+
muiEditTextFieldProps: {
|
|
170
|
+
select: true,
|
|
171
|
+
error: !!(validationErrors == null ? void 0 : validationErrors.state),
|
|
172
|
+
helperText: validationErrors == null ? void 0 : validationErrors.state
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
accessorKey: "entityName",
|
|
177
|
+
header: "Mapped Entity Name",
|
|
178
|
+
enableEditing: false
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
accessorKey: "status",
|
|
182
|
+
header: "Status",
|
|
183
|
+
enableEditing: false,
|
|
184
|
+
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(
|
|
185
|
+
Box,
|
|
186
|
+
{
|
|
187
|
+
component: "span",
|
|
188
|
+
bgcolor: getColorFromStatus(cell.getValue()),
|
|
189
|
+
borderRadius: "0.25rem",
|
|
190
|
+
color: "white",
|
|
191
|
+
p: "0.25rem"
|
|
192
|
+
},
|
|
193
|
+
makeReadable(cell.getValue())
|
|
194
|
+
)
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
accessorKey: "serviceUrl",
|
|
198
|
+
header: "Service URL",
|
|
199
|
+
visibleInShowHideMenu: false,
|
|
200
|
+
enableEditing: false
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
[validationErrors]
|
|
204
|
+
);
|
|
205
|
+
const {
|
|
206
|
+
data: fetchedMappings = [],
|
|
207
|
+
isError: isLoadingMappingsError,
|
|
208
|
+
isFetching: isFetchingMappings,
|
|
209
|
+
isLoading: isLoadingMappings
|
|
210
|
+
} = useGetMappings();
|
|
211
|
+
const { mutateAsync: updateMapping, isPending: isUpdatingMapping } = useUpdateMapping();
|
|
212
|
+
const handleSaveMapping = async ({ values, table }) => {
|
|
213
|
+
var _a;
|
|
214
|
+
setValidationErrors({});
|
|
215
|
+
values.entityName = ((_a = catalogEntities.find((entity) => entity.id === values.entityRef)) == null ? void 0 : _a.name) || "";
|
|
216
|
+
values.status = "RefreshToUpdate";
|
|
217
|
+
await updateMapping(values);
|
|
218
|
+
table.setEditingRow(null);
|
|
219
|
+
};
|
|
220
|
+
const openInBrowser = (url) => {
|
|
221
|
+
window.open(url, "_blank", "noreferrer");
|
|
222
|
+
};
|
|
223
|
+
const dataTable = useMaterialReactTable({
|
|
224
|
+
columns,
|
|
225
|
+
data: fetchedMappings,
|
|
226
|
+
editDisplayMode: "modal",
|
|
227
|
+
// default ('row', 'cell', 'table', and 'custom' are also available)
|
|
228
|
+
enableEditing: true,
|
|
229
|
+
positionActionsColumn: "last",
|
|
230
|
+
enableStickyHeader: true,
|
|
231
|
+
enableFilters: true,
|
|
232
|
+
getRowId: (row) => row.serviceId,
|
|
233
|
+
muiToolbarAlertBannerProps: isLoadingMappingsError ? {
|
|
234
|
+
color: "error",
|
|
235
|
+
children: "Error loading data"
|
|
236
|
+
} : void 0,
|
|
237
|
+
muiTableContainerProps: {
|
|
238
|
+
sx: {
|
|
239
|
+
minHeight: "500px"
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
onEditingRowCancel: () => setValidationErrors({}),
|
|
243
|
+
onEditingRowSave: handleSaveMapping,
|
|
244
|
+
// optionally customize modal content
|
|
245
|
+
renderEditRowDialogContent: ({ table, row }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DialogTitle, null, "Edit Mapping"), /* @__PURE__ */ React.createElement(DialogContent, null, /* @__PURE__ */ React.createElement(Grid, null, /* @__PURE__ */ React.createElement(Typography, { variant: "overline" }, /* @__PURE__ */ React.createElement("b", null, "PagerDuty Service")), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, row.getValue("serviceName")), /* @__PURE__ */ React.createElement(Typography, { variant: "overline" }, /* @__PURE__ */ React.createElement("b", null, "Team")), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, row.getValue("team")), /* @__PURE__ */ React.createElement(Typography, { variant: "overline" }, /* @__PURE__ */ React.createElement("b", null, "Escalation Policy")), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, row.getValue("escalationPolicy")), /* @__PURE__ */ React.createElement(Typography, { variant: "overline" }, /* @__PURE__ */ React.createElement("b", null, "Mapping")), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, row.getValue("entityRef")))), /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(MRT_EditActionButtons, { variant: "text", table, row }))),
|
|
246
|
+
renderRowActions: ({ row, table }) => /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex" } }, /* @__PURE__ */ React.createElement(Tooltip, { title: "Edit" }, /* @__PURE__ */ React.createElement(IconButton, { onClick: () => table.setEditingRow(row) }, /* @__PURE__ */ React.createElement(EditIcon, null))), /* @__PURE__ */ React.createElement(Tooltip, { title: "Open in PagerDuty" }, /* @__PURE__ */ React.createElement(
|
|
247
|
+
IconButton,
|
|
248
|
+
{
|
|
249
|
+
onClick: () => openInBrowser(row.getValue("serviceUrl"))
|
|
250
|
+
},
|
|
251
|
+
/* @__PURE__ */ React.createElement(OpenInBrowser, null)
|
|
252
|
+
))),
|
|
253
|
+
state: {
|
|
254
|
+
isLoading: isLoadingMappings,
|
|
255
|
+
isSaving: isUpdatingMapping,
|
|
256
|
+
showAlertBanner: isLoadingMappingsError,
|
|
257
|
+
showProgressBars: isFetchingMappings,
|
|
258
|
+
columnVisibility: {
|
|
259
|
+
serviceId: false,
|
|
260
|
+
entityRef: false,
|
|
261
|
+
serviceUrl: false
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
|
|
266
|
+
};
|
|
267
|
+
const queryClient = new QueryClient();
|
|
268
|
+
return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(DenseTable, null));
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const PagerDutyPage = () => {
|
|
272
|
+
return /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(Header, { title: "PagerDuty", subtitle: "Advanced configurations" }), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, direction: "column" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, "Service to Entity mapping"), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, "Easily map your services to entities in Backstage without the need to add anotations to all your projects."), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, /* @__PURE__ */ React.createElement("b", null, "Warning: "), "Only 1:1 mapping is allowed at this time.")), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(ServiceMappingComponent, null)))));
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export { PagerDutyPage };
|
|
276
|
+
//# sourceMappingURL=index-0909ce8b.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-0909ce8b.esm.js","sources":["../../src/components/PagerDutyPage/ServiceMappingComponent.tsx","../../src/components/PagerDutyPage/index.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport {\n Box,\n DialogActions,\n DialogContent,\n DialogTitle,\n Grid,\n IconButton,\n Tooltip,\n Typography,\n} from \"@material-ui/core\";\nimport EditIcon from \"@mui/icons-material/Edit\";\nimport { PagerDutyEntityMapping } from \"@pagerduty/backstage-plugin-common\";\nimport { useApi } from \"@backstage/core-plugin-api\";\nimport { pagerDutyApiRef } from \"../../api\";\nimport {\n QueryClient,\n QueryClientProvider,\n useMutation,\n useQuery,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport {\n DropdownOption,\n MRT_ColumnDef,\n MRT_EditActionButtons, \n MRT_TableOptions,\n MaterialReactTable,\n useMaterialReactTable,\n} from \"material-react-table\";\nimport { catalogApiRef } from \"@backstage/plugin-catalog-react\";\nimport { OpenInBrowser } from \"@material-ui/icons\";\n// import { catalogApiRef } from \"@backstage/plugin-catalog-react\";\n// import { Entity } from \"@backstage/catalog-model\";\n\ntype Service = {\n name: string; // \"Ads\"\n id: string; // \"QWe1j283n12j132\"\n system: string; // \"Production\"\n owner: string; // \"Mapped\"\n lifecycle: string; // \"Ads\"\n};\n\n// type TableItem = {\n// name: string | undefined;\n// team: string | undefined;\n// escalationPolicy: string | undefined;\n// mappingStatus: JSX.Element;\n// mapping: JSX.Element;\n// actions: JSX.Element;\n// };\n\n// type DenseTableProps = {\n// items: TableItem[];\n// };\n\nfunction getColorFromStatus(status?: string) {\n switch (status) {\n case \"InSync\":\n return \"green\";\n case \"OutOfSync\":\n return \"red\";\n case \"NotMapped\":\n return \"orange\";\n default:\n return \"gray\";\n }\n}\n\nfunction makeReadable(status?: string) {\n switch (status) {\n case \"InSync\":\n return \"In Sync\";\n case \"OutOfSync\":\n return \"Out of Sync\";\n case \"NotMapped\":\n return \"Not Mapped\";\n default:\n return \"Refresh to Update\";\n }\n}\n\nexport const ServiceMappingComponent = () => {\n\n const [catalogEntities, setCatalogEntities] = useState<Service[]>([]);\n const [entityOptions, setEntityOptions] = useState<DropdownOption[]>([]);\n\n const pagerDutyApi = useApi(pagerDutyApiRef);\n const catalogApi = useApi(catalogApiRef);\n\n // READ hook (get mappings from api)\n function useGetMappings() {\n return useQuery<PagerDutyEntityMapping[]>({\n queryKey: [\"mappings\"],\n queryFn: async () => {\n // send api request here\n const { mappings: foundMappings } =\n await pagerDutyApi.getEntityMappings();\n\n return foundMappings;\n },\n refetchOnWindowFocus: false,\n });\n }\n\n // UPDATE hook (put mapping in api)\n function useUpdateMapping() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (mapping: PagerDutyEntityMapping) => {\n return await pagerDutyApi.storeServiceMapping(\n mapping.serviceId,\n mapping.entityRef\n );\n },\n // client side optimistic update\n onMutate: (newMappingInfo: PagerDutyEntityMapping) => {\n queryClient.setQueryData([\"updateMappings\"], (prevMappings: any) =>\n prevMappings?.map((prevMapping: PagerDutyEntityMapping) => {\n if (prevMapping.serviceId === newMappingInfo.serviceId) {\n newMappingInfo.entityName = catalogEntities.find((entity) => entity.id === newMappingInfo.entityRef)?.name || \"\";\n\n return newMappingInfo;\n }\n return prevMapping; \n }\n )\n );\n },\n });\n }\n\n function fetchCatalogEntities() {\n catalogApi\n .getEntities({\n filter: { kind: \"Component\" },\n })\n .then(({ items }) => {\n const entities: Service[] = [];\n items.forEach((entity: any) => {\n entities.push({\n name: entity.metadata?.name,\n id: entity.metadata?.uid ?? \"\",\n system: JSON.stringify(entity.spec?.system) || \"\",\n owner: JSON.stringify(entity.spec?.owner) || \"\",\n lifecycle: JSON.stringify(entity.spec?.lifecycle) || \"\",\n });\n });\n setCatalogEntities(entities);\n });\n }\n\n function getCatalogEntityOptions() : DropdownOption[] {\n // fetch entities if not already fetched\n if (catalogEntities.length === 0) {\n fetchCatalogEntities();\n }\n\n if(entityOptions.length === 0) {\n const options : DropdownOption[] = [];\n // Add empty object\n options.push({ value: \"\", label: \"None\" });\n\n catalogEntities.forEach((entity) => {\n options.push({\n value: entity.id,\n label: entity.name,\n });\n setEntityOptions(options);\n });\n }\n\n return entityOptions;\n }\n\n const DenseTable = () => {\n const [validationErrors, setValidationErrors] = useState<\n Record<string, string | undefined>\n >({});\n\n const columns = useMemo<MRT_ColumnDef<PagerDutyEntityMapping>[]>(\n () => [\n {\n accessorKey: \"serviceId\",\n header: \"Service ID\",\n visibleInShowHideMenu: false,\n enableEditing: false,\n Cell: ({ cell }) => (\n <Typography variant=\"body1\" style={{fontWeight: 600}}>\n {cell.getValue<string>()}\n </Typography> \n ),\n },\n {\n accessorKey: \"serviceName\",\n header: \"PagerDuty Service\",\n enableEditing: false,\n },\n {\n accessorKey: \"team\",\n header: \"Team\",\n enableEditing: false,\n },\n {\n accessorKey: \"escalationPolicy\",\n header: \"Escalation Policy\",\n enableEditing: false,\n },\n {\n accessorKey: \"entityRef\",\n header: \"Mapping\",\n visibleInShowHideMenu: false,\n editVariant: \"select\",\n editSelectOptions: getCatalogEntityOptions(),\n muiEditTextFieldProps: {\n select: true,\n error: !!validationErrors?.state,\n helperText: validationErrors?.state,\n },\n },\n {\n accessorKey: \"entityName\",\n header: \"Mapped Entity Name\",\n enableEditing: false,\n },\n {\n accessorKey: \"status\",\n header: \"Status\",\n enableEditing: false,\n Cell: ({ cell }) => (\n <Box\n component=\"span\"\n bgcolor={getColorFromStatus(cell.getValue<string>())}\n borderRadius=\"0.25rem\"\n color=\"white\"\n p=\"0.25rem\"\n >\n {makeReadable(cell.getValue<string>())}\n </Box>\n ),\n },\n {\n accessorKey: \"serviceUrl\",\n header: \"Service URL\",\n visibleInShowHideMenu: false,\n enableEditing: false,\n },\n ],\n [validationErrors]\n );\n\n // call READ hook\n const {\n data: fetchedMappings = [],\n isError: isLoadingMappingsError,\n isFetching: isFetchingMappings,\n isLoading: isLoadingMappings,\n } = useGetMappings();\n\n // call UPDATE hook\n const { mutateAsync: updateMapping, isPending: isUpdatingMapping } =\n useUpdateMapping();\n\n // UPDATE action\n const handleSaveMapping: MRT_TableOptions<PagerDutyEntityMapping>[\"onEditingRowSave\"] =\n async ({ values, table }) => {\n setValidationErrors({});\n values.entityName = catalogEntities.find((entity) => entity.id === values.entityRef)?.name || \"\";\n values.status = \"RefreshToUpdate\";\n await updateMapping(values);\n table.setEditingRow(null); // exit editing mode\n };\n\n const openInBrowser = (url: string) => {\n window.open(url, \"_blank\", \"noreferrer\");\n };\n\n const dataTable = useMaterialReactTable({\n columns,\n data: fetchedMappings,\n editDisplayMode: \"modal\", // default ('row', 'cell', 'table', and 'custom' are also available)\n enableEditing: true,\n positionActionsColumn: \"last\",\n enableStickyHeader: true,\n enableFilters: true,\n getRowId: (row) => row.serviceId,\n muiToolbarAlertBannerProps: isLoadingMappingsError\n ? {\n color: \"error\",\n children: \"Error loading data\",\n }\n : undefined,\n muiTableContainerProps: {\n sx: {\n minHeight: \"500px\",\n },\n },\n onEditingRowCancel: () => setValidationErrors({}),\n onEditingRowSave: handleSaveMapping,\n // optionally customize modal content\n renderEditRowDialogContent: ({ table, row }) => (\n <>\n <DialogTitle>Edit Mapping</DialogTitle>\n <DialogContent>\n <Grid>\n <Typography variant=\"overline\">\n <b>PagerDuty Service</b>\n </Typography>\n <Typography variant=\"body2\">\n {row.getValue(\"serviceName\")}\n </Typography>\n <Typography variant=\"overline\">\n <b>Team</b>\n </Typography>\n <Typography variant=\"body2\">{row.getValue(\"team\")}</Typography>\n <Typography variant=\"overline\">\n <b>Escalation Policy</b>\n </Typography>\n <Typography variant=\"body2\">\n {row.getValue(\"escalationPolicy\")}\n </Typography>\n <Typography variant=\"overline\">\n <b>Mapping</b>\n </Typography>\n <Typography variant=\"body2\">\n {row.getValue(\"entityRef\")}\n </Typography>\n </Grid>\n {/* {internalEditComponents}{\" \"} */}\n {/* or render custom edit components here */}\n </DialogContent>\n <DialogActions>\n <MRT_EditActionButtons variant=\"text\" table={table} row={row} />\n </DialogActions>\n </>\n ),\n renderRowActions: ({ row, table }) => (\n <Box sx={{ display: \"flex\" }}>\n <Tooltip title=\"Edit\">\n <IconButton onClick={() => table.setEditingRow(row)}>\n <EditIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Open in PagerDuty\">\n <IconButton\n onClick={() => openInBrowser(row.getValue(\"serviceUrl\"))}\n >\n <OpenInBrowser />\n </IconButton>\n </Tooltip>\n </Box>\n ),\n state: {\n isLoading: isLoadingMappings,\n isSaving: isUpdatingMapping,\n showAlertBanner: isLoadingMappingsError,\n showProgressBars: isFetchingMappings,\n columnVisibility: {\n serviceId: false,\n entityRef: false,\n serviceUrl: false,\n },\n },\n });\n\n return <MaterialReactTable table={dataTable} />;\n };\n\n const queryClient = new QueryClient();\n\n return (\n <QueryClientProvider client={queryClient}>\n <DenseTable />\n </QueryClientProvider>\n );\n};\n","import React from \"react\";\nimport { Grid, Typography } from \"@material-ui/core\";\nimport { Header, Page, Content } from \"@backstage/core-components\";\nimport { ServiceMappingComponent } from \"./ServiceMappingComponent\";\n\n/** @public */\nexport const PagerDutyPage = () => {\n return (\n <Page themeId=\"home\">\n <Header title=\"PagerDuty\" subtitle=\"Advanced configurations\" />\n <Content>\n <Grid container spacing={3} direction=\"column\">\n <Grid item>\n <Typography variant=\"h4\">Service to Entity mapping</Typography>\n <Typography variant=\"body1\">\n Easily map your services to entities in Backstage without the need to add anotations to all your projects.\n </Typography>\n <Typography variant=\"body1\">\n <b>Warning: </b>Only 1:1 mapping is allowed at this time.\n </Typography>\n </Grid>\n <Grid item>\n <ServiceMappingComponent />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["queryClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAS,mBAAmB,MAAiB,EAAA;AAC3C,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,QAAA;AACH,MAAO,OAAA,OAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,KAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,QAAA,CAAA;AAAA,IACT;AACE,MAAO,OAAA,MAAA,CAAA;AAAA,GACX;AACF,CAAA;AAEA,SAAS,aAAa,MAAiB,EAAA;AACrC,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,QAAA;AACH,MAAO,OAAA,SAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,aAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,YAAA,CAAA;AAAA,IACT;AACE,MAAO,OAAA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,aAAA,CAAC,MAAO,EAAA,EAAA,KAAA,EAAM,WAAY,EAAA,QAAA,EAAS,yBAA0B,EAAA,CAAA,kBAC5D,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,sCACE,IAAK,EAAA,EAAA,SAAA,EAAS,IAAC,EAAA,OAAA,EAAS,CAAG,EAAA,SAAA,EAAU,QACpC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,2BAAyB,CAAA,kBACjD,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,EAAQ,4GAE5B,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAE,WAAS,CAAA,EAAI,2CAClB,CACF,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,uBAAwB,EAAA,IAAA,CAC3B,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { P as PagerDutyCard } from './index-
|
|
2
|
+
import { P as PagerDutyCard } from './index-53ae5dcf.esm.js';
|
|
3
3
|
import '@backstage/core-plugin-api';
|
|
4
4
|
import '@backstage/errors';
|
|
5
5
|
import '@backstage/plugin-home-react';
|
|
@@ -34,4 +34,4 @@ const Content = (props) => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export { Content };
|
|
37
|
-
//# sourceMappingURL=index-
|
|
37
|
+
//# sourceMappingURL=index-0fb4de6c.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-0fb4de6c.esm.js","sources":["../../src/components/HomePagePagerDutyCard/Content.tsx"],"sourcesContent":["/*\n * Copyright 2020 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// eslint-disable-next-line @backstage/no-undeclared-imports\nimport React from 'react';\n\nimport { PagerDutyEntity } from '../../types';\nimport { PagerDutyCard } from '../PagerDutyCard';\n\n/** @public */\nexport type HomePagePagerDutyCardProps = PagerDutyEntity & {\n readOnly?: boolean;\n};\n\n/** @public */\nexport const Content = (props: HomePagePagerDutyCardProps) => {\n return <PagerDutyCard {...props} />;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Ba,MAAA,OAAA,GAAU,CAAC,KAAsC,KAAA;AAC5D,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,aAAe,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA,CAAA;AACnC;;;;"}
|
|
@@ -83,12 +83,30 @@ class PagerDutyClient {
|
|
|
83
83
|
}
|
|
84
84
|
return response;
|
|
85
85
|
}
|
|
86
|
-
async
|
|
86
|
+
async getEntityMappings() {
|
|
87
87
|
const url = `${await this.config.discoveryApi.getBaseUrl(
|
|
88
88
|
"pagerduty"
|
|
89
|
-
)}/
|
|
89
|
+
)}/mapping/entity`;
|
|
90
90
|
return await this.findByUrl(url);
|
|
91
91
|
}
|
|
92
|
+
async storeServiceMapping(serviceId, backstageEntityId) {
|
|
93
|
+
const body = JSON.stringify({
|
|
94
|
+
entityRef: backstageEntityId,
|
|
95
|
+
serviceId
|
|
96
|
+
});
|
|
97
|
+
const options = {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: {
|
|
100
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
101
|
+
Accept: "application/json, text/plain, */*"
|
|
102
|
+
},
|
|
103
|
+
body
|
|
104
|
+
};
|
|
105
|
+
const url = `${await this.config.discoveryApi.getBaseUrl(
|
|
106
|
+
"pagerduty"
|
|
107
|
+
)}/mapping/entity`;
|
|
108
|
+
return this.request(url, options);
|
|
109
|
+
}
|
|
92
110
|
async getServiceByEntity(entity) {
|
|
93
111
|
return await this.getServiceByPagerDutyEntity(getPagerDutyEntity(entity));
|
|
94
112
|
}
|
|
@@ -211,7 +229,7 @@ const pagerDutyPlugin = createPlugin({
|
|
|
211
229
|
const PagerDutyPage = pagerDutyPlugin.provide(
|
|
212
230
|
createRoutableExtension({
|
|
213
231
|
name: "PagerDutyPage",
|
|
214
|
-
component: () => import('./index-
|
|
232
|
+
component: () => import('./index-0909ce8b.esm.js').then((m) => m.PagerDutyPage),
|
|
215
233
|
mountPoint: rootRouteRef
|
|
216
234
|
})
|
|
217
235
|
);
|
|
@@ -239,7 +257,7 @@ const HomePagePagerDutyCard = pagerDutyPlugin.provide(
|
|
|
239
257
|
createCardExtension({
|
|
240
258
|
name: "HomePagePagerDutyCard",
|
|
241
259
|
title: "PagerDuty Homepage Card",
|
|
242
|
-
components: () => import('./index-
|
|
260
|
+
components: () => import('./index-0fb4de6c.esm.js'),
|
|
243
261
|
settings: {
|
|
244
262
|
schema: {
|
|
245
263
|
title: "PagerDuty",
|
|
@@ -1605,4 +1623,4 @@ function TriggerButton(props) {
|
|
|
1605
1623
|
const PagerDutyCard = EntityPagerDutyCard;
|
|
1606
1624
|
|
|
1607
1625
|
export { EntityPagerDutyCard$1 as E, HomePagePagerDutyCard as H, PagerDutyCard$1 as P, TriggerButton as T, UnauthorizedError as U, pagerDutyPlugin as a, PagerDutyPage as b, EntityPagerDutySmallCard$1 as c, isPluginApplicableToEntity as d, PagerDutyClient as e, PagerDutyCard as f, isPluginApplicableToEntity$1 as i, pagerDutyApiRef as p };
|
|
1608
|
-
//# sourceMappingURL=index-
|
|
1626
|
+
//# sourceMappingURL=index-53ae5dcf.esm.js.map
|