@pagerduty/backstage-plugin 0.15.7 → 0.15.8-next.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 +36 -0
- package/config.d.ts +4 -1
- package/dist/alpha.d.ts +8 -0
- package/dist/alpha.esm.js +67 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/api/client.esm.js +9 -3
- package/dist/api/client.esm.js.map +1 -1
- package/dist/components/ChangeEvents/ChangeEventEmptyState.esm.js +20 -11
- package/dist/components/ChangeEvents/ChangeEventEmptyState.esm.js.map +1 -1
- package/dist/components/ChangeEvents/ChangeEventForbiddenState.esm.js +20 -11
- package/dist/components/ChangeEvents/ChangeEventForbiddenState.esm.js.map +1 -1
- package/dist/components/ChangeEvents/ChangeEventListItem.esm.js +37 -34
- package/dist/components/ChangeEvents/ChangeEventListItem.esm.js.map +1 -1
- package/dist/components/ChangeEvents/ChangeEvents.esm.js +5 -2
- package/dist/components/ChangeEvents/ChangeEvents.esm.js.map +1 -1
- package/dist/components/EntityPagerDutyCard/index.esm.js +13 -10
- package/dist/components/EntityPagerDutyCard/index.esm.js.map +1 -1
- package/dist/components/EntityPagerDutySmallCard/index.esm.js +13 -10
- package/dist/components/EntityPagerDutySmallCard/index.esm.js.map +1 -1
- package/dist/components/Escalation/EscalationPolicy.esm.js +9 -24
- package/dist/components/Escalation/EscalationPolicy.esm.js.map +1 -1
- package/dist/components/Escalation/EscalationUser.esm.js +16 -26
- package/dist/components/Escalation/EscalationUser.esm.js.map +1 -1
- package/dist/components/Icons/index.esm.js.map +1 -1
- package/dist/components/Incident/IncidentEmptyState.esm.js.map +1 -1
- package/dist/components/Incident/IncidentForbiddenState.esm.js +20 -11
- package/dist/components/Incident/IncidentForbiddenState.esm.js.map +1 -1
- package/dist/components/Incident/IncidentListItem.esm.js +17 -15
- package/dist/components/Incident/IncidentListItem.esm.js.map +1 -1
- package/dist/components/Incident/Incidents.esm.js +1 -1
- package/dist/components/Incident/Incidents.esm.js.map +1 -1
- package/dist/components/PagerDutyCard/index.esm.js +67 -90
- package/dist/components/PagerDutyCard/index.esm.js.map +1 -1
- package/dist/components/PagerDutyCardCommon/InsightsCard.esm.js +2 -1
- package/dist/components/PagerDutyCardCommon/InsightsCard.esm.js.map +1 -1
- package/dist/components/PagerDutyCardCommon/OpenServiceButton.esm.js +27 -32
- package/dist/components/PagerDutyCardCommon/OpenServiceButton.esm.js.map +1 -1
- package/dist/components/PagerDutyCardCommon/ServiceStandardsCard.esm.js +59 -38
- package/dist/components/PagerDutyCardCommon/ServiceStandardsCard.esm.js.map +1 -1
- package/dist/components/PagerDutyCardCommon/StatusCard.esm.js +9 -6
- package/dist/components/PagerDutyCardCommon/StatusCard.esm.js.map +1 -1
- package/dist/components/PagerDutyCardCommon/TriggerIncidentButton.esm.js +28 -30
- package/dist/components/PagerDutyCardCommon/TriggerIncidentButton.esm.js.map +1 -1
- package/dist/components/PagerDutyPage/MappingTable.esm.js +30 -19
- package/dist/components/PagerDutyPage/MappingTable.esm.js.map +1 -1
- package/dist/components/PagerDutyPage/ServiceMappingComponent.esm.js.map +1 -1
- package/dist/components/PagerDutyPage/index.esm.js +46 -77
- package/dist/components/PagerDutyPage/index.esm.js.map +1 -1
- package/dist/components/PagerDutySmallCard/index.esm.js +34 -56
- package/dist/components/PagerDutySmallCard/index.esm.js.map +1 -1
- package/dist/components/TriggerDialog/TriggerDialog.esm.js +14 -9
- package/dist/components/TriggerDialog/TriggerDialog.esm.js.map +1 -1
- package/dist/components/pagerDutyEntity.esm.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +34 -10
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# PagerDuty Backstage Plugin
|
|
2
|
+
|
|
3
|
+
> The PagerDuty plugin reduces the cognitive load on developers responsible for maintaining services in production.
|
|
4
|
+
Instead of having to go to PagerDuty's console, you can now access the necessary information directly within Backstage.
|
|
5
|
+
This includes finding active incidents or opening a new incident, reviewing recent changes made to the service,
|
|
6
|
+
and checking who is on-call.
|
|
7
|
+
|
|
8
|
+
## New Frontend System (NFS)
|
|
9
|
+
|
|
10
|
+
This frontend plugin is starting the adoption of the [New Frontend System](https://backstage.io/docs/frontend-system/). This allow us to be present in Portal and keep up to date with Backstage's recommended best practices.
|
|
11
|
+
|
|
12
|
+
### Migration
|
|
13
|
+
|
|
14
|
+
We're still migrating to the NFS, since it is still in alpha. You can find this version of the plugin on the export `@pagerduty/backstage-plugin/alpha`, which allows you to start using it even in Backstage under the new `createApp` helper from `@backstage/frontend-defaults`.
|
|
15
|
+
|
|
16
|
+
### Extensions
|
|
17
|
+
|
|
18
|
+
The NFS allows for extendable plugins, which means there are parts of it that users can replace to elevate their experience. We've historically exported two components the `EntityPagerDutyCard` and the `EntityPagerDutySmallCard` to expose some PagerDuty's service information on your Backstage entities. In the NFS, we default to `EntityPagerDutyCard` as an entity card extension, which means you can still make use of the `EntityPagerDutySmallCard` through overrides.
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import PagerDutyPlugin from '@pagerduty/backstage-plugin/alpha';
|
|
22
|
+
import { EntityPagerDutySmallCard } from '@pagerduty/backstage-plugin';
|
|
23
|
+
|
|
24
|
+
const OverriddenPagerDutyPlugin = PagerDutyPlugin.withOverrides({
|
|
25
|
+
extensions: [
|
|
26
|
+
PagerDutyPlugin.getExtension('entity-card:pagerduty/EntityPagerDutyCard').override({
|
|
27
|
+
factory: originalFactory =>
|
|
28
|
+
originalFactory({
|
|
29
|
+
params: {
|
|
30
|
+
loader: async () => Promise.resolve(<EntityPagerDutySmallCard />)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
```
|
package/config.d.ts
CHANGED
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
PagerDutyAccountConfig,
|
|
19
|
+
PagerDutyOAuthConfig,
|
|
20
|
+
} from '@pagerduty/backstage-plugin-common';
|
|
18
21
|
|
|
19
22
|
export interface Config {
|
|
20
23
|
/**
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { FrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
|
+
|
|
4
|
+
declare const rootRouteRef: _backstage_frontend_plugin_api.RouteRef<undefined>;
|
|
5
|
+
/** @alpha */
|
|
6
|
+
declare const _default: FrontendPlugin;
|
|
7
|
+
|
|
8
|
+
export { _default as default, rootRouteRef };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { createRouteRef, ApiBlueprint, fetchApiRef, configApiRef, discoveryApiRef, PageBlueprint, NavItemBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
4
|
+
import { compatWrapper } from '@backstage/core-compat-api';
|
|
5
|
+
import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
6
|
+
import { PagerDutyClient, pagerDutyApiRef } from './api/client.esm.js';
|
|
7
|
+
import '@backstage/plugin-catalog-react';
|
|
8
|
+
import './components/PagerDutyCard/index.esm.js';
|
|
9
|
+
import './components/PagerDutySmallCard/index.esm.js';
|
|
10
|
+
import { PagerDutyIcon } from './components/Icons/index.esm.js';
|
|
11
|
+
import './components/TriggerButton/index.esm.js';
|
|
12
|
+
|
|
13
|
+
const rootRouteRef = createRouteRef();
|
|
14
|
+
const PagerDutyAPI = ApiBlueprint.make({
|
|
15
|
+
params: {
|
|
16
|
+
factory: {
|
|
17
|
+
api: pagerDutyApiRef,
|
|
18
|
+
deps: {
|
|
19
|
+
discoveryApi: discoveryApiRef,
|
|
20
|
+
configApi: configApiRef,
|
|
21
|
+
fetchApi: fetchApiRef
|
|
22
|
+
},
|
|
23
|
+
factory: ({
|
|
24
|
+
configApi,
|
|
25
|
+
discoveryApi,
|
|
26
|
+
fetchApi
|
|
27
|
+
}) => PagerDutyClient.fromConfig(configApi, { discoveryApi, fetchApi })
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const PagerDutyPage = PageBlueprint.make({
|
|
32
|
+
params: {
|
|
33
|
+
defaultPath: "/pagerduty",
|
|
34
|
+
routeRef: rootRouteRef,
|
|
35
|
+
loader: () => import('./components/PagerDutyPage/index.esm.js').then((m) => compatWrapper(/* @__PURE__ */ jsx(m.PagerDutyPage, {})))
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const EntityPagerDutyCard = EntityCardBlueprint.make({
|
|
39
|
+
name: "EntityPagerDutyCard",
|
|
40
|
+
params: {
|
|
41
|
+
filter: "kind:component",
|
|
42
|
+
loader: async () => import('./components/EntityPagerDutyCard/index.esm.js').then((m) => compatWrapper(/* @__PURE__ */ jsx(m.EntityPagerDutyCard, {})))
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const PagerDutyNavBarItem = NavItemBlueprint.make({
|
|
46
|
+
name: "PagerDutyNavBarItem",
|
|
47
|
+
params: {
|
|
48
|
+
title: "PagerDuty",
|
|
49
|
+
icon: () => /* @__PURE__ */ jsx(PagerDutyIcon, {}),
|
|
50
|
+
routeRef: rootRouteRef
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
var alpha = createFrontendPlugin({
|
|
54
|
+
pluginId: "pagerduty",
|
|
55
|
+
extensions: [
|
|
56
|
+
EntityPagerDutyCard,
|
|
57
|
+
PagerDutyAPI,
|
|
58
|
+
PagerDutyPage,
|
|
59
|
+
PagerDutyNavBarItem
|
|
60
|
+
],
|
|
61
|
+
routes: {
|
|
62
|
+
root: rootRouteRef
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export { alpha as default, rootRouteRef };
|
|
67
|
+
//# sourceMappingURL=alpha.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 \"react\";\nimport { \n ApiBlueprint, \n createFrontendPlugin, \n createRouteRef, \n FrontendPlugin, \n PageBlueprint,\n NavItemBlueprint,\n discoveryApiRef,\n configApiRef,\n fetchApiRef,\n ConfigApi,\n DiscoveryApi,\n FetchApi\n} from \"@backstage/frontend-plugin-api\";\nimport { compatWrapper } from \"@backstage/core-compat-api\";\nimport { EntityCardBlueprint } from \"@backstage/plugin-catalog-react/alpha\"\nimport { pagerDutyApiRef, PagerDutyClient } from './api';\nimport { PagerDutyIcon } from './components';\n\nexport const rootRouteRef = createRouteRef();\n\n/** @alpha */\nconst PagerDutyAPI = ApiBlueprint.make({\n params: {\n factory: {\n api: pagerDutyApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n configApi: configApiRef,\n fetchApi: fetchApiRef\n },\n factory: ({ \n configApi, \n discoveryApi, \n fetchApi \n }: { configApi: ConfigApi; discoveryApi: DiscoveryApi; fetchApi: FetchApi }) =>\n PagerDutyClient.fromConfig(configApi, { discoveryApi, fetchApi }),\n }\n }\n});\n\n/** @alpha */\nconst PagerDutyPage = PageBlueprint.make({\n params: {\n defaultPath: '/pagerduty',\n routeRef: rootRouteRef,\n loader: () =>\n import('./components/PagerDutyPage')\n .then(m => compatWrapper(<m.PagerDutyPage />)),\n }\n});\n\n/** @alpha */\nconst EntityPagerDutyCard = EntityCardBlueprint.make({\n name: 'EntityPagerDutyCard',\n params: {\n filter: 'kind:component',\n loader: async () => import('./components/EntityPagerDutyCard') \n .then(m => compatWrapper(<m.EntityPagerDutyCard />)),\n }\n});\n\n/** @alpha */\nconst PagerDutyNavBarItem = NavItemBlueprint.make({\n name: 'PagerDutyNavBarItem',\n params: {\n title: 'PagerDuty',\n icon: () => <PagerDutyIcon />,\n routeRef: rootRouteRef,\n }\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n pluginId: 'pagerduty',\n extensions: [\n EntityPagerDutyCard,\n PagerDutyAPI,\n PagerDutyPage,\n PagerDutyNavBarItem\n ],\n routes: {\n root: rootRouteRef\n }\n}) as FrontendPlugin;\n"],"names":[],"mappings":";;;;;;;;;;;;AAoCO,MAAM,eAAe,cAAA;AAG5B,MAAM,YAAA,GAAe,aAAa,IAAA,CAAK;AAAA,EACrC,MAAA,EAAQ;AAAA,IACN,OAAA,EAAS;AAAA,MACP,GAAA,EAAK,eAAA;AAAA,MACL,IAAA,EAAM;AAAA,QACJ,YAAA,EAAc,eAAA;AAAA,QACd,SAAA,EAAW,YAAA;AAAA,QACX,QAAA,EAAU;AAAA,OACZ;AAAA,MACA,SAAS,CAAC;AAAA,QACR,SAAA;AAAA,QACA,YAAA;AAAA,QACA;AAAA,YAEA,eAAA,CAAgB,UAAA,CAAW,WAAW,EAAE,YAAA,EAAc,UAAU;AAAA;AACpE;AAEJ,CAAC,CAAA;AAGD,MAAM,aAAA,GAAgB,cAAc,IAAA,CAAK;AAAA,EACvC,MAAA,EAAQ;AAAA,IACN,WAAA,EAAa,YAAA;AAAA,IACb,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,yCAA4B,CAAA,CAChC,IAAA,CAAK,CAAA,CAAA,KAAK,aAAA,iBAAc,GAAA,CAAC,CAAA,CAAE,aAAA,EAAF,EAAgB,CAAE,CAAC;AAAA;AAErD,CAAC,CAAA;AAGD,MAAM,mBAAA,GAAsB,oBAAoB,IAAA,CAAK;AAAA,EACnD,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,MAAA,EAAQ,gBAAA;AAAA,IACR,MAAA,EAAQ,YAAY,OAAO,+CAAkC,CAAA,CAC1D,IAAA,CAAK,CAAA,CAAA,KAAK,aAAA,iBAAc,GAAA,CAAC,CAAA,CAAE,mBAAA,EAAF,EAAsB,CAAE,CAAC;AAAA;AAEzD,CAAC,CAAA;AAGD,MAAM,mBAAA,GAAsB,iBAAiB,IAAA,CAAK;AAAA,EAChD,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,WAAA;AAAA,IACP,IAAA,EAAM,sBAAM,GAAA,CAAC,aAAA,EAAA,EAAc,CAAA;AAAA,IAC3B,QAAA,EAAU;AAAA;AAEd,CAAC,CAAA;AAGD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,WAAA;AAAA,EACV,UAAA,EAAY;AAAA,IACV,mBAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA;AAEV,CAAC,CAAA;;;;"}
|
package/dist/api/client.esm.js
CHANGED
|
@@ -33,7 +33,9 @@ class PagerDutyClient {
|
|
|
33
33
|
if (account) {
|
|
34
34
|
url = `${url}&account=${account}`;
|
|
35
35
|
}
|
|
36
|
-
const serviceResponse = await this.findByUrl(
|
|
36
|
+
const serviceResponse = await this.findByUrl(
|
|
37
|
+
url
|
|
38
|
+
);
|
|
37
39
|
if (serviceResponse.service === void 0) throw new NotFoundError();
|
|
38
40
|
response = serviceResponse;
|
|
39
41
|
} else if (serviceId) {
|
|
@@ -197,10 +199,14 @@ class PagerDutyClient {
|
|
|
197
199
|
async request(url, options) {
|
|
198
200
|
const response = await this.config.fetchApi.fetch(url, options);
|
|
199
201
|
if (response.status === 401) {
|
|
200
|
-
throw new UnauthorizedError(
|
|
202
|
+
throw new UnauthorizedError(
|
|
203
|
+
"Unauthorized: You don't have access to this resource"
|
|
204
|
+
);
|
|
201
205
|
}
|
|
202
206
|
if (response.status === 403) {
|
|
203
|
-
throw new ForbiddenError(
|
|
207
|
+
throw new ForbiddenError(
|
|
208
|
+
"Forbidden: You are not allowed to perform this action"
|
|
209
|
+
);
|
|
204
210
|
}
|
|
205
211
|
if (response.status === 404) {
|
|
206
212
|
throw new NotFoundError("Not Found: Resource not found");
|
|
@@ -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 PagerDutyEntityMappingsResponse,\n PagerDutySetting\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, account } = 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\n if(account) {\n url = `${url}&account=${account}`;\n }\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 if (account) {\n url = `${url}?account=${account}`;\n }\n\n response = await this.findByUrl<PagerDutyServiceResponse>(url);\n } else {\n throw new NotFoundError();\n }\n\n return response;\n }\n\n async getSetting(id: string): Promise<PagerDutySetting> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/settings/${id}`;\n\n return await this.findByUrl<PagerDutySetting>(url);\n }\n\n async storeSettings(settings: PagerDutySetting[]): Promise<Response> {\n const body = JSON.stringify(settings);\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 )}/settings`;\n\n return this.request(url, options);\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, account: string): Promise<Response> {\n\n const body = JSON.stringify({\n entityRef: backstageEntityRef,\n serviceId: serviceId,\n integrationKey: integrationKey,\n account: account,\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, account?: string): Promise<PagerDutyServiceResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n if(account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceResponse>(url);\n }\n\n async getIncidentsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyIncidentsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/incidents`;\n\n if(account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyIncidentsResponse>(url);\n }\n\n async getChangeEventsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyChangeEventsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/change-events`;\n\n if(account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyChangeEventsResponse>(url);\n }\n\n async getServiceStandardsByServiceId(\n serviceId: string,\n account?: string\n ): Promise<PagerDutyServiceStandardsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/standards`;\n\n if(account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceStandardsResponse>(url);\n }\n\n async getServiceMetricsByServiceId(\n serviceId: string,\n account?: string\n ): Promise<PagerDutyServiceMetricsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/metrics`;\n\n if (account){\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceMetricsResponse>(url);\n }\n\n async getOnCallByPolicyId(\n policyId: string,\n account?: string,\n ): Promise<PagerDutyUser[]> {\n const params = `escalation_policy_ids[]=${policyId}`;\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/oncall-users?${params}`;\n\n if (account) {\n url = url.concat(`&account=${account}`);\n }\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":";;;;AAwCO,MAAM,0BAA0B,KAAA,CAAM;AAAC;AAGvC,MAAM,uBAAuB,KAAA,CAAM;AAAE;AAGrC,MAAM,kBAAkB,YAAA,CAA2B;AAAA,EACxD,EAAA,EAAI;AACN,CAAC;AAGM,MAAM,eAAA,CAAwC;AAAA,EAkBnD,YAA6B,MAAA,EAAkC;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAAmC;AAAA,EAjBhE,OAAO,UAAA,CACL,SAAA,EACA,YAAA,EACA;AACA,IAAA,MAAM,EAAE,YAAA,EAAc,QAAA,EAAS,GAAI,YAAA;AAEnC,IAAA,MAAM,aAAA,GACJ,SAAA,CAAU,iBAAA,CAAkB,yBAAyB,CAAA,IACrD,iCAAA;AAEF,IAAA,OAAO,IAAI,eAAA,CAAgB;AAAA,MACzB,aAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AAAA,EAIA,MAAM,4BACJ,eAAA,EACmC;AACnC,IAAA,MAAM,EAAE,cAAA,EAAgB,SAAA,EAAW,OAAA,EAAQ,GAAI,eAAA;AAE/C,IAAA,IAAI,QAAA;AACJ,IAAA,IAAI,GAAA;AAEJ,IAAA,IAAI,cAAA,EAAgB;AAClB,MAAA,GAAA,GAAM,CAAA,EAAG,MAAM,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AS,IAAA,EAAK;AAAA,EACvB;AAAA,EAEA,MAAc,OAAA,CACZ,GAAA,EACA,OAAA,EACmB;AACnB,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,OAAO,QAAA,CAAS,KAAA,CAAM,KAAK,OAAO,CAAA;AAC9D,IAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,MAAA,MAAM,IAAI,kBAAkB,sDAAsD,CAAA;AAAA,IACpF;AAEA,IAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,MAAA,MAAM,IAAI,eAAe,uDAAuD,CAAA;AAAA,IAClF;AAEA,IAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,MAAA,MAAM,IAAI,cAAc,+BAA+B,CAAA;AAAA,IACzD;AAEA,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,IAAA,EAAK;AACpC,MAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,KAAkB,KAAK,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpE,MAAA,MAAM,OAAA,GAAU,CAAA,oBAAA,EAAuB,QAAA,CAAS,MAAM,KAAK,MAAM,CAAA,CAAA;AACjE,MAAA,MAAM,IAAI,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,QAAA;AAAA,EACT;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 {\n PagerDutyChangeEventsResponse,\n PagerDutyOnCallUsersResponse,\n PagerDutyUser,\n PagerDutyServiceResponse,\n PagerDutyIncidentsResponse,\n PagerDutyServiceStandardsResponse,\n PagerDutyServiceMetricsResponse,\n PagerDutyEntityMappingsResponse,\n PagerDutySetting,\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, account } = 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\n if (account) {\n url = `${url}&account=${account}`;\n }\n const serviceResponse = await this.findByUrl<PagerDutyServiceResponse>(\n url,\n );\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 if (account) {\n url = `${url}?account=${account}`;\n }\n\n response = await this.findByUrl<PagerDutyServiceResponse>(url);\n } else {\n throw new NotFoundError();\n }\n\n return response;\n }\n\n async getSetting(id: string): Promise<PagerDutySetting> {\n const url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/settings/${id}`;\n\n return await this.findByUrl<PagerDutySetting>(url);\n }\n\n async storeSettings(settings: PagerDutySetting[]): Promise<Response> {\n const body = JSON.stringify(settings);\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 )}/settings`;\n\n return this.request(url, options);\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(\n serviceId: string,\n integrationKey: string,\n backstageEntityRef: string,\n account: string,\n ): Promise<Response> {\n const body = JSON.stringify({\n entityRef: backstageEntityRef,\n serviceId: serviceId,\n integrationKey: integrationKey,\n account: account,\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(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyServiceResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}`;\n\n if (account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceResponse>(url);\n }\n\n async getIncidentsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyIncidentsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/incidents`;\n\n if (account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyIncidentsResponse>(url);\n }\n\n async getChangeEventsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyChangeEventsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/change-events`;\n\n if (account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyChangeEventsResponse>(url);\n }\n\n async getServiceStandardsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyServiceStandardsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/standards`;\n\n if (account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceStandardsResponse>(url);\n }\n\n async getServiceMetricsByServiceId(\n serviceId: string,\n account?: string,\n ): Promise<PagerDutyServiceMetricsResponse> {\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/services/${serviceId}/metrics`;\n\n if (account) {\n url = url.concat(`?account=${account}`);\n }\n\n return await this.findByUrl<PagerDutyServiceMetricsResponse>(url);\n }\n\n async getOnCallByPolicyId(\n policyId: string,\n account?: string,\n ): Promise<PagerDutyUser[]> {\n const params = `escalation_policy_ids[]=${policyId}`;\n let url = `${await this.config.discoveryApi.getBaseUrl(\n 'pagerduty',\n )}/oncall-users?${params}`;\n\n if (account) {\n url = url.concat(`&account=${account}`);\n }\n\n const response: PagerDutyOnCallUsersResponse =\n 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(\n \"Unauthorized: You don't have access to this resource\",\n );\n }\n\n if (response.status === 403) {\n throw new ForbiddenError(\n 'Forbidden: You are not allowed to perform this action',\n );\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":";;;;AAyCO,MAAM,0BAA0B,KAAA,CAAM;AAAC;AAGvC,MAAM,uBAAuB,KAAA,CAAM;AAAC;AAGpC,MAAM,kBAAkB,YAAA,CAA2B;AAAA,EACxD,EAAA,EAAI;AACN,CAAC;AAGM,MAAM,eAAA,CAAwC;AAAA,EAkBnD,YAA6B,MAAA,EAAkC;AAAlC,IAAA,IAAA,CAAA,MAAA,GAAA,M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KAAK,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpE,MAAA,MAAM,OAAA,GAAU,CAAA,oBAAA,EAAuB,QAAA,CAAS,MAAM,KAAK,MAAM,CAAA,CAAA;AACjE,MAAA,MAAM,IAAI,MAAM,OAAO,CAAA;AAAA,IACzB;AACA,IAAA,OAAO,QAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -3,17 +3,26 @@ import { Grid, Typography } from '@material-ui/core';
|
|
|
3
3
|
import EmptyStateImage from '../../assets/emptystate.svg';
|
|
4
4
|
|
|
5
5
|
const ChangeEventEmptyState = () => {
|
|
6
|
-
return /* @__PURE__ */ jsxs(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
return /* @__PURE__ */ jsxs(
|
|
7
|
+
Grid,
|
|
8
|
+
{
|
|
9
|
+
container: true,
|
|
10
|
+
justifyContent: "center",
|
|
11
|
+
direction: "column",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Typography, { variant: "h5", children: "No change events to display yet." }) }),
|
|
15
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
|
|
16
|
+
"img",
|
|
17
|
+
{
|
|
18
|
+
src: EmptyStateImage,
|
|
19
|
+
alt: "EmptyState",
|
|
20
|
+
"data-testid": "emptyStateImg"
|
|
21
|
+
}
|
|
22
|
+
) })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
);
|
|
17
26
|
};
|
|
18
27
|
|
|
19
28
|
export { ChangeEventEmptyState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeEventEmptyState.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventEmptyState.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\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { Grid, Typography } from '@material-ui/core';\nimport EmptyStateImage from '../../assets/emptystate.svg';\n\nexport const ChangeEventEmptyState = () => {\n return (\n <Grid
|
|
1
|
+
{"version":3,"file":"ChangeEventEmptyState.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventEmptyState.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\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { Grid, Typography } from '@material-ui/core';\nimport EmptyStateImage from '../../assets/emptystate.svg';\n\nexport const ChangeEventEmptyState = () => {\n return (\n <Grid\n container\n justifyContent=\"center\"\n direction=\"column\"\n alignItems=\"center\"\n >\n <Grid item xs={12}>\n <Typography variant=\"h5\">No change events to display yet.</Typography>\n </Grid>\n <Grid item xs={12}>\n <img\n src={EmptyStateImage}\n alt=\"EmptyState\"\n data-testid=\"emptyStateImg\"\n />\n </Grid>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,wBAAwB,MAAM;AACzC,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAS,IAAA;AAAA,MACT,cAAA,EAAe,QAAA;AAAA,MACf,SAAA,EAAU,QAAA;AAAA,MACV,UAAA,EAAW,QAAA;AAAA,MAEX,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,EAAA,EACb,8BAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,IAAA,EAAK,QAAA,EAAA,kCAAA,EAAgC,CAAA,EAC3D,CAAA;AAAA,wBACA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAK,eAAA;AAAA,YACL,GAAA,EAAI,YAAA;AAAA,YACJ,aAAA,EAAY;AAAA;AAAA,SACd,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -3,17 +3,26 @@ import { Grid, Typography } from '@material-ui/core';
|
|
|
3
3
|
import ForbiddenStateImage from '../../assets/forbiddenstate.svg';
|
|
4
4
|
|
|
5
5
|
const ChangeEventForbiddenState = () => {
|
|
6
|
-
return /* @__PURE__ */ jsxs(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
return /* @__PURE__ */ jsxs(
|
|
7
|
+
Grid,
|
|
8
|
+
{
|
|
9
|
+
container: true,
|
|
10
|
+
justifyContent: "center",
|
|
11
|
+
direction: "column",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Typography, { variant: "h5", children: "Feature not available with your account or token." }) }),
|
|
15
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
|
|
16
|
+
"img",
|
|
17
|
+
{
|
|
18
|
+
src: ForbiddenStateImage,
|
|
19
|
+
alt: "ForbiddenState",
|
|
20
|
+
"data-testid": "forbiddenStateImg"
|
|
21
|
+
}
|
|
22
|
+
) })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
);
|
|
17
26
|
};
|
|
18
27
|
|
|
19
28
|
export { ChangeEventForbiddenState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeEventForbiddenState.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventForbiddenState.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\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { Grid, Typography } from '@material-ui/core';\nimport ForbiddenStateImage from '../../assets/forbiddenstate.svg';\n\nexport const ChangeEventForbiddenState = () => {\n return (\n <Grid
|
|
1
|
+
{"version":3,"file":"ChangeEventForbiddenState.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventForbiddenState.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\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { Grid, Typography } from '@material-ui/core';\nimport ForbiddenStateImage from '../../assets/forbiddenstate.svg';\n\nexport const ChangeEventForbiddenState = () => {\n return (\n <Grid\n container\n justifyContent=\"center\"\n direction=\"column\"\n alignItems=\"center\"\n >\n <Grid item xs={12}>\n <Typography variant=\"h5\">\n Feature not available with your account or token.\n </Typography>\n </Grid>\n <Grid item xs={12}>\n <img\n src={ForbiddenStateImage}\n alt=\"ForbiddenState\"\n data-testid=\"forbiddenStateImg\"\n />\n </Grid>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,4BAA4B,MAAM;AAC7C,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAS,IAAA;AAAA,MACT,cAAA,EAAe,QAAA;AAAA,MACf,SAAA,EAAU,QAAA;AAAA,MACV,UAAA,EAAW,QAAA;AAAA,MAEX,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,EAAA,EAAI,EAAA,EACb,8BAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,IAAA,EAAK,QAAA,EAAA,mDAAA,EAEzB,CAAA,EACF,CAAA;AAAA,wBACA,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAI,IAAA,EAAC,IAAI,EAAA,EACb,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAK,mBAAA;AAAA,YACL,GAAA,EAAI,gBAAA;AAAA,YACJ,aAAA,EAAY;AAAA;AAAA,SACd,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { makeStyles, ListItem, ListItemText, Typography, ListItemSecondaryAction } from '@material-ui/core';
|
|
3
|
+
import { TooltipTrigger, ButtonIcon, Tooltip } from '@backstage/ui';
|
|
4
4
|
import { DateTime, Duration } from 'luxon';
|
|
5
5
|
import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
|
|
6
6
|
import LinkIcon from '@material-ui/icons/Link';
|
|
7
7
|
|
|
8
|
-
const useStyles = makeStyles((
|
|
8
|
+
const useStyles = makeStyles(() => ({
|
|
9
9
|
denseListIcon: {
|
|
10
10
|
marginRight: 0,
|
|
11
11
|
display: "flex",
|
|
@@ -15,35 +15,35 @@ const useStyles = makeStyles((theme) => ({
|
|
|
15
15
|
},
|
|
16
16
|
listItemPrimary: {
|
|
17
17
|
fontWeight: "bold"
|
|
18
|
-
},
|
|
19
|
-
smallExternalLinkIconStyle: {
|
|
20
|
-
color: theme.palette.text.primary
|
|
21
|
-
},
|
|
22
|
-
smallExternalLinkWithoutMarginIconStyle: {
|
|
23
|
-
color: theme.palette.text.primary,
|
|
24
|
-
marginRight: "-20px"
|
|
25
|
-
},
|
|
26
|
-
smallIconStyle: {
|
|
27
|
-
color: theme.palette.text.primary,
|
|
28
|
-
marginRight: "-20px"
|
|
29
18
|
}
|
|
30
19
|
}));
|
|
31
20
|
const ChangeEventListItem = ({ changeEvent }) => {
|
|
32
21
|
const classes = useStyles();
|
|
33
22
|
const duration = (/* @__PURE__ */ new Date()).getTime() - new Date(changeEvent.timestamp).getTime();
|
|
34
23
|
const changedAt = DateTime.local().minus(Duration.fromMillis(duration)).toRelative({ locale: "en" });
|
|
24
|
+
const handleExternalLinkClick = (url) => {
|
|
25
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
26
|
+
};
|
|
27
|
+
const handlePagerDutyClick = () => {
|
|
28
|
+
if (changeEvent.html_url) {
|
|
29
|
+
window.open(changeEvent.html_url, "_blank", "noopener,noreferrer");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
35
32
|
let externalLinkElem;
|
|
36
|
-
if (changeEvent.links.length > 0) {
|
|
33
|
+
if (changeEvent.links.length > 0 && changeEvent.links[0]?.href) {
|
|
37
34
|
const text = changeEvent.links[0].text;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
const linkHref = changeEvent.links[0].href;
|
|
36
|
+
externalLinkElem = /* @__PURE__ */ jsxs(TooltipTrigger, { children: [
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
ButtonIcon,
|
|
39
|
+
{
|
|
40
|
+
icon: /* @__PURE__ */ jsx(LinkIcon, {}),
|
|
41
|
+
variant: "tertiary",
|
|
42
|
+
onClick: () => handleExternalLinkClick(linkHref)
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(Tooltip, { children: text })
|
|
46
|
+
] });
|
|
47
47
|
}
|
|
48
48
|
return /* @__PURE__ */ jsxs(ListItem, { dense: true, children: [
|
|
49
49
|
/* @__PURE__ */ jsx(
|
|
@@ -65,15 +65,18 @@ const ChangeEventListItem = ({ changeEvent }) => {
|
|
|
65
65
|
),
|
|
66
66
|
/* @__PURE__ */ jsxs(ListItemSecondaryAction, { children: [
|
|
67
67
|
externalLinkElem,
|
|
68
|
-
changeEvent.html_url === void 0 ? null : /* @__PURE__ */
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
changeEvent.html_url === void 0 ? null : /* @__PURE__ */ jsxs(TooltipTrigger, { children: [
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
ButtonIcon,
|
|
71
|
+
{
|
|
72
|
+
"aria-label": "view-in-pd-button",
|
|
73
|
+
icon: /* @__PURE__ */ jsx(OpenInBrowserIcon, { className: classes.smallIconStyle }),
|
|
74
|
+
variant: "tertiary",
|
|
75
|
+
onClick: handlePagerDutyClick
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx(Tooltip, { children: "View in PagerDuty" })
|
|
79
|
+
] })
|
|
77
80
|
] })
|
|
78
81
|
] }, changeEvent.id);
|
|
79
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeEventListItem.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventListItem.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\
|
|
1
|
+
{"version":3,"file":"ChangeEventListItem.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEventListItem.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\nimport {\n ListItem,\n ListItemSecondaryAction,\n ListItemText,\n makeStyles,\n Typography,\n} from '@material-ui/core';\nimport { ButtonIcon, Tooltip, TooltipTrigger } from '@backstage/ui';\nimport { DateTime, Duration } from 'luxon';\nimport { PagerDutyChangeEvent } from '@pagerduty/backstage-plugin-common';\nimport OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';\nimport LinkIcon from '@material-ui/icons/Link';\nimport { BackstageTheme } from '@backstage/theme';\n\nconst useStyles = makeStyles<BackstageTheme>(() => ({\n denseListIcon: {\n marginRight: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n listItemPrimary: {\n fontWeight: 'bold',\n },\n}));\n\ntype Props = {\n changeEvent: PagerDutyChangeEvent;\n};\n\nexport const ChangeEventListItem = ({ changeEvent }: Props) => {\n const classes = useStyles();\n const duration =\n new Date().getTime() - new Date(changeEvent.timestamp).getTime();\n const changedAt = DateTime.local()\n .minus(Duration.fromMillis(duration))\n .toRelative({ locale: 'en' });\n\n const handleExternalLinkClick = (url: string) => {\n window.open(url, '_blank', 'noopener,noreferrer');\n };\n\n const handlePagerDutyClick = () => {\n if (changeEvent.html_url) {\n window.open(changeEvent.html_url, '_blank', 'noopener,noreferrer');\n }\n };\n\n let externalLinkElem: JSX.Element | undefined;\n if (changeEvent.links.length > 0 && changeEvent.links[0]?.href) {\n const text: string = changeEvent.links[0].text;\n const linkHref = changeEvent.links[0].href;\n externalLinkElem = (\n <TooltipTrigger>\n <ButtonIcon\n icon={<LinkIcon />}\n variant=\"tertiary\"\n onClick={() => handleExternalLinkClick(linkHref)}\n />\n <Tooltip>{text}</Tooltip>\n </TooltipTrigger>\n );\n }\n\n return (\n <ListItem dense key={changeEvent.id}>\n <ListItemText\n primary={<>{changeEvent.summary}</>}\n primaryTypographyProps={{\n variant: 'body1',\n className: classes.listItemPrimary,\n }}\n secondary={\n <Typography variant=\"body2\" color=\"textSecondary\">\n Triggered from {changeEvent.source} {changedAt}.\n </Typography>\n }\n />\n <ListItemSecondaryAction>\n {externalLinkElem}\n {changeEvent.html_url === undefined ? null : (\n <TooltipTrigger>\n <ButtonIcon\n aria-label=\"view-in-pd-button\"\n icon={<OpenInBrowserIcon className={classes.smallIconStyle} />}\n variant=\"tertiary\"\n onClick={handlePagerDutyClick}\n />\n <Tooltip>View in PagerDuty</Tooltip>\n </TooltipTrigger>\n )}\n </ListItemSecondaryAction>\n </ListItem>\n );\n};\n"],"names":[],"mappings":";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X,IAAA,kBAAM,GAAA,CAAC,iBAAA,EAAA,EAAkB,SAAA,EAAW,QAAQ,cAAA,EAAgB,CAAA;AAAA,YAC5D,OAAA,EAAQ,UAAA;AAAA,YACR,OAAA,EAAS;AAAA;AAAA,SACX;AAAA,wBACA,GAAA,CAAC,WAAQ,QAAA,EAAA,mBAAA,EAAiB;AAAA,OAAA,EAC5B;AAAA,KAAA,EAEJ;AAAA,GAAA,EAAA,EA1BmB,YAAY,EA2BjC,CAAA;AAEJ;;;;"}
|
|
@@ -14,7 +14,10 @@ const ChangeEvents = ({ serviceId, account, refreshEvents }) => {
|
|
|
14
14
|
const api = useApi(pagerDutyApiRef);
|
|
15
15
|
const [{ value: changeEvents, loading, error }, getChangeEvents] = useAsyncFn(
|
|
16
16
|
async () => {
|
|
17
|
-
const { change_events } = await api.getChangeEventsByServiceId(
|
|
17
|
+
const { change_events } = await api.getChangeEventsByServiceId(
|
|
18
|
+
serviceId,
|
|
19
|
+
account
|
|
20
|
+
);
|
|
18
21
|
return change_events;
|
|
19
22
|
}
|
|
20
23
|
);
|
|
@@ -31,7 +34,7 @@ const ChangeEvents = ({ serviceId, account, refreshEvents }) => {
|
|
|
31
34
|
] });
|
|
32
35
|
}
|
|
33
36
|
if (loading) {
|
|
34
|
-
return /* @__PURE__ */ jsx(Progress, {});
|
|
37
|
+
return /* @__PURE__ */ jsx("div", { style: { height: "253px" }, children: /* @__PURE__ */ jsx(Progress, {}) });
|
|
35
38
|
}
|
|
36
39
|
if (!changeEvents?.length) {
|
|
37
40
|
return /* @__PURE__ */ jsx(ChangeEventEmptyState, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeEvents.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEvents.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\
|
|
1
|
+
{"version":3,"file":"ChangeEvents.esm.js","sources":["../../../src/components/ChangeEvents/ChangeEvents.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\nimport { useEffect } from 'react';\nimport { List } from '@material-ui/core';\nimport { ChangeEventListItem } from './ChangeEventListItem';\nimport { ChangeEventEmptyState } from './ChangeEventEmptyState';\nimport { ChangeEventForbiddenState } from './ChangeEventForbiddenState';\nimport useAsyncFn from 'react-use/lib/useAsyncFn';\nimport { pagerDutyApiRef } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Progress } from '@backstage/core-components';\nimport { Alert } from '@material-ui/lab';\n\ntype Props = {\n serviceId: string;\n account?: string;\n refreshEvents: boolean;\n};\n\nexport const ChangeEvents = ({ serviceId, account, refreshEvents }: Props) => {\n const api = useApi(pagerDutyApiRef);\n\n const [{ value: changeEvents, loading, error }, getChangeEvents] = useAsyncFn(\n async () => {\n const { change_events } = await api.getChangeEventsByServiceId(\n serviceId,\n account,\n );\n return change_events;\n },\n );\n\n useEffect(() => {\n getChangeEvents();\n }, [refreshEvents, getChangeEvents]);\n\n if (error) {\n if (error.message.includes('Forbidden')) {\n return <ChangeEventForbiddenState />;\n }\n\n return (\n <Alert severity=\"error\">\n Error encountered while fetching information. {error.message}\n </Alert>\n );\n }\n\n if (loading) {\n return (\n <div style={{ height: '253px' }}>\n <Progress />\n </div>\n );\n }\n\n if (!changeEvents?.length) {\n return <ChangeEventEmptyState />;\n }\n\n return (\n <List dense>\n {changeEvents!.map((changeEvent, index) => (\n <ChangeEventListItem\n key={changeEvent.id + index}\n changeEvent={changeEvent}\n />\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAiCO,MAAM,eAAe,CAAC,EAAE,SAAA,EAAW,OAAA,EAAS,eAAc,KAAa;AAC5E,EAAA,MAAM,GAAA,GAAM,OAAO,eAAe,CAAA;AAElC,EAAA,MAAM,CAAC,EAAE,KAAA,EAAO,YAAA,EAAc,SAAS,KAAA,EAAM,EAAG,eAAe,CAAA,GAAI,UAAA;AAAA,IACjE,YAAY;AACV,MAAA,MAAM,EAAE,aAAA,EAAc,GAAI,MAAM,GAAA,CAAI,0BAAA;AAAA,QAClC,SAAA;AAAA,QACA;AAAA,OACF;AACA,MAAA,OAAO,aAAA;AAAA,IACT;AAAA,GACF;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,eAAA,EAAgB;AAAA,EAClB,CAAA,EAAG,CAAC,aAAA,EAAe,eAAe,CAAC,CAAA;AAEnC,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,CAAS,WAAW,CAAA,EAAG;AACvC,MAAA,2BAAQ,yBAAA,EAAA,EAA0B,CAAA;AAAA,IACpC;AAEA,IAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAM,QAAA,EAAS,OAAA,EAAQ,QAAA,EAAA;AAAA,MAAA,gDAAA;AAAA,MACyB,KAAA,CAAM;AAAA,KAAA,EACvD,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,uBACE,GAAA,CAAC,SAAI,KAAA,EAAO,EAAE,QAAQ,OAAA,EAAQ,EAC5B,QAAA,kBAAA,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA,EACZ,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,CAAC,cAAc,MAAA,EAAQ;AACzB,IAAA,2BAAQ,qBAAA,EAAA,EAAsB,CAAA;AAAA,EAChC;AAEA,EAAA,uBACE,GAAA,CAAC,QAAK,KAAA,EAAK,IAAA,EACR,uBAAc,GAAA,CAAI,CAAC,aAAa,KAAA,qBAC/B,GAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MAEC;AAAA,KAAA;AAAA,IADK,YAAY,EAAA,GAAK;AAAA,GAGzB,CAAA,EACH,CAAA;AAEJ;;;;"}
|
|
@@ -10,16 +10,19 @@ const isPluginApplicableToEntity = (entity) => Boolean(
|
|
|
10
10
|
const EntityPagerDutyCard = (props) => {
|
|
11
11
|
const { readOnly, disableChangeEvents, disableOnCall } = props;
|
|
12
12
|
const { entity } = useEntity();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
if (isPluginApplicableToEntity(entity)) {
|
|
14
|
+
const pagerDutyEntity = getPagerDutyEntity(entity);
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { "data-theme": localStorage.getItem("theme") ?? "light", children: /* @__PURE__ */ jsx(
|
|
16
|
+
PagerDutyCard,
|
|
17
|
+
{
|
|
18
|
+
...pagerDutyEntity,
|
|
19
|
+
readOnly,
|
|
20
|
+
disableChangeEvents,
|
|
21
|
+
disableOnCall
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export { EntityPagerDutyCard, isPluginApplicableToEntity };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/EntityPagerDutyCard/index.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 { Entity } from '@backstage/catalog-model';\nimport { PAGERDUTY_INTEGRATION_KEY, PAGERDUTY_SERVICE_ID } from '../constants';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { getPagerDutyEntity } from '../pagerDutyEntity';\nimport { PagerDutyCard } from '../PagerDutyCard';\n\n/** @public */\nexport const isPluginApplicableToEntity = (entity: Entity) =>\n Boolean(\n entity.metadata.annotations?.[PAGERDUTY_INTEGRATION_KEY] ||\n entity.metadata.annotations?.[PAGERDUTY_SERVICE_ID],\n );\n\n/** @public */\nexport type EntityPagerDutyCardProps = {\n readOnly?: boolean;\n disableChangeEvents?: boolean;\n disableOnCall?: boolean;\n};\n\n/** @public */\nexport const EntityPagerDutyCard = (props: EntityPagerDutyCardProps) => {\n const { readOnly, disableChangeEvents, disableOnCall } = props;\n const { entity } = useEntity();\n const pagerDutyEntity = getPagerDutyEntity(entity);\n
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/EntityPagerDutyCard/index.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 { Entity } from '@backstage/catalog-model';\nimport { PAGERDUTY_INTEGRATION_KEY, PAGERDUTY_SERVICE_ID } from '../constants';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { getPagerDutyEntity } from '../pagerDutyEntity';\nimport { PagerDutyCard } from '../PagerDutyCard';\n\n/** @public */\nexport const isPluginApplicableToEntity = (entity: Entity) =>\n Boolean(\n entity.metadata.annotations?.[PAGERDUTY_INTEGRATION_KEY] ||\n entity.metadata.annotations?.[PAGERDUTY_SERVICE_ID],\n );\n\n/** @public */\nexport type EntityPagerDutyCardProps = {\n readOnly?: boolean;\n disableChangeEvents?: boolean;\n disableOnCall?: boolean;\n};\n\n/** @public */\nexport const EntityPagerDutyCard = (props: EntityPagerDutyCardProps) => {\n const { readOnly, disableChangeEvents, disableOnCall } = props;\n const { entity } = useEntity();\n\n if (isPluginApplicableToEntity(entity)) {\n const pagerDutyEntity = getPagerDutyEntity(entity);\n\n return (\n <div data-theme={localStorage.getItem('theme') ?? 'light'}>\n <PagerDutyCard\n {...pagerDutyEntity}\n readOnly={readOnly}\n disableChangeEvents={disableChangeEvents}\n disableOnCall={disableOnCall}\n />\n </div>\n );\n }\n\n return null;\n};\n"],"names":[],"mappings":";;;;;;AAuBO,MAAM,0BAAA,GAA6B,CAAC,MAAA,KACzC,OAAA;AAAA,EACE,MAAA,CAAO,SAAS,WAAA,GAAc,yBAAyB,KACrD,MAAA,CAAO,QAAA,CAAS,cAAc,oBAAoB;AACtD;AAUK,MAAM,mBAAA,GAAsB,CAAC,KAAA,KAAoC;AACtE,EAAA,MAAM,EAAE,QAAA,EAAU,mBAAA,EAAqB,aAAA,EAAc,GAAI,KAAA;AACzD,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAE7B,EAAA,IAAI,0BAAA,CAA2B,MAAM,CAAA,EAAG;AACtC,IAAA,MAAM,eAAA,GAAkB,mBAAmB,MAAM,CAAA;AAEjD,IAAA,2BACG,KAAA,EAAA,EAAI,YAAA,EAAY,aAAa,OAAA,CAAQ,OAAO,KAAK,OAAA,EAChD,QAAA,kBAAA,GAAA;AAAA,MAAC,aAAA;AAAA,MAAA;AAAA,QACE,GAAG,eAAA;AAAA,QACJ,QAAA;AAAA,QACA,mBAAA;AAAA,QACA;AAAA;AAAA,KACF,EACF,CAAA;AAAA,EAEJ;AAEA,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
@@ -10,16 +10,19 @@ const isPluginApplicableToEntity = (entity) => Boolean(
|
|
|
10
10
|
const EntityPagerDutySmallCard = (props) => {
|
|
11
11
|
const { readOnly, disableInsights, disableOnCall } = props;
|
|
12
12
|
const { entity } = useEntity();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
if (isPluginApplicableToEntity(entity)) {
|
|
14
|
+
const pagerDutyEntity = getPagerDutyEntity(entity);
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { "data-theme": localStorage.getItem("theme") ?? "light", children: /* @__PURE__ */ jsx(
|
|
16
|
+
PagerDutySmallCard,
|
|
17
|
+
{
|
|
18
|
+
...pagerDutyEntity,
|
|
19
|
+
readOnly,
|
|
20
|
+
disableInsights,
|
|
21
|
+
disableOnCall
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export { EntityPagerDutySmallCard, isPluginApplicableToEntity };
|