@pagerduty/backstage-plugin 0.13.0-next.8 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/assets/PD-Icon.svg +13 -0
- package/dist/api/client.esm.js +4 -3
- package/dist/api/client.esm.js.map +1 -1
- package/dist/assets/PD-Icon.svg +13 -0
- package/dist/components/Icons/index.esm.js +9 -0
- package/dist/components/Icons/index.esm.js.map +1 -0
- package/dist/components/PagerDutyPage/MappingTable.esm.js +245 -0
- package/dist/components/PagerDutyPage/MappingTable.esm.js.map +1 -0
- package/dist/components/PagerDutyPage/ServiceMappingComponent.esm.js +35 -199
- package/dist/components/PagerDutyPage/ServiceMappingComponent.esm.js.map +1 -1
- package/dist/components/PagerDutyPage/index.esm.js +1 -1
- package/dist/components/PagerDutyPage/index.esm.js.map +1 -1
- package/dist/deprecated.esm.js +1 -0
- package/dist/deprecated.esm.js.map +1 -1
- package/dist/hooks/index.esm.js +0 -2
- package/dist/hooks/index.esm.js.map +1 -1
- package/dist/index.d.ts +18 -14
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ The PagerDuty plugin reduces the cognitive load on developers responsible for ma
|
|
|
13
13
|
- **[See Active Incidents](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#view-any-open-incidents>)** - View all active incidents for a service directly in Backstage.
|
|
14
14
|
- **[Check for Recent Changes](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#view-change-events-associated-to-a-service>)** - Identify recent changes that may be the root cause of potential issues with your service.
|
|
15
15
|
- **[Identify On-Call Personnel](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#see-and-contact-on-call-staff>)** - Quickly determine who is responsible for a failing service and resolve the incident as quickly as possible. This feature allows companies to spend more time solving problems rather than determining who should solve them.
|
|
16
|
+
- **Map existing PagerDuty services to Backstage entities** - Leverage PagerDuty's Advanced Configuration page to map existing PagerDuty services to Backstage entities without code changes.
|
|
16
17
|
|
|
17
18
|
## Getting Started
|
|
18
19
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 120.6 175" style="enable-background:new 0 0 120.6 175;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:#B5B5B5;}
|
|
7
|
+
</style>
|
|
8
|
+
<g>
|
|
9
|
+
<rect y="128.4" class="st0" width="25.7" height="46.6"/>
|
|
10
|
+
<path class="st0" d="M96.5,8.6C82.8,1.2,73.2,0,50.7,0H0v106.1h25.7H29h21.5c20,0,35-1.2,48.2-10c14.4-9.5,21.9-25.4,21.9-43.8
|
|
11
|
+
C120.6,32.5,111.4,16.6,96.5,8.6z M56.4,83.9H25.7V22.7l29-0.2c26.4-0.2,39.6,9,39.6,30.1C94.3,75.3,77.9,83.9,56.4,83.9z"/>
|
|
12
|
+
</g>
|
|
13
|
+
</svg>
|
package/dist/api/client.esm.js
CHANGED
|
@@ -51,10 +51,11 @@ class PagerDutyClient {
|
|
|
51
51
|
)}/mapping/entity`;
|
|
52
52
|
return await this.findByUrl(url);
|
|
53
53
|
}
|
|
54
|
-
async storeServiceMapping(serviceId,
|
|
54
|
+
async storeServiceMapping(serviceId, integrationKey, backstageEntityRef) {
|
|
55
55
|
const body = JSON.stringify({
|
|
56
|
-
entityRef:
|
|
57
|
-
serviceId
|
|
56
|
+
entityRef: backstageEntityRef,
|
|
57
|
+
serviceId,
|
|
58
|
+
integrationKey
|
|
58
59
|
});
|
|
59
60
|
const options = {
|
|
60
61
|
method: "POST",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.esm.js","sources":["../../src/api/client.ts"],"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\nimport {\n PagerDutyApi,\n PagerDutyTriggerAlarmRequest,\n PagerDutyClientApiDependencies,\n PagerDutyClientApiConfig,\n RequestOptions,\n} from './types';\nimport { PagerDutyChangeEventsResponse, \n PagerDutyOnCallUsersResponse, \n PagerDutyUser, \n PagerDutyServiceResponse,\n PagerDutyIncidentsResponse,\n PagerDutyServiceStandardsResponse,\n PagerDutyServiceMetricsResponse,\n PagerDutyEntityMappingResponse\n} from '@pagerduty/backstage-plugin-common';\nimport { createApiRef, ConfigApi } from '@backstage/core-plugin-api';\nimport { NotFoundError } from '@backstage/errors';\nimport { Entity } from '@backstage/catalog-model';\nimport { getPagerDutyEntity } from '../components/pagerDutyEntity';\nimport { PagerDutyEntity } from '../types';\n\n/** @public */\nexport class UnauthorizedError extends Error {}\n\n/** @public */\nexport class ForbiddenError extends Error { }\n\n/** @public */\nexport const pagerDutyApiRef = createApiRef<PagerDutyApi>({\n id: 'plugin.pagerduty.api',\n});\n\n/** @public */\nexport class PagerDutyClient implements PagerDutyApi {\n static fromConfig(\n configApi: ConfigApi,\n dependencies: PagerDutyClientApiDependencies,\n ) {\n const { discoveryApi, fetchApi } = dependencies;\n\n const eventsBaseUrl: string =\n configApi.getOptionalString('pagerDuty.eventsBaseUrl') ??\n 'https://events.pagerduty.com/v2';\n\n return new PagerDutyClient({\n eventsBaseUrl,\n discoveryApi,\n fetchApi,\n });\n }\n\n constructor(private readonly config: PagerDutyClientApiConfig) {}\n\n async getServiceByPagerDutyEntity(\n pagerDutyEntity: PagerDutyEntity,\n ): Promise<PagerDutyServiceResponse> {\n const { integrationKey, serviceId } = pagerDutyEntity;\n\n let response: PagerDutyServiceResponse;\n let url: string;\n\n if (integrationKey) {\n url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services?integration_key=${integrationKey}`;\n const serviceResponse = await this.findByUrl<PagerDutyServiceResponse>(url);\n\n if (serviceResponse.service === undefined) throw new NotFoundError();\n\n response = serviceResponse;\n } else if (serviceId) {\n url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n response = await this.findByUrl<PagerDutyServiceResponse>(url);\n } else {\n throw new NotFoundError();\n }\n\n return response;\n }\n\n async getEntityMappings(): Promise<PagerDutyEntityMappingResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/mapping/entity`;\n\n return await this.findByUrl<PagerDutyEntityMappingResponse>(url);\n }\n\n async storeServiceMapping(serviceId: string, backstageEntityId: string): Promise<Response> {\n\n const body = JSON.stringify({\n entityRef: backstageEntityId,\n serviceId: serviceId,\n });\n\n const options = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8',\n Accept: 'application/json, text/plain, */*',\n },\n body,\n };\n\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/mapping/entity`;\n\n return this.request(url, options);\n }\n\n async getServiceByEntity(entity: Entity): Promise<PagerDutyServiceResponse> {\n return await this.getServiceByPagerDutyEntity(getPagerDutyEntity(entity));\n }\n\n async getServiceById(serviceId: string): Promise<PagerDutyServiceResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n return await this.findByUrl<PagerDutyServiceResponse>(url);\n }\n\n async getIncidentsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyIncidentsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/incidents`;\n\n return await this.findByUrl<PagerDutyIncidentsResponse>(url);\n }\n\n async getChangeEventsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyChangeEventsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/change-events`;\n\n return await this.findByUrl<PagerDutyChangeEventsResponse>(url);\n }\n\n async getServiceStandardsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyServiceStandardsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/standards`;\n\n return await this.findByUrl<PagerDutyServiceStandardsResponse>(url);\n }\n\n async getServiceMetricsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyServiceMetricsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/metrics`;\n\n return await this.findByUrl<PagerDutyServiceMetricsResponse>(url);\n }\n\n async getOnCallByPolicyId(\n policyId: string,\n ): Promise<PagerDutyUser[]> {\n const params = `escalation_policy_ids[]=${policyId}`;\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/oncall-users?${params}`;\n\n const response: PagerDutyOnCallUsersResponse = await this.findByUrl<PagerDutyOnCallUsersResponse>(url);\n return response.users;\n }\n\n triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response> {\n const { integrationKey, source, description, userName } = request;\n\n const body = JSON.stringify({\n event_action: 'trigger',\n routing_key: integrationKey,\n client: 'Backstage',\n client_url: source,\n payload: {\n summary: description,\n source: source,\n severity: 'error',\n class: 'manual trigger',\n custom_details: {\n user: userName,\n },\n },\n });\n\n const options = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8',\n Accept: 'application/json, text/plain, */*',\n },\n body,\n };\n\n const url = this.config.eventsBaseUrl ?? 'https://events.pagerduty.com/v2';\n\n return this.request(`${url}/enqueue`, options);\n }\n\n private async findByUrl<T>(url: string): Promise<T> {\n const options = {\n method: 'GET',\n headers: {\n Accept: 'application/vnd.pagerduty+json;version=2',\n 'Content-Type': 'application/json',\n },\n };\n const response = await this.request(url, options);\n return response.json();\n }\n\n private async request(\n url: string,\n options: RequestOptions,\n ): Promise<Response> {\n const response = await this.config.fetchApi.fetch(url, options);\n if (response.status === 401) {\n throw new UnauthorizedError(\"Unauthorized: You don't have access to this resource\");\n }\n\n if (response.status === 403) {\n throw new ForbiddenError(\"Forbidden: You are not allowed to perform this action\");\n }\n\n if (response.status === 404) {\n throw new NotFoundError(\"Not Found: Resource not found\");\n }\n\n if (!response.ok) {\n const payload = await response.json();\n const errors = payload.errors.map((error: string) => error).join(' ');\n const message = `Request failed with ${response.status}, ${errors}`;\n throw new Error(message);\n }\n return response;\n }\n}\n"],"names":[],"mappings":";;;;AAuCO,MAAM,0BAA0B,KAAM,CAAA;AAAC,CAAA;AAGvC,MAAM,uBAAuB,KAAM,CAAA;AAAE,CAAA;AAGrC,MAAM,kBAAkB,YAA2B,CAAA;AAAA,EACxD,EAAI,EAAA,sBAAA;AACN,CAAC,EAAA;AAGM,MAAM,eAAwC,CAAA;AAAA,EAkBnD,YAA6B,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAAA,GAAmC;AAAA,EAjBhE,OAAO,UACL,CAAA,SAAA,EACA,YACA,EAAA;AAtDJ,IAAA,IAAA,EAAA,CAAA;AAuDI,IAAM,MAAA,EAAE,YAAc,EAAA,QAAA,EAAa,GAAA,YAAA,CAAA;AAEnC,IAAA,MAAM,aACJ,GAAA,CAAA,EAAA,GAAA,SAAA,CAAU,iBAAkB,CAAA,yBAAyB,MAArD,IACA,GAAA,EAAA,GAAA,iCAAA,CAAA;AAEF,IAAA,OAAO,IAAI,eAAgB,CAAA;AAAA,MACzB,aAAA;AAAA,MACA,YAAA;AAAA,MACA,QAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AAAA,E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AAAA,EAEA,MAAc,OACZ,CAAA,GAAA,EACA,OACmB,EAAA;AACnB,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,OAAO,QAAS,CAAA,KAAA,CAAM,KAAK,OAAO,CAAA,CAAA;AAC9D,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAM,MAAA,IAAI,kBAAkB,sDAAsD,CAAA,CAAA;AAAA,KACpF;AAEA,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAM,MAAA,IAAI,eAAe,uDAAuD,CAAA,CAAA;AAAA,KAClF;AAEA,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAM,MAAA,IAAI,cAAc,+BAA+B,CAAA,CAAA;AAAA,KACzD;AAEA,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,IAAK,EAAA,CAAA;AACpC,MAAM,MAAA,MAAA,GAAS,QAAQ,MAAO,CAAA,GAAA,CAAI,CAAC,KAAkB,KAAA,KAAK,CAAE,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AACpE,MAAA,MAAM,OAAU,GAAA,CAAA,oBAAA,EAAuB,QAAS,CAAA,MAAM,KAAK,MAAM,CAAA,CAAA,CAAA;AACjE,MAAM,MAAA,IAAI,MAAM,OAAO,CAAA,CAAA;AAAA,KACzB;AACA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"client.esm.js","sources":["../../src/api/client.ts"],"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\nimport {\n PagerDutyApi,\n PagerDutyTriggerAlarmRequest,\n PagerDutyClientApiDependencies,\n PagerDutyClientApiConfig,\n RequestOptions,\n} from './types';\nimport { PagerDutyChangeEventsResponse, \n PagerDutyOnCallUsersResponse, \n PagerDutyUser, \n PagerDutyServiceResponse,\n PagerDutyIncidentsResponse,\n PagerDutyServiceStandardsResponse,\n PagerDutyServiceMetricsResponse,\n PagerDutyEntityMappingsResponse\n} from '@pagerduty/backstage-plugin-common';\nimport { createApiRef, ConfigApi } from '@backstage/core-plugin-api';\nimport { NotFoundError } from '@backstage/errors';\nimport { Entity } from '@backstage/catalog-model';\nimport { getPagerDutyEntity } from '../components/pagerDutyEntity';\nimport { PagerDutyEntity } from '../types';\n\n/** @public */\nexport class UnauthorizedError extends Error {}\n\n/** @public */\nexport class ForbiddenError extends Error { }\n\n/** @public */\nexport const pagerDutyApiRef = createApiRef<PagerDutyApi>({\n id: 'plugin.pagerduty.api',\n});\n\n/** @public */\nexport class PagerDutyClient implements PagerDutyApi {\n static fromConfig(\n configApi: ConfigApi,\n dependencies: PagerDutyClientApiDependencies,\n ) {\n const { discoveryApi, fetchApi } = dependencies;\n\n const eventsBaseUrl: string =\n configApi.getOptionalString('pagerDuty.eventsBaseUrl') ??\n 'https://events.pagerduty.com/v2';\n\n return new PagerDutyClient({\n eventsBaseUrl,\n discoveryApi,\n fetchApi,\n });\n }\n\n constructor(private readonly config: PagerDutyClientApiConfig) {}\n\n async getServiceByPagerDutyEntity(\n pagerDutyEntity: PagerDutyEntity,\n ): Promise<PagerDutyServiceResponse> {\n const { integrationKey, serviceId } = pagerDutyEntity;\n\n let response: PagerDutyServiceResponse;\n let url: string;\n\n if (integrationKey) {\n url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services?integration_key=${integrationKey}`;\n const serviceResponse = await this.findByUrl<PagerDutyServiceResponse>(url);\n\n if (serviceResponse.service === undefined) throw new NotFoundError();\n\n response = serviceResponse;\n } else if (serviceId) {\n url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n response = await this.findByUrl<PagerDutyServiceResponse>(url);\n } else {\n throw new NotFoundError();\n }\n\n return response;\n }\n\n async getEntityMappings(): Promise<PagerDutyEntityMappingsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/mapping/entity`;\n\n return await this.findByUrl<PagerDutyEntityMappingsResponse>(url);\n }\n\n async storeServiceMapping(serviceId: string, integrationKey: string, backstageEntityRef: string): Promise<Response> {\n\n const body = JSON.stringify({\n entityRef: backstageEntityRef,\n serviceId: serviceId,\n integrationKey: integrationKey,\n });\n\n const options = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8',\n Accept: 'application/json, text/plain, */*',\n },\n body,\n };\n\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/mapping/entity`;\n\n return this.request(url, options);\n }\n\n async getServiceByEntity(entity: Entity): Promise<PagerDutyServiceResponse> {\n return await this.getServiceByPagerDutyEntity(getPagerDutyEntity(entity));\n }\n\n async getServiceById(serviceId: string): Promise<PagerDutyServiceResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n return await this.findByUrl<PagerDutyServiceResponse>(url);\n }\n\n async getIncidentsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyIncidentsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/incidents`;\n\n return await this.findByUrl<PagerDutyIncidentsResponse>(url);\n }\n\n async getChangeEventsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyChangeEventsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/change-events`;\n\n return await this.findByUrl<PagerDutyChangeEventsResponse>(url);\n }\n\n async getServiceStandardsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyServiceStandardsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/standards`;\n\n return await this.findByUrl<PagerDutyServiceStandardsResponse>(url);\n }\n\n async getServiceMetricsByServiceId(\n serviceId: string,\n ): Promise<PagerDutyServiceMetricsResponse> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/metrics`;\n\n return await this.findByUrl<PagerDutyServiceMetricsResponse>(url);\n }\n\n async getOnCallByPolicyId(\n policyId: string,\n ): Promise<PagerDutyUser[]> {\n const params = `escalation_policy_ids[]=${policyId}`;\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/oncall-users?${params}`;\n\n const response: PagerDutyOnCallUsersResponse = await this.findByUrl<PagerDutyOnCallUsersResponse>(url);\n return response.users;\n }\n\n triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response> {\n const { integrationKey, source, description, userName } = request;\n\n const body = JSON.stringify({\n event_action: 'trigger',\n routing_key: integrationKey,\n client: 'Backstage',\n client_url: source,\n payload: {\n summary: description,\n source: source,\n severity: 'error',\n class: 'manual trigger',\n custom_details: {\n user: userName,\n },\n },\n });\n\n const options = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json; charset=UTF-8',\n Accept: 'application/json, text/plain, */*',\n },\n body,\n };\n\n const url = this.config.eventsBaseUrl ?? 'https://events.pagerduty.com/v2';\n\n return this.request(`${url}/enqueue`, options);\n }\n\n private async findByUrl<T>(url: string): Promise<T> {\n const options = {\n method: 'GET',\n headers: {\n Accept: 'application/vnd.pagerduty+json;version=2',\n 'Content-Type': 'application/json',\n },\n };\n const response = await this.request(url, options);\n return response.json();\n }\n\n private async request(\n url: string,\n options: RequestOptions,\n ): Promise<Response> {\n const response = await this.config.fetchApi.fetch(url, options);\n if (response.status === 401) {\n throw new UnauthorizedError(\"Unauthorized: You don't have access to this resource\");\n }\n\n if (response.status === 403) {\n throw new ForbiddenError(\"Forbidden: You are not allowed to perform this action\");\n }\n\n if (response.status === 404) {\n throw new NotFoundError(\"Not Found: Resource not found\");\n }\n\n if (!response.ok) {\n const payload = await response.json();\n const errors = payload.errors.map((error: string) => error).join(' ');\n const message = `Request failed with ${response.status}, ${errors}`;\n throw new Error(message);\n }\n return response;\n }\n}\n"],"names":[],"mappings":";;;;AAuCO,MAAM,0BAA0B,KAAM,CAAA;AAAC,CAAA;AAGvC,MAAM,uBAAuB,KAAM,CAAA;AAAE,CAAA;AAGrC,MAAM,kBAAkB,YAA2B,CAAA;AAAA,EACxD,EAAI,EAAA,sBAAA;AACN,CAAC,EAAA;AAGM,MAAM,eAAwC,CAAA;AAAA,EAkBnD,YAA6B,MAAkC,EAAA;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAAA,GAAmC;AAAA,EAjBhE,OAAO,UACL,CAAA,SAAA,EACA,YACA,EAAA;AAtDJ,IAAA,IAAA,EAAA,CAAA;AAuDI,IAAM,MAAA,EAAE,YAAc,EAAA,QAAA,EAAa,GAAA,YAAA,CAAA;AAEnC,IAAA,MAAM,aACJ,GAAA,CAAA,EAAA,GAAA,SAAA,CAAU,iBAAkB,CAAA,yBAAyB,MAArD,IACA,GAAA,EAAA,GAAA,iCAAA,CAAA;AAEF,IAAA,OAAO,IAAI,eAAgB,CAAA;AAAA,MACzB,aAAA;AAAA,MACA,YAAA;AAAA,MACA,QAAA;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AAAA,EAIA,MAAM,4BACJ,eACmC,EAAA;AACnC,IAAM,MAAA,EAAE,cAAgB,EAAA,SAAA,EAAc,GAAA,eAAA,CAAA;AAEtC,IAAI,IAAA,QAAA,CAAA;AACJ,IAAI,IAAA,GAAA,CAAA;AAEJ,IAAA,IAAI,cAAgB,EAAA;AAClB,MAAA,GAAA,GAAM,CAAG,EAAA,MAAM,IAAK,CAAA,MAAA,CAAO,YAAa,CAAA,UAAA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CAAA;AAAA,KACpF;AAEA,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAM,MAAA,IAAI,eAAe,uDAAuD,CAAA,CAAA;AAAA,KAClF;AAEA,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAM,MAAA,IAAI,cAAc,+BAA+B,CAAA,CAAA;AAAA,KACzD;AAEA,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,IAAK,EAAA,CAAA;AACpC,MAAM,MAAA,MAAA,GAAS,QAAQ,MAAO,CAAA,GAAA,CAAI,CAAC,KAAkB,KAAA,KAAK,CAAE,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AACpE,MAAA,MAAM,OAAU,GAAA,CAAA,oBAAA,EAAuB,QAAS,CAAA,MAAM,KAAK,MAAM,CAAA,CAAA,CAAA;AACjE,MAAM,MAAA,IAAI,MAAM,OAAO,CAAA,CAAA;AAAA,KACzB;AACA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 120.6 175" style="enable-background:new 0 0 120.6 175;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:#B5B5B5;}
|
|
7
|
+
</style>
|
|
8
|
+
<g>
|
|
9
|
+
<rect y="128.4" class="st0" width="25.7" height="46.6"/>
|
|
10
|
+
<path class="st0" d="M96.5,8.6C82.8,1.2,73.2,0,50.7,0H0v106.1h25.7H29h21.5c20,0,35-1.2,48.2-10c14.4-9.5,21.9-25.4,21.9-43.8
|
|
11
|
+
C120.6,32.5,111.4,16.6,96.5,8.6z M56.4,83.9H25.7V22.7l29-0.2c26.4-0.2,39.6,9,39.6,30.1C94.3,75.3,77.9,83.9,56.4,83.9z"/>
|
|
12
|
+
</g>
|
|
13
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PDIcon from '../../assets/PD-Icon.svg';
|
|
3
|
+
|
|
4
|
+
function PagerDutyIcon() {
|
|
5
|
+
return /* @__PURE__ */ React.createElement("img", { src: PDIcon, alt: "PagerDuty", height: "20px" });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { PagerDutyIcon };
|
|
9
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/Icons/index.tsx"],"sourcesContent":["import React from \"react\";\nimport PDIcon from \"../../assets/PD-Icon.svg\";\n\n/** @public */\nexport function PagerDutyIcon() {\n\n return <img src={PDIcon} alt=\"PagerDuty\" height=\"20px\" />;\n};\n"],"names":[],"mappings":";;;AAIO,SAAS,aAAgB,GAAA;AAE9B,EAAA,2CAAQ,KAAI,EAAA,EAAA,GAAA,EAAK,QAAQ,GAAI,EAAA,WAAA,EAAY,QAAO,MAAO,EAAA,CAAA,CAAA;AACzD;;;;"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useMaterialReactTable, MRT_EditActionButtons, MaterialReactTable } from 'material-react-table';
|
|
3
|
+
import { Typography, Box, DialogTitle, DialogContent, DialogActions, Tooltip, IconButton } from '@material-ui/core';
|
|
4
|
+
import { QueryClient, QueryClientProvider, useMutation } from '@tanstack/react-query';
|
|
5
|
+
import { Edit, OpenInBrowser } from '@mui/icons-material';
|
|
6
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
7
|
+
import { pagerDutyApiRef } from '../../api/client.esm.js';
|
|
8
|
+
|
|
9
|
+
function getColorFromStatus(status) {
|
|
10
|
+
switch (status) {
|
|
11
|
+
case "InSync":
|
|
12
|
+
return "green";
|
|
13
|
+
case "OutOfSync":
|
|
14
|
+
return "red";
|
|
15
|
+
case "NotMapped":
|
|
16
|
+
return "orange";
|
|
17
|
+
default:
|
|
18
|
+
return "gray";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function makeReadable(status) {
|
|
22
|
+
switch (status) {
|
|
23
|
+
case "InSync":
|
|
24
|
+
return "In Sync";
|
|
25
|
+
case "OutOfSync":
|
|
26
|
+
return "Out of Sync";
|
|
27
|
+
case "NotMapped":
|
|
28
|
+
return "Not Mapped";
|
|
29
|
+
default:
|
|
30
|
+
return "Refresh to Update";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const MappingTable = ({
|
|
34
|
+
mappings,
|
|
35
|
+
catalogEntities
|
|
36
|
+
}) => {
|
|
37
|
+
const DenseTable = () => {
|
|
38
|
+
const [validationErrors, setValidationErrors] = useState({});
|
|
39
|
+
const [entityOptions, setEntityOptions] = useState(
|
|
40
|
+
[]
|
|
41
|
+
);
|
|
42
|
+
const pagerDutyApi = useApi(pagerDutyApiRef);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
getEntityOptions();
|
|
45
|
+
}, []);
|
|
46
|
+
const columns = useMemo(
|
|
47
|
+
() => [
|
|
48
|
+
{
|
|
49
|
+
accessorKey: "serviceId",
|
|
50
|
+
header: "Service ID",
|
|
51
|
+
visibleInShowHideMenu: false,
|
|
52
|
+
enableEditing: false,
|
|
53
|
+
Edit: () => null,
|
|
54
|
+
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(Typography, { variant: "body1", style: { fontWeight: 600 } }, cell.getValue())
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
accessorKey: "integrationKey",
|
|
58
|
+
header: "Integration Key",
|
|
59
|
+
visibleInShowHideMenu: false,
|
|
60
|
+
enableEditing: false,
|
|
61
|
+
Edit: () => null
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
accessorKey: "serviceName",
|
|
65
|
+
header: "PagerDuty Service",
|
|
66
|
+
enableEditing: false
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
accessorKey: "team",
|
|
70
|
+
header: "Team",
|
|
71
|
+
enableEditing: false
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
accessorKey: "escalationPolicy",
|
|
75
|
+
header: "Escalation Policy",
|
|
76
|
+
enableEditing: false
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
accessorKey: "entityRef",
|
|
80
|
+
header: "Mapping",
|
|
81
|
+
visibleInShowHideMenu: false,
|
|
82
|
+
editVariant: "select",
|
|
83
|
+
editSelectOptions: entityOptions,
|
|
84
|
+
muiEditTextFieldProps: {
|
|
85
|
+
select: true,
|
|
86
|
+
error: !!(validationErrors == null ? void 0 : validationErrors.state),
|
|
87
|
+
helperText: validationErrors == null ? void 0 : validationErrors.state,
|
|
88
|
+
multiline: true,
|
|
89
|
+
type: "range"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
accessorKey: "entityName",
|
|
94
|
+
header: "Mapped Entity Name",
|
|
95
|
+
enableEditing: false,
|
|
96
|
+
Edit: () => null
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
accessorKey: "status",
|
|
100
|
+
header: "Status",
|
|
101
|
+
enableEditing: false,
|
|
102
|
+
Edit: () => null,
|
|
103
|
+
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(
|
|
104
|
+
Box,
|
|
105
|
+
{
|
|
106
|
+
component: "span",
|
|
107
|
+
bgcolor: getColorFromStatus(cell.getValue()),
|
|
108
|
+
borderRadius: "0.25rem",
|
|
109
|
+
color: "white",
|
|
110
|
+
p: "0.25rem"
|
|
111
|
+
},
|
|
112
|
+
makeReadable(cell.getValue())
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
accessorKey: "serviceUrl",
|
|
117
|
+
header: "Service URL",
|
|
118
|
+
visibleInShowHideMenu: false,
|
|
119
|
+
enableEditing: false,
|
|
120
|
+
Edit: () => null
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
[validationErrors, entityOptions]
|
|
124
|
+
);
|
|
125
|
+
function useUpdateMapping() {
|
|
126
|
+
return useMutation({
|
|
127
|
+
mutationFn: async (mapping) => {
|
|
128
|
+
return await pagerDutyApi.storeServiceMapping(
|
|
129
|
+
mapping.serviceId,
|
|
130
|
+
mapping.integrationKey || "",
|
|
131
|
+
mapping.entityRef
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const { mutateAsync: updateMapping, isPending: isUpdatingMapping } = useUpdateMapping();
|
|
137
|
+
const handleSaveMapping = async ({ values, table }) => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
setValidationErrors({});
|
|
140
|
+
values.entityName = (_b = (_a = catalogEntities.find(
|
|
141
|
+
(entity) => `${entity.type}:${entity.namespace}/${entity.name}`.toLowerCase() === values.entityRef
|
|
142
|
+
)) == null ? void 0 : _a.name) != null ? _b : "";
|
|
143
|
+
values.status = "RefreshToUpdate";
|
|
144
|
+
await updateMapping(values);
|
|
145
|
+
const existingMapping = mappings.find(
|
|
146
|
+
(item) => item.serviceId === values.serviceId
|
|
147
|
+
);
|
|
148
|
+
if (existingMapping) {
|
|
149
|
+
existingMapping.entityRef = values.entityRef;
|
|
150
|
+
existingMapping.entityName = values.entityName;
|
|
151
|
+
}
|
|
152
|
+
table.setEditingRow(null);
|
|
153
|
+
};
|
|
154
|
+
const openInBrowser = (url) => {
|
|
155
|
+
window.open(url, "_blank", "noreferrer");
|
|
156
|
+
};
|
|
157
|
+
const dataTable = useMaterialReactTable({
|
|
158
|
+
columns,
|
|
159
|
+
data: mappings,
|
|
160
|
+
editDisplayMode: "modal",
|
|
161
|
+
enableEditing: true,
|
|
162
|
+
positionActionsColumn: "last",
|
|
163
|
+
enableStickyHeader: true,
|
|
164
|
+
enableFilters: true,
|
|
165
|
+
getRowId: (row) => row.serviceId,
|
|
166
|
+
muiToolbarAlertBannerProps: mappings === void 0 ? {
|
|
167
|
+
color: "error",
|
|
168
|
+
children: "Error loading data"
|
|
169
|
+
} : void 0,
|
|
170
|
+
muiTableContainerProps: {
|
|
171
|
+
sx: {
|
|
172
|
+
minHeight: "500px"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
onEditingRowCancel: () => setValidationErrors({}),
|
|
176
|
+
onEditingRowSave: handleSaveMapping,
|
|
177
|
+
renderEditRowDialogContent: ({ table, row, internalEditComponents }) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DialogTitle, null, "Update Entity Mapping"), /* @__PURE__ */ React.createElement(
|
|
178
|
+
DialogContent,
|
|
179
|
+
{
|
|
180
|
+
style: { display: "flex", flexDirection: "column", gap: "1rem" }
|
|
181
|
+
},
|
|
182
|
+
internalEditComponents
|
|
183
|
+
), /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(MRT_EditActionButtons, { variant: "text", table, row }))),
|
|
184
|
+
renderRowActions: ({ row, table }) => /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex" } }, /* @__PURE__ */ React.createElement(Tooltip, { title: "Edit" }, /* @__PURE__ */ React.createElement(
|
|
185
|
+
IconButton,
|
|
186
|
+
{
|
|
187
|
+
onClick: () => {
|
|
188
|
+
getEntityOptions();
|
|
189
|
+
table.setEditingRow(row);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
/* @__PURE__ */ React.createElement(Edit, null)
|
|
193
|
+
)), /* @__PURE__ */ React.createElement(Tooltip, { title: "Open in PagerDuty" }, /* @__PURE__ */ React.createElement(
|
|
194
|
+
IconButton,
|
|
195
|
+
{
|
|
196
|
+
onClick: () => openInBrowser(row.getValue("serviceUrl"))
|
|
197
|
+
},
|
|
198
|
+
/* @__PURE__ */ React.createElement(OpenInBrowser, null)
|
|
199
|
+
))),
|
|
200
|
+
state: {
|
|
201
|
+
isLoading: mappings.length === 0 || catalogEntities.length === 0,
|
|
202
|
+
isSaving: isUpdatingMapping,
|
|
203
|
+
showAlertBanner: mappings === void 0 || catalogEntities === void 0,
|
|
204
|
+
showProgressBars: mappings.length === 0 || catalogEntities.length === 0,
|
|
205
|
+
columnVisibility: {
|
|
206
|
+
serviceId: false,
|
|
207
|
+
entityRef: false,
|
|
208
|
+
serviceUrl: false,
|
|
209
|
+
integrationKey: false
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
function getEntityOptions() {
|
|
214
|
+
const options = [];
|
|
215
|
+
options.push({ value: "", label: "None" });
|
|
216
|
+
catalogEntities.forEach((entity) => {
|
|
217
|
+
const foundServiceAnnotation = entity.annotations["pagerduty.com/service-id"];
|
|
218
|
+
const foundIntegrationKeyAnnotation = entity.annotations["pagerduty.com/integration-key"];
|
|
219
|
+
let foundServiceMapping;
|
|
220
|
+
if (foundServiceAnnotation || foundIntegrationKeyAnnotation) {
|
|
221
|
+
foundServiceMapping = mappings.find(
|
|
222
|
+
(item) => item.serviceId === foundServiceAnnotation || item.integrationKey === foundIntegrationKeyAnnotation
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
const entityRef = `${entity.type}:${entity.namespace}/${entity.name}`.toLowerCase();
|
|
226
|
+
const foundEntityMapping = mappings.find(
|
|
227
|
+
(item) => item.entityRef === entityRef
|
|
228
|
+
);
|
|
229
|
+
if (!foundEntityMapping && (!foundServiceAnnotation || !foundIntegrationKeyAnnotation) || (foundServiceAnnotation || foundIntegrationKeyAnnotation) && foundServiceMapping && !foundEntityMapping) {
|
|
230
|
+
options.push({
|
|
231
|
+
value: entityRef,
|
|
232
|
+
label: entity.name
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
setEntityOptions(options);
|
|
237
|
+
}
|
|
238
|
+
return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
|
|
239
|
+
};
|
|
240
|
+
const queryClient = new QueryClient();
|
|
241
|
+
return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(DenseTable, null));
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export { MappingTable };
|
|
245
|
+
//# sourceMappingURL=MappingTable.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MappingTable.esm.js","sources":["../../../src/components/PagerDutyPage/MappingTable.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { PagerDutyEntityMapping } from \"@pagerduty/backstage-plugin-common\";\nimport {\n MRT_ColumnDef,\n MRT_EditActionButtons,\n MRT_TableOptions,\n MaterialReactTable,\n useMaterialReactTable,\n} from \"material-react-table\";\nimport {\n Box,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n Tooltip,\n Typography,\n} from \"@material-ui/core\";\nimport {\n QueryClient,\n QueryClientProvider,\n useMutation,\n} from \"@tanstack/react-query\";\nimport { Edit, OpenInBrowser } from \"@mui/icons-material\";\nimport { useApi } from \"@backstage/core-plugin-api\";\nimport { pagerDutyApiRef } from \"../../api\";\n\ntype BackstageEntity = {\n id: string;\n name: string;\n namespace: string;\n type: string;\n system: string;\n owner: string;\n lifecycle: string;\n annotations: Annotations;\n};\n\nexport type Annotations = {\n \"pagerduty.com/integration-key\": string;\n \"pagerduty.com/service-id\": string;\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\ntype MappingTableProps = {\n mappings: PagerDutyEntityMapping[];\n catalogEntities: BackstageEntity[];\n};\n\nexport const MappingTable = ({\n mappings,\n catalogEntities,\n}: MappingTableProps) => {\n const DenseTable = () => {\n const [validationErrors, setValidationErrors] = useState<\n Record<string, string | undefined>\n >({});\n const [entityOptions, setEntityOptions] = useState<CatalogEntityOptions[]>(\n []\n );\n const pagerDutyApi = useApi(pagerDutyApiRef);\n\n useEffect(() => {\n getEntityOptions();\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: \"integrationKey\",\n header: \"Integration Key\",\n visibleInShowHideMenu: false,\n enableEditing: false,\n Edit: () => null,\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: entityOptions,\n muiEditTextFieldProps: {\n select: true,\n error: !!validationErrors?.state,\n helperText: validationErrors?.state,\n multiline: true,\n type: \"range\",\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, entityOptions]\n );\n\n // UPDATE hook (put mapping in api)\n function useUpdateMapping() {\n return useMutation({\n mutationFn: async (mapping: PagerDutyEntityMapping) => {\n return await pagerDutyApi.storeServiceMapping(\n mapping.serviceId,\n mapping.integrationKey || \"\",\n mapping.entityRef\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\n values.entityName =\n catalogEntities.find(\n (entity) =>\n `${entity.type}:${entity.namespace}/${entity.name}`.toLowerCase() ===\n values.entityRef\n )?.name ?? \"\";\n values.status = \"RefreshToUpdate\";\n\n await updateMapping(values);\n\n // find corresponding mapping in mappings array\n // and update it with new values\n const existingMapping = mappings.find(\n (item) => item.serviceId === values.serviceId\n );\n if (existingMapping) {\n existingMapping.entityRef = values.entityRef;\n existingMapping.entityName = values.entityName;\n }\n\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: mappings,\n editDisplayMode: \"modal\",\n enableEditing: true,\n positionActionsColumn: \"last\",\n enableStickyHeader: true,\n enableFilters: true,\n getRowId: (row) => row.serviceId,\n muiToolbarAlertBannerProps:\n mappings === undefined\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 renderEditRowDialogContent: ({ table, row, internalEditComponents }) => (\n <>\n <DialogTitle>Update Entity Mapping</DialogTitle>\n <DialogContent\n style={{ display: \"flex\", flexDirection: \"column\", gap: \"1rem\" }}\n >\n {internalEditComponents}\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\n onClick={() => {\n getEntityOptions();\n table.setEditingRow(row);\n }}\n >\n <Edit />\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: mappings.length === 0 || catalogEntities.length === 0,\n isSaving: isUpdatingMapping,\n showAlertBanner:\n mappings === undefined || catalogEntities === undefined,\n showProgressBars: mappings.length === 0 || catalogEntities.length === 0,\n columnVisibility: {\n serviceId: false,\n entityRef: false,\n serviceUrl: false,\n integrationKey: false,\n },\n },\n });\n\n function getEntityOptions() {\n const options: CatalogEntityOptions[] = [];\n // initialize with empty object\n options.push({ value: \"\", label: \"None\" });\n\n catalogEntities.forEach((entity) => {\n // find service-id annotation in entity\n const foundServiceAnnotation =\n entity.annotations[\"pagerduty.com/service-id\"];\n\n // find integration-key annotation in entity\n const foundIntegrationKeyAnnotation =\n entity.annotations[\"pagerduty.com/integration-key\"];\n\n // find entity with service-id in mappings array if service-id is found in entity\n let foundServiceMapping: PagerDutyEntityMapping | undefined;\n if (foundServiceAnnotation || foundIntegrationKeyAnnotation) {\n foundServiceMapping = mappings.find(\n (item) =>\n item.serviceId === foundServiceAnnotation ||\n item.integrationKey === foundIntegrationKeyAnnotation\n );\n }\n\n const entityRef =\n `${entity.type}:${entity.namespace}/${entity.name}`.toLowerCase();\n // find entity with entity.id in entityMappings array\n const foundEntityMapping = mappings.find(\n (item) => item.entityRef === entityRef\n );\n\n if (\n (!foundEntityMapping &&\n (!foundServiceAnnotation || !foundIntegrationKeyAnnotation)) ||\n ((foundServiceAnnotation || foundIntegrationKeyAnnotation) &&\n foundServiceMapping &&\n !foundEntityMapping)\n ) {\n options.push({\n value: entityRef,\n label: entity.name,\n });\n }\n });\n\n setEntityOptions(options);\n }\n\n return <MaterialReactTable table={dataTable} />;\n };\n\n const queryClient = new QueryClient();\n\n return (\n <QueryClientProvider client={queryClient}>\n <DenseTable />\n </QueryClientProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA2CA,SAAS,mBAAmB,MAAiB,EAAA;AAC3C,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,QAAA;AACH,MAAO,OAAA,OAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,KAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,QAAA,CAAA;AAAA,IACT;AACE,MAAO,OAAA,MAAA,CAAA;AAAA,GACX;AACF,CAAA;AAEA,SAAS,aAAa,MAAiB,EAAA;AACrC,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,QAAA;AACH,MAAO,OAAA,SAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,aAAA,CAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAO,OAAA,YAAA,CAAA;AAAA,IACT;AACE,MAAO,OAAA,mBAAA,CAAA;AAAA,GACX;AACF,CAAA;AAYO,MAAM,eAAe,CAAC;AAAA,EAC3B,QAAA;AAAA,EACA,eAAA;AACF,CAAyB,KAAA;AACvB,EAAA,MAAM,aAAa,MAAM;AACvB,IAAA,MAAM,CAAC,gBAAkB,EAAA,mBAAmB,CAAI,GAAA,QAAA,CAE9C,EAAE,CAAA,CAAA;AACJ,IAAM,MAAA,CAAC,aAAe,EAAA,gBAAgB,CAAI,GAAA,QAAA;AAAA,MACxC,EAAC;AAAA,KACH,CAAA;AACA,IAAM,MAAA,YAAA,GAAe,OAAO,eAAe,CAAA,CAAA;AA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AO,EAAA,SAAA;AAAA,YACP,OAAO,MAAO,CAAA,IAAA;AAAA,WACf,CAAA,CAAA;AAAA,SACH;AAAA,OACD,CAAA,CAAA;AAED,MAAA,gBAAA,CAAiB,OAAO,CAAA,CAAA;AAAA,KAC1B;AAEA,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,kBAAmB,EAAA,EAAA,KAAA,EAAO,SAAW,EAAA,CAAA,CAAA;AAAA,GAC/C,CAAA;AAEA,EAAM,MAAA,WAAA,GAAc,IAAI,WAAY,EAAA,CAAA;AAEpC,EAAA,2CACG,mBAAoB,EAAA,EAAA,MAAA,EAAQ,WAC3B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,gBAAW,CACd,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,212 +1,48 @@
|
|
|
1
|
-
import React, { useState,
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
|
|
4
|
+
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
5
|
+
import { MappingTable } from './MappingTable.esm.js';
|
|
9
6
|
|
|
10
|
-
function getColorFromStatus(status) {
|
|
11
|
-
switch (status) {
|
|
12
|
-
case "InSync":
|
|
13
|
-
return "green";
|
|
14
|
-
case "OutOfSync":
|
|
15
|
-
return "red";
|
|
16
|
-
case "NotMapped":
|
|
17
|
-
return "orange";
|
|
18
|
-
default:
|
|
19
|
-
return "gray";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function makeReadable(status) {
|
|
23
|
-
switch (status) {
|
|
24
|
-
case "InSync":
|
|
25
|
-
return "In Sync";
|
|
26
|
-
case "OutOfSync":
|
|
27
|
-
return "Out of Sync";
|
|
28
|
-
case "NotMapped":
|
|
29
|
-
return "Not Mapped";
|
|
30
|
-
default:
|
|
31
|
-
return "Refresh to Update";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
7
|
const ServiceMappingComponent = () => {
|
|
8
|
+
const [entityMappings, setEntityMappings] = useState([]);
|
|
9
|
+
const [catalogEntities, setCatalogEntities] = useState([]);
|
|
35
10
|
const pagerDutyApi = useApi(pagerDutyApiRef);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const [validationErrors, setValidationErrors] = useState({});
|
|
42
|
-
const columns = useMemo(
|
|
43
|
-
() => [
|
|
44
|
-
{
|
|
45
|
-
accessorKey: "serviceId",
|
|
46
|
-
header: "Service ID",
|
|
47
|
-
visibleInShowHideMenu: false,
|
|
48
|
-
enableEditing: false,
|
|
49
|
-
Edit: () => null,
|
|
50
|
-
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(Typography, { variant: "body1", style: { fontWeight: 600 } }, cell.getValue())
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
accessorKey: "serviceName",
|
|
54
|
-
header: "PagerDuty Service",
|
|
55
|
-
enableEditing: false
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
accessorKey: "team",
|
|
59
|
-
header: "Team",
|
|
60
|
-
enableEditing: false
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
accessorKey: "escalationPolicy",
|
|
64
|
-
header: "Escalation Policy",
|
|
65
|
-
enableEditing: false
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
accessorKey: "entityRef",
|
|
69
|
-
header: "Mapping",
|
|
70
|
-
visibleInShowHideMenu: false,
|
|
71
|
-
editVariant: "select",
|
|
72
|
-
editSelectOptions: [],
|
|
73
|
-
// getCatalogEntityOptions(),
|
|
74
|
-
muiEditTextFieldProps: {
|
|
75
|
-
select: true,
|
|
76
|
-
error: !!(validationErrors == null ? void 0 : validationErrors.state),
|
|
77
|
-
helperText: validationErrors == null ? void 0 : validationErrors.state
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
accessorKey: "entityName",
|
|
82
|
-
header: "Mapped Entity Name",
|
|
83
|
-
enableEditing: false,
|
|
84
|
-
Edit: () => null
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
accessorKey: "status",
|
|
88
|
-
header: "Status",
|
|
89
|
-
enableEditing: false,
|
|
90
|
-
Edit: () => null,
|
|
91
|
-
Cell: ({ cell }) => /* @__PURE__ */ React.createElement(
|
|
92
|
-
Box,
|
|
93
|
-
{
|
|
94
|
-
component: "span",
|
|
95
|
-
bgcolor: getColorFromStatus(cell.getValue()),
|
|
96
|
-
borderRadius: "0.25rem",
|
|
97
|
-
color: "white",
|
|
98
|
-
p: "0.25rem"
|
|
99
|
-
},
|
|
100
|
-
makeReadable(cell.getValue())
|
|
101
|
-
)
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
accessorKey: "serviceUrl",
|
|
105
|
-
header: "Service URL",
|
|
106
|
-
visibleInShowHideMenu: false,
|
|
107
|
-
enableEditing: false,
|
|
108
|
-
Edit: () => null
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
[validationErrors]
|
|
112
|
-
);
|
|
113
|
-
function useGetMappings() {
|
|
114
|
-
return useQuery({
|
|
115
|
-
queryKey: ["mappings"],
|
|
116
|
-
queryFn: async () => fetchMappings(),
|
|
117
|
-
refetchOnWindowFocus: false
|
|
11
|
+
const catalogApi = useApi(catalogApiRef);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
function fetchMappings() {
|
|
14
|
+
pagerDutyApi.getEntityMappings().then((result) => {
|
|
15
|
+
setEntityMappings(result.mappings);
|
|
118
16
|
});
|
|
119
17
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
18
|
+
function fetchCatalogEntities() {
|
|
19
|
+
catalogApi.getEntities({
|
|
20
|
+
filter: { kind: "Component" }
|
|
21
|
+
}).then((result) => {
|
|
22
|
+
const entities = [];
|
|
23
|
+
result.items.forEach((entity) => {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
25
|
+
const annotations = JSON.parse(
|
|
26
|
+
JSON.stringify(entity.metadata.annotations)
|
|
126
27
|
);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// return prevMapping;
|
|
140
|
-
// })
|
|
141
|
-
// );
|
|
142
|
-
// },
|
|
28
|
+
entities.push({
|
|
29
|
+
name: (_a = entity.metadata) == null ? void 0 : _a.name,
|
|
30
|
+
id: (_c = (_b = entity.metadata) == null ? void 0 : _b.uid) != null ? _c : "",
|
|
31
|
+
namespace: (_e = (_d = entity.metadata) == null ? void 0 : _d.namespace) != null ? _e : "",
|
|
32
|
+
type: (_f = entity.kind) != null ? _f : "",
|
|
33
|
+
system: JSON.stringify((_g = entity.spec) == null ? void 0 : _g.system) || "",
|
|
34
|
+
owner: JSON.stringify((_h = entity.spec) == null ? void 0 : _h.owner) || "",
|
|
35
|
+
lifecycle: JSON.stringify((_i = entity.spec) == null ? void 0 : _i.lifecycle) || "",
|
|
36
|
+
annotations
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
setCatalogEntities(entities);
|
|
143
40
|
});
|
|
144
41
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
isLoading: isLoadingMappings
|
|
150
|
-
} = useGetMappings();
|
|
151
|
-
const { mutateAsync: updateMapping, isPending: isUpdatingMapping } = useUpdateMapping();
|
|
152
|
-
const handleSaveMapping = async ({ values, table }) => {
|
|
153
|
-
setValidationErrors({});
|
|
154
|
-
values.status = "RefreshToUpdate";
|
|
155
|
-
await updateMapping(values);
|
|
156
|
-
table.setEditingRow(null);
|
|
157
|
-
};
|
|
158
|
-
const openInBrowser = (url) => {
|
|
159
|
-
window.open(url, "_blank", "noreferrer");
|
|
160
|
-
};
|
|
161
|
-
const dataTable = useMaterialReactTable({
|
|
162
|
-
columns,
|
|
163
|
-
data: fetchedMappings,
|
|
164
|
-
editDisplayMode: "modal",
|
|
165
|
-
// default ('row', 'cell', 'table', and 'custom' are also available)
|
|
166
|
-
enableEditing: true,
|
|
167
|
-
positionActionsColumn: "last",
|
|
168
|
-
enableStickyHeader: true,
|
|
169
|
-
enableFilters: true,
|
|
170
|
-
getRowId: (row) => row.serviceId,
|
|
171
|
-
muiToolbarAlertBannerProps: isLoadingMappingsError ? {
|
|
172
|
-
color: "error",
|
|
173
|
-
children: "Error loading data"
|
|
174
|
-
} : void 0,
|
|
175
|
-
muiTableContainerProps: {
|
|
176
|
-
sx: {
|
|
177
|
-
minHeight: "500px"
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
onEditingRowCancel: () => setValidationErrors({}),
|
|
181
|
-
onEditingRowSave: handleSaveMapping,
|
|
182
|
-
// optionally customize modal content
|
|
183
|
-
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 }))),
|
|
184
|
-
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(
|
|
185
|
-
IconButton,
|
|
186
|
-
{
|
|
187
|
-
onClick: () => openInBrowser(row.getValue("serviceUrl"))
|
|
188
|
-
},
|
|
189
|
-
/* @__PURE__ */ React.createElement(OpenInBrowserIcon, null)
|
|
190
|
-
))),
|
|
191
|
-
state: {
|
|
192
|
-
isLoading: isLoadingMappings,
|
|
193
|
-
// || isLoadingCatalogEntities,
|
|
194
|
-
isSaving: isUpdatingMapping,
|
|
195
|
-
showAlertBanner: isLoadingMappingsError,
|
|
196
|
-
// || isLoadingCatalogEntitiesError,
|
|
197
|
-
showProgressBars: isFetchingMappings,
|
|
198
|
-
// || isFetchingCatalogEntities,
|
|
199
|
-
columnVisibility: {
|
|
200
|
-
serviceId: false,
|
|
201
|
-
entityRef: false,
|
|
202
|
-
serviceUrl: false
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
return /* @__PURE__ */ React.createElement(MaterialReactTable, { table: dataTable });
|
|
207
|
-
};
|
|
208
|
-
const queryClient = new QueryClient();
|
|
209
|
-
return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(DenseTable, null));
|
|
42
|
+
fetchMappings();
|
|
43
|
+
fetchCatalogEntities();
|
|
44
|
+
}, [catalogApi, pagerDutyApi]);
|
|
45
|
+
return /* @__PURE__ */ React.createElement(MappingTable, { mappings: entityMappings, catalogEntities });
|
|
210
46
|
};
|
|
211
47
|
|
|
212
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\";\n// import { catalogApiRef } from \"@backstage/plugin-catalog-react\";\nimport OpenInBrowser from \"@material-ui/icons/OpenInBrowser\";\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\nfunction getColorFromStatus(status?: string) {\n switch (status) {\n case \"InSync\":\n return \"green\";\n case \"OutOfSync\":\n return \"red\";\n case \"NotMapped\":\n return \"orange\";\n default:\n return \"gray\";\n }\n}\n\nfunction makeReadable(status?: string) {\n switch (status) {\n case \"InSync\":\n return \"In Sync\";\n case \"OutOfSync\":\n return \"Out of Sync\";\n case \"NotMapped\":\n return \"Not Mapped\";\n default:\n return \"Refresh to Update\";\n }\n}\n\nexport const ServiceMappingComponent = () => {\n // const [_, setEntityMappings] = useState<\n // PagerDutyEntityMapping[]\n // >([]);\n // const [catalogEntities, setCatalogEntities] = useState<Service[]>([]);\n // const [entityOptions, setEntityOptions] = useState<CatalogEntityOptions[]>([]);\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 // async function fetchCatalogEntities(): Promise<Service[]> {\n // if (catalogEntities.length === 0) {\n // const result = await catalogApi.getEntities({\n // filter: { kind: \"Component\" },\n // });\n\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 // return catalogEntities;\n // }\n\n // type CatalogEntityOptions = {\n // value: string;\n // label: string;\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 // // setEntityOptions(options);\n\n // return options;\n // }\n\n // READ hook (get mappings from api)\n\n const DenseTable = () => {\n const [validationErrors, setValidationErrors] = useState<\n Record<string, string | undefined>\n >({});\n\n const columns = useMemo<MRT_ColumnDef<PagerDutyEntityMapping>[]>(\n () => [\n {\n accessorKey: \"serviceId\",\n header: \"Service ID\",\n visibleInShowHideMenu: false,\n enableEditing: false,\n 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 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 // 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 READ hook\n const {\n data: fetchedMappings = [],\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 // 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 // fetchedCatalogEntities.find(\n // (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: fetchedMappings,\n editDisplayMode: \"modal\", // default ('row', 'cell', 'table', and 'custom' are also available)\n enableEditing: true,\n positionActionsColumn: \"last\",\n enableStickyHeader: true,\n enableFilters: true,\n getRowId: (row) => row.serviceId,\n muiToolbarAlertBannerProps: isLoadingMappingsError\n ? {\n color: \"error\",\n children: \"Error loading data\",\n }\n : undefined,\n muiTableContainerProps: {\n sx: {\n minHeight: \"500px\",\n },\n },\n onEditingRowCancel: () => setValidationErrors({}),\n onEditingRowSave: handleSaveMapping,\n // optionally customize modal content\n renderEditRowDialogContent: ({ table, row, 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: isLoadingMappings, // || isLoadingCatalogEntities,\n isSaving: isUpdatingMapping,\n showAlertBanner: isLoadingMappingsError, // || isLoadingCatalogEntitiesError,\n showProgressBars: isFetchingMappings, // || isFetchingCatalogEntities,\n columnVisibility: {\n serviceId: false,\n entityRef: false,\n serviceUrl: false,\n },\n },\n });\n\n return <MaterialReactTable table={dataTable} />;\n };\n\n const queryClient = new QueryClient();\n\n return (\n <QueryClientProvider client={queryClient}>\n <DenseTable />\n </QueryClientProvider>\n );\n};\n"],"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,KAAK,WAAA;AACH,MAAO,OAAA,aAAA,CAA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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\";\nimport { BackstageEntity, Annotations } from \"../types\";\n\nexport const ServiceMappingComponent = () => {\n const [entityMappings, setEntityMappings] = useState<\n PagerDutyEntityMapping[]\n >([]);\n const [catalogEntities, setCatalogEntities] = useState<BackstageEntity[]>([]);\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() {\n pagerDutyApi.getEntityMappings().then((result) => {\n setEntityMappings(result.mappings);\n });\n }\n\n function fetchCatalogEntities() {\n catalogApi\n .getEntities({\n filter: { kind: \"Component\" },\n })\n .then((result) => {\n const entities: BackstageEntity[] = [];\n result.items.forEach((entity: any) => {\n const annotations: Annotations = JSON.parse(\n JSON.stringify(entity.metadata.annotations)\n );\n\n entities.push({\n name: entity.metadata?.name,\n id: entity.metadata?.uid ?? \"\",\n namespace: entity.metadata?.namespace ?? \"\",\n type: entity.kind ?? \"\",\n system: JSON.stringify(entity.spec?.system) || \"\",\n owner: JSON.stringify(entity.spec?.owner) || \"\",\n lifecycle: JSON.stringify(entity.spec?.lifecycle) || \"\",\n annotations: annotations,\n });\n });\n\n setCatalogEntities(entities);\n });\n }\n\n fetchMappings();\n fetchCatalogEntities();\n }, [catalogApi, pagerDutyApi]);\n\n \n return (\n <MappingTable mappings={entityMappings} catalogEntities={catalogEntities} />\n );\n};\n"],"names":[],"mappings":";;;;;;AAQO,MAAM,0BAA0B,MAAM;AAC3C,EAAA,MAAM,CAAC,cAAgB,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|
import { ServiceMappingComponent } from './ServiceMappingComponent.esm.js';
|
|
5
5
|
|
|
6
6
|
const PagerDutyPage = () => {
|
|
7
|
-
return /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(Header, { title: "PagerDuty", subtitle: "Advanced configurations" }), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, direction: "column" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, "Service to Entity mapping"), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, "Easily map your services to entities in Backstage without the need to add anotations to all your projects."), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, /* @__PURE__ */ React.createElement("b", null, "Warning: "), "Only 1:1 mapping is allowed at this time.")), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(ServiceMappingComponent, null)))));
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(Header, { title: "PagerDuty", subtitle: "Advanced configurations" }), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, { container: true, spacing: 3, direction: "column" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h4" }, "Service to Entity mapping"), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, "Easily map your existing PagerDuty services to entities in Backstage without the need to add anotations to all your projects."), /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, /* @__PURE__ */ React.createElement("b", null, "Warning: "), "Only 1:1 mapping is allowed at this time.")), /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(ServiceMappingComponent, null)))));
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { PagerDutyPage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/PagerDutyPage/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, Typography } from \"@material-ui/core\";\nimport { Header, Page, Content } from \"@backstage/core-components\";\nimport { ServiceMappingComponent } from \"./ServiceMappingComponent\";\n\n/** @public */\nexport const PagerDutyPage = () => {\n return (\n <Page themeId=\"home\">\n <Header title=\"PagerDuty\" subtitle=\"Advanced configurations\" />\n <Content>\n <Grid container spacing={3} direction=\"column\">\n <Grid item>\n <Typography variant=\"h4\">Service to Entity mapping</Typography>\n <Typography variant=\"body1\">\n Easily map your services to entities in Backstage without the need to add anotations to all your projects.\n </Typography>\n <Typography variant=\"body1\">\n <b>Warning: </b>Only 1:1 mapping is allowed at this time.\n </Typography>\n </Grid>\n <Grid item>\n <ServiceMappingComponent />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;AAMO,MAAM,gBAAgB,MAAM;AACjC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACZ,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,KAAA,EAAM,WAAY,EAAA,QAAA,EAAS,yBAA0B,EAAA,CAAA,kBAC5D,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,sCACE,IAAK,EAAA,EAAA,SAAA,EAAS,IAAC,EAAA,OAAA,EAAS,CAAG,EAAA,SAAA,EAAU,QACpC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,2BAAyB,CAAA,kBACjD,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,EAAQ,
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/PagerDutyPage/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, Typography } from \"@material-ui/core\";\nimport { Header, Page, Content } from \"@backstage/core-components\";\nimport { ServiceMappingComponent } from \"./ServiceMappingComponent\";\n\n/** @public */\nexport const PagerDutyPage = () => {\n return (\n <Page themeId=\"home\">\n <Header title=\"PagerDuty\" subtitle=\"Advanced configurations\" />\n <Content>\n <Grid container spacing={3} direction=\"column\">\n <Grid item>\n <Typography variant=\"h4\">Service to Entity mapping</Typography>\n <Typography variant=\"body1\">\n Easily map your existing PagerDuty services to entities in Backstage without the need to add anotations to all your projects.\n </Typography>\n <Typography variant=\"body1\">\n <b>Warning: </b>Only 1:1 mapping is allowed at this time.\n </Typography>\n </Grid>\n <Grid item>\n <ServiceMappingComponent />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;AAMO,MAAM,gBAAgB,MAAM;AACjC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACZ,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,KAAA,EAAM,WAAY,EAAA,QAAA,EAAS,yBAA0B,EAAA,CAAA,kBAC5D,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,sCACE,IAAK,EAAA,EAAA,SAAA,EAAS,IAAC,EAAA,OAAA,EAAS,CAAG,EAAA,SAAA,EAAU,QACpC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,QAAK,2BAAyB,CAAA,kBACjD,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,EAAQ,+HAE5B,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAE,WAAS,CAAA,EAAI,2CAClB,CACF,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IACR,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,uBAAwB,EAAA,IAAA,CAC3B,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
package/dist/deprecated.esm.js
CHANGED
|
@@ -2,6 +2,7 @@ import { EntityPagerDutyCard } from './components/EntityPagerDutyCard/index.esm.
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import '@backstage/plugin-catalog-react';
|
|
4
4
|
import './components/PagerDutySmallCard/index.esm.js';
|
|
5
|
+
import './assets/PD-Icon.svg';
|
|
5
6
|
import './components/TriggerButton/index.esm.js';
|
|
6
7
|
|
|
7
8
|
const PagerDutyCard = EntityPagerDutyCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated.esm.js","sources":["../src/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EntityPagerDutyCardProps, EntityPagerDutyCard } from './components';\n\n/**\n * @public\n * @deprecated Please use EntityPagerDutyCard\n */\nexport const PagerDutyCard = EntityPagerDutyCard;\n\n/**\n * @public\n * @deprecated Please use EntityPagerDutyCardProps\n */\nexport type PagerDutyCardProps = EntityPagerDutyCardProps;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deprecated.esm.js","sources":["../src/deprecated.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EntityPagerDutyCardProps, EntityPagerDutyCard } from './components';\n\n/**\n * @public\n * @deprecated Please use EntityPagerDutyCard\n */\nexport const PagerDutyCard = EntityPagerDutyCard;\n\n/**\n * @public\n * @deprecated Please use EntityPagerDutyCardProps\n */\nexport type PagerDutyCardProps = EntityPagerDutyCardProps;\n"],"names":[],"mappings":";;;;;;;AAsBO,MAAM,aAAgB,GAAA;;;;"}
|
package/dist/hooks/index.esm.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useEntity } from '@backstage/plugin-catalog-react';
|
|
2
2
|
import { getPagerDutyEntity } from '../components/pagerDutyEntity.esm.js';
|
|
3
|
-
import '@backstage/core-plugin-api';
|
|
4
|
-
import 'react-use';
|
|
5
3
|
|
|
6
4
|
function usePagerdutyEntity() {
|
|
7
5
|
const { entity } = useEntity();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/hooks/index.ts"],"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\nimport {
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/hooks/index.ts"],"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\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { PagerDutyEntity } from '../types';\nimport { getPagerDutyEntity } from '../components/pagerDutyEntity';\n\nexport function usePagerdutyEntity(): PagerDutyEntity {\n const { entity } = useEntity();\n\n return getPagerDutyEntity(entity);\n}\n"],"names":[],"mappings":";;;AAoBO,SAAS,kBAAsC,GAAA;AACpD,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAE7B,EAAA,OAAO,mBAAmB,MAAM,CAAA,CAAA;AAClC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import * as _backstage_plugin_home_react from '@backstage/plugin-home-react';
|
|
2
3
|
import { Entity } from '@backstage/catalog-model';
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import React__default, { ReactNode } from 'react';
|
|
5
6
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
6
7
|
import { DiscoveryApi, FetchApi, ConfigApi } from '@backstage/core-plugin-api';
|
|
7
|
-
import {
|
|
8
|
+
import { PagerDutyEntityMappingsResponse, PagerDutyServiceResponse, PagerDutyIncidentsResponse, PagerDutyChangeEventsResponse, PagerDutyServiceStandardsResponse, PagerDutyServiceMetricsResponse, PagerDutyUser } from '@pagerduty/backstage-plugin-common';
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
11
|
declare const isPluginApplicableToEntity$1: (entity: Entity) => boolean;
|
|
@@ -39,18 +40,21 @@ type HomePagePagerDutyCardProps = PagerDutyEntity & {
|
|
|
39
40
|
/** @public */
|
|
40
41
|
declare const pagerDutyPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {}, {}>;
|
|
41
42
|
/** @public */
|
|
42
|
-
declare const PagerDutyPage: () =>
|
|
43
|
+
declare const PagerDutyPage: () => React.JSX.Element;
|
|
43
44
|
/** @public */
|
|
44
|
-
declare const EntityPagerDutyCard: (props: EntityPagerDutyCardProps) =>
|
|
45
|
+
declare const EntityPagerDutyCard: (props: EntityPagerDutyCardProps) => React.JSX.Element;
|
|
45
46
|
/** @public */
|
|
46
|
-
declare const EntityPagerDutySmallCard: (props: EntityPagerDutySmallCardProps) =>
|
|
47
|
+
declare const EntityPagerDutySmallCard: (props: EntityPagerDutySmallCardProps) => React.JSX.Element;
|
|
47
48
|
/** @public */
|
|
48
|
-
declare const HomePagePagerDutyCard: (props: _backstage_plugin_home_react.CardExtensionProps<HomePagePagerDutyCardProps>) =>
|
|
49
|
+
declare const HomePagePagerDutyCard: (props: _backstage_plugin_home_react.CardExtensionProps<HomePagePagerDutyCardProps>) => React.JSX.Element;
|
|
50
|
+
|
|
51
|
+
/** @public */
|
|
52
|
+
declare function PagerDutyIcon(): React__default.JSX.Element;
|
|
49
53
|
|
|
50
54
|
/** @public */
|
|
51
55
|
declare function TriggerButton(props: {
|
|
52
56
|
children?: ReactNode;
|
|
53
|
-
}):
|
|
57
|
+
}): React__default.JSX.Element;
|
|
54
58
|
|
|
55
59
|
/** @public */
|
|
56
60
|
type PagerDutyTriggerAlarmRequest = {
|
|
@@ -65,12 +69,12 @@ interface PagerDutyApi {
|
|
|
65
69
|
* Fetches all entity mappings.
|
|
66
70
|
*
|
|
67
71
|
*/
|
|
68
|
-
getEntityMappings(): Promise<
|
|
72
|
+
getEntityMappings(): Promise<PagerDutyEntityMappingsResponse>;
|
|
69
73
|
/**
|
|
70
74
|
* Stores the service mapping in the database.
|
|
71
75
|
*
|
|
72
76
|
*/
|
|
73
|
-
storeServiceMapping(serviceId: string,
|
|
77
|
+
storeServiceMapping(serviceId: string, integrationKey: string, entityRef: string): Promise<Response>;
|
|
74
78
|
/**
|
|
75
79
|
* Fetches the service for the provided pager duty Entity.
|
|
76
80
|
*
|
|
@@ -137,8 +141,8 @@ declare class PagerDutyClient implements PagerDutyApi {
|
|
|
137
141
|
static fromConfig(configApi: ConfigApi, dependencies: PagerDutyClientApiDependencies): PagerDutyClient;
|
|
138
142
|
constructor(config: PagerDutyClientApiConfig);
|
|
139
143
|
getServiceByPagerDutyEntity(pagerDutyEntity: PagerDutyEntity): Promise<PagerDutyServiceResponse>;
|
|
140
|
-
getEntityMappings(): Promise<
|
|
141
|
-
storeServiceMapping(serviceId: string,
|
|
144
|
+
getEntityMappings(): Promise<PagerDutyEntityMappingsResponse>;
|
|
145
|
+
storeServiceMapping(serviceId: string, integrationKey: string, backstageEntityRef: string): Promise<Response>;
|
|
142
146
|
getServiceByEntity(entity: Entity): Promise<PagerDutyServiceResponse>;
|
|
143
147
|
getServiceById(serviceId: string): Promise<PagerDutyServiceResponse>;
|
|
144
148
|
getIncidentsByServiceId(serviceId: string): Promise<PagerDutyIncidentsResponse>;
|
|
@@ -155,11 +159,11 @@ declare class PagerDutyClient implements PagerDutyApi {
|
|
|
155
159
|
* @public
|
|
156
160
|
* @deprecated Please use EntityPagerDutyCard
|
|
157
161
|
*/
|
|
158
|
-
declare const PagerDutyCard: (props: EntityPagerDutyCardProps) =>
|
|
162
|
+
declare const PagerDutyCard: (props: EntityPagerDutyCardProps) => React.JSX.Element;
|
|
159
163
|
/**
|
|
160
164
|
* @public
|
|
161
165
|
* @deprecated Please use EntityPagerDutyCardProps
|
|
162
166
|
*/
|
|
163
167
|
type PagerDutyCardProps = EntityPagerDutyCardProps;
|
|
164
168
|
|
|
165
|
-
export { EntityPagerDutyCard, type EntityPagerDutyCardProps, EntityPagerDutySmallCard, type EntityPagerDutySmallCardProps, HomePagePagerDutyCard, type HomePagePagerDutyCardProps, type PagerDutyApi, PagerDutyCard, type PagerDutyCardProps, PagerDutyClient, type PagerDutyClientApiConfig, type PagerDutyClientApiDependencies, type PagerDutyEntity, PagerDutyPage, type PagerDutyTriggerAlarmRequest, TriggerButton, UnauthorizedError, isPluginApplicableToEntity as isPagerDutyAvailable, isPluginApplicableToEntity$1 as isPagerDutySmallCardAvailable, isPluginApplicableToEntity, pagerDutyApiRef, pagerDutyPlugin, pagerDutyPlugin as plugin };
|
|
169
|
+
export { EntityPagerDutyCard, type EntityPagerDutyCardProps, EntityPagerDutySmallCard, type EntityPagerDutySmallCardProps, HomePagePagerDutyCard, type HomePagePagerDutyCardProps, type PagerDutyApi, PagerDutyCard, type PagerDutyCardProps, PagerDutyClient, type PagerDutyClientApiConfig, type PagerDutyClientApiDependencies, type PagerDutyEntity, PagerDutyIcon, PagerDutyPage, type PagerDutyTriggerAlarmRequest, TriggerButton, UnauthorizedError, isPluginApplicableToEntity as isPagerDutyAvailable, isPluginApplicableToEntity$1 as isPagerDutySmallCardAvailable, isPluginApplicableToEntity, pagerDutyApiRef, pagerDutyPlugin, pagerDutyPlugin as plugin };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { EntityPagerDutyCard, EntityPagerDutySmallCard, HomePagePagerDutyCard, PagerDutyPage, pagerDutyPlugin, pagerDutyPlugin as plugin } from './plugin.esm.js';
|
|
2
2
|
export { isPluginApplicableToEntity as isPagerDutyAvailable, isPluginApplicableToEntity } from './components/EntityPagerDutyCard/index.esm.js';
|
|
3
3
|
export { isPluginApplicableToEntity as isPagerDutySmallCardAvailable } from './components/EntityPagerDutySmallCard/index.esm.js';
|
|
4
|
+
export { PagerDutyIcon } from './components/Icons/index.esm.js';
|
|
4
5
|
export { TriggerButton } from './components/TriggerButton/index.esm.js';
|
|
5
6
|
export { PagerDutyClient, UnauthorizedError, pagerDutyApiRef } from './api/client.esm.js';
|
|
6
7
|
export { PagerDutyCard } from './deprecated.esm.js';
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
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
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -48,12 +48,13 @@
|
|
|
48
48
|
"@mui/icons-material": "^5.15.19",
|
|
49
49
|
"@mui/material": "^5.15.19",
|
|
50
50
|
"@mui/x-date-pickers": "^7.6.1",
|
|
51
|
-
"@pagerduty/backstage-plugin-common": "
|
|
51
|
+
"@pagerduty/backstage-plugin-common": "0.1.5",
|
|
52
52
|
"@tanstack/react-query": "^5.40.1",
|
|
53
53
|
"classnames": "^2.2.6",
|
|
54
54
|
"luxon": "^3.4.1",
|
|
55
55
|
"material-react-table": "^2.13.0",
|
|
56
56
|
"react-use": "^17.2.4",
|
|
57
|
+
"uuid": "^10.0.0",
|
|
57
58
|
"validate-color": "^2.2.4"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
"@types/luxon": "^3.3.1",
|
|
77
78
|
"@types/node": "^16.11.26",
|
|
78
79
|
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
80
|
+
"@types/uuid": "^10.0.0",
|
|
79
81
|
"copyfiles": "^2.4.1",
|
|
80
82
|
"msw": "^1.2.4",
|
|
81
83
|
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|