@pagerduty/backstage-plugin 0.13.0-next.24 → 0.13.0-next.25

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.
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+
3
+ const MappingTable = ({ mappings, catalogEntities }) => {
4
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", null, "MappingTable"), mappings.forEach((mapping) => {
5
+ /* @__PURE__ */ React.createElement("p", null, mapping.serviceId);
6
+ }), catalogEntities.forEach((entity) => {
7
+ /* @__PURE__ */ React.createElement("p", null, entity.id);
8
+ }));
9
+ };
10
+
11
+ export { MappingTable };
12
+ //# sourceMappingURL=MappingTable.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MappingTable.esm.js","sources":["../../../src/components/PagerDutyPage/MappingTable.tsx"],"sourcesContent":["import React from 'react';\nimport { PagerDutyEntityMapping } from \"@pagerduty/backstage-plugin-common\";\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\ntype MappingTableProps = {\n mappings: PagerDutyEntityMapping[];\n catalogEntities: Service[];\n};\n\nexport const MappingTable = ({mappings, catalogEntities} : MappingTableProps) => {\n return (\n <>\n <div>MappingTable</div>\n\n {mappings.forEach((mapping) => {\n <p>{mapping.serviceId}</p>;\n })}\n {catalogEntities.forEach((entity) => {\n <p>{entity.id}</p>;\n })}\n </>\n );\n}"],"names":[],"mappings":";;AAgBO,MAAM,YAAe,GAAA,CAAC,EAAC,QAAA,EAAU,iBAAyC,KAAA;AAC/E,EACE,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,sCACG,KAAI,EAAA,IAAA,EAAA,cAAY,GAEhB,QAAS,CAAA,OAAA,CAAQ,CAAC,OAAY,KAAA;AAC7B,oBAAC,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAG,QAAQ,SAAU,CAAA,CAAA;AAAA,GACvB,CAAA,EACA,eAAgB,CAAA,OAAA,CAAQ,CAAC,MAAW,KAAA;AACnC,oBAAC,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAG,OAAO,EAAG,CAAA,CAAA;AAAA,GACf,CACH,CAAA,CAAA;AAEJ;;;;"}
@@ -1,51 +1,23 @@
1
- import React, { useState, useMemo } from 'react';
2
- import { Typography, Box, DialogTitle, DialogContent, DialogActions, Tooltip, IconButton } from '@material-ui/core';
3
- import EditIcon from '@mui/icons-material/Edit';
1
+ import React, { useState, useEffect } from 'react';
4
2
  import { useApi } from '@backstage/core-plugin-api';
5
3
  import { pagerDutyApiRef } from '../../api/client.esm.js';
6
- import { QueryClient, QueryClientProvider, useQueries, useMutation } from '@tanstack/react-query';
7
- import { useMaterialReactTable, MRT_EditActionButtons, MaterialReactTable } from 'material-react-table';
8
4
  import { catalogApiRef } from '@backstage/plugin-catalog-react';
9
- import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
5
+ import { MappingTable } from './MappingTable.esm.js';
10
6
 
