@incident-io/backstage 0.0.15 → 0.2.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 +35 -1
- package/config.d.ts +11 -5
- package/dist/alpha.d.ts +5 -0
- package/dist/alpha.esm.js +91 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/api/client.esm.js +34 -0
- package/dist/api/client.esm.js.map +1 -0
- package/dist/components/AlertListItem/index.esm.js +68 -0
- package/dist/components/AlertListItem/index.esm.js.map +1 -0
- package/dist/components/EntityAlertCard/index.esm.js +113 -0
- package/dist/components/EntityAlertCard/index.esm.js.map +1 -0
- package/dist/components/EntityIncidentCard/index.esm.js +125 -0
- package/dist/components/EntityIncidentCard/index.esm.js.map +1 -0
- package/dist/components/EntityOnCallCard/index.esm.js +198 -0
- package/dist/components/EntityOnCallCard/index.esm.js.map +1 -0
- package/dist/components/HomePageAlertCard/Content.esm.js +76 -0
- package/dist/components/HomePageAlertCard/Content.esm.js.map +1 -0
- package/dist/components/HomePageAlertCard/index.esm.js +2 -0
- package/dist/components/HomePageAlertCard/index.esm.js.map +1 -0
- package/dist/components/HomePageIncidentCard/Content.esm.js +54 -0
- package/dist/components/HomePageIncidentCard/Content.esm.js.map +1 -0
- package/dist/components/HomePageIncidentCard/Context.esm.js +33 -0
- package/dist/components/HomePageIncidentCard/Context.esm.js.map +1 -0
- package/dist/components/HomePageIncidentCard/index.esm.js +3 -0
- package/dist/components/HomePageIncidentCard/index.esm.js.map +1 -0
- package/dist/components/HomePageOnCallCard/Content.esm.js +38 -0
- package/dist/components/HomePageOnCallCard/Content.esm.js.map +1 -0
- package/dist/components/HomePageOnCallCard/index.esm.js +6 -0
- package/dist/components/HomePageOnCallCard/index.esm.js.map +1 -0
- package/dist/components/IncidentListItem/index.esm.js +68 -0
- package/dist/components/IncidentListItem/index.esm.js.map +1 -0
- package/dist/components/styles.esm.js +34 -0
- package/dist/components/styles.esm.js.map +1 -0
- package/dist/components/utils.esm.js +19 -0
- package/dist/components/utils.esm.js.map +1 -0
- package/dist/hooks/useIncidentRequest.esm.js +65 -0
- package/dist/hooks/useIncidentRequest.esm.js.map +1 -0
- package/dist/hooks/useOnCallRequest.esm.js +116 -0
- package/dist/hooks/useOnCallRequest.esm.js.map +1 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.esm.js +1 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +99 -0
- package/dist/plugin.esm.js.map +1 -0
- package/package.json +64 -31
- package/src/alpha.test.ts +9 -0
- package/src/alpha.tsx +111 -0
- package/src/api/client.test.ts +43 -0
- package/src/api/types.test.ts +15 -0
- package/src/api/types.ts +49796 -11325
- package/src/components/AlertListItem/index.tsx +82 -0
- package/src/components/EntityAlertCard/index.test.tsx +242 -0
- package/src/components/EntityAlertCard/index.tsx +168 -0
- package/src/components/EntityIncidentCard/index.test.tsx +135 -0
- package/src/components/EntityIncidentCard/index.tsx +3 -23
- package/src/components/EntityOnCallCard/index.test.tsx +134 -0
- package/src/components/EntityOnCallCard/index.tsx +301 -0
- package/src/components/HomePageAlertCard/Content.test.tsx +56 -0
- package/src/components/HomePageAlertCard/Content.tsx +85 -0
- package/src/components/HomePageAlertCard/index.tsx +1 -0
- package/src/components/HomePageIncidentCard/Content.test.tsx +4 -3
- package/src/components/HomePageIncidentCard/Content.tsx +2 -2
- package/src/components/HomePageIncidentCard/Context.tsx +2 -2
- package/src/components/HomePageOnCallCard/Content.test.tsx +90 -0
- package/src/components/HomePageOnCallCard/Content.tsx +58 -0
- package/src/components/HomePageOnCallCard/index.ts +3 -0
- package/src/components/IncidentListItem/index.tsx +3 -26
- package/src/components/styles.tsx +30 -0
- package/src/components/utils.tsx +24 -0
- package/src/hooks/useIncidentRequest.test.ts +189 -0
- package/src/hooks/useIncidentRequest.ts +56 -3
- package/src/hooks/useOnCallRequest.test.ts +52 -0
- package/src/hooks/useOnCallRequest.ts +141 -0
- package/src/index.ts +4 -0
- package/src/plugin.ts +45 -1
- package/src/setupTests.ts +2 -2
- package/dist/esm/index-3220e1e0.esm.js +0 -96
- package/dist/esm/index-3220e1e0.esm.js.map +0 -1
- package/dist/esm/index-5cb52808.esm.js +0 -73
- package/dist/esm/index-5cb52808.esm.js.map +0 -1
- package/dist/esm/index-632bbd58.esm.js +0 -117
- package/dist/esm/index-632bbd58.esm.js.map +0 -1
- package/dist/esm/index-8f5c4c5f.esm.js +0 -101
- package/dist/esm/index-8f5c4c5f.esm.js.map +0 -1
package/src/alpha.tsx
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiBlueprint,
|
|
3
|
+
createFrontendPlugin,
|
|
4
|
+
FrontendPlugin,
|
|
5
|
+
} from "@backstage/frontend-plugin-api";
|
|
6
|
+
import {
|
|
7
|
+
discoveryApiRef,
|
|
8
|
+
fetchApiRef,
|
|
9
|
+
} from "@backstage/core-plugin-api";
|
|
10
|
+
import { EntityCardBlueprint } from "@backstage/plugin-catalog-react/alpha";
|
|
11
|
+
import { HomePageWidgetBlueprint } from "@backstage/plugin-home-react/alpha";
|
|
12
|
+
import { IncidentApi, IncidentApiRef } from "./api/client";
|
|
13
|
+
|
|
14
|
+
const incidentApi = ApiBlueprint.make({
|
|
15
|
+
params: defineParams =>
|
|
16
|
+
defineParams({
|
|
17
|
+
api: IncidentApiRef,
|
|
18
|
+
deps: {
|
|
19
|
+
discoveryApi: discoveryApiRef,
|
|
20
|
+
fetchApi: fetchApiRef,
|
|
21
|
+
},
|
|
22
|
+
factory: ({ discoveryApi, fetchApi }) =>{
|
|
23
|
+
return new IncidentApi({
|
|
24
|
+
discoveryApi: discoveryApi,
|
|
25
|
+
fetchApi: fetchApi
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const entityIncidentCard = EntityCardBlueprint.make({
|
|
32
|
+
name: "EntityIncidentCard",
|
|
33
|
+
params: {
|
|
34
|
+
loader: async () =>
|
|
35
|
+
import("./components/EntityIncidentCard").then(m=><m.EntityIncidentCard />),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const entityAlertCard = EntityCardBlueprint.make({
|
|
40
|
+
name: "EntityAlertCard",
|
|
41
|
+
params: {
|
|
42
|
+
loader: async () =>
|
|
43
|
+
import("./components/EntityAlertCard").then(m=><m.EntityAlertCard />),
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const entityOnCallCard = EntityCardBlueprint.make({
|
|
48
|
+
name: "EntityOnCallCard",
|
|
49
|
+
params: {
|
|
50
|
+
loader: async () =>
|
|
51
|
+
import("./components/EntityOnCallCard").then(m=><m.EntityOnCallCard />),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const homePageIncidentCard = HomePageWidgetBlueprint.make({
|
|
56
|
+
name: "HomePageIncidentCard",
|
|
57
|
+
params: {
|
|
58
|
+
title: "Ongoing Incidents",
|
|
59
|
+
components: () => import("./components/HomePageIncidentCard"),
|
|
60
|
+
settings: {
|
|
61
|
+
schema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
filterType: {
|
|
65
|
+
type: "string",
|
|
66
|
+
title: "Filter Type",
|
|
67
|
+
description: "Whether to filter on status category or status",
|
|
68
|
+
oneOf: [
|
|
69
|
+
{ enum: ["status_category"], title: "Status Category" },
|
|
70
|
+
{ enum: ["status"], title: "Status" },
|
|
71
|
+
],
|
|
72
|
+
default: "status_category",
|
|
73
|
+
},
|
|
74
|
+
filter: {
|
|
75
|
+
type: "string",
|
|
76
|
+
title: "Filter",
|
|
77
|
+
description:
|
|
78
|
+
"The filter to use. This is a string that will be passed to the API.",
|
|
79
|
+
default: "active",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
const homePageAlertCard = HomePageWidgetBlueprint.make({
|
|
89
|
+
name: "HomePageAlertCard",
|
|
90
|
+
params: {
|
|
91
|
+
title: "Ongoing Alerts",
|
|
92
|
+
components: () => import("./components/HomePageAlertCard"),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const homePageOnCallCard = HomePageWidgetBlueprint.make({
|
|
99
|
+
name: "HomePageOnCallCard",
|
|
100
|
+
params: {
|
|
101
|
+
title: "On-call",
|
|
102
|
+
components: () => import("./components/HomePageOnCallCard"),
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const plugin: FrontendPlugin = createFrontendPlugin({
|
|
107
|
+
pluginId: "incident",
|
|
108
|
+
extensions: [incidentApi, entityIncidentCard, entityAlertCard, homePageIncidentCard, homePageAlertCard, homePageOnCallCard, entityOnCallCard],
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export default plugin;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IncidentApi } from "./client";
|
|
2
|
+
|
|
3
|
+
const mockDiscoveryApi = {
|
|
4
|
+
getBaseUrl: async () => "http://localhost:7007/api/proxy",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
describe("IncidentApi", () => {
|
|
8
|
+
it("should call the correct URL and return parsed JSON", async () => {
|
|
9
|
+
const mockFetchApi = {
|
|
10
|
+
fetch: async () => ({
|
|
11
|
+
ok: true,
|
|
12
|
+
json: async () => ({ id: "123" }),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const client = new IncidentApi({
|
|
17
|
+
discoveryApi: mockDiscoveryApi as any,
|
|
18
|
+
fetchApi: mockFetchApi as any,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const result = await client.request({ path: "/v2/incidents" });
|
|
22
|
+
expect(result).toEqual({ id: "123" });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should throw an error when the response is not ok", async () => {
|
|
26
|
+
const mockFetchApi = {
|
|
27
|
+
fetch: async () => ({
|
|
28
|
+
ok: false,
|
|
29
|
+
status: 401,
|
|
30
|
+
statusText: "Unauthorized",
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const client = new IncidentApi({
|
|
35
|
+
discoveryApi: mockDiscoveryApi as any,
|
|
36
|
+
fetchApi: mockFetchApi as any,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await expect(client.request({ path: "/v2/incidents" })).rejects.toThrow(
|
|
40
|
+
"401 Unauthorized",
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { paths } from "./types";
|
|
2
|
+
|
|
3
|
+
describe("types", () => {
|
|
4
|
+
it("should expose the incidents list path", () => {
|
|
5
|
+
type HasIncidentsPath = "/v2/incidents" extends keyof paths ? true : false;
|
|
6
|
+
const check: HasIncidentsPath = true;
|
|
7
|
+
expect(check).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should expose the identity path", () => {
|
|
11
|
+
type HasIdentityPath = "/v1/identity" extends keyof paths ? true : false;
|
|
12
|
+
const check: HasIdentityPath = true;
|
|
13
|
+
expect(check).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
});
|