@burdenoff/microfe-bigconsole 2026.1124.1 → 2026.1124.3
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 +12 -0
- package/dist/bigconsole/components/fleet/FleetChildrenPanel.js +179 -184
- package/dist/bigconsole/components/fleet/FleetCopySection.d.ts +18 -0
- package/dist/bigconsole/components/fleet/FleetCopySection.js +263 -0
- package/dist/bigconsole/components/fleet/FleetWidgetActions.d.ts +36 -0
- package/dist/bigconsole/components/fleet/FleetWidgetActions.js +82 -0
- package/dist/bigconsole/components/widgets/WidgetMenu.js +146 -96
- 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/useFleetConfirm.d.ts +7 -0
- package/dist/bigconsole/hooks/useFleetConfirm.js +17 -0
- 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/useFleetWidgetActions.d.ts +10 -0
- package/dist/bigconsole/hooks/useFleetWidgetActions.js +41 -0
- package/dist/bigconsole/hooks/useOwnerBoundRun.d.ts +28 -0
- package/dist/bigconsole/hooks/useOwnerBoundRun.js +56 -0
- package/dist/bigconsole/hooks/useWidgetOperations.js +2 -0
- package/dist/bigconsole/pages/DashboardViewPage.js +335 -320
- package/dist/bigconsole/pages/DashboardsPage.js +13 -13
- package/dist/bigconsole/types/index.d.ts +4 -0
- package/dist/bigconsole/utils/fleetFlags.d.ts +22 -0
- package/dist/bigconsole/utils/fleetFlags.js +40 -0
- package/dist/bigconsole/utils/fleetNotices.d.ts +12 -0
- package/dist/bigconsole/utils/fleetNotices.js +5 -0
- package/dist/bigconsole/utils/fleetTree.d.ts +9 -0
- package/dist/bigconsole/utils/fleetTree.js +5 -1
- package/dist/bigconsole/utils/fleetWidgetMenu.d.ts +20 -0
- package/dist/bigconsole/utils/fleetWidgetMenu.js +13 -0
- package/dist/generated/wspace-operations.d.ts +155 -0
- package/dist/generated/wspace-operations.js +928 -99
- package/dist/generated/wspace-types.d.ts +395 -9
- package/dist/generated/wspace-types.js +6 -4
- package/package.json +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { useBigConsole as e } from "../../context/BigConsoleContext.js";
|
|
2
|
+
import { BIGCONSOLE_PERMISSIONS as t } from "../../../constants/permissions.js";
|
|
3
|
+
import { useTr as n } from "../../../shared/hooks/useTr.js";
|
|
4
|
+
import "../../context/index.js";
|
|
5
|
+
import { useFleetConfirm as r } from "../../hooks/useFleetConfirm.js";
|
|
6
|
+
import { useFleetCopyActions as i } from "../../hooks/useFleetCopyActions.js";
|
|
7
|
+
import { useFleetFlags as ee } from "../../hooks/useFleetFlags.js";
|
|
8
|
+
import { useOwnerBoundRun as a } from "../../hooks/useOwnerBoundRun.js";
|
|
9
|
+
import { allowedAnswers as o, changedFieldLabel as s, restoreIsEmpty as c } from "../../utils/fleetFlags.js";
|
|
10
|
+
import { restoreNoticeText as l } from "../../utils/fleetNotices.js";
|
|
11
|
+
import { memo as u, useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import { PermissionButton as h } from "@burdenoff/fe-libs/shared/components";
|
|
13
|
+
import { Button as g, Spinner as _ } from "@burdenoff/fe-libs/ui";
|
|
14
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
// src/bigconsole/components/fleet/FleetCopySection.tsx
|
|
16
|
+
var b = (e, t) => e instanceof Error && e.message ? e.message : t, x = u(function({ dashboardId: u, masterName: x, onBoardChanged: S, lock: C, changeToken: w }) {
|
|
17
|
+
let T = n(), { workspaceId: E, currentUser: D } = e(), O = `${E ?? ""}:${D?.id ?? ""}:${u}`, { loading: k, error: A, flags: j, refetch: M } = ee(u, !0), N = i(), P = p(w);
|
|
18
|
+
f(() => {
|
|
19
|
+
w !== P.current && (P.current = w, I((e) => e.phase === "preview" ? { phase: "idle" } : e), M());
|
|
20
|
+
}, [w, M]);
|
|
21
|
+
let [F, I] = m({ phase: "idle" }), [L, R] = m(null), [z, B] = m([]), V = d(() => {
|
|
22
|
+
I({ phase: "idle" }), R(null), B([]);
|
|
23
|
+
}, []), H = d(async () => {
|
|
24
|
+
await M(), await S?.();
|
|
25
|
+
}, [S, M]), { acting: U, begin: W, run: G } = a(O, H, V, C), K = N.busy || U, q = r(), J = (e) => l(T, e), Y = (e, t) => e === "ACCEPTED_MASTER" ? T("bigconsole.fleet.flags.accept", "Take the master's version") : e === "REMOVED" ? T("bigconsole.fleet.flags.remove", "Remove it") : t === "MASTER_REMOVED" ? T("bigconsole.fleet.flags.keepRemoved", "Keep it") : T("bigconsole.fleet.flags.keep", "Keep mine"), X = d(async (e, t) => {
|
|
26
|
+
let n = W();
|
|
27
|
+
if (t === "ACCEPTED_MASTER") {
|
|
28
|
+
if (!await q(T("bigconsole.fleet.flags.acceptTitle", "Take the master's version?"), T("bigconsole.fleet.flags.acceptConfirm", "\"{{title}}\" goes back to the master's version. Your changes to it are lost.", { title: e.widgetTitle }), T("bigconsole.fleet.flags.acceptOk", "Take it")) || !n()) return;
|
|
29
|
+
} else if (t === "REMOVED" && (!await q(T("bigconsole.fleet.flags.removeTitle", "Remove this widget?"), T("bigconsole.fleet.flags.removeConfirm", "\"{{title}}\" is removed from this board. A push does not give it back.", { title: e.widgetTitle }), T("bigconsole.fleet.flags.removeOk", "Remove")) || !n())) return;
|
|
30
|
+
R(null), B([]), await G(() => N.resolveFlag(e.id, t), (n) => {
|
|
31
|
+
I({ phase: "idle" }), B(n), R({
|
|
32
|
+
tone: "ok",
|
|
33
|
+
text: t === "ACCEPTED_MASTER" ? T("bigconsole.fleet.flags.accepted", "\"{{title}}\" is back to the master's version.", { title: e.widgetTitle }) : t === "REMOVED" ? T("bigconsole.fleet.flags.removed", "\"{{title}}\" was removed.", { title: e.widgetTitle }) : T("bigconsole.fleet.flags.kept", "\"{{title}}\" is now your own. The master will not flag it again.", { title: e.widgetTitle })
|
|
34
|
+
});
|
|
35
|
+
}, (e) => R({
|
|
36
|
+
tone: "error",
|
|
37
|
+
text: b(e, T("bigconsole.fleet.error.flag", "The flag could not be answered."))
|
|
38
|
+
}));
|
|
39
|
+
}, [
|
|
40
|
+
N,
|
|
41
|
+
W,
|
|
42
|
+
q,
|
|
43
|
+
G,
|
|
44
|
+
T
|
|
45
|
+
]), Z = d(() => (R(null), B([]), G(() => N.previewRestore(u), (e) => I({
|
|
46
|
+
phase: "preview",
|
|
47
|
+
counts: e
|
|
48
|
+
}), (e) => R({
|
|
49
|
+
tone: "error",
|
|
50
|
+
text: b(e, T("bigconsole.fleet.error.restorePreview", "The preview could not be made."))
|
|
51
|
+
}))), [
|
|
52
|
+
N,
|
|
53
|
+
u,
|
|
54
|
+
G,
|
|
55
|
+
T
|
|
56
|
+
]), Q = d(async () => {
|
|
57
|
+
let e = W();
|
|
58
|
+
await q(T("bigconsole.fleet.restore.title", "Restore this board to its original?"), T("bigconsole.fleet.restore.confirm", "Edited widgets go back to the master's version and removed ones come back. Your own widgets stay."), T("bigconsole.fleet.restore.ok", "Restore")) && e() && (R(null), await G(() => N.restore(u), (e) => {
|
|
59
|
+
I({
|
|
60
|
+
phase: "done",
|
|
61
|
+
counts: e
|
|
62
|
+
}), B(e.notices);
|
|
63
|
+
}, (e) => R({
|
|
64
|
+
tone: "error",
|
|
65
|
+
text: b(e, T("bigconsole.fleet.error.restore", "The board could not be restored."))
|
|
66
|
+
})));
|
|
67
|
+
}, [
|
|
68
|
+
N,
|
|
69
|
+
W,
|
|
70
|
+
q,
|
|
71
|
+
u,
|
|
72
|
+
G,
|
|
73
|
+
T
|
|
74
|
+
]), $ = (e, t) => t ? T("bigconsole.fleet.restore.done", "{{restored}} edited widgets went back to the master's version, {{back}} removed ones came back, {{kept}} of your own stayed.", {
|
|
75
|
+
restored: e.widgetsRestored,
|
|
76
|
+
back: e.widgetsBroughtBack,
|
|
77
|
+
kept: e.localWidgetsKept
|
|
78
|
+
}) : T("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.", {
|
|
79
|
+
restored: e.widgetsRestored,
|
|
80
|
+
back: e.widgetsBroughtBack,
|
|
81
|
+
kept: e.localWidgetsKept
|
|
82
|
+
});
|
|
83
|
+
return /* @__PURE__ */ y("div", {
|
|
84
|
+
className: "flex flex-col gap-form-gap",
|
|
85
|
+
"data-testid": "fleet-copy-section",
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ v("p", {
|
|
88
|
+
style: {
|
|
89
|
+
margin: 0,
|
|
90
|
+
color: "var(--color-text-secondary)",
|
|
91
|
+
fontSize: "var(--font-size-body-sm)"
|
|
92
|
+
},
|
|
93
|
+
children: x ? T("bigconsole.fleet.copy.follows", "This board is a linked copy of \"{{name}}\".", { name: x }) : T("bigconsole.fleet.copy.followsUnknown", "This board is a linked copy of another board.")
|
|
94
|
+
}),
|
|
95
|
+
L && /* @__PURE__ */ v("p", {
|
|
96
|
+
role: L.tone === "error" ? "alert" : "status",
|
|
97
|
+
"data-testid": "fleet-copy-message",
|
|
98
|
+
style: {
|
|
99
|
+
margin: 0,
|
|
100
|
+
color: L.tone === "error" ? "var(--color-status-error-text)" : "var(--color-text-primary)",
|
|
101
|
+
fontSize: "var(--font-size-body-sm)"
|
|
102
|
+
},
|
|
103
|
+
children: L.text
|
|
104
|
+
}),
|
|
105
|
+
z.length > 0 && /* @__PURE__ */ v("ul", {
|
|
106
|
+
"data-testid": "fleet-copy-notices",
|
|
107
|
+
style: {
|
|
108
|
+
margin: 0,
|
|
109
|
+
paddingLeft: "1.25rem",
|
|
110
|
+
color: "var(--color-text-secondary)",
|
|
111
|
+
fontSize: "var(--font-size-body-sm)"
|
|
112
|
+
},
|
|
113
|
+
children: z.map((e, t) => /* @__PURE__ */ v("li", { children: J(e) }, `${e.widgetId}-${t}`))
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ v("strong", {
|
|
116
|
+
style: { color: "var(--color-text-primary)" },
|
|
117
|
+
children: T("bigconsole.fleet.flags.title", "Waiting for your answer")
|
|
118
|
+
}),
|
|
119
|
+
k && j.length === 0 && /* @__PURE__ */ y("div", {
|
|
120
|
+
className: "flex items-center gap-2",
|
|
121
|
+
style: { color: "var(--color-text-secondary)" },
|
|
122
|
+
children: [/* @__PURE__ */ v(_, { style: {
|
|
123
|
+
height: "var(--size-icon-sm)",
|
|
124
|
+
width: "var(--size-icon-sm)"
|
|
125
|
+
} }), T("bigconsole.fleet.flags.loading", "Loading…")]
|
|
126
|
+
}),
|
|
127
|
+
!k && A && /* @__PURE__ */ v("p", {
|
|
128
|
+
role: "alert",
|
|
129
|
+
style: {
|
|
130
|
+
margin: 0,
|
|
131
|
+
color: "var(--color-status-error-text)"
|
|
132
|
+
},
|
|
133
|
+
children: T("bigconsole.fleet.flags.loadError", "The flags on this board could not be loaded.")
|
|
134
|
+
}),
|
|
135
|
+
!k && !A && j.length === 0 && /* @__PURE__ */ v("p", {
|
|
136
|
+
"data-testid": "fleet-flags-none",
|
|
137
|
+
style: {
|
|
138
|
+
margin: 0,
|
|
139
|
+
color: "var(--color-text-secondary)",
|
|
140
|
+
fontSize: "var(--font-size-body-sm)"
|
|
141
|
+
},
|
|
142
|
+
children: T("bigconsole.fleet.flags.none", "Nothing. The master has no change waiting for you.")
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ v("ul", {
|
|
145
|
+
className: "flex flex-col gap-1",
|
|
146
|
+
style: {
|
|
147
|
+
listStyle: "none",
|
|
148
|
+
margin: 0,
|
|
149
|
+
padding: 0
|
|
150
|
+
},
|
|
151
|
+
children: j.map((e) => /* @__PURE__ */ y("li", {
|
|
152
|
+
"data-testid": "fleet-flag",
|
|
153
|
+
className: "flex flex-col gap-2 rounded-input border px-3 py-2",
|
|
154
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ v("span", {
|
|
157
|
+
style: { color: "var(--color-text-primary)" },
|
|
158
|
+
children: e.widgetTitle
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ v("span", {
|
|
161
|
+
style: {
|
|
162
|
+
color: "var(--color-text-secondary)",
|
|
163
|
+
fontSize: "var(--font-size-body-sm)"
|
|
164
|
+
},
|
|
165
|
+
children: e.type === "MASTER_REMOVED" ? T("bigconsole.fleet.flags.removedByMaster", "The master removed this widget. It stays on your board until you answer.") : T("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) => {
|
|
166
|
+
let t = s(e);
|
|
167
|
+
return t ? T(t.key, t.fallback) : e;
|
|
168
|
+
}).join(", ") })
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ v(h, {
|
|
171
|
+
permission: t.DASHBOARD_UPDATE,
|
|
172
|
+
deniedBehavior: "hide",
|
|
173
|
+
children: /* @__PURE__ */ v("span", {
|
|
174
|
+
className: "flex flex-wrap gap-2",
|
|
175
|
+
children: o(e.type).map((t) => /* @__PURE__ */ v(g, {
|
|
176
|
+
size: "sm",
|
|
177
|
+
variant: t === "REMOVED" ? "ghost" : "outline",
|
|
178
|
+
disabled: K,
|
|
179
|
+
onClick: () => void X(e, t),
|
|
180
|
+
"data-testid": `fleet-flag-${t}`,
|
|
181
|
+
children: Y(t, e.type)
|
|
182
|
+
}, t))
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
}, e.id))
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ v("strong", {
|
|
189
|
+
style: { color: "var(--color-text-primary)" },
|
|
190
|
+
children: T("bigconsole.fleet.restore.heading", "Back to the original")
|
|
191
|
+
}),
|
|
192
|
+
F.phase === "idle" && /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(h, {
|
|
193
|
+
permission: t.DASHBOARD_UPDATE,
|
|
194
|
+
deniedBehavior: "hide",
|
|
195
|
+
children: /* @__PURE__ */ v(g, {
|
|
196
|
+
variant: "outline",
|
|
197
|
+
onClick: Z,
|
|
198
|
+
disabled: K,
|
|
199
|
+
"data-testid": "fleet-restore",
|
|
200
|
+
children: T("bigconsole.fleet.restore.start", "Restore board to original…")
|
|
201
|
+
})
|
|
202
|
+
}) }),
|
|
203
|
+
F.phase === "preview" && /* @__PURE__ */ y("div", {
|
|
204
|
+
className: "flex flex-col gap-form-gap rounded-input border p-3",
|
|
205
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
206
|
+
"data-testid": "fleet-restore-preview",
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ v("span", {
|
|
209
|
+
style: { color: "var(--color-text-primary)" },
|
|
210
|
+
children: T("bigconsole.fleet.restore.previewTitle", "Preview: nothing has been changed yet")
|
|
211
|
+
}),
|
|
212
|
+
/* @__PURE__ */ v("span", {
|
|
213
|
+
"data-testid": "fleet-restore-counts",
|
|
214
|
+
style: {
|
|
215
|
+
color: "var(--color-text-secondary)",
|
|
216
|
+
fontSize: "var(--font-size-body-sm)"
|
|
217
|
+
},
|
|
218
|
+
children: $(F.counts, !1)
|
|
219
|
+
}),
|
|
220
|
+
c(F.counts) && /* @__PURE__ */ v("span", {
|
|
221
|
+
style: {
|
|
222
|
+
color: "var(--color-text-secondary)",
|
|
223
|
+
fontSize: "var(--font-size-body-sm)"
|
|
224
|
+
},
|
|
225
|
+
children: T("bigconsole.fleet.restore.nothing", "Nothing to restore: this board already matches its master.")
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ y("div", {
|
|
228
|
+
className: "flex gap-2",
|
|
229
|
+
children: [/* @__PURE__ */ y(g, {
|
|
230
|
+
onClick: () => void Q(),
|
|
231
|
+
disabled: K || c(F.counts),
|
|
232
|
+
"data-testid": "fleet-restore-confirm",
|
|
233
|
+
children: [K && /* @__PURE__ */ v(_, { style: {
|
|
234
|
+
height: "var(--size-icon-sm)",
|
|
235
|
+
width: "var(--size-icon-sm)"
|
|
236
|
+
} }), T("bigconsole.fleet.restore.ok", "Restore")]
|
|
237
|
+
}), /* @__PURE__ */ v(g, {
|
|
238
|
+
variant: "outline",
|
|
239
|
+
onClick: () => I({ phase: "idle" }),
|
|
240
|
+
disabled: K,
|
|
241
|
+
children: T("bigconsole.fleet.link.cancel", "Cancel")
|
|
242
|
+
})]
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
}),
|
|
246
|
+
F.phase === "done" && /* @__PURE__ */ y("div", {
|
|
247
|
+
className: "flex flex-col gap-form-gap rounded-input border p-3",
|
|
248
|
+
style: { borderColor: "var(--color-border-subtle)" },
|
|
249
|
+
"data-testid": "fleet-restore-done",
|
|
250
|
+
children: [/* @__PURE__ */ v("span", {
|
|
251
|
+
"data-testid": "fleet-restore-result",
|
|
252
|
+
style: { color: "var(--color-text-primary)" },
|
|
253
|
+
children: $(F.counts, !0)
|
|
254
|
+
}), /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(g, {
|
|
255
|
+
variant: "outline",
|
|
256
|
+
onClick: () => I({ phase: "idle" }),
|
|
257
|
+
children: T("bigconsole.fleet.push.done", "Done")
|
|
258
|
+
}) })]
|
|
259
|
+
})
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
export { x as FleetCopySection, x as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ActionLock } from '../../hooks/useOwnerBoundRun';
|
|
3
|
+
/** What the widget menu needs to know about a widget. */
|
|
4
|
+
export interface FleetMenuWidget {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FleetWidgetMenuValue {
|
|
9
|
+
/** The board follows a master (an active link) whose board the caller can read. */
|
|
10
|
+
isActiveCopy: boolean;
|
|
11
|
+
/** An action is running: the menu items are held until it is done. */
|
|
12
|
+
busy: boolean;
|
|
13
|
+
/** The words of the two menu items, so the menu itself needs no translation provider. */
|
|
14
|
+
labels: {
|
|
15
|
+
restore: string;
|
|
16
|
+
promote: string;
|
|
17
|
+
};
|
|
18
|
+
restore: (widget: FleetMenuWidget) => Promise<void>;
|
|
19
|
+
promote: (widget: FleetMenuWidget) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** The fleet actions of the widget menu, or null where the board offers none. */
|
|
22
|
+
export declare function useFleetWidgetMenu(): FleetWidgetMenuValue | null;
|
|
23
|
+
export interface FleetWidgetActionsProviderProps {
|
|
24
|
+
dashboardId: string;
|
|
25
|
+
isActiveCopy: boolean;
|
|
26
|
+
/** The board this one follows, when its name can be read. */
|
|
27
|
+
masterName: string | null;
|
|
28
|
+
/** Shared with the Children panel, so an action in one holds the buttons of the other. */
|
|
29
|
+
lock: ActionLock;
|
|
30
|
+
/** Reads the board's widgets again after an action. Awaited. */
|
|
31
|
+
onBoardChanged?: () => Promise<unknown> | void;
|
|
32
|
+
/** Called after an action changed this board, for the Children panel to read its flags again. */
|
|
33
|
+
onChanged?: () => void;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
export declare const FleetWidgetActionsProvider: FC<FleetWidgetActionsProviderProps>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useBigConsole as e } from "../../context/BigConsoleContext.js";
|
|
2
|
+
import { useTr as t } from "../../../shared/hooks/useTr.js";
|
|
3
|
+
import "../../context/index.js";
|
|
4
|
+
import { useFleetConfirm as n } from "../../hooks/useFleetConfirm.js";
|
|
5
|
+
import { useFleetWidgetActions as r } from "../../hooks/useFleetWidgetActions.js";
|
|
6
|
+
import { useOwnerBoundRun as i } from "../../hooks/useOwnerBoundRun.js";
|
|
7
|
+
import { restoreNoticeText as a } from "../../utils/fleetNotices.js";
|
|
8
|
+
import { createContext as o, useCallback as s, useContext as c, useLayoutEffect as l, useMemo as u, useRef as d } from "react";
|
|
9
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
10
|
+
import { toast as p } from "sonner";
|
|
11
|
+
// src/bigconsole/components/fleet/FleetWidgetActions.tsx
|
|
12
|
+
var m = o(null);
|
|
13
|
+
function h() {
|
|
14
|
+
return c(m);
|
|
15
|
+
}
|
|
16
|
+
var g = (e, t) => e instanceof Error && e.message ? e.message : t, _ = () => {}, v = ({ dashboardId: o, isActiveCopy: c, masterName: h, lock: v, onBoardChanged: y, onChanged: b, children: x }) => {
|
|
17
|
+
let S = t(), { workspaceId: C, currentUser: w } = e(), T = `${C ?? ""}:${w?.id ?? ""}:${o}`, E = r(), D = n(), O = d(c);
|
|
18
|
+
l(() => {
|
|
19
|
+
O.current = c;
|
|
20
|
+
}, [c]);
|
|
21
|
+
let k = s(async () => {
|
|
22
|
+
await y?.(), b?.();
|
|
23
|
+
}, [y, b]), { acting: A, begin: j, run: M } = i(T, k, _, v), N = A || E.busy, P = s((e) => {
|
|
24
|
+
for (let t of e) p.warning(a(S, t));
|
|
25
|
+
}, [S]), F = s(async (e) => {
|
|
26
|
+
if (N) return;
|
|
27
|
+
let t = j();
|
|
28
|
+
await D(S("bigconsole.fleet.widget.restoreTitle", "Restore to the master's version?"), S("bigconsole.fleet.widget.restoreConfirm", "\"{{title}}\" goes back to the master's version. Your changes to it are lost. Where it sits on the board is kept.", { title: e.title }), S("bigconsole.fleet.widget.restoreOk", "Restore")) && t() && O.current && await M(() => E.restoreWidget(e.id), (t) => {
|
|
29
|
+
p.success(S("bigconsole.fleet.widget.restored", "\"{{title}}\" is back to the master's version.", { title: e.title })), P(t);
|
|
30
|
+
}, (e) => p.error(g(e, S("bigconsole.fleet.error.widgetRestore", "The widget could not be restored."))));
|
|
31
|
+
}, [
|
|
32
|
+
E,
|
|
33
|
+
j,
|
|
34
|
+
N,
|
|
35
|
+
D,
|
|
36
|
+
M,
|
|
37
|
+
P,
|
|
38
|
+
S
|
|
39
|
+
]), I = s(async (e) => {
|
|
40
|
+
if (N) return;
|
|
41
|
+
let t = j(), n = h ? `"${h}"` : S("bigconsole.fleet.widget.theMaster", "the master");
|
|
42
|
+
await D(S("bigconsole.fleet.widget.promoteTitle", "Promote to the master?"), S("bigconsole.fleet.widget.promoteConfirm", "\"{{title}}\" is added to {{master}}, and this board's widget follows it from now on. The master's other copies get it with the next push.", {
|
|
43
|
+
title: e.title,
|
|
44
|
+
master: n
|
|
45
|
+
}), S("bigconsole.fleet.widget.promoteOk", "Promote")) && t() && O.current && await M(() => E.promoteWidget(e.id), (t) => {
|
|
46
|
+
p.success(S("bigconsole.fleet.widget.promoted", "\"{{title}}\" is now on {{master}}.", {
|
|
47
|
+
title: e.title,
|
|
48
|
+
master: n
|
|
49
|
+
})), P(t);
|
|
50
|
+
}, (e) => p.error(g(e, S("bigconsole.fleet.error.widgetPromote", "The widget could not be promoted."))));
|
|
51
|
+
}, [
|
|
52
|
+
E,
|
|
53
|
+
j,
|
|
54
|
+
N,
|
|
55
|
+
D,
|
|
56
|
+
h,
|
|
57
|
+
M,
|
|
58
|
+
P,
|
|
59
|
+
S
|
|
60
|
+
]), L = S("bigconsole.fleet.widget.restore", "Restore to master's version"), R = S("bigconsole.fleet.widget.promote", "Promote to master"), z = u(() => ({
|
|
61
|
+
isActiveCopy: c,
|
|
62
|
+
busy: N,
|
|
63
|
+
labels: {
|
|
64
|
+
restore: L,
|
|
65
|
+
promote: R
|
|
66
|
+
},
|
|
67
|
+
restore: F,
|
|
68
|
+
promote: I
|
|
69
|
+
}), [
|
|
70
|
+
c,
|
|
71
|
+
N,
|
|
72
|
+
L,
|
|
73
|
+
R,
|
|
74
|
+
F,
|
|
75
|
+
I
|
|
76
|
+
]);
|
|
77
|
+
return /* @__PURE__ */ f(m.Provider, {
|
|
78
|
+
value: z,
|
|
79
|
+
children: x
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
export { v as FleetWidgetActionsProvider, h as useFleetWidgetMenu };
|