@incident-io/backstage 0.1.0 → 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 +22 -3
- package/config.d.ts +11 -5
- package/dist/alpha.esm.js +32 -6
- package/dist/alpha.esm.js.map +1 -1
- package/dist/{esm/client-646572ea.esm.js → api/client.esm.js} +6 -13
- 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 -64
- 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 +44 -23
- package/src/alpha.test.ts +9 -0
- package/src/alpha.tsx +38 -4
- 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/alpha/package.json +0 -7
- package/dist/esm/client-646572ea.esm.js.map +0 -1
- package/dist/esm/index-55bf4982.esm.js +0 -72
- package/dist/esm/index-55bf4982.esm.js.map +0 -1
- package/dist/esm/index-633a0241.esm.js +0 -96
- package/dist/esm/index-633a0241.esm.js.map +0 -1
- package/dist/esm/index-a220a8f7.esm.js +0 -116
- package/dist/esm/index-a220a8f7.esm.js.map +0 -1
package/src/alpha.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import {
|
|
3
2
|
ApiBlueprint,
|
|
4
3
|
createFrontendPlugin,
|
|
@@ -37,6 +36,22 @@ const entityIncidentCard = EntityCardBlueprint.make({
|
|
|
37
36
|
},
|
|
38
37
|
});
|
|
39
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
|
+
|
|
40
55
|
const homePageIncidentCard = HomePageWidgetBlueprint.make({
|
|
41
56
|
name: "HomePageIncidentCard",
|
|
42
57
|
params: {
|
|
@@ -68,10 +83,29 @@ const homePageIncidentCard = HomePageWidgetBlueprint.make({
|
|
|
68
83
|
},
|
|
69
84
|
},
|
|
70
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
|
+
|
|
71
97
|
|
|
72
|
-
const
|
|
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({
|
|
73
107
|
pluginId: "incident",
|
|
74
|
-
extensions: [incidentApi, entityIncidentCard, homePageIncidentCard],
|
|
75
|
-
});
|
|
108
|
+
extensions: [incidentApi, entityIncidentCard, entityAlertCard, homePageIncidentCard, homePageAlertCard, homePageOnCallCard, entityOnCallCard],
|
|
109
|
+
});
|
|
76
110
|
|
|
77
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
|
+
});
|