@burdenoff/microfe-bigconsole 2026.1124.1 → 2026.1124.2
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/dist/bigconsole/components/fleet/FleetChildrenPanel.d.ts +4 -0
- package/dist/bigconsole/components/fleet/FleetChildrenPanel.js +174 -184
- package/dist/bigconsole/components/fleet/FleetCopySection.d.ts +13 -0
- package/dist/bigconsole/components/fleet/FleetCopySection.js +266 -0
- package/dist/bigconsole/hooks/useFleetBreadcrumb.d.ts +8 -1
- package/dist/bigconsole/hooks/useFleetBreadcrumb.js +4 -1
- package/dist/bigconsole/hooks/useFleetChildren.d.ts +2 -0
- package/dist/bigconsole/hooks/useFleetChildren.js +10 -6
- package/dist/bigconsole/hooks/useFleetCopyActions.d.ts +23 -0
- package/dist/bigconsole/hooks/useFleetCopyActions.js +74 -0
- package/dist/bigconsole/hooks/useFleetFlags.d.ts +16 -0
- package/dist/bigconsole/hooks/useFleetFlags.js +79 -0
- package/dist/bigconsole/hooks/useOwnerBoundRun.d.ts +33 -0
- package/dist/bigconsole/hooks/useOwnerBoundRun.js +41 -0
- package/dist/bigconsole/pages/DashboardViewPage.js +290 -287
- package/dist/bigconsole/pages/DashboardsPage.js +13 -13
- package/dist/bigconsole/utils/fleetFlags.d.ts +22 -0
- package/dist/bigconsole/utils/fleetFlags.js +40 -0
- package/dist/bigconsole/utils/fleetTree.d.ts +9 -0
- package/dist/bigconsole/utils/fleetTree.js +5 -1
- package/dist/generated/wspace-operations.d.ts +101 -0
- package/dist/generated/wspace-operations.js +609 -90
- package/dist/generated/wspace-types.js +6 -4
- package/package.json +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { useBigConsole as e } from "../../context/BigConsoleContext.js";
|
|
2
|
+
import { BIGCONSOLE_PERMISSIONS as t } from "../../../constants/permissions.js";
|
|
3
|
+
import { nativeConfirm as n } from "../../../utils/nativeBridge.js";
|
|
4
|
+
import { useTr as r } from "../../../shared/hooks/useTr.js";
|
|
5
|
+
import "../../context/index.js";
|
|
6
|
+
import { useFleetCopyActions as i } from "../../hooks/useFleetCopyActions.js";
|
|
7
|
+
import { useFleetFlags as a } from "../../hooks/useFleetFlags.js";
|
|
8
|
+
import { useOwnerBoundRun as o } from "../../hooks/useOwnerBoundRun.js";
|
|
9
|
+
import { allowedAnswers as s, changedFieldLabel as c, restoreIsEmpty as l } from "../../utils/fleetFlags.js";
|
|
10
|
+
import { memo as u, useCallback as d, useState as f } from "react";
|
|
11
|
+
import { PermissionButton as p } from "@burdenoff/fe-libs/shared/components";
|
|
12
|
+
import { Button as m, Spinner as h } from "@burdenoff/fe-libs/ui";
|
|
13
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
14
|
+
// src/bigconsole/components/fleet/FleetCopySection.tsx
|
|
15
|
+
var v = (e, t) => e instanceof Error && e.message ? e.message : t, y = u(function({ dashboardId: u, masterName: y, onBoardChanged: b, lock: x }) {
|
|
16
|
+
let S = r(), { workspaceId: C, currentUser: w } = e(), T = `${C ?? ""}:${w?.id ?? ""}:${u}`, { loading: E, error: D, flags: O, refetch: k } = a(u, !0), A = i(), [j, M] = f({ phase: "idle" }), [N, P] = f(null), [F, I] = f([]), L = d(() => {
|
|
17
|
+
M({ phase: "idle" }), P(null), I([]);
|
|
18
|
+
}, []), R = d(async () => {
|
|
19
|
+
await k(), await b?.();
|
|
20
|
+
}, [b, k]), { acting: z, begin: B, run: V } = o(T, R, L, x), H = A.busy || z, U = d(async (e, t, r) => {
|
|
21
|
+
let i = await n({
|
|
22
|
+
title: e,
|
|
23
|
+
message: t,
|
|
24
|
+
okButtonTitle: r,
|
|
25
|
+
cancelButtonTitle: S("bigconsole.fleet.link.cancel", "Cancel")
|
|
26
|
+
});
|
|
27
|
+
return i === null ? window.confirm(t) : i;
|
|
28
|
+
}, [S]), W = (e) => S("bigconsole.fleet.copy.noticeDrilldown", "A widget's drilldown led to the page \"{{page}}\", which this board does not have, so it now opens the default page.", { page: e.pageName }), G = (e, t) => e === "ACCEPTED_MASTER" ? S("bigconsole.fleet.flags.accept", "Take the master's version") : e === "REMOVED" ? S("bigconsole.fleet.flags.remove", "Remove it") : t === "MASTER_REMOVED" ? S("bigconsole.fleet.flags.keepRemoved", "Keep it") : S("bigconsole.fleet.flags.keep", "Keep mine"), K = d(async (e, t) => {
|
|
29
|
+
let n = B();
|
|
30
|
+
if (t === "ACCEPTED_MASTER") {
|
|
31
|
+
if (!await U(S("bigconsole.fleet.flags.acceptTitle", "Take the master's version?"), S("bigconsole.fleet.flags.acceptConfirm", "\"{{title}}\" goes back to the master's version. Your changes to it are lost.", { title: e.widgetTitle }), S("bigconsole.fleet.flags.acceptOk", "Take it")) || !n()) return;
|
|
32
|
+
} else if (t === "REMOVED" && (!await U(S("bigconsole.fleet.flags.removeTitle", "Remove this widget?"), S("bigconsole.fleet.flags.removeConfirm", "\"{{title}}\" is removed from this board. A push does not give it back.", { title: e.widgetTitle }), S("bigconsole.fleet.flags.removeOk", "Remove")) || !n())) return;
|
|
33
|
+
P(null), I([]), await V(() => A.resolveFlag(e.id, t), (n) => {
|
|
34
|
+
M({ phase: "idle" }), I(n), P({
|
|
35
|
+
tone: "ok",
|
|
36
|
+
text: t === "ACCEPTED_MASTER" ? S("bigconsole.fleet.flags.accepted", "\"{{title}}\" is back to the master's version.", { title: e.widgetTitle }) : t === "REMOVED" ? S("bigconsole.fleet.flags.removed", "\"{{title}}\" was removed.", { title: e.widgetTitle }) : S("bigconsole.fleet.flags.kept", "\"{{title}}\" is now your own. The master will not flag it again.", { title: e.widgetTitle })
|
|
37
|
+
});
|
|
38
|
+
}, (e) => P({
|
|
39
|
+
tone: "error",
|
|
40
|
+
text: v(e, S("bigconsole.fleet.error.flag", "The flag could not be answered."))
|
|
41
|
+
}));
|
|
42
|
+
}, [
|
|
43
|
+
A,
|
|
44
|
+
B,
|
|
45
|
+
U,
|
|
46
|
+
V,
|
|
47
|
+
S
|
|
48
|
+
]), q = d(() => (P(null), I([]), V(() => A.previewRestore(u), (e) => M({
|
|
49
|
+
phase: "preview",
|
|
50
|
+
counts: e
|
|
51
|
+
}), (e) => P({
|
|
52
|
+
tone: "error",
|
|
53
|
+
text: v(e, S("bigconsole.fleet.error.restorePreview", "The preview could not be made."))
|
|
54
|
+
}))), [
|
|
55
|
+
A,
|
|
56
|
+
u,
|
|
57
|
+
V,
|
|
58
|
+
S
|
|
59
|
+
]), J = d(async () => {
|
|
60
|
+
let e = B();
|
|
61
|
+
await U(S("bigconsole.fleet.restore.title", "Restore this board to its original?"), S("bigconsole.fleet.restore.confirm", "Edited widgets go back to the master's version and removed ones come back. Your own widgets stay."), S("bigconsole.fleet.restore.ok", "Restore")) && e() && (P(null), await V(() => A.restore(u), (e) => {
|
|
62
|
+
M({
|
|
63
|
+
phase: "done",
|
|
64
|
+
counts: e
|
|
65
|
+
}), I(e.notices);
|
|
66
|
+
}, (e) => P({
|
|
67
|
+
tone: "error",
|
|
68
|
+
text: v(e, S("bigconsole.fleet.error.restore", "The board could not be restored."))
|
|
69
|
+
})));
|
|
70
|
+
}, [
|
|
71
|
+
A,
|
|
72
|
+
B,
|
|
73
|
+
U,
|
|
74
|
+
u,
|
|
75
|
+
V,
|
|
76
|
+
S
|
|
77
|
+
]), Y = (e, t) => t ? S("bigconsole.fleet.restore.done", "{{restored}} edited widgets went back to the master's version, {{back}} removed ones came back, {{kept}} of your own stayed.", {
|
|
78
|
+
restored: e.widgetsRestored,
|
|
79
|
+
back: e.widgetsBroughtBack,
|
|
80
|
+
kept: e.localWidgetsKept
|
|
81
|
+
}) : S("bigconsole.fleet.restore.preview", "{{restored}} edited widgets would go back to the master's version, {{back}} removed ones would come back, {{kept}} of your own would stay.", {
|
|
82
|
+
restored: e.widgetsRestored,
|
|
83
|
+
back: e.widgetsBroughtBack,
|
|
84
|
+
kept: e.localWidgetsKept
|
|
85
|
+
});
|
|
86
|
+
return /* @__PURE__ */ _("div", {
|
|
87
|
+
className: "flex flex-col gap-form-gap",
|
|
88
|
+
"data-testid": "fleet-copy-section",
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ g("p", {
|
|
91
|
+
style: {
|
|
92
|
+
margin: 0,
|
|
93
|
+
color: "var(--color-text-secondary)",
|
|
94
|
+
fontSize: "var(--font-size-body-sm)"
|
|
95
|
+
},
|
|
96
|
+
children: y ? S("bigconsole.fleet.copy.follows", "This board is a linked copy of \"{{name}}\".", { name: y }) : S("bigconsole.fleet.copy.followsUnknown", "This board is a linked copy of another board.")
|
|
97
|
+
}),
|
|
98
|
+
N && /* @__PURE__ */ g("p", {
|
|
99
|
+
role: N.tone === "error" ? "alert" : "status",
|
|
100
|
+
"data-testid": "fleet-copy-message",
|
|
101
|
+
style: {
|
|
102
|
+
margin: 0,
|
|
103
|
+
color: N.tone === "error" ? "var(--color-status-error-text)" : "var(--color-text-primary)",
|
|
104
|
+
fontSize: "var(--font-size-body-sm)"
|
|
105
|
+
},
|
|
106
|
+
children: N.text
|
|
107
|
+
}),
|
|
108
|
+
F.length > 0 && /* @__PURE__ */ g("ul", {
|
|
109
|
+
"data-testid": "fleet-copy-notices",
|
|
110
|
+
style: {
|
|
111
|
+
margin: 0,
|
|
112
|
+
paddingLeft: "1.25rem",
|
|
113
|
+
color: "var(--color-text-secondary)",
|
|
114
|
+
fontSize: "var(--font-size-body-sm)"
|
|
115
|
+
},
|
|
116
|
+
children: F.map((e, t) => /* @__PURE__ */ g("li", { children: W(e) }, `${e.widgetId}-${t}`))
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ g("strong", {
|
|
119
|
+
style: { color: "var(--color-text-primary)" },
|
|
120
|
+
children: S("bigconsole.fleet.flags.title", "Waiting for your answer")
|
|
121
|
+
}),
|
|
122
|
+
E && O.length === 0 && /* @__PURE__ */ _("div", {
|
|
123
|
+
className: "flex items-center gap-2",
|
|
124
|
+
style: { color: "var(--color-text-secondary)" },
|
|
125
|
+
children: [/* @__PURE__ */ g(h, { style: {
|
|
126
|
+
height: "var(--size-icon-sm)",
|
|
127
|
+
width: "var(--size-icon-sm)"
|
|
128
|
+
} }), S("bigconsole.fleet.flags.loading", "Loading…")]
|
|
129
|
+
}),
|
|
130
|
+
!E && D && /* @__PURE__ */ g("p", {
|
|
131
|
+
role: "alert",
|
|
132
|
+
style: {
|
|
133
|
+
margin: 0,
|
|
134
|
+
color: "var(--color-status-error-text)"
|
|
135
|
+
},
|
|
136
|
+
children: S("bigconsole.fleet.flags.loadError", "The flags on this board could not be loaded.")
|
|
137
|
+
}),
|
|
138
|
+
!E && !D && O.length === 0 && /* @__PURE__ */ g("p", {
|
|
139
|
+
"data-testid": "fleet-flags-none",
|
|
140
|
+
style: {
|
|
141
|
+
margin: 0,
|
|
142
|
+
color: "var(--color-text-secondary)",
|
|
143
|
+
fontSize: "var(--font-size-body-sm)"
|
|
144
|
+
},
|
|
145
|
+
children: S("bigconsole.fleet.flags.none", "Nothing. The master has no change waiting for you.")
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ g("ul", {
|
|
148
|
+
className: "flex flex-col gap-1",
|
|
149
|
+
style: {
|
|
150
|
+
listStyle: "none",
|
|
151
|
+
margin: 0,
|
|
152
|
+
padding: 0
|
|
153
|
+
},
|
|
154
|
+
children: O.map((e) => /* @__PURE__ */ _("li", {
|
|
155
|
+
"data-testid": "fleet-flag",
|
|
156
|
+
className: "flex flex-col gap-2 rounded-input border px-3 py-2",
|
|
157
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ g("span", {
|
|
160
|
+
style: { color: "var(--color-text-primary)" },
|
|
161
|
+
children: e.widgetTitle
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ g("span", {
|
|
164
|
+
style: {
|
|
165
|
+
color: "var(--color-text-secondary)",
|
|
166
|
+
fontSize: "var(--font-size-body-sm)"
|
|
167
|
+
},
|
|
168
|
+
children: e.type === "MASTER_REMOVED" ? S("bigconsole.fleet.flags.removedByMaster", "The master removed this widget. It stays on your board until you answer.") : S("bigconsole.fleet.flags.changedByMaster", "The master changed this widget and you edited it too. Your version stays until you answer. Changed: {{fields}}.", { fields: e.changedFields.map((e) => {
|
|
169
|
+
let t = c(e);
|
|
170
|
+
return t ? S(t.key, t.fallback) : e;
|
|
171
|
+
}).join(", ") })
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ g(p, {
|
|
174
|
+
permission: t.DASHBOARD_UPDATE,
|
|
175
|
+
deniedBehavior: "hide",
|
|
176
|
+
children: /* @__PURE__ */ g("span", {
|
|
177
|
+
className: "flex flex-wrap gap-2",
|
|
178
|
+
children: s(e.type).map((t) => /* @__PURE__ */ g(m, {
|
|
179
|
+
size: "sm",
|
|
180
|
+
variant: t === "REMOVED" ? "ghost" : "outline",
|
|
181
|
+
disabled: H,
|
|
182
|
+
onClick: () => void K(e, t),
|
|
183
|
+
"data-testid": `fleet-flag-${t}`,
|
|
184
|
+
children: G(t, e.type)
|
|
185
|
+
}, t))
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}, e.id))
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ g("strong", {
|
|
192
|
+
style: { color: "var(--color-text-primary)" },
|
|
193
|
+
children: S("bigconsole.fleet.restore.heading", "Back to the original")
|
|
194
|
+
}),
|
|
195
|
+
j.phase === "idle" && /* @__PURE__ */ g("div", { children: /* @__PURE__ */ g(p, {
|
|
196
|
+
permission: t.DASHBOARD_UPDATE,
|
|
197
|
+
deniedBehavior: "hide",
|
|
198
|
+
children: /* @__PURE__ */ g(m, {
|
|
199
|
+
variant: "outline",
|
|
200
|
+
onClick: q,
|
|
201
|
+
disabled: H,
|
|
202
|
+
"data-testid": "fleet-restore",
|
|
203
|
+
children: S("bigconsole.fleet.restore.start", "Restore board to original…")
|
|
204
|
+
})
|
|
205
|
+
}) }),
|
|
206
|
+
j.phase === "preview" && /* @__PURE__ */ _("div", {
|
|
207
|
+
className: "flex flex-col gap-form-gap rounded-input border p-3",
|
|
208
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
209
|
+
"data-testid": "fleet-restore-preview",
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ g("span", {
|
|
212
|
+
style: { color: "var(--color-text-primary)" },
|
|
213
|
+
children: S("bigconsole.fleet.restore.previewTitle", "Preview: nothing has been changed yet")
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ g("span", {
|
|
216
|
+
"data-testid": "fleet-restore-counts",
|
|
217
|
+
style: {
|
|
218
|
+
color: "var(--color-text-secondary)",
|
|
219
|
+
fontSize: "var(--font-size-body-sm)"
|
|
220
|
+
},
|
|
221
|
+
children: Y(j.counts, !1)
|
|
222
|
+
}),
|
|
223
|
+
l(j.counts) && /* @__PURE__ */ g("span", {
|
|
224
|
+
style: {
|
|
225
|
+
color: "var(--color-text-secondary)",
|
|
226
|
+
fontSize: "var(--font-size-body-sm)"
|
|
227
|
+
},
|
|
228
|
+
children: S("bigconsole.fleet.restore.nothing", "Nothing to restore: this board already matches its master.")
|
|
229
|
+
}),
|
|
230
|
+
/* @__PURE__ */ _("div", {
|
|
231
|
+
className: "flex gap-2",
|
|
232
|
+
children: [/* @__PURE__ */ _(m, {
|
|
233
|
+
onClick: () => void J(),
|
|
234
|
+
disabled: H || l(j.counts),
|
|
235
|
+
"data-testid": "fleet-restore-confirm",
|
|
236
|
+
children: [H && /* @__PURE__ */ g(h, { style: {
|
|
237
|
+
height: "var(--size-icon-sm)",
|
|
238
|
+
width: "var(--size-icon-sm)"
|
|
239
|
+
} }), S("bigconsole.fleet.restore.ok", "Restore")]
|
|
240
|
+
}), /* @__PURE__ */ g(m, {
|
|
241
|
+
variant: "outline",
|
|
242
|
+
onClick: () => M({ phase: "idle" }),
|
|
243
|
+
disabled: H,
|
|
244
|
+
children: S("bigconsole.fleet.link.cancel", "Cancel")
|
|
245
|
+
})]
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
}),
|
|
249
|
+
j.phase === "done" && /* @__PURE__ */ _("div", {
|
|
250
|
+
className: "flex flex-col gap-form-gap rounded-input border p-3",
|
|
251
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
252
|
+
"data-testid": "fleet-restore-done",
|
|
253
|
+
children: [/* @__PURE__ */ g("span", {
|
|
254
|
+
"data-testid": "fleet-restore-result",
|
|
255
|
+
style: { color: "var(--color-text-primary)" },
|
|
256
|
+
children: Y(j.counts, !0)
|
|
257
|
+
}), /* @__PURE__ */ g("div", { children: /* @__PURE__ */ g(m, {
|
|
258
|
+
variant: "outline",
|
|
259
|
+
onClick: () => M({ phase: "idle" }),
|
|
260
|
+
children: S("bigconsole.fleet.push.done", "Done")
|
|
261
|
+
}) })]
|
|
262
|
+
})
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
export { y as FleetCopySection, y as default };
|
|
@@ -10,4 +10,11 @@ export interface FleetBreadcrumbAncestor {
|
|
|
10
10
|
id: string;
|
|
11
11
|
name: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
interface UseFleetBreadcrumbResult {
|
|
14
|
+
/** The masters above the board that can be read, from the top down. */
|
|
15
|
+
ancestors: FleetBreadcrumbAncestor[];
|
|
16
|
+
/** The board this one directly follows, readable or not; null when it follows none. */
|
|
17
|
+
directMasterId: string | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function useFleetBreadcrumb(dashboardId: string | undefined): UseFleetBreadcrumbResult;
|
|
20
|
+
export {};
|
|
@@ -47,6 +47,9 @@ function c(c) {
|
|
|
47
47
|
d,
|
|
48
48
|
p,
|
|
49
49
|
u
|
|
50
|
-
]),
|
|
50
|
+
]), {
|
|
51
|
+
ancestors: f.length > 0 && m.key === p ? m.items : [],
|
|
52
|
+
directMasterId: f.length > 0 ? f[f.length - 1] ?? null : null
|
|
53
|
+
};
|
|
51
54
|
}
|
|
52
55
|
export { c as useFleetBreadcrumb };
|
|
@@ -30,6 +30,8 @@ interface UseFleetChildrenResult {
|
|
|
30
30
|
loading: boolean;
|
|
31
31
|
error: Error | null;
|
|
32
32
|
isMaster: boolean;
|
|
33
|
+
/** Where the board's own link to a master stands: a linked copy is ACTIVE, null follows none. */
|
|
34
|
+
linkStatus: 'ACTIVE' | 'PENDING' | null;
|
|
33
35
|
summary: FleetChildrenSummary | null;
|
|
34
36
|
refetch: () => Promise<void>;
|
|
35
37
|
}
|
|
@@ -8,6 +8,7 @@ function l(l, u) {
|
|
|
8
8
|
let { workspaceId: d, currentUser: f } = e(), p = c(), m = `${d ?? ""}:${f?.id ?? ""}:${l ?? ""}`, [h, g] = s({
|
|
9
9
|
key: "",
|
|
10
10
|
isMaster: !1,
|
|
11
|
+
linkStatus: null,
|
|
11
12
|
summary: null,
|
|
12
13
|
error: null
|
|
13
14
|
}), [_, v] = s(u && !!l), y = o(m), b = o(0);
|
|
@@ -23,14 +24,14 @@ function l(l, u) {
|
|
|
23
24
|
};
|
|
24
25
|
try {
|
|
25
26
|
v(!0);
|
|
26
|
-
let e =
|
|
27
|
+
let e = await p.query({
|
|
27
28
|
query: t,
|
|
28
29
|
variables: { id: l },
|
|
29
30
|
fetchPolicy: "no-cache",
|
|
30
31
|
errorPolicy: "none",
|
|
31
32
|
context: i
|
|
32
|
-
})
|
|
33
|
-
if (
|
|
33
|
+
}), a = e.data?.getDashboard?.isMaster === !0, o = e.data?.getDashboard?.linkStatus, s = o === "ACTIVE" || o === "PENDING" ? o : null, c = null;
|
|
34
|
+
if (a) {
|
|
34
35
|
let e = (await p.query({
|
|
35
36
|
query: n,
|
|
36
37
|
variables: { masterDashboardId: l },
|
|
@@ -38,7 +39,7 @@ function l(l, u) {
|
|
|
38
39
|
errorPolicy: "none",
|
|
39
40
|
context: i
|
|
40
41
|
})).data?.dashboardChildren;
|
|
41
|
-
e && (
|
|
42
|
+
e && (c = {
|
|
42
43
|
total: e.total,
|
|
43
44
|
active: e.active,
|
|
44
45
|
pending: e.pending,
|
|
@@ -58,14 +59,16 @@ function l(l, u) {
|
|
|
58
59
|
}
|
|
59
60
|
r() && g({
|
|
60
61
|
key: m,
|
|
61
|
-
isMaster:
|
|
62
|
-
|
|
62
|
+
isMaster: a,
|
|
63
|
+
linkStatus: s,
|
|
64
|
+
summary: c,
|
|
63
65
|
error: null
|
|
64
66
|
});
|
|
65
67
|
} catch (e) {
|
|
66
68
|
r() && g({
|
|
67
69
|
key: m,
|
|
68
70
|
isMaster: !1,
|
|
71
|
+
linkStatus: null,
|
|
69
72
|
summary: null,
|
|
70
73
|
error: e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the copies of this board")
|
|
71
74
|
});
|
|
@@ -86,6 +89,7 @@ function l(l, u) {
|
|
|
86
89
|
loading: _ || u && !S,
|
|
87
90
|
error: S ? h.error : null,
|
|
88
91
|
isMaster: S && h.isMaster,
|
|
92
|
+
linkStatus: S ? h.linkStatus : null,
|
|
89
93
|
summary: S ? h.summary : null,
|
|
90
94
|
refetch: x
|
|
91
95
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FlagAnswer } from '../utils/fleetFlags';
|
|
2
|
+
export interface RestoreNotice {
|
|
3
|
+
code: string;
|
|
4
|
+
pageName: string;
|
|
5
|
+
widgetId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RestoreCounts {
|
|
8
|
+
widgetsRestored: number;
|
|
9
|
+
widgetsBroughtBack: number;
|
|
10
|
+
localWidgetsKept: number;
|
|
11
|
+
}
|
|
12
|
+
export interface RestoreOutcome extends RestoreCounts {
|
|
13
|
+
notices: RestoreNotice[];
|
|
14
|
+
}
|
|
15
|
+
interface UseFleetCopyActionsResult {
|
|
16
|
+
busy: boolean;
|
|
17
|
+
/** Answers a flag. Returns what could not be carried over exactly when the master's version was taken. */
|
|
18
|
+
resolveFlag: (flagId: string, answer: FlagAnswer) => Promise<RestoreNotice[]>;
|
|
19
|
+
previewRestore: (dashboardId: string) => Promise<RestoreCounts>;
|
|
20
|
+
restore: (dashboardId: string) => Promise<RestoreOutcome>;
|
|
21
|
+
}
|
|
22
|
+
export declare function useFleetCopyActions(): UseFleetCopyActionsResult;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { PreviewRestoreDashboardToOriginalDocument as e, ResolveWidgetFlagDocument as t, RestoreDashboardToOriginalDocument as n } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { BigConsoleWidgetFlagAnswer as r } from "../../generated/wspace-types.js";
|
|
3
|
+
import { useCallback as i, useState as a } from "react";
|
|
4
|
+
import { useApolloClient as o } from "@apollo/client/react";
|
|
5
|
+
// src/bigconsole/hooks/useFleetCopyActions.ts
|
|
6
|
+
var s = (e) => {
|
|
7
|
+
switch (e) {
|
|
8
|
+
case "ACCEPTED_MASTER": return r.AcceptedMaster;
|
|
9
|
+
case "REMOVED": return r.Removed;
|
|
10
|
+
default: return r.KeptLocal;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function c() {
|
|
14
|
+
let r = o(), [c, l] = a(!1), u = i(async (e) => {
|
|
15
|
+
l(!0);
|
|
16
|
+
try {
|
|
17
|
+
return await e();
|
|
18
|
+
} finally {
|
|
19
|
+
l(!1);
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
return {
|
|
23
|
+
busy: c,
|
|
24
|
+
resolveFlag: i((e, n) => u(async () => {
|
|
25
|
+
let i = await r.mutate({
|
|
26
|
+
mutation: t,
|
|
27
|
+
variables: {
|
|
28
|
+
flagId: e,
|
|
29
|
+
answer: s(n)
|
|
30
|
+
},
|
|
31
|
+
errorPolicy: "none"
|
|
32
|
+
});
|
|
33
|
+
if (!i.data?.resolveWidgetFlag) throw Error("The flag could not be answered.");
|
|
34
|
+
return i.data.resolveWidgetFlag.notices.map((e) => ({
|
|
35
|
+
code: e.code,
|
|
36
|
+
pageName: e.pageName,
|
|
37
|
+
widgetId: e.widgetId
|
|
38
|
+
}));
|
|
39
|
+
}), [r, u]),
|
|
40
|
+
previewRestore: i((t) => u(async () => {
|
|
41
|
+
let n = (await r.query({
|
|
42
|
+
query: e,
|
|
43
|
+
variables: { dashboardId: t },
|
|
44
|
+
fetchPolicy: "no-cache",
|
|
45
|
+
errorPolicy: "none"
|
|
46
|
+
})).data?.previewRestoreDashboardToOriginal;
|
|
47
|
+
if (!n) throw Error("The preview could not be made.");
|
|
48
|
+
return {
|
|
49
|
+
widgetsRestored: n.widgetsRestored,
|
|
50
|
+
widgetsBroughtBack: n.widgetsBroughtBack,
|
|
51
|
+
localWidgetsKept: n.localWidgetsKept
|
|
52
|
+
};
|
|
53
|
+
}), [r, u]),
|
|
54
|
+
restore: i((e) => u(async () => {
|
|
55
|
+
let t = (await r.mutate({
|
|
56
|
+
mutation: n,
|
|
57
|
+
variables: { dashboardId: e },
|
|
58
|
+
errorPolicy: "none"
|
|
59
|
+
})).data?.restoreDashboardToOriginal;
|
|
60
|
+
if (!t) throw Error("The board could not be restored.");
|
|
61
|
+
return {
|
|
62
|
+
widgetsRestored: t.widgetsRestored,
|
|
63
|
+
widgetsBroughtBack: t.widgetsBroughtBack,
|
|
64
|
+
localWidgetsKept: t.localWidgetsKept,
|
|
65
|
+
notices: t.notices.map((e) => ({
|
|
66
|
+
code: e.code,
|
|
67
|
+
pageName: e.pageName,
|
|
68
|
+
widgetId: e.widgetId
|
|
69
|
+
}))
|
|
70
|
+
};
|
|
71
|
+
}), [r, u])
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export { c as useFleetCopyActions };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FlagType } from '../utils/fleetFlags';
|
|
2
|
+
export interface FleetFlag {
|
|
3
|
+
id: string;
|
|
4
|
+
widgetId: string;
|
|
5
|
+
widgetTitle: string;
|
|
6
|
+
type: FlagType | string;
|
|
7
|
+
changedFields: string[];
|
|
8
|
+
}
|
|
9
|
+
interface UseFleetFlagsResult {
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
flags: FleetFlag[];
|
|
13
|
+
refetch: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function useFleetFlags(dashboardId: string | undefined, enabled: boolean): UseFleetFlagsResult;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import "../context/index.js";
|
|
2
|
+
import { useBigConsole as e } from "../context/BigConsoleContext.js";
|
|
3
|
+
import { FleetWidgetFlagsDocument as t } from "../../generated/wspace-operations.js";
|
|
4
|
+
import { openFlags as n } from "../utils/fleetFlags.js";
|
|
5
|
+
import { useCallback as r, useEffect as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
|
|
6
|
+
import { useApolloClient as c } from "@apollo/client/react";
|
|
7
|
+
// src/bigconsole/hooks/useFleetFlags.ts
|
|
8
|
+
var l = [], u = 100, d = 50;
|
|
9
|
+
function f(f, p) {
|
|
10
|
+
let { workspaceId: m, currentUser: h } = e(), g = c(), _ = `${m ?? ""}:${h?.id ?? ""}:${f ?? ""}`, [v, y] = s({
|
|
11
|
+
key: "",
|
|
12
|
+
flags: l,
|
|
13
|
+
error: null
|
|
14
|
+
}), [b, x] = s(p && !!f), S = o(_), C = o(0);
|
|
15
|
+
a(() => (S.current = _, () => {
|
|
16
|
+
S.current = "", C.current += 1;
|
|
17
|
+
}), [_]);
|
|
18
|
+
let w = r(async () => {
|
|
19
|
+
if (!f) return;
|
|
20
|
+
let e = ++C.current, r = () => S.current === _ && C.current === e;
|
|
21
|
+
try {
|
|
22
|
+
x(!0);
|
|
23
|
+
let e = [];
|
|
24
|
+
for (let n = 0; n < d; n += 1) {
|
|
25
|
+
let r = (await g.query({
|
|
26
|
+
query: t,
|
|
27
|
+
variables: {
|
|
28
|
+
dashboardId: f,
|
|
29
|
+
offset: n * u
|
|
30
|
+
},
|
|
31
|
+
fetchPolicy: "no-cache",
|
|
32
|
+
errorPolicy: "none",
|
|
33
|
+
context: {
|
|
34
|
+
requiredWorkspaceAuth: !0,
|
|
35
|
+
requiredWorkspaceId: m,
|
|
36
|
+
queryDeduplication: !1
|
|
37
|
+
}
|
|
38
|
+
})).data?.dashboardWidgetFlags ?? [];
|
|
39
|
+
if (e.push(...r), r.length < u) break;
|
|
40
|
+
}
|
|
41
|
+
let i = n(e).map((e) => ({
|
|
42
|
+
id: e.id,
|
|
43
|
+
widgetId: e.widgetId,
|
|
44
|
+
widgetTitle: e.widgetTitle,
|
|
45
|
+
type: e.type,
|
|
46
|
+
changedFields: e.changedFields
|
|
47
|
+
}));
|
|
48
|
+
r() && y({
|
|
49
|
+
key: _,
|
|
50
|
+
flags: i,
|
|
51
|
+
error: null
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
r() && y({
|
|
55
|
+
key: _,
|
|
56
|
+
flags: l,
|
|
57
|
+
error: e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the flags")
|
|
58
|
+
});
|
|
59
|
+
} finally {
|
|
60
|
+
r() && x(!1);
|
|
61
|
+
}
|
|
62
|
+
}, [
|
|
63
|
+
g,
|
|
64
|
+
f,
|
|
65
|
+
_,
|
|
66
|
+
m
|
|
67
|
+
]);
|
|
68
|
+
i(() => {
|
|
69
|
+
p && w();
|
|
70
|
+
}, [p, w]);
|
|
71
|
+
let T = v.key === _;
|
|
72
|
+
return {
|
|
73
|
+
loading: b || p && !T,
|
|
74
|
+
error: T ? v.error : null,
|
|
75
|
+
flags: T ? v.flags : l,
|
|
76
|
+
refetch: w
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export { f as useFleetFlags };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useOwnerBoundRun (BOFF-15410)
|
|
3
|
+
*
|
|
4
|
+
* Runs an action of a fleet panel, then shows its outcome, then reads the board again, in a way that cannot
|
|
5
|
+
* leak across boards, workspaces or accounts:
|
|
6
|
+
*
|
|
7
|
+
* - the outcome is shown only if the panel is still on the owner (board, workspace and account) the action
|
|
8
|
+
* started for, so an answer that arrives after the person moved on is dropped before it touches any state;
|
|
9
|
+
* - a failed re-read is not a failed action: the action already happened, and the read reports its own failure;
|
|
10
|
+
* - `acting` stays true until the re-read is done, not only until the action returns, so a second click cannot
|
|
11
|
+
* start a second action in the gap.
|
|
12
|
+
*
|
|
13
|
+
* When the owner changes, `onOwnerChange` lets the panel drop the state that belonged to the previous one.
|
|
14
|
+
*
|
|
15
|
+
* Two sections of one panel can share a lock (`useActionLock`), so an action in one holds the buttons of the
|
|
16
|
+
* other: a board that is both a copy and a master must not start a push while a restore is still running.
|
|
17
|
+
* A run that finishes after the panel went away is dropped too: it must not touch a board the person left.
|
|
18
|
+
*/
|
|
19
|
+
/** The state of an action lock: which owner has an action running, or null. */
|
|
20
|
+
export type ActionLock = readonly [string | null, (owner: string | null) => void];
|
|
21
|
+
/** One lock for the sections of a panel to share. */
|
|
22
|
+
export declare function useActionLock(): ActionLock;
|
|
23
|
+
interface UseOwnerBoundRunResult {
|
|
24
|
+
acting: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Notes the owner now and returns a check that stays true only while the panel is still on it. Call it before
|
|
27
|
+
* anything that waits (a confirmation prompt), and check after: the person may have left in the meantime.
|
|
28
|
+
*/
|
|
29
|
+
begin: () => () => boolean;
|
|
30
|
+
run: <T>(action: () => Promise<T>, onSuccess: (value: T) => void, onError: (err: unknown) => void) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare function useOwnerBoundRun(owner: string, afterwards: () => Promise<void>, onOwnerChange: () => void, lock?: ActionLock): UseOwnerBoundRunResult;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
|
+
// src/bigconsole/hooks/useOwnerBoundRun.ts
|
|
3
|
+
function a() {
|
|
4
|
+
return i(null);
|
|
5
|
+
}
|
|
6
|
+
function o(a, o, s, c) {
|
|
7
|
+
let l = i(null), [u, d] = c ?? l, f = r(!0), p = r(a), m = r(s);
|
|
8
|
+
n(() => {
|
|
9
|
+
m.current = s;
|
|
10
|
+
}, [s]), t(() => (f.current = !0, () => {
|
|
11
|
+
f.current = !1;
|
|
12
|
+
}), []), t(() => {
|
|
13
|
+
p.current !== a && (p.current = a, m.current());
|
|
14
|
+
}, [a]);
|
|
15
|
+
let h = e(async (e, t, n) => {
|
|
16
|
+
let r = p.current, i = () => !f.current || p.current !== r;
|
|
17
|
+
d(r);
|
|
18
|
+
try {
|
|
19
|
+
let r;
|
|
20
|
+
try {
|
|
21
|
+
r = await e();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
i() || n(e);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (i()) return;
|
|
27
|
+
t(r), await o();
|
|
28
|
+
} finally {
|
|
29
|
+
i() || d(null);
|
|
30
|
+
}
|
|
31
|
+
}, [o, d]), g = e(() => {
|
|
32
|
+
let e = p.current;
|
|
33
|
+
return () => f.current && p.current === e;
|
|
34
|
+
}, []);
|
|
35
|
+
return {
|
|
36
|
+
acting: u === a,
|
|
37
|
+
begin: g,
|
|
38
|
+
run: h
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { a as useActionLock, o as useOwnerBoundRun };
|