@pagerduty/backstage-plugin 0.12.1-next.56 → 0.12.1-next.58

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { P as PagerDutyCard } from './index-c49d6ec3.esm.js';
2
+ import { P as PagerDutyCard } from './index-dd02e85a.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-a775a548.esm.js.map
37
+ //# sourceMappingURL=index-2977760b.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-a775a548.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;;;;"}
1
+ {"version":3,"file":"index-2977760b.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;;;;"}
@@ -0,0 +1,182 @@
1
+ import React, { useState, useMemo } from 'react';
2
+ import { DialogTitle, DialogContent, DialogActions, Box, Tooltip, IconButton, Grid } 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-dd02e85a.esm.js';
7
+ import { catalogApiRef } from '@backstage/plugin-catalog-react';
8
+ import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
9
+ import { useMaterialReactTable, MRT_EditActionButtons, MaterialReactTable } from 'material-react-table';
10
+ import '@backstage/errors';
11
+ import '@backstage/plugin-home-react';
12
+ import 'luxon';
13
+ import '@material-ui/icons/OpenInBrowser';
14
+ import '../assets/emptystate.svg';
15
+ import 'react-use/lib/useAsyncFn';
16
+ import '@material-ui/lab';
17
+ import '../assets/forbiddenstate.svg';
18
+ import '@material-ui/core/Avatar';
19
+ import '@material-ui/icons/Notifications';
20
+ import 'react-use/lib/useAsync';
21
+ import '@material-ui/icons/Link';
22
+ import '../assets/PD-Green.svg';
23
+ import '../assets/PD-White.svg';
24
+ import 'validate-color';
25
+ import '@material-ui/icons/Info';
26
+ import '@material-ui/icons/CheckCircle';
27
+ import '@material-ui/icons/RadioButtonUnchecked';
28
+ import '@material-ui/core/styles';
29
+ import 'react-use';
30
+ import '@material-ui/lab/Alert/Alert';
31
+ import '@backstage/catalog-model';
32
+ import '@material-ui/icons/AddAlert';
33
+ import '@material-ui/icons/ExpandMore';
34
+
35
+ const ServiceMappingComponent = () => {
36
+ const pagerDutyApi = useApi(pagerDutyApiRef);
37
+ const catalogApi = useApi(catalogApiRef);
38
+ function useGetCatalogEntities() {
39
+ return useQuery({
40
+ queryKey: ["mappings"],
41
+ queryFn: async () => {
42
+ const { items } = await catalogApi.getEntities({
43
+ filter: { kind: "Component" }
44
+ });
45
+ const entities = [];
46
+ items.forEach((entity) => {
47
+ var _a, _b, _c;
48
+ entities.push({
49
+ value: (_b = (_a = entity.metadata) == null ? void 0 : _a.uid) != null ? _b : "",
50
+ label: (_c = entity.metadata) == null ? void 0 : _c.name
51
+ });
52
+ });
53
+ return entities;
54
+ },
55
+ refetchOnWindowFocus: false
56
+ });
57
+ }
58
+ const DenseTable = () => {
59
+ const [validationErrors, setValidationErrors] = useState({});
60
+ const {
61
+ data: fetchedEntities = [],
62
+ isError: isLoadingEntitiesError,
63
+ isFetching: isFetchingEntities,
64
+ isLoading: isLoadingEntities
65
+ } = useGetCatalogEntities();
66
+ const columns = useMemo(
67
+ () => [
68
+ {
69
+ accessorKey: "name",
70
+ header: "PagerDuty Service",
71
+ enableEditing: false
72
+ },
73
+ {
74
+ accessorKey: "team",
75
+ header: "Team",
76
+ enableEditing: false
77
+ },
78
+ {
79
+ accessorKey: "escalationPolicy",
80
+ header: "Escalation Policy",
81
+ enableEditing: false
82
+ },
83
+ {
84
+ accessorKey: "mapping",
85
+ header: "Mapping",
86
+ editVariant: "select",
87
+ editSelectOptions: fetchedEntities,
88
+ muiEditTextFieldProps: {
89
+ select: true,
90
+ error: !!(validationErrors == null ? void 0 : validationErrors.state),
91
+ helperText: validationErrors == null ? void 0 : validationErrors.state
92
+ }
93
+ },
94
+ {
95
+ accessorKey: "status",
96
+ header: "Status",
97
+ enableEditing: false
98
+ }
99
+ ],
100
+ [fetchedEntities, validationErrors]
101
+ );
102
+ const {
103
+ data: fetchedMappings = [],
104
+ isError: isLoadingMappingsError,
105
+ isFetching: isFetchingMappings,
106
+ isLoading: isLoadingMappings
107
+ } = useGetMappings();
108
+ const { mutateAsync: updateUser, isPending: isUpdatingMapping } = useUpdateMapping();
109
+ const handleSaveUser = async ({ values, table }) => {
110
+ await updateUser(values);
111
+ table.setEditingRow(null);
112
+ };
113
+ const dataTable = useMaterialReactTable({
114
+ columns,
115
+ data: fetchedMappings,
116
+ editDisplayMode: "modal",
117
+ // default ('row', 'cell', 'table', and 'custom' are also available)
118
+ enableEditing: true,
119
+ getRowId: (row) => row.serviceId,
120
+ muiToolbarAlertBannerProps: isLoadingMappingsError ? {
121
+ color: "error",
122
+ children: "Error loading data"
123
+ } : void 0,
124
+ muiTableContainerProps: {
125
+ sx: {
126
+ minHeight: "500px"
127
+ }
128
+ },
129
+ onEditingRowCancel: () => setValidationErrors({}),
130
+ onEditingRowSave: handleSaveUser,
131
+ // optionally customize modal content
132
+ 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 }))),
133
+ 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)))),
134
+ state: {
135
+ isLoading: isLoadingMappings || isLoadingEntities,
136
+ isSaving: isUpdatingMapping,
137
+ showAlertBanner: isLoadingMappingsError || isLoadingEntitiesError,
138
+ showProgressBars: isFetchingMappings || isFetchingEntities
139
+ }
140
+ });
141
+ return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
142
+ };
143
+ function useGetMappings() {
144
+ return useQuery({
145
+ queryKey: ["mappings"],
146
+ queryFn: async () => {
147
+ const { mappings: foundMappings } = await pagerDutyApi.getEntityMappings();
148
+ return foundMappings;
149
+ },
150
+ refetchOnWindowFocus: false
151
+ });
152
+ }
153
+ function useUpdateMapping() {
154
+ const queryClient2 = useQueryClient();
155
+ return useMutation({
156
+ mutationFn: async (mapping) => {
157
+ await pagerDutyApi.storeServiceMapping(
158
+ mapping.serviceId,
159
+ mapping.entityRef
160
+ );
161
+ },
162
+ // client side optimistic update
163
+ onMutate: (newMappingInfo) => {
164
+ queryClient2.setQueryData(
165
+ ["mappings"],
166
+ (prevMappings) => prevMappings == null ? void 0 : prevMappings.map(
167
+ (prevMapping) => prevMapping.serviceId === newMappingInfo.serviceId ? newMappingInfo : prevMapping
168
+ )
169
+ );
170
+ }
171
+ });
172
+ }
173
+ const queryClient = new QueryClient();
174
+ return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(DenseTable, null));
175
+ };
176
+
177
+ const PagerDutyPage = () => {
178
+ 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(ServiceMappingComponent, null)))));
179
+ };
180
+
181
+ export { PagerDutyPage };
182
+ //# sourceMappingURL=index-7cef8fd8.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-7cef8fd8.esm.js","sources":["../../src/components/PagerDutyPage/ServiceMappingComponent.tsx","../../src/components/PagerDutyPage/index.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\n// import { Table, TableColumn } from \"@backstage/core-components\";\nimport {\n Box,\n // Button,\n DialogActions,\n DialogContent,\n DialogTitle,\n // FormControl,\n IconButton,\n // MenuItem,\n // Select,\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 { catalogApiRef } from \"@backstage/plugin-catalog-react\";\nimport { Entity } from \"@backstage/catalog-model\";\nimport { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { DropdownOption, MRT_ColumnDef, MRT_EditActionButtons, MRT_TableOptions, MaterialReactTable, useMaterialReactTable } from \"material-react-table\";\n\n// type 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\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\nexport const ServiceMappingComponent = () => {\n // const [catalogEntities, setCatalogEntities] = useState<Service[]>([]);\n // const [, setServiceMappings] = useState<PagerDutyEntityMapping[]>([]);\n // const [tableData, setTableData] = useState<TableItem[]>([]);\n // const [isLoading, setIsLoading] = useState(true);\n\n // const pagerDutyApi = useApi(pagerDutyApiRef);\n // const catalogApi = useApi(catalogApiRef);\n\n // useEffect(() => {\n // async function fetchEntities(): Promise<Service[]> {\n // const { items } = await catalogApi.getEntities({\n // filter: { kind: \"Component\" },\n // });\n\n // const backstageServices: Service[] = [];\n // items.forEach((entity: Entity) => {\n // backstageServices.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 // return backstageServices;\n // }\n\n // async function fetchServices(): Promise<PagerDutyEntityMapping[]> {\n // const { mappings: foundServices } = await pagerDutyApi.getEntityMappings();\n\n // return foundServices;\n // }\n\n // if (catalogEntities.length === 0) {\n // Promise.all([fetchEntities(), fetchServices()]).then(\n // ([entities, mappings]) => {\n // setCatalogEntities(entities);\n // setServiceMappings(mappings);\n\n // const data: TableItem[] = buildTableData(\n // entities,\n // mappings\n // );\n\n // setTableData(data);\n // setIsLoading(false);\n // }\n // );\n // }\n // }, [catalogApi, catalogEntities, pagerDutyApi]);\n\n // function buildTableData(\n // entities: Service[],\n // mappings: PagerDutyEntityMapping[]\n // ): TableItem[] {\n // const data: TableItem[] = mappings.map((service) => {\n // return {\n // name: service.serviceName,\n // team: service.team,\n // escalationPolicy: service.escalationPolicy,\n // // status of mapping\n // mappingStatus: (\n // <Typography\n // variant=\"body2\"\n // style={{\n // color: getColorFromStatus(service.status),\n // }}\n // >\n // {service.status}\n // </Typography>\n // ),\n // mapping: (\n // // dropdown menu with static options. If service.mapping is defined select that option\n // <FormControl variant=\"standard\">\n // <Select\n // displayEmpty\n // onChange={(selection) => {\n // handleMappingChange(service, selection);\n\n // }}\n // value={service.entityRef}\n // >\n // <MenuItem value=\"\">\n // <em>None</em>\n // </MenuItem>\n // {entities.map((backstageService) => {\n // return (\n // <MenuItem\n // key={backstageService.id}\n // value={backstageService.id}\n // >\n // {backstageService.name}\n // </MenuItem>\n // );\n // })}\n // </Select>\n // </FormControl>\n // ),\n // actions: (\n // <Button variant=\"contained\" color=\"primary\" href={service.serviceUrl}>\n // Open in PagerDuty\n // </Button>\n // ),\n // };\n // });\n\n // return data;\n // }\n\n // async function handleMappingChange(\n // service: PagerDutyEntityMapping,\n // event: ChangeEvent<{\n // name?: string | undefined;\n // value: unknown;\n // }>\n // ) {\n // // event.preventDefault();\n // const updatedData = [...tableData];\n\n // // find the service in updatedData\n // updatedData.findIndex((item) => item.name === service.serviceName);\n // // // updatedData[serviceIndex].mappingStatus = (\n // // // <Typography\n // // // variant=\"body2\"\n // // // style={{\n // // // color: getColorFromStatus(\"OutOfSync\"),\n // // // }}\n // // // >\n // // // \"OutOfSync\"\n // // // </Typography>\n // // // );\n\n // // // update the mapping status\n // // // service.status = \"OutOfSync\";\n\n // // // // update the mapping\n // // // service.entityRef = entityId;\n\n // // // store the mapping in the database\n // await pagerDutyApi.storeServiceMapping(\n // service.serviceId,\n // event.target.value as string\n // );\n // setTableData(updatedData);\n // }\n\n // const DenseTable = ({ items }: DenseTableProps) => {\n // // const [data, _] = useState<TableItem[]>(items);\n\n // // useEffect(() => {\n // // setData(items);\n // // }, [items]);\n\n // const columns: TableColumn[] = [\n // { title: \"PagerDuty Service\", field: \"name\" },\n // { title: \"Team\", field: \"team\" },\n // { title: \"Escalation Policy\", field: \"escalationPolicy\" },\n // { title: \"Mapping\", field: \"mapping\" },\n // { title: \"Status\", field: \"mappingStatus\" },\n // { title: \"Actions\", field: \"actions\" },\n // ];\n\n // return (\n // <Table\n // isLoading={isLoading}\n // title=\"PagerDuty Service Import\"\n // subtitle=\"Use this page to import services from PagerDuty and map them to existing Backstage services. Only 1:1 mapping is allowed.\"\n // options={{\n // search: true,\n // paging: true,\n // pageSize: 10,\n // pageSizeOptions: [10, 25, 50],\n // sorting: true,\n // emptyRowsWhenPaging: false,\n // showFirstLastPageButtons: true,\n // columnResizable: true,\n // columnsButton: true,\n // rowStyle: {\n // height: \"10px\",\n // },\n // padding: \"dense\",\n // }}\n // columns={columns}\n // data={items}\n // />\n // );\n // };\n\n // return <DenseTable items={tableData} />;\n\n const pagerDutyApi = useApi(pagerDutyApiRef);\n const catalogApi = useApi(catalogApiRef);\n\n function useGetCatalogEntities() {\n return useQuery<DropdownOption[]>({\n queryKey: [\"mappings\"],\n queryFn: async () => {\n // send api request here\n const { items } = await catalogApi.getEntities({\n filter: { kind: \"Component\" },\n });\n\n const entities: DropdownOption[] = [];\n items.forEach((entity: Entity) => {\n entities.push({\n value: entity.metadata?.uid ?? \"\",\n label: entity.metadata?.name,\n });\n });\n\n return entities;\n },\n refetchOnWindowFocus: false,\n });\n }\n\n const DenseTable = () => {\n const [validationErrors, setValidationErrors] = useState<\n Record<string, string | undefined>\n >({});\n\n const {\n data: fetchedEntities = [],\n isError: isLoadingEntitiesError,\n isFetching: isFetchingEntities,\n isLoading: isLoadingEntities,\n } = useGetCatalogEntities();\n\n const columns = useMemo<MRT_ColumnDef<PagerDutyEntityMapping>[]>(\n () => [\n {\n accessorKey: \"name\",\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: \"mapping\",\n header: \"Mapping\",\n editVariant: \"select\",\n editSelectOptions: fetchedEntities,\n muiEditTextFieldProps: {\n select: true,\n error: !!validationErrors?.state,\n helperText: validationErrors?.state,\n },\n },\n {\n accessorKey: \"status\",\n header: \"Status\",\n enableEditing: false,\n },\n ],\n [fetchedEntities, 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: updateUser, isPending: isUpdatingMapping } =\n useUpdateMapping();\n\n // UPDATE action\n const handleSaveUser: MRT_TableOptions<PagerDutyEntityMapping>[\"onEditingRowSave\"] =\n async ({ values, table }) => {\n await updateUser(values);\n table.setEditingRow(null); // exit editing mode\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 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: handleSaveUser,\n // optionally customize modal content\n renderEditRowDialogContent: ({ table, row, internalEditComponents }) => (\n <>\n <DialogTitle>Edit Mapping</DialogTitle>\n <DialogContent>\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 </Box>\n ),\n state: {\n isLoading: isLoadingMappings || isLoadingEntities,\n isSaving: isUpdatingMapping,\n showAlertBanner: isLoadingMappingsError || isLoadingEntitiesError,\n showProgressBars: isFetchingMappings || isFetchingEntities,\n },\n });\n\n return <MaterialReactTable table={dataTable} />;\n };\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 await pagerDutyApi.storeServiceMapping(\n mapping.serviceId,\n mapping.entityRef\n );\n },\n // client side optimistic update\n onMutate: (newMappingInfo: PagerDutyEntityMapping) => {\n queryClient.setQueryData([\"mappings\"], (prevMappings: any) =>\n prevMappings?.map((prevMapping: PagerDutyEntityMapping) =>\n prevMapping.serviceId === newMappingInfo.serviceId ? newMappingInfo : prevMapping\n )\n );\n },\n });\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 } 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 alignContent=\"flex-end\">\n <Button variant=\"contained\" color=\"primary\" onClick={() => {handleImport()}}>\n Import\n </Button>\n <Button variant=\"outlined\" color=\"primary\" onClick={() => {handleSave()}}>\n Save\n </Button>\n </Grid>\n </Grid> */}\n <Grid container spacing={3} direction=\"column\">\n <Grid item>\n <ServiceMappingComponent />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["queryClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DO,MAAM,0BAA0B,MAAM;AAgM3C,EAAM,MAAA,YAAA,GAAe,OA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in({
229
229
  const PagerDutyPage = pagerDutyPlugin.provide(
230
230
  createRoutableExtension({
231
231
  name: "PagerDutyPage",
232
- component: () => import('./index-e3fee98b.esm.js').then((m) => m.PagerDutyPage),
232
+ component: () => import('./index-7cef8fd8.esm.js').then((m) => m.PagerDutyPage),
233
233
  mountPoint: rootRouteRef
234
234
  })
235
235
  );
@@ -257,7 +257,7 @@ const HomePagePagerDutyCard = pagerDutyPlugin.provide(
257
257
  createCardExtension({
258
258
  name: "HomePagePagerDutyCard",
259
259
  title: "PagerDuty Homepage Card",
260
- components: () => import('./index-a775a548.esm.js'),
260
+ components: () => import('./index-2977760b.esm.js'),
261
261
  settings: {
262
262
  schema: {
263
263
  title: "PagerDuty",
@@ -1623,4 +1623,4 @@ function TriggerButton(props) {
1623
1623
  const PagerDutyCard = EntityPagerDutyCard;
1624
1624
 
1625
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 };
1626
- //# sourceMappingURL=index-c49d6ec3.esm.js.map
1626
+ //# sourceMappingURL=index-dd02e85a.esm.js.map