@pagerduty/backstage-plugin 0.13.0-next.23 → 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,49 +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
- async function fetchMappings() {
41
- const { mappings: foundMappings } = await pagerDutyApi.getEntityMappings();
42
- setEntityMappings(foundMappings);
43
- return foundMappings;
44
- }
45
- function fetchCatalogEntities() {
46
- 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() {
47
21
  catalogApi.getEntities({
48
22
  filter: { kind: "Component" }
49
23
  }).then((result) => {
@@ -62,193 +36,13 @@ const ServiceMappingComponent = () => {
62
36
  return entities;
63
37
  });
64
38
  }
65
- return catalogEntities;
66
- }
67
- function getCatalogEntityOptions() {
68
- const options = [];
69
- options.push({ value: "", label: "None" });
70
- catalogEntities.forEach((entity) => {
71
- const foundEntity = entityMappings.find(
72
- (item) => item.entityRef === entity.id
73
- );
74
- if (!foundEntity) {
75
- options.push({
76
- value: entity.id,
77
- label: entity.name
78
- });
79
- }
80
- });
81
- return options;
82
- }
83
- const DenseTable = () => {
84
- const [validationErrors, setValidationErrors] = useState({});
85
- const [getMappingsQuery, getCatalogEntitiesQuery] = useQueries({
86
- queries: [
87
- {
88
- queryKey: ["mappings"],
89
- queryFn: async () => fetchMappings(),
90
- refetchOnWindowFocus: false
91
- },
92
- {
93
- queryKey: ["entities"],
94
- queryFn: () => fetchCatalogEntities(),
95
- refetchOnWindowFocus: false
96
- }
97
- ]
98
- });
99
- const columns = useMemo(
100
- () => [
101
- {
102
- accessorKey: "serviceId",
103
- header: "Service ID",
104
- visibleInShowHideMenu: false,
105
- enableEditing: false,
106
- Edit: () => null,
107
- Cell: ({ cell }) => /* @__PURE__ */ React.createElement(Typography, { variant: "body1", style: { fontWeight: 600 } }, cell.getValue())
108
- },
109
- {
110
- accessorKey: "serviceName",
111
- header: "PagerDuty Service",
112
- enableEditing: false
113
- },
114
- {
115
- accessorKey: "team",
116
- header: "Team",
117
- enableEditing: false
118
- },
119
- {
120
- accessorKey: "escalationPolicy",
121
- header: "Escalation Policy",
122
- enableEditing: false
123
- },
124
- {
125
- accessorKey: "entityRef",
126
- header: "Mapping",
127
- visibleInShowHideMenu: false,
128
- editVariant: "select",
129
- editSelectOptions: getCatalogEntityOptions(),
130
- muiEditTextFieldProps: {
131
- select: true,
132
- error: !!(validationErrors == null ? void 0 : validationErrors.state),
133
- helperText: validationErrors == null ? void 0 : validationErrors.state
134
- }
135
- },
136
- {
137
- accessorKey: "entityName",
138
- header: "Mapped Entity Name",
139
- enableEditing: false,
140
- Edit: () => null
141
- },
142
- {
143
- accessorKey: "status",
144
- header: "Status",
145
- enableEditing: false,
146
- Edit: () => null,
147
- Cell: ({ cell }) => /* @__PURE__ */ React.createElement(
148
- Box,
149
- {
150
- component: "span",
151
- bgcolor: getColorFromStatus(cell.getValue()),
152
- borderRadius: "0.25rem",
153
- color: "white",
154
- p: "0.25rem"
155
- },
156
- makeReadable(cell.getValue())
157
- )
158
- },
159
- {
160
- accessorKey: "serviceUrl",
161
- header: "Service URL",
162
- visibleInShowHideMenu: false,
163
- enableEditing: false,
164
- Edit: () => null
165
- }
166
- ],
167
- [validationErrors]
168
- );
169
- function useUpdateMapping() {
170
- return useMutation({
171
- mutationFn: async (mapping) => {
172
- return await pagerDutyApi.storeServiceMapping(
173
- mapping.serviceId,
174
- mapping.entityRef
175
- );
176
- }
177
- // client side optimistic update
178
- // onMutate: (newMappingInfo: PagerDutyEntityMapping) => {
179
- // queryClient.setQueryData(["updateMappings"], (prevMappings: any) =>
180
- // prevMappings?.map((prevMapping: PagerDutyEntityMapping) => {
181
- // if (prevMapping.serviceId === newMappingInfo.serviceId) {
182
- // newMappingInfo.entityName =
183
- // fetchedCatalogEntities.find(
184
- // (entity) => entity.id === newMappingInfo.entityRef
185
- // )?.name || "";
186
- // return newMappingInfo;
187
- // }
188
- // return prevMapping;
189
- // })
190
- // );
191
- // },
192
- });
193
- }
194
- const { mutateAsync: updateMapping, isPending: isUpdatingMapping } = useUpdateMapping();
195
- const handleSaveMapping = async ({ values, table }) => {
196
- var _a;
197
- setValidationErrors({});
198
- values.entityName = ((_a = catalogEntities.find((entity) => entity.id === values.entityRef)) == null ? void 0 : _a.name) || "";
199
- values.status = "RefreshToUpdate";
200
- await updateMapping(values);
201
- table.setEditingRow(null);
202
- };
203
- const openInBrowser = (url) => {
204
- window.open(url, "_blank", "noreferrer");
205
- };
206
- const dataTable = useMaterialReactTable({
207
- columns,
208
- data: entityMappings,
209
- editDisplayMode: "modal",
210
- // default ('row', 'cell', 'table', and 'custom' are also available)
211
- enableEditing: true,
212
- positionActionsColumn: "last",
213
- enableStickyHeader: true,
214
- enableFilters: true,
215
- getRowId: (row) => row.serviceId,
216
- muiToolbarAlertBannerProps: getMappingsQuery.isLoadingError ? {
217
- color: "error",
218
- children: "Error loading data"
219
- } : void 0,
220
- muiTableContainerProps: {
221
- sx: {
222
- minHeight: "500px"
223
- }
224
- },
225
- onEditingRowCancel: () => setValidationErrors({}),
226
- onEditingRowSave: handleSaveMapping,
227
- // optionally customize modal content
228
- 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 }))),
229
- 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(
230
- IconButton,
231
- {
232
- onClick: () => openInBrowser(row.getValue("serviceUrl"))
233
- },
234
- /* @__PURE__ */ React.createElement(OpenInBrowserIcon, null)
235
- ))),
236
- state: {
237
- isLoading: getMappingsQuery.isLoading || getCatalogEntitiesQuery.isLoading,
238
- isSaving: isUpdatingMapping,
239
- showAlertBanner: getMappingsQuery.isLoadingError || getCatalogEntitiesQuery.isLoadingError,
240
- showProgressBars: getMappingsQuery.isFetching || getCatalogEntitiesQuery.isFetching,
241
- columnVisibility: {
242
- serviceId: false,
243
- entityRef: false,
244
- serviceUrl: false
245
- }
246
- }
247
- });
248
- return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
249
- };
250
- const queryClient = new QueryClient();
251
- 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
+ );
252
46
  };
253
47
 
254
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 async function fetchMappings(): Promise<PagerDutyEntityMapping[]> {\n const { mappings: foundMappings } = await pagerDutyApi.getEntityMappings();\n\n setEntityMappings(foundMappings);\n\n return foundMappings;\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: async () => 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,IAC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AAM,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;AAC5B,MAAA,UAAA,CACG,WAAY,CAAA;AAAA,QACX,MAAA,EA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A,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.23",
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",