11
- function getColorFromStatus(status) {
12
- switch (status) {
13
- case "InSync":
14
- return "green";
15
- case "OutOfSync":
16
- return "red";
17
- case "NotMapped":
18
- return "orange";
19
- default:
20
- return "gray";
21
- }
22
- }
23
- function makeReadable(status) {
24
- switch (status) {
25
- case "InSync":
26
- return "In Sync";
27
- case "OutOfSync":
28
- return "Out of Sync";
29
- case "NotMapped":
30
- return "Not Mapped";
31
- default:
32
- return "Refresh to Update";
33
- }
34
- }
35
7
  const ServiceMappingComponent = () => {
36
8
  const [entityMappings, setEntityMappings] = useState([]);
37
9
  const [catalogEntities, setCatalogEntities] = useState([]);
38
10
  const pagerDutyApi = useApi(pagerDutyApiRef);
39
11
  const catalogApi = useApi(catalogApiRef);
40
- function fetchMappings() {
41
- pagerDutyApi.getEntityMappings().then((result) => {
42
- setEntityMappings(result.mappings);
43
- return result.mappings;
44
- });
45
- return [];
46
- }
47
- function fetchCatalogEntities() {
48
- if (catalogEntities.length === 0) {
12
+ useEffect(() => {
13
+ function fetchMappings() {
14
+ pagerDutyApi.getEntityMappings().then((result) => {
15
+ setEntityMappings(result.mappings);
16
+ return result.mappings;
17
+ });
18
+ return [];
19
+ }
20
+ function fetchCatalogEntities() {
49
21
  catalogApi.getEntities({
50
22
  filter: { kind: "Component" }
51
23
  }).then((result) => {
@@ -64,193 +36,13 @@ const ServiceMappingComponent = () => {
64
36
  return entities;
65
37
  });
66
38
  }
67
- return catalogEntities;
68
- }
69
- function getCatalogEntityOptions() {
70
- const options = [];
71
- options.push({ value: "", label: "None" });
72
- catalogEntities.forEach((entity) => {
73
- const foundEntity = entityMappings.find(
74
- (item) => item.entityRef === entity.id
75
- );
76
- if (!foundEntity) {
77
- options.push({
78
- value: entity.id,
79
- label: entity.name
80
- });
81
- }
82
- });
83
- return options;
84
- }
85
- const DenseTable = () => {
86
- const [validationErrors, setValidationErrors] = useState({});
87
- const [getMappingsQuery, getCatalogEntitiesQuery] = useQueries({
88
- queries: [
89
- {
90
- queryKey: ["mappings"],
91
- queryFn: () => fetchMappings(),
92
- refetchOnWindowFocus: false
93
- },
94
- {
95
- queryKey: ["entities"],
96
- queryFn: () => fetchCatalogEntities(),
97
- refetchOnWindowFocus: false
98
- }
99
- ]
100
- });
101
- const columns = useMemo(
102
- () => [
103
- {
104
- accessorKey: "serviceId",
105
- header: "Service ID",
106
- visibleInShowHideMenu: false,
107
- enableEditing: false,
108
- Edit: () => null,
109
- Cell: ({ cell }) => /* @__PURE__ */ React.createElement(Typography, { variant: "body1", style: { fontWeight: 600 } }, cell.getValue())
110
- },
111
- {
112
- accessorKey: "serviceName",
113
- header: "PagerDuty Service",
114
- enableEditing: false
115
- },
116
- {
117
- accessorKey: "team",
118
- header: "Team",
119
- enableEditing: false
120
- },
121
- {
122
- accessorKey: "escalationPolicy",
123
- header: "Escalation Policy",
124
- enableEditing: false
125
- },
126
- {
127
- accessorKey: "entityRef",
128
- header: "Mapping",
129
- visibleInShowHideMenu: false,
130
- editVariant: "select",
131
- editSelectOptions: getCatalogEntityOptions(),
132
- muiEditTextFieldProps: {
133
- select: true,
134
- error: !!(validationErrors == null ? void 0 : validationErrors.state),
135
- helperText: validationErrors == null ? void 0 : validationErrors.state
136
- }
137
- },
138
- {
139
- accessorKey: "entityName",
140
- header: "Mapped Entity Name",
141
- enableEditing: false,
142
- Edit: () => null
143
- },
144
- {
145
- accessorKey: "status",
146
- header: "Status",
147
- enableEditing: false,
148
- Edit: () => null,
149
- Cell: ({ cell }) => /* @__PURE__ */ React.createElement(
150
- Box,
151
- {
152
- component: "span",
153
- bgcolor: getColorFromStatus(cell.getValue()),
154
- borderRadius: "0.25rem",
155
- color: "white",
156
- p: "0.25rem"
157
- },
158
- makeReadable(cell.getValue())
159
- )
160
- },
161
- {
162
- accessorKey: "serviceUrl",
163
- header: "Service URL",
164
- visibleInShowHideMenu: false,
165
- enableEditing: false,
166
- Edit: () => null
167
- }
168
- ],
169
- [validationErrors]
170
- );
171
- function useUpdateMapping() {
172
- return useMutation({
173
- mutationFn: async (mapping) => {
174
- return await pagerDutyApi.storeServiceMapping(
175
- mapping.serviceId,
176
- mapping.entityRef
177
- );
178
- }
179
- // client side optimistic update
180
- // onMutate: (newMappingInfo: PagerDutyEntityMapping) => {
181
- // queryClient.setQueryData(["updateMappings"], (prevMappings: any) =>
182
- // prevMappings?.map((prevMapping: PagerDutyEntityMapping) => {
183
- // if (prevMapping.serviceId === newMappingInfo.serviceId) {
184
- // newMappingInfo.entityName =
185
- // fetchedCatalogEntities.find(
186
- // (entity) => entity.id === newMappingInfo.entityRef
187
- // )?.name || "";
188
- // return newMappingInfo;
189
- // }
190
- // return prevMapping;
191
- // })
192
- // );
193
- // },
194
- });
195
- }
196
- const { mutateAsync: updateMapping, isPending: isUpdatingMapping } = useUpdateMapping();
197
- const handleSaveMapping = async ({ values, table }) => {
198
- var _a;
199
- setValidationErrors({});
200
- values.entityName = ((_a = catalogEntities.find((entity) => entity.id === values.entityRef)) == null ? void 0 : _a.name) || "";
201
- values.status = "RefreshToUpdate";
202
- await updateMapping(values);
203
- table.setEditingRow(null);
204
- };
205
- const openInBrowser = (url) => {
206
- window.open(url, "_blank", "noreferrer");
207
- };
208
- const dataTable = useMaterialReactTable({
209
- columns,
210
- data: entityMappings,
211
- editDisplayMode: "modal",
212
- // default ('row', 'cell', 'table', and 'custom' are also available)
213
- enableEditing: true,
214
- positionActionsColumn: "last",
215
- enableStickyHeader: true,
216
- enableFilters: true,
217
- getRowId: (row) => row.serviceId,
218
- muiToolbarAlertBannerProps: getMappingsQuery.isLoadingError ? {
219
- color: "error",
220
- children: "Error loading data"
221
- } : void 0,
222
- muiTableContainerProps: {
223
- sx: {
224
- minHeight: "500px"
225
- }
226
- },
227
- onEditingRowCancel: () => setValidationErrors({}),
228
- onEditingRowSave: handleSaveMapping,
229
- // optionally customize modal content
230
- renderEditRowDialogContent: ({ table, row, internalEditComponents }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DialogTitle, null, "Edit Mapping"), /* @__PURE__ */ React.createElement(DialogContent, null, internalEditComponents, " "), /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(MRT_EditActionButtons, { variant: "text", table, row }))),
231
- 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(
232
- IconButton,
233
- {
234
- onClick: () => openInBrowser(row.getValue("serviceUrl"))
235
- },
236
- /* @__PURE__ */ React.createElement(OpenInBrowserIcon, null)
237
- ))),
238
- state: {
239
- isLoading: getMappingsQuery.isLoading || getCatalogEntitiesQuery.isLoading,
240
- isSaving: isUpdatingMapping,
241
- showAlertBanner: getMappingsQuery.isLoadingError || getCatalogEntitiesQuery.isLoadingError,
242
- showProgressBars: getMappingsQuery.isFetching || getCatalogEntitiesQuery.isFetching,
243
- columnVisibility: {
244
- serviceId: false,
245
- entityRef: false,
246
- serviceUrl: false
247
- }
248
- }
249
- });
250
- return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
251
- };
252
- const queryClient = new QueryClient();
253
- return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(DenseTable, null));
39
+ fetchMappings();
40
+ fetchCatalogEntities();
41
+ });
42
+ return (
43
+ // <QueryClientProvider client={queryClient}>
44
+ /* @__PURE__ */ React.createElement(MappingTable, { mappings: entityMappings, catalogEntities })
45
+ );
254
46
  };
