@burdenoff/microfe-bigconsole 2026.1123.2 → 2026.1123.4

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.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * useFleetChildren (BOFF-15410)
3
+ *
4
+ * What the Children panel shows for one board: whether it is a master, and (for a master) its copies with how
5
+ * many are active, pending and behind. Two small reads, because the full dashboard selection trips the gateway
6
+ * cost limit. A read that finishes after the board, workspace or account changed is dropped.
7
+ *
8
+ * A failure is returned for the panel to say so, never thrown: the board itself keeps working.
9
+ */
10
+ export interface FleetChild {
11
+ dashboardId: string;
12
+ name: string;
13
+ ownerId: string;
14
+ isMaster: boolean;
15
+ status: 'ACTIVE' | 'PENDING';
16
+ behindMaster: boolean;
17
+ missingWidgetCount: number | null;
18
+ openFlagCount: number;
19
+ }
20
+ export interface FleetChildrenSummary {
21
+ total: number;
22
+ active: number;
23
+ pending: number;
24
+ behind: number;
25
+ /** Copies the caller cannot read: counted above, not listed below. */
26
+ hiddenCount: number;
27
+ children: FleetChild[];
28
+ }
29
+ interface UseFleetChildrenResult {
30
+ loading: boolean;
31
+ error: Error | null;
32
+ isMaster: boolean;
33
+ summary: FleetChildrenSummary | null;
34
+ refetch: () => Promise<void>;
35
+ }
36
+ export declare function useFleetChildren(dashboardId: string | undefined, enabled: boolean): UseFleetChildrenResult;
37
+ export {};
@@ -0,0 +1,93 @@
1
+ import "../context/index.js";
2
+ import { useBigConsole as e } from "../context/BigConsoleContext.js";
3
+ import { FleetBoardStateDocument as t, FleetChildrenDocument as n } from "../../generated/wspace-operations.js";
4
+ import { useCallback as r, useEffect as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
5
+ import { useApolloClient as c } from "@apollo/client/react";
6
+ // src/bigconsole/hooks/useFleetChildren.ts
7
+ function l(l, u) {
8
+ let { workspaceId: d, currentUser: f } = e(), p = c(), m = `${d ?? ""}:${f?.id ?? ""}:${l ?? ""}`, [h, g] = s({
9
+ key: "",
10
+ isMaster: !1,
11
+ summary: null,
12
+ error: null
13
+ }), [_, v] = s(u && !!l), y = o(m), b = o(0);
14
+ a(() => (y.current = m, () => {
15
+ y.current = "", b.current += 1;
16
+ }), [m]);
17
+ let x = r(async () => {
18
+ if (!l) return;
19
+ let e = ++b.current, r = () => y.current === m && b.current === e, i = {
20
+ requiredWorkspaceAuth: !0,
21
+ requiredWorkspaceId: d,
22
+ queryDeduplication: !1
23
+ };
24
+ try {
25
+ v(!0);
26
+ let e = (await p.query({
27
+ query: t,
28
+ variables: { id: l },
29
+ fetchPolicy: "no-cache",
30
+ errorPolicy: "none",
31
+ context: i
32
+ })).data?.getDashboard?.isMaster === !0, a = null;
33
+ if (e) {
34
+ let e = (await p.query({
35
+ query: n,
36
+ variables: { masterDashboardId: l },
37
+ fetchPolicy: "no-cache",
38
+ errorPolicy: "none",
39
+ context: i
40
+ })).data?.dashboardChildren;
41
+ e && (a = {
42
+ total: e.total,
43
+ active: e.active,
44
+ pending: e.pending,
45
+ behind: e.behind,
46
+ hiddenCount: e.hiddenCount,
47
+ children: e.children.map((e) => ({
48
+ dashboardId: e.dashboardId,
49
+ name: e.name,
50
+ ownerId: e.ownerId,
51
+ isMaster: e.isMaster,
52
+ status: e.linkStatus === "PENDING" ? "PENDING" : "ACTIVE",
53
+ behindMaster: e.behindMaster,
54
+ missingWidgetCount: e.missingWidgetCount ?? null,
55
+ openFlagCount: e.openFlagCount
56
+ }))
57
+ });
58
+ }
59
+ r() && g({
60
+ key: m,
61
+ isMaster: e,
62
+ summary: a,
63
+ error: null
64
+ });
65
+ } catch (e) {
66
+ r() && g({
67
+ key: m,
68
+ isMaster: !1,
69
+ summary: null,
70
+ error: e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the copies of this board")
71
+ });
72
+ } finally {
73
+ r() && v(!1);
74
+ }
75
+ }, [
76
+ p,
77
+ l,
78
+ m,
79
+ d
80
+ ]);
81
+ i(() => {
82
+ u && x();
83
+ }, [u, x]);
84
+ let S = h.key === m;
85
+ return {
86
+ loading: _ || u && !S,
87
+ error: S ? h.error : null,
88
+ isMaster: S && h.isMaster,
89
+ summary: S ? h.summary : null,
90
+ refetch: x
91
+ };
92
+ }
93
+ export { l as useFleetChildren };
@@ -0,0 +1,13 @@
1
+ import { FleetPushResultFragment } from '../../generated/wspace-operations';
2
+ export type FleetPushScope = 'DIRECT_COPIES' | 'ALL_UNDER';
3
+ export type FleetPushResult = FleetPushResultFragment;
4
+ interface UseFleetMasterActionsResult {
5
+ busy: boolean;
6
+ setAsMaster: (dashboardId: string) => Promise<void>;
7
+ unsetAsMaster: (dashboardId: string) => Promise<void>;
8
+ createLinkedCopy: (masterDashboardId: string, name: string) => Promise<string>;
9
+ previewPush: (masterDashboardId: string, scope: FleetPushScope) => Promise<FleetPushResult>;
10
+ push: (masterDashboardId: string, scope: FleetPushScope) => Promise<FleetPushResult>;
11
+ }
12
+ export declare function useFleetMasterActions(): UseFleetMasterActionsResult;
13
+ export {};
@@ -0,0 +1,71 @@
1
+ import { CreateLinkedCopyDocument as e, PreviewPushToCopiesDocument as t, PushToCopiesDocument as n, SetDashboardAsMasterDocument as r, UnsetDashboardAsMasterDocument as i } from "../../generated/wspace-operations.js";
2
+ import { BigConsolePushScope as a } from "../../generated/wspace-types.js";
3
+ import { useCallback as o, useState as s } from "react";
4
+ import { useApolloClient as c } from "@apollo/client/react";
5
+ // src/bigconsole/hooks/useFleetMasterActions.ts
6
+ var l = (e) => e === "ALL_UNDER" ? a.AllUnder : a.DirectCopies;
7
+ function u() {
8
+ let a = c(), [u, d] = s(!1), f = o(async (e) => {
9
+ d(!0);
10
+ try {
11
+ return await e();
12
+ } finally {
13
+ d(!1);
14
+ }
15
+ }, []);
16
+ return {
17
+ busy: u,
18
+ setAsMaster: o((e) => f(async () => {
19
+ await a.mutate({
20
+ mutation: r,
21
+ variables: { id: e },
22
+ errorPolicy: "none"
23
+ });
24
+ }), [a, f]),
25
+ unsetAsMaster: o((e) => f(async () => {
26
+ await a.mutate({
27
+ mutation: i,
28
+ variables: { id: e },
29
+ errorPolicy: "none"
30
+ });
31
+ }), [a, f]),
32
+ createLinkedCopy: o((t, n) => f(async () => {
33
+ let r = (await a.mutate({
34
+ mutation: e,
35
+ variables: { input: {
36
+ masterDashboardId: t,
37
+ name: n
38
+ } },
39
+ errorPolicy: "none"
40
+ })).data?.createLinkedCopy?.id;
41
+ if (!r) throw Error("The linked copy was not created.");
42
+ return r;
43
+ }), [a, f]),
44
+ previewPush: o((e, n) => f(async () => {
45
+ let r = await a.query({
46
+ query: t,
47
+ variables: { input: {
48
+ masterDashboardId: e,
49
+ scope: l(n)
50
+ } },
51
+ fetchPolicy: "no-cache",
52
+ errorPolicy: "none"
53
+ });
54
+ if (!r.data?.previewPushToCopies) throw Error("The preview could not be made.");
55
+ return r.data.previewPushToCopies;
56
+ }), [a, f]),
57
+ push: o((e, t) => f(async () => {
58
+ let r = await a.mutate({
59
+ mutation: n,
60
+ variables: { input: {
61
+ masterDashboardId: e,
62
+ scope: l(t)
63
+ } },
64
+ errorPolicy: "none"
65
+ });
66
+ if (!r.data?.pushToCopies) throw Error("The push could not be made.");
67
+ return r.data.pushToCopies;
68
+ }), [a, f])
69
+ };
70
+ }
71
+ export { u as useFleetMasterActions };