@checkstack/dashboard-frontend 0.7.8 → 0.8.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.
@@ -1,107 +0,0 @@
1
- import React from "react";
2
- import {
3
- Sheet,
4
- SheetContent,
5
- SheetHeader,
6
- SheetTitle,
7
- SheetBody,
8
- Button,
9
- Badge,
10
- } from "@checkstack/ui";
11
- import { Link } from "react-router-dom";
12
- import { usePluginRoute, useApi, accessApiRef } from "@checkstack/frontend-api";
13
- import {
14
- incidentRoutes,
15
- incidentAccess,
16
- type IncidentWithSystems,
17
- } from "@checkstack/incident-common";
18
- import { resolveRoute } from "@checkstack/common";
19
- import type { System } from "@checkstack/catalog-common";
20
-
21
- interface Props {
22
- open: boolean;
23
- onOpenChange: (open: boolean) => void;
24
- incidents: IncidentWithSystems[];
25
- systems: System[];
26
- }
27
-
28
- export const IncidentOverviewSheet: React.FC<Props> = ({
29
- open,
30
- onOpenChange,
31
- incidents,
32
- systems,
33
- }) => {
34
- const getRoute = usePluginRoute();
35
- const accessApi = useApi(accessApiRef);
36
- const { allowed: canManage } = accessApi.useAccess(incidentAccess.incident.manage);
37
-
38
- // Map of systemId -> systemName
39
- const systemMap = new Map(systems.map((s) => [s.id, s.name]));
40
-
41
- return (
42
- <Sheet open={open} onOpenChange={onOpenChange}>
43
- <SheetContent>
44
- <SheetHeader className="flex flex-row items-start justify-between gap-4 pt-6">
45
- <div className="flex flex-col gap-1 text-left">
46
- <SheetTitle>Active Incidents</SheetTitle>
47
- <p className="text-sm text-muted-foreground">
48
- Overview of unresolved issues
49
- </p>
50
- </div>
51
- {canManage && (
52
- <Button variant="outline" size="sm" asChild>
53
- <Link to={getRoute(incidentRoutes.routes.config)}>Manage</Link>
54
- </Button>
55
- )}
56
- </SheetHeader>
57
-
58
- <SheetBody className="flex flex-col gap-3 pb-8">
59
- {incidents.length === 0 ? (
60
- <p className="text-sm text-muted-foreground text-center py-8">
61
- No active incidents
62
- </p>
63
- ) : (
64
- incidents.map((incident) => {
65
- const affectedSystemNames = incident.systemIds
66
- .map((id) => systemMap.get(id) || id)
67
- .join(", ");
68
-
69
- const variant =
70
- incident.severity === "critical"
71
- ? "destructive"
72
- : incident.severity === "major"
73
- ? "warning"
74
- : "info";
75
-
76
- return (
77
- <Link
78
- key={incident.id}
79
- to={resolveRoute(incidentRoutes.routes.detail, { incidentId: incident.id })}
80
- onClick={() => onOpenChange(false)}
81
- className="flex flex-col gap-2 rounded-lg border border-border bg-card p-4 hover:border-primary/50 hover:shadow-sm transition-all text-left"
82
- >
83
- <div className="flex items-start justify-between gap-4">
84
- <h4 className="font-medium text-foreground">
85
- {incident.title}
86
- </h4>
87
- <Badge variant={variant} className="capitalize flex-shrink-0">
88
- {incident.severity}
89
- </Badge>
90
- </div>
91
- <div className="flex flex-col gap-1 mt-2">
92
- <span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">
93
- Affected Systems
94
- </span>
95
- <span className="text-sm text-foreground">
96
- {affectedSystemNames || "None"}
97
- </span>
98
- </div>
99
- </Link>
100
- );
101
- })
102
- )}
103
- </SheetBody>
104
- </SheetContent>
105
- </Sheet>
106
- );
107
- };
@@ -1,128 +0,0 @@
1
- import React from "react";
2
- import {
3
- Sheet,
4
- SheetContent,
5
- SheetHeader,
6
- SheetTitle,
7
- SheetBody,
8
- Button,
9
- Badge,
10
- } from "@checkstack/ui";
11
- import { Link } from "react-router-dom";
12
- import { usePluginRoute, useApi, accessApiRef } from "@checkstack/frontend-api";
13
- import {
14
- maintenanceRoutes,
15
- maintenanceAccess,
16
- type MaintenanceWithSystems,
17
- } from "@checkstack/maintenance-common";
18
- import { resolveRoute } from "@checkstack/common";
19
- import type { System } from "@checkstack/catalog-common";
20
-
21
- interface Props {
22
- open: boolean;
23
- onOpenChange: (open: boolean) => void;
24
- maintenances: MaintenanceWithSystems[];
25
- systems: System[];
26
- }
27
-
28
- export const MaintenanceOverviewSheet: React.FC<Props> = ({
29
- open,
30
- onOpenChange,
31
- maintenances,
32
- systems,
33
- }) => {
34
- const getRoute = usePluginRoute();
35
- const accessApi = useApi(accessApiRef);
36
- const { allowed: canManage } = accessApi.useAccess(maintenanceAccess.maintenance.manage);
37
-
38
- const systemMap = new Map(systems.map((s) => [s.id, s.name]));
39
-
40
- return (
41
- <Sheet open={open} onOpenChange={onOpenChange}>
42
- <SheetContent>
43
- <SheetHeader className="flex flex-row items-start justify-between gap-4 pt-6">
44
- <div className="flex flex-col gap-1 text-left">
45
- <SheetTitle>Active & Scheduled Maintenances</SheetTitle>
46
- <p className="text-sm text-muted-foreground">
47
- Overview of scheduled and ongoing windows
48
- </p>
49
- </div>
50
- {canManage && (
51
- <Button variant="outline" size="sm" asChild>
52
- <Link to={getRoute(maintenanceRoutes.routes.config)}>Manage</Link>
53
- </Button>
54
- )}
55
- </SheetHeader>
56
-
57
- <SheetBody className="flex flex-col gap-3 pb-8">
58
- {maintenances.length === 0 ? (
59
- <p className="text-sm text-muted-foreground text-center py-8">
60
- No active maintenances
61
- </p>
62
- ) : (
63
- maintenances.map((maintenance) => {
64
- const affectedSystemNames = maintenance.systemIds
65
- .map((id) => systemMap.get(id) || id)
66
- .join(", ");
67
-
68
- const badgeVariant =
69
- maintenance.status === "in_progress"
70
- ? "warning"
71
- : maintenance.status === "scheduled"
72
- ? "info"
73
- : maintenance.status === "completed"
74
- ? "success"
75
- : "secondary";
76
-
77
- return (
78
- <Link
79
- key={maintenance.id}
80
- to={resolveRoute(maintenanceRoutes.routes.detail, { maintenanceId: maintenance.id })}
81
- onClick={() => onOpenChange(false)}
82
- className="flex flex-col gap-2 rounded-lg border border-border bg-card p-4 hover:border-primary/50 hover:shadow-sm transition-all text-left"
83
- >
84
- <div className="flex items-start justify-between gap-4">
85
- <h4 className="font-medium text-foreground">
86
- {maintenance.title}
87
- </h4>
88
- <Badge variant={badgeVariant} className="capitalize flex-shrink-0">
89
- {maintenance.status.replace("_", " ")}
90
- </Badge>
91
- </div>
92
- <div className="flex flex-col gap-1 mt-2">
93
- <span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">
94
- Affected Systems
95
- </span>
96
- <span className="text-sm text-foreground">
97
- {affectedSystemNames || "None"}
98
- </span>
99
- </div>
100
- <div className="flex flex-col gap-1 mt-2">
101
- <span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">
102
- Schedule
103
- </span>
104
- <span className="text-sm text-foreground">
105
- {new Date(maintenance.startAt).toLocaleString(undefined, {
106
- month: "short",
107
- day: "numeric",
108
- hour: "numeric",
109
- minute: "2-digit",
110
- })}
111
- {" - "}
112
- {new Date(maintenance.endAt).toLocaleString(undefined, {
113
- month: "short",
114
- day: "numeric",
115
- hour: "numeric",
116
- minute: "2-digit",
117
- })}
118
- </span>
119
- </div>
120
- </Link>
121
- );
122
- })
123
- )}
124
- </SheetBody>
125
- </SheetContent>
126
- </Sheet>
127
- );
128
- };