255
47
 
256
48
  export { ServiceMappingComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceMappingComponent.esm.js","sources":["../../../src/components/PagerDutyPage/ServiceMappingComponent.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport {\n Box,\n DialogActions,\n DialogContent,\n DialogTitle,\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 useQueries,\n // useQuery,\n} from \"@tanstack/react-query\";\nimport {\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/OpenInBrowser\";\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\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\ntype CatalogEntityOptions = {\n value: string;\n label: string;\n};\n\nexport const ServiceMappingComponent = () => {\n const [entityMappings, setEntityMappings] = useState<\n PagerDutyEntityMapping[]\n >([]);\n const [catalogEntities, setCatalogEntities] = useState<Service[]>([]);\n // const [entityOptions, setEntityOptions] = useState<CatalogEntityOptions[]>(\n // []\n // );\n\n const pagerDutyApi = useApi(pagerDutyApiRef);\n const catalogApi = useApi(catalogApiRef);\n\n // function fetchCatalogEntities() {\n // catalogApi\n // .getEntities({\n // filter: { kind: \"Component\" },\n // })\n // .then((result) => {\n // const entities: Service[] = [];\n // result.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\n // setCatalogEntities(entities);\n // });\n // }\n\n function fetchMappings(): PagerDutyEntityMapping[] {\n pagerDutyApi.getEntityMappings().then((result) => {\n setEntityMappings(result.mappings);\n\n return(result.mappings);\n });\n\n return [];\n }\n\n function fetchCatalogEntities() {\n if (catalogEntities.length === 0) {\n catalogApi\n .getEntities({\n filter: { kind: \"Component\" },\n })\n .then((result) => {\n const entities: Service[] = [];\n result.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\n setCatalogEntities(entities);\n\n return entities;\n });\n }\n\n return catalogEntities;\n }\n\n function getCatalogEntityOptions(): CatalogEntityOptions[] {\n const options: CatalogEntityOptions[] = [];\n // if (entityOptions.length === 0) {\n // initialize with empty object\n options.push({ value: \"\", label: \"None\" });\n // }\n\n catalogEntities.forEach((entity) => {\n // find entity with entity.id in entityMappings array\n const foundEntity = entityMappings.find(\n (item) => item.entityRef === entity.id\n );\n\n if (!foundEntity) {\n options.push({\n value: entity.id,\n label: entity.name,\n });\n }\n });\n\n return options;\n }\n\n const DenseTable = () => {\n const [validationErrors, setValidationErrors] = useState<\n Record<string, string | undefined>\n >({});\n\n // call READ hook\n // const {\n // isError: isLoadingMappingsError,\n // isFetching: isFetchingMappings,\n // isLoading: isLoadingMappings,\n // } = useGetMappings();\n\n // // call READ hook\n // const {\n // // data: fetchedCatalogEntities = [],\n // isError: isLoadingCatalogEntitiesError,\n // isFetching: isFetchingCatalogEntities,\n // isLoading: isLoadingCatalogEntities,\n // } = useGetCatalogEntities();\n\n const [getMappingsQuery, getCatalogEntitiesQuery] = useQueries({\n queries: [\n {\n queryKey: [\"mappings\"],\n queryFn: () => fetchMappings(),\n refetchOnWindowFocus: false,\n },\n {\n queryKey: [\"entities\"],\n queryFn: () => fetchCatalogEntities(),\n refetchOnWindowFocus: false,\n },\n ],\n });\n\n // function useGetMappings() {\n // return useQuery<PagerDutyEntityMapping[]>({\n // queryKey: [\"mappings\"],\n // queryFn: async () => fetchMappings(),\n // refetchOnWindowFocus: false,\n // });\n // }\n\n // READ hook (get catalog entities from api)\n // function useGetCatalogEntities() {\n // return useQuery<Service[]>({\n // queryKey: [\"entities\"],\n // queryFn: async () => fetchCatalogEntities(),\n // refetchOnMount: false,\n // refetchOnWindowFocus: false,\n // refetchOnReconnect: false,\n // });\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 Edit: () => null,\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 Edit: () => null,\n },\n {\n accessorKey: \"status\",\n header: \"Status\",\n enableEditing: false,\n Edit: () => null,\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 Edit: () => null,\n },\n ],\n [validationErrors]\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 =\n // fetchedCatalogEntities.find(\n // (entity) => entity.id === newMappingInfo.entityRef\n // )?.name || \"\";\n\n // return newMappingInfo;\n // }\n // return prevMapping;\n // })\n // );\n // },\n });\n }\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 =\n catalogEntities.find((entity) => entity.id === values.entityRef)\n ?.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: entityMappings,\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: getMappingsQuery.isLoadingError\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, internalEditComponents }) => (\n <>\n <DialogTitle>Edit Mapping</DialogTitle>\n <DialogContent>{internalEditComponents} </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: getMappingsQuery.isLoading || getCatalogEntitiesQuery.isLoading,\n isSaving: isUpdatingMapping,\n showAlertBanner:\n getMappingsQuery.isLoadingError || getCatalogEntitiesQuery.isLoadingError,\n showProgressBars: getMappingsQuery.isFetching || getCatalogEntitiesQuery.isFetching,\n columnVisibility: {\n serviceId: false,\n entityRef: false,\n serviceUrl: false,\n },\n },\n });\n\n // function getCatalogEntityOptions(): CatalogEntityOptions[] {\n // const options: CatalogEntityOptions[] = [];\n // // if (entityOptions.length === 0) {\n // // initialize with empty object\n // options.push({ value: \"\", label: \"None\" });\n // // }\n\n // catalogEntities.forEach((entity) => {\n // // find entity with entity.id in entityMappings array\n // const foundEntity = fetchedMappings.find(\n // (item) => item.entityRef === entity.id\n // );\n\n // if (!foundEntity) {\n // options.push({\n // value: entity.id,\n // label: entity.name,\n // });\n // }\n // });\n\n // // setEntityOptions(options);\n\n // return options;\n // }\n\n return <MaterialReactTable table={dataTable} />;\n };\n\n const queryClient = new QueryClient();\n // fetchCatalogEntities();\n\n return (\n <QueryClientProvider client={queryClient}>\n <DenseTable />\n </QueryClientProvider>\n );\n};\n"],"names":["OpenInBrowser"],"mappings":";;;;;;;;;;AAuCA,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,KA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O,SAAW,EAAA,CAAA,CAAA;AAAA,GAC/C,CAAA;AAEA,EAAM,MAAA,WAAA,GAAc,IAAI,WAAY,EAAA,CAAA;AAGpC,EAAA,2CACG,mBAAoB,EAAA,EAAA,MAAA,EAAQ,WAC3B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,gBAAW,CACd,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ServiceMappingComponent.esm.js","sources":["../../../src/components/PagerDutyPage/ServiceMappingComponent.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { PagerDutyEntityMapping } from \"@pagerduty/backstage-plugin-common\";\nimport { useApi } from \"@backstage/core-plugin-api\";\nimport { pagerDutyApiRef } from \"../../api\";\nimport { catalogApiRef } from \"@backstage/plugin-catalog-react\";\nimport { MappingTable } from \"./MappingTable\";\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// function 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\n// function 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\n// type CatalogEntityOptions = {\n// value: string;\n// label: string;\n// };\n\nexport const ServiceMappingComponent = () => {\n const [entityMappings, setEntityMappings] = useState<\n PagerDutyEntityMapping[]\n >([]);\n const [catalogEntities, setCatalogEntities] = useState<Service[]>([]);\n // const [entityOptions, setEntityOptions] = useState<CatalogEntityOptions[]>(\n // []\n // );\n\n const pagerDutyApi = useApi(pagerDutyApiRef);\n const catalogApi = useApi(catalogApiRef);\n\n // call fetchMappings() and fetchCatalogEntities() on useEffect hook\n useEffect(() => {\n function fetchMappings(): PagerDutyEntityMapping[] {\n pagerDutyApi.getEntityMappings().then((result) => {\n setEntityMappings(result.mappings);\n\n return result.mappings;\n });\n\n return [];\n }\n\n function fetchCatalogEntities() {\n catalogApi\n .getEntities({\n filter: { kind: \"Component\" },\n })\n .then((result) => {\n const entities: Service[] = [];\n result.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\n setCatalogEntities(entities);\n\n return entities;\n });\n }\n\n fetchMappings();\n fetchCatalogEntities();\n });\n\n\n // function fetchCatalogEntities() {\n // catalogApi\n // .getEntities({\n // filter: { kind: \"Component\" },\n // })\n // .then((result) => {\n // const entities: Service[] = [];\n // result.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\n // setCatalogEntities(entities);\n // });\n // }\n\n \n\n // function getCatalogEntityOptions(): CatalogEntityOptions[] {\n // const options: CatalogEntityOptions[] = [];\n // // if (entityOptions.length === 0) {\n // // initialize with empty object\n // options.push({ value: \"\", label: \"None\" });\n // // }\n\n // catalogEntities.forEach((entity) => {\n // // find entity with entity.id in entityMappings array\n // const foundEntity = entityMappings.find(\n // (item) => item.entityRef === entity.id\n // );\n\n // if (!foundEntity) {\n // options.push({\n // value: entity.id,\n // label: entity.name,\n // });\n // }\n // });\n\n // return options;\n // }\n\n // const DenseTable = () => {\n // const [validationErrors, setValidationErrors] = useState<\n // Record<string, string | undefined>\n // >({});\n\n // // call READ hook\n // // const {\n // // isError: isLoadingMappingsError,\n // // isFetching: isFetchingMappings,\n // // isLoading: isLoadingMappings,\n // // } = useGetMappings();\n\n // // // call READ hook\n // // const {\n // // // data: fetchedCatalogEntities = [],\n // // isError: isLoadingCatalogEntitiesError,\n // // isFetching: isFetchingCatalogEntities,\n // // isLoading: isLoadingCatalogEntities,\n // // } = useGetCatalogEntities();\n\n // const [getMappingsQuery, getCatalogEntitiesQuery] = useQueries({\n // queries: [\n // {\n // queryKey: [\"mappings\"],\n // queryFn: () => fetchMappings(),\n // refetchOnWindowFocus: false,\n // },\n // {\n // queryKey: [\"entities\"],\n // queryFn: () => fetchCatalogEntities(),\n // refetchOnWindowFocus: false,\n // },\n // ],\n // });\n\n // // function useGetMappings() {\n // // return useQuery<PagerDutyEntityMapping[]>({\n // // queryKey: [\"mappings\"],\n // // queryFn: async () => fetchMappings(),\n // // refetchOnWindowFocus: false,\n // // });\n // // }\n\n // // READ hook (get catalog entities from api)\n // // function useGetCatalogEntities() {\n // // return useQuery<Service[]>({\n // // queryKey: [\"entities\"],\n // // queryFn: async () => fetchCatalogEntities(),\n // // refetchOnMount: false,\n // // refetchOnWindowFocus: false,\n // // refetchOnReconnect: false,\n // // });\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 // Edit: () => null,\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 // Edit: () => null,\n // },\n // {\n // accessorKey: \"status\",\n // header: \"Status\",\n // enableEditing: false,\n // Edit: () => null,\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 // Edit: () => null,\n // },\n // ],\n // [validationErrors]\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 =\n // // fetchedCatalogEntities.find(\n // // (entity) => entity.id === newMappingInfo.entityRef\n // // )?.name || \"\";\n\n // // return newMappingInfo;\n // // }\n // // return prevMapping;\n // // })\n // // );\n // // },\n // });\n // }\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 =\n // catalogEntities.find((entity) => entity.id === values.entityRef)\n // ?.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: entityMappings,\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: getMappingsQuery.isLoadingError\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, internalEditComponents }) => (\n // <>\n // <DialogTitle>Edit Mapping</DialogTitle>\n // <DialogContent>{internalEditComponents} </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: getMappingsQuery.isLoading || getCatalogEntitiesQuery.isLoading,\n // isSaving: isUpdatingMapping,\n // showAlertBanner:\n // getMappingsQuery.isLoadingError || getCatalogEntitiesQuery.isLoadingError,\n // showProgressBars: getMappingsQuery.isFetching || getCatalogEntitiesQuery.isFetching,\n // columnVisibility: {\n // serviceId: false,\n // entityRef: false,\n // serviceUrl: false,\n // },\n // },\n // });\n\n // // function getCatalogEntityOptions(): CatalogEntityOptions[] {\n // // const options: CatalogEntityOptions[] = [];\n // // // if (entityOptions.length === 0) {\n // // // initialize with empty object\n // // options.push({ value: \"\", label: \"None\" });\n // // // }\n\n // // catalogEntities.forEach((entity) => {\n // // // find entity with entity.id in entityMappings array\n // // const foundEntity = fetchedMappings.find(\n // // (item) => item.entityRef === entity.id\n // // );\n\n // // if (!foundEntity) {\n // // options.push({\n // // value: entity.id,\n // // label: entity.name,\n // // });\n // // }\n // // });\n\n // // // setEntityOptions(options);\n\n // // return options;\n // // }\n\n // return <MaterialReactTable table={dataTable} />;\n // };\n\n // const queryClient = new QueryClient();\n // fetchCatalogEntities();\n\n return (\n // <QueryClientProvider client={queryClient}>\n <MappingTable mappings={entityMappings} catalogEntities={catalogEntities} />\n // </QueryClientProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;AA8CO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,MAAM,CAAC,cAAgB,EAAA,iBAAiB,CAAI,GAAA,QAAA,CAE1C,EAAE,CAAA,CAAA;AACJ,EAAA,MAAM,CAAC,eAAiB,EAAA,kBAAkB,CAAI,GAAA,QAAA,CAAoB,EAAE,CAAA,CAAA;AAKpE,EAAM,MAAA,YAAA,GAAe,OAAO,eAAe,CAAA,CAAA;AAC3C,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AAGvC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,SAAS,aAA0C,GAAA;AACjD,MAAA,YAAA,CAAa,iBAAkB,EAAA,CAAE,IAAK,CAAA,CAAC,MAAW,KAAA;AAChD,QAAA,iBAAA,CAAkB,OAAO,QAAQ,CAAA,CAAA;AAEjC,QAAA,OAAO,MAAO,CAAA,QAAA,CAAA;AAAA,OACf,CAAA,CAAA;AAED,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AAEA,IAAA,SAAS,oBAAuB,GAAA;AA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aAAA,EAAA,CAAA;AACd,IAAqB,oBAAA,EAAA,CAAA;AAAA,GACtB,CAAA,CAAA;AAkUD,EAAA;AAAA;AAAA,oBAEK,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,QAAU,EAAA,cAAA,EAAgB,eAAmC,EAAA,CAAA;AAAA,IAAA;AAGjF;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagerduty/backstage-plugin",
3
3
  "description": "A Backstage plugin that integrates towards PagerDuty",
4
- "version": "0.13.0-next.24",
4
+ "version": "0.13.0-next.25",
5
5
  "main": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",