@checkstack/healthcheck-frontend 0.2.0 → 0.4.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,12 +1,13 @@
1
1
  import {
2
- useApi,
3
2
  wrapInSuspense,
4
- permissionApiRef,
3
+ accessApiRef,
4
+ useApi,
5
+ usePluginClient,
5
6
  } from "@checkstack/frontend-api";
6
- import { healthCheckApiRef } from "../api";
7
7
  import {
8
8
  PageLayout,
9
9
  usePagination,
10
+ usePaginationSync,
10
11
  Card,
11
12
  CardHeader,
12
13
  CardTitle,
@@ -16,33 +17,37 @@ import {
16
17
  HealthCheckRunsTable,
17
18
  type HealthCheckRunDetailed,
18
19
  } from "../components/HealthCheckRunsTable";
20
+ import {
21
+ healthCheckAccess,
22
+ HealthCheckApi,
23
+ } from "@checkstack/healthcheck-common";
19
24
 
20
25
  const HealthCheckHistoryPageContent = () => {
21
- const api = useApi(healthCheckApiRef);
22
- const permissionApi = useApi(permissionApiRef);
23
- const { allowed: canManage, loading: permissionLoading } =
24
- permissionApi.useResourcePermission("healthcheck", "manage");
26
+ const healthCheckClient = usePluginClient(HealthCheckApi);
27
+ const accessApi = useApi(accessApiRef);
28
+ const { allowed: canManage, loading: accessLoading } = accessApi.useAccess(
29
+ healthCheckAccess.configuration.manage
30
+ );
25
31
 
26
- const {
27
- items: runs,
28
- loading,
29
- pagination,
30
- } = usePagination({
31
- fetchFn: (params: { limit: number; offset: number }) =>
32
- api.getDetailedHistory({
33
- limit: params.limit,
34
- offset: params.offset,
35
- }),
36
- getItems: (response) => response.runs as HealthCheckRunDetailed[],
37
- getTotal: (response) => response.total,
38
- defaultLimit: 20,
32
+ // Pagination state
33
+ const pagination = usePagination({ defaultLimit: 20 });
34
+
35
+ // Fetch data with useQuery
36
+ const { data, isLoading } = healthCheckClient.getDetailedHistory.useQuery({
37
+ limit: pagination.limit,
38
+ offset: pagination.offset,
39
39
  });
40
40
 
41
+ // Sync total from response
42
+ usePaginationSync(pagination, data?.total);
43
+
44
+ const runs = (data?.runs ?? []) as HealthCheckRunDetailed[];
45
+
41
46
  return (
42
47
  <PageLayout
43
48
  title="Health Check History"
44
49
  subtitle="Detailed run history with full result data"
45
- loading={permissionLoading}
50
+ loading={accessLoading}
46
51
  allowed={canManage}
47
52
  >
48
53
  <Card>
@@ -52,7 +57,7 @@ const HealthCheckHistoryPageContent = () => {
52
57
  <CardContent>
53
58
  <HealthCheckRunsTable
54
59
  runs={runs}
55
- loading={loading}
60
+ loading={isLoading}
56
61
  showFilterColumns
57
62
  pagination={pagination}
58
63
  />