camox 0.75.0 → 0.76.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.
- package/dist/features/provider/AuthenticatedCamoxProvider.js +75 -63
- package/dist/features/routes/pageRuntime.d.ts +6 -4
- package/dist/features/routes/pageRuntime.js +5 -1
- package/dist/features/studio/components/ChatWidget.js +137 -121
- package/dist/features/studio/components/ClearThread.js +121 -0
- package/dist/features/studio/components/DeleteDraftDialog.js +67 -65
- package/dist/features/studio/components/DraftBar.js +60 -49
- package/dist/features/studio/components/DraftNotices.js +149 -0
- package/dist/features/studio/components/DraftsControl.js +217 -180
- package/dist/features/studio/components/DraftsSheet.js +387 -0
- package/dist/features/studio/components/PublishedTab.js +511 -0
- package/dist/features/studio/components/ReviewDraftDialog.js +104 -89
- package/dist/features/studio/components/SheetTable.js +46 -0
- package/dist/features/studio/components/Specialists.js +1 -1
- package/dist/features/studio/components/ThreadMessages.js +222 -167
- package/dist/features/studio/draftLabel.js +15 -1
- package/dist/features/studio/draftNotice.js +1 -0
- package/dist/features/studio/studioStore.js +5 -5
- package/dist/features/studio/useArchiveDraft.js +60 -0
- package/dist/features/studio/useRestoreDraft.js +70 -0
- package/dist/features/studio/viewSwitch.js +19 -11
- package/dist/lib/draft-scope.d.ts +1 -1
- package/dist/lib/draft-scope.js +6 -3
- package/dist/lib/queries.js +12 -1
- package/dist/lib/studio-reads.js +22 -0
- package/dist/lib/use-project-room.js +19 -13
- package/dist/lib/use-thread.js +1 -1
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { publicationMutations } from "../../../lib/queries.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { Button } from "@camox/ui/button";
|
|
7
|
+
import { toast } from "@camox/ui/toaster";
|
|
8
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
9
|
+
import { Spinner } from "@camox/ui/spinner";
|
|
10
|
+
|
|
11
|
+
//#region src/features/studio/components/ClearThread.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Clear thread, for a Publication's thread a secret was pasted into: asks first, then wipes the
|
|
14
|
+
* thread for good. The Publication stays, so it can still be reverted (ADR 0045).
|
|
15
|
+
*/
|
|
16
|
+
function ClearThread(t0) {
|
|
17
|
+
const $ = c(24);
|
|
18
|
+
const { projectId, id } = t0;
|
|
19
|
+
const [open, setOpen] = React.useState(false);
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t1 = {
|
|
23
|
+
...publicationMutations.clearThread(),
|
|
24
|
+
onSuccess: () => setOpen(false),
|
|
25
|
+
onError: _temp
|
|
26
|
+
};
|
|
27
|
+
$[0] = t1;
|
|
28
|
+
} else t1 = $[0];
|
|
29
|
+
const clearThread = useMutation(t1);
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t2 = /* @__PURE__ */ jsx(Button, {
|
|
33
|
+
type: "button",
|
|
34
|
+
variant: "ghost",
|
|
35
|
+
size: "sm",
|
|
36
|
+
onClick: () => setOpen(true),
|
|
37
|
+
children: "Clear thread"
|
|
38
|
+
});
|
|
39
|
+
$[1] = t2;
|
|
40
|
+
} else t2 = $[1];
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[2] !== clearThread.isPending) {
|
|
43
|
+
t3 = (next) => {
|
|
44
|
+
if (!clearThread.isPending) setOpen(next);
|
|
45
|
+
};
|
|
46
|
+
$[2] = clearThread.isPending;
|
|
47
|
+
$[3] = t3;
|
|
48
|
+
} else t3 = $[3];
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
51
|
+
t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Clear this thread?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Its messages are deleted for everyone, for good. What was published, and what it replaced, stay. This can't be undone." })] });
|
|
52
|
+
$[4] = t4;
|
|
53
|
+
} else t4 = $[4];
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[5] !== clearThread.isPending) {
|
|
56
|
+
t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
57
|
+
variant: "outline",
|
|
58
|
+
size: "default",
|
|
59
|
+
disabled: clearThread.isPending,
|
|
60
|
+
children: "Cancel"
|
|
61
|
+
});
|
|
62
|
+
$[5] = clearThread.isPending;
|
|
63
|
+
$[6] = t5;
|
|
64
|
+
} else t5 = $[6];
|
|
65
|
+
let t6;
|
|
66
|
+
if ($[7] !== clearThread || $[8] !== id || $[9] !== projectId) {
|
|
67
|
+
t6 = () => clearThread.mutate({
|
|
68
|
+
projectId,
|
|
69
|
+
id
|
|
70
|
+
});
|
|
71
|
+
$[7] = clearThread;
|
|
72
|
+
$[8] = id;
|
|
73
|
+
$[9] = projectId;
|
|
74
|
+
$[10] = t6;
|
|
75
|
+
} else t6 = $[10];
|
|
76
|
+
let t7;
|
|
77
|
+
if ($[11] !== clearThread.isPending) {
|
|
78
|
+
t7 = clearThread.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
79
|
+
$[11] = clearThread.isPending;
|
|
80
|
+
$[12] = t7;
|
|
81
|
+
} else t7 = $[12];
|
|
82
|
+
let t8;
|
|
83
|
+
if ($[13] !== clearThread.isPending || $[14] !== t6 || $[15] !== t7) {
|
|
84
|
+
t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
85
|
+
variant: "destructive",
|
|
86
|
+
disabled: clearThread.isPending,
|
|
87
|
+
onClick: t6,
|
|
88
|
+
children: [t7, "Clear thread"]
|
|
89
|
+
});
|
|
90
|
+
$[13] = clearThread.isPending;
|
|
91
|
+
$[14] = t6;
|
|
92
|
+
$[15] = t7;
|
|
93
|
+
$[16] = t8;
|
|
94
|
+
} else t8 = $[16];
|
|
95
|
+
let t9;
|
|
96
|
+
if ($[17] !== t5 || $[18] !== t8) {
|
|
97
|
+
t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
|
|
98
|
+
$[17] = t5;
|
|
99
|
+
$[18] = t8;
|
|
100
|
+
$[19] = t9;
|
|
101
|
+
} else t9 = $[19];
|
|
102
|
+
let t10;
|
|
103
|
+
if ($[20] !== open || $[21] !== t3 || $[22] !== t9) {
|
|
104
|
+
t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, /* @__PURE__ */ jsx(AlertDialog, {
|
|
105
|
+
open,
|
|
106
|
+
onOpenChange: t3,
|
|
107
|
+
children: t9
|
|
108
|
+
})] });
|
|
109
|
+
$[20] = open;
|
|
110
|
+
$[21] = t3;
|
|
111
|
+
$[22] = t9;
|
|
112
|
+
$[23] = t10;
|
|
113
|
+
} else t10 = $[23];
|
|
114
|
+
return t10;
|
|
115
|
+
}
|
|
116
|
+
function _temp(error) {
|
|
117
|
+
return toast.error(error.message || "Could not clear the thread");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { ClearThread };
|
|
@@ -7,102 +7,104 @@ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
|
|
|
7
7
|
import { Spinner } from "@camox/ui/spinner";
|
|
8
8
|
|
|
9
9
|
//#region src/features/studio/components/DeleteDraftDialog.tsx
|
|
10
|
-
/** Asks before deleting
|
|
10
|
+
/** Asks before deleting an archived draft for good, then deletes it (ADR 0046). */
|
|
11
11
|
function DeleteDraftDialog(t0) {
|
|
12
12
|
const $ = c(26);
|
|
13
|
-
const { projectId,
|
|
13
|
+
const { projectId, draftId, onOpenChange } = t0;
|
|
14
14
|
let t1;
|
|
15
15
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
16
16
|
t1 = draftMutations.delete();
|
|
17
17
|
$[0] = t1;
|
|
18
18
|
} else t1 = $[0];
|
|
19
19
|
let t2;
|
|
20
|
-
if ($[1] !==
|
|
20
|
+
if ($[1] !== onOpenChange) {
|
|
21
21
|
t2 = {
|
|
22
22
|
...t1,
|
|
23
|
-
onSuccess: (
|
|
24
|
-
const { ended } = t3;
|
|
25
|
-
onOpenChange(false);
|
|
26
|
-
onDeleted(ended);
|
|
27
|
-
},
|
|
23
|
+
onSuccess: () => onOpenChange(false),
|
|
28
24
|
onError: _temp
|
|
29
25
|
};
|
|
30
|
-
$[1] =
|
|
31
|
-
$[2] =
|
|
32
|
-
|
|
33
|
-
} else t2 = $[3];
|
|
26
|
+
$[1] = onOpenChange;
|
|
27
|
+
$[2] = t2;
|
|
28
|
+
} else t2 = $[2];
|
|
34
29
|
const deleteDraft = useMutation(t2);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const t3 = draftId !== null;
|
|
31
|
+
let t4;
|
|
32
|
+
if ($[3] !== deleteDraft.isPending || $[4] !== onOpenChange) {
|
|
33
|
+
t4 = (next) => {
|
|
38
34
|
if (!deleteDraft.isPending) onOpenChange(next);
|
|
39
35
|
};
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
42
|
-
$[
|
|
43
|
-
} else
|
|
44
|
-
let t4;
|
|
45
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
46
|
-
t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this draft?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Every change in this draft is deleted for everyone. Live stays as it is. This can't be undone." })] });
|
|
47
|
-
$[7] = t4;
|
|
48
|
-
} else t4 = $[7];
|
|
36
|
+
$[3] = deleteDraft.isPending;
|
|
37
|
+
$[4] = onOpenChange;
|
|
38
|
+
$[5] = t4;
|
|
39
|
+
} else t4 = $[5];
|
|
49
40
|
let t5;
|
|
50
|
-
if ($[
|
|
51
|
-
t5 = /* @__PURE__ */ jsx(
|
|
41
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
42
|
+
t5 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete this draft?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Its changes, its thread and its code are deleted for everyone. Live stays as it is. This can't be undone." })] });
|
|
43
|
+
$[6] = t5;
|
|
44
|
+
} else t5 = $[6];
|
|
45
|
+
let t6;
|
|
46
|
+
if ($[7] !== deleteDraft.isPending) {
|
|
47
|
+
t6 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
52
48
|
variant: "outline",
|
|
53
49
|
size: "default",
|
|
54
50
|
disabled: deleteDraft.isPending,
|
|
55
51
|
children: "Cancel"
|
|
56
52
|
});
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else
|
|
60
|
-
let t6;
|
|
61
|
-
if ($[10] !== deleteDraft || $[11] !== projectId) {
|
|
62
|
-
t6 = () => deleteDraft.mutate({ projectId });
|
|
63
|
-
$[10] = deleteDraft;
|
|
64
|
-
$[11] = projectId;
|
|
65
|
-
$[12] = t6;
|
|
66
|
-
} else t6 = $[12];
|
|
53
|
+
$[7] = deleteDraft.isPending;
|
|
54
|
+
$[8] = t6;
|
|
55
|
+
} else t6 = $[8];
|
|
67
56
|
let t7;
|
|
57
|
+
if ($[9] !== deleteDraft || $[10] !== draftId || $[11] !== projectId) {
|
|
58
|
+
t7 = () => {
|
|
59
|
+
if (draftId) deleteDraft.mutate({
|
|
60
|
+
projectId,
|
|
61
|
+
draftId
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
$[9] = deleteDraft;
|
|
65
|
+
$[10] = draftId;
|
|
66
|
+
$[11] = projectId;
|
|
67
|
+
$[12] = t7;
|
|
68
|
+
} else t7 = $[12];
|
|
69
|
+
let t8;
|
|
68
70
|
if ($[13] !== deleteDraft.isPending) {
|
|
69
|
-
|
|
71
|
+
t8 = deleteDraft.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
70
72
|
$[13] = deleteDraft.isPending;
|
|
71
|
-
$[14] =
|
|
72
|
-
} else
|
|
73
|
-
let
|
|
74
|
-
if ($[15] !== deleteDraft.isPending || $[16] !==
|
|
75
|
-
|
|
73
|
+
$[14] = t8;
|
|
74
|
+
} else t8 = $[14];
|
|
75
|
+
let t9;
|
|
76
|
+
if ($[15] !== deleteDraft.isPending || $[16] !== t7 || $[17] !== t8) {
|
|
77
|
+
t9 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
76
78
|
variant: "destructive",
|
|
77
79
|
disabled: deleteDraft.isPending,
|
|
78
|
-
onClick:
|
|
79
|
-
children: [
|
|
80
|
+
onClick: t7,
|
|
81
|
+
children: [t8, "Delete draft"]
|
|
80
82
|
});
|
|
81
83
|
$[15] = deleteDraft.isPending;
|
|
82
|
-
$[16] =
|
|
83
|
-
$[17] =
|
|
84
|
-
$[18] =
|
|
85
|
-
} else
|
|
86
|
-
let t9;
|
|
87
|
-
if ($[19] !== t5 || $[20] !== t8) {
|
|
88
|
-
t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
|
|
89
|
-
$[19] = t5;
|
|
90
|
-
$[20] = t8;
|
|
91
|
-
$[21] = t9;
|
|
92
|
-
} else t9 = $[21];
|
|
84
|
+
$[16] = t7;
|
|
85
|
+
$[17] = t8;
|
|
86
|
+
$[18] = t9;
|
|
87
|
+
} else t9 = $[18];
|
|
93
88
|
let t10;
|
|
94
|
-
if ($[
|
|
95
|
-
t10 = /* @__PURE__ */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
89
|
+
if ($[19] !== t6 || $[20] !== t9) {
|
|
90
|
+
t10 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t5, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t6, t9] })] });
|
|
91
|
+
$[19] = t6;
|
|
92
|
+
$[20] = t9;
|
|
93
|
+
$[21] = t10;
|
|
94
|
+
} else t10 = $[21];
|
|
95
|
+
let t11;
|
|
96
|
+
if ($[22] !== t10 || $[23] !== t3 || $[24] !== t4) {
|
|
97
|
+
t11 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
98
|
+
open: t3,
|
|
99
|
+
onOpenChange: t4,
|
|
100
|
+
children: t10
|
|
99
101
|
});
|
|
100
|
-
$[22] =
|
|
102
|
+
$[22] = t10;
|
|
101
103
|
$[23] = t3;
|
|
102
|
-
$[24] =
|
|
103
|
-
$[25] =
|
|
104
|
-
} else
|
|
105
|
-
return
|
|
104
|
+
$[24] = t4;
|
|
105
|
+
$[25] = t11;
|
|
106
|
+
} else t11 = $[25];
|
|
107
|
+
return t11;
|
|
106
108
|
}
|
|
107
109
|
function _temp(error) {
|
|
108
110
|
return toast.error(error.message || "Could not delete the draft");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
2
|
import { studioStore } from "../studioStore.js";
|
|
3
3
|
import { plural } from "../draftLabel.js";
|
|
4
|
+
import { useArchiveDraft } from "../useArchiveDraft.js";
|
|
4
5
|
import { useDrafts } from "./DraftsControl.js";
|
|
5
6
|
import { c } from "react/compiler-runtime";
|
|
6
7
|
import * as React from "react";
|
|
@@ -16,16 +17,18 @@ import { FloatingToolbar } from "@camox/ui/floating-toolbar";
|
|
|
16
17
|
*/
|
|
17
18
|
const SETTLE_MS = 1500;
|
|
18
19
|
/**
|
|
19
|
-
* Asks what to do with the draft being viewed, once its edits settle:
|
|
20
|
+
* Asks what to do with the draft being viewed, once its edits settle: archive it, unless it's
|
|
21
|
+
* Camox's Catch-up Draft, or publish it.
|
|
20
22
|
* Publishing waits while Camox's agent is mid-turn in the draft, so half a change never goes live;
|
|
21
23
|
* nothing else Camox does holds it here. `stacked` places it in the Preview toolbar's column, just above the toolbar;
|
|
22
24
|
* otherwise it floats at the bottom of the screen on its own.
|
|
23
25
|
*/
|
|
24
26
|
function DraftBar(t0) {
|
|
25
|
-
const $ = c(
|
|
27
|
+
const $ = c(32);
|
|
26
28
|
const { stacked: t1 } = t0;
|
|
27
29
|
const stacked = t1 === void 0 ? false : t1;
|
|
28
30
|
const { projectId, current } = useDrafts();
|
|
31
|
+
const { archive, archiving } = useArchiveDraft(projectId);
|
|
29
32
|
const settled = useSettled(current?.id ?? null, current?.lastChangedAt ?? null);
|
|
30
33
|
let t2;
|
|
31
34
|
if ($[0] !== current) {
|
|
@@ -68,82 +71,90 @@ function DraftBar(t0) {
|
|
|
68
71
|
$[9] = t7;
|
|
69
72
|
} else t7 = $[9];
|
|
70
73
|
let t8;
|
|
71
|
-
if ($[10]
|
|
72
|
-
t8 = /* @__PURE__ */ jsx(Button, {
|
|
74
|
+
if ($[10] !== archive || $[11] !== archiving || $[12] !== current.catchUp) {
|
|
75
|
+
t8 = !current.catchUp && /* @__PURE__ */ jsx(Button, {
|
|
73
76
|
type: "button",
|
|
74
77
|
variant: "outline",
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
disabled: archiving,
|
|
79
|
+
onClick: archive,
|
|
80
|
+
children: "Archive"
|
|
77
81
|
});
|
|
78
|
-
$[10] =
|
|
79
|
-
|
|
82
|
+
$[10] = archive;
|
|
83
|
+
$[11] = archiving;
|
|
84
|
+
$[12] = current.catchUp;
|
|
85
|
+
$[13] = t8;
|
|
86
|
+
} else t8 = $[13];
|
|
80
87
|
const t9 = !working;
|
|
81
88
|
const t10 = working ? 0 : void 0;
|
|
82
89
|
let t11;
|
|
83
|
-
if ($[
|
|
90
|
+
if ($[14] !== t10) {
|
|
84
91
|
t11 = /* @__PURE__ */ jsx("span", { tabIndex: t10 });
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
87
|
-
} else t11 = $[
|
|
92
|
+
$[14] = t10;
|
|
93
|
+
$[15] = t11;
|
|
94
|
+
} else t11 = $[15];
|
|
88
95
|
const t12 = empty || working;
|
|
89
96
|
let t13;
|
|
90
|
-
if ($[
|
|
97
|
+
if ($[16] !== t12) {
|
|
91
98
|
t13 = /* @__PURE__ */ jsx(Button, {
|
|
92
99
|
type: "button",
|
|
93
100
|
disabled: t12,
|
|
94
|
-
onClick:
|
|
101
|
+
onClick: _temp,
|
|
95
102
|
children: "Publish…"
|
|
96
103
|
});
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
} else t13 = $[
|
|
104
|
+
$[16] = t12;
|
|
105
|
+
$[17] = t13;
|
|
106
|
+
} else t13 = $[17];
|
|
100
107
|
let t14;
|
|
101
|
-
if ($[
|
|
108
|
+
if ($[18] !== t11 || $[19] !== t13) {
|
|
102
109
|
t14 = /* @__PURE__ */ jsx(TooltipTrigger, {
|
|
103
110
|
render: t11,
|
|
104
111
|
children: t13
|
|
105
112
|
});
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
} else t14 = $[
|
|
113
|
+
$[18] = t11;
|
|
114
|
+
$[19] = t13;
|
|
115
|
+
$[20] = t14;
|
|
116
|
+
} else t14 = $[20];
|
|
110
117
|
let t15;
|
|
111
|
-
if ($[
|
|
118
|
+
if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
119
|
t15 = /* @__PURE__ */ jsx(TooltipContent, { children: "Camox's agent is working" });
|
|
113
|
-
$[
|
|
114
|
-
} else t15 = $[
|
|
120
|
+
$[21] = t15;
|
|
121
|
+
} else t15 = $[21];
|
|
115
122
|
let t16;
|
|
116
|
-
if ($[
|
|
117
|
-
t16 = /* @__PURE__ */ jsxs(
|
|
118
|
-
|
|
119
|
-
children: [
|
|
120
|
-
disabled: t9,
|
|
121
|
-
children: [t14, t15]
|
|
122
|
-
})]
|
|
123
|
+
if ($[22] !== t14 || $[23] !== t9) {
|
|
124
|
+
t16 = /* @__PURE__ */ jsxs(Tooltip, {
|
|
125
|
+
disabled: t9,
|
|
126
|
+
children: [t14, t15]
|
|
123
127
|
});
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
} else t16 = $[
|
|
128
|
+
$[22] = t14;
|
|
129
|
+
$[23] = t9;
|
|
130
|
+
$[24] = t16;
|
|
131
|
+
} else t16 = $[24];
|
|
128
132
|
let t17;
|
|
129
|
-
if ($[
|
|
130
|
-
t17 = /* @__PURE__ */ jsxs(
|
|
133
|
+
if ($[25] !== t16 || $[26] !== t8) {
|
|
134
|
+
t17 = /* @__PURE__ */ jsxs("div", {
|
|
135
|
+
className: "flex items-center gap-2",
|
|
136
|
+
children: [t8, t16]
|
|
137
|
+
});
|
|
138
|
+
$[25] = t16;
|
|
139
|
+
$[26] = t8;
|
|
140
|
+
$[27] = t17;
|
|
141
|
+
} else t17 = $[27];
|
|
142
|
+
let t18;
|
|
143
|
+
if ($[28] !== t17 || $[29] !== t4 || $[30] !== t7) {
|
|
144
|
+
t18 = /* @__PURE__ */ jsxs(FloatingToolbar, {
|
|
131
145
|
"aria-label": "Draft",
|
|
132
146
|
className: t4,
|
|
133
|
-
children: [t7,
|
|
147
|
+
children: [t7, t17]
|
|
134
148
|
});
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
function _temp2() {
|
|
143
|
-
return studioStore.send({ type: "openReviewDraftDialog" });
|
|
149
|
+
$[28] = t17;
|
|
150
|
+
$[29] = t4;
|
|
151
|
+
$[30] = t7;
|
|
152
|
+
$[31] = t18;
|
|
153
|
+
} else t18 = $[31];
|
|
154
|
+
return t18;
|
|
144
155
|
}
|
|
145
156
|
function _temp() {
|
|
146
|
-
return studioStore.send({ type: "
|
|
157
|
+
return studioStore.send({ type: "openReviewDraftDialog" });
|
|
147
158
|
}
|
|
148
159
|
/**
|
|
149
160
|
* Whether the draft went without a change for `SETTLE_MS`. Once settled it stays so for that
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { useDraftScope } from "../../../lib/draft-scope.js";
|
|
2
|
+
import { AuthContext } from "../../../lib/auth.js";
|
|
3
|
+
import { reads, useReadQuery } from "../../../lib/studio-reads.js";
|
|
4
|
+
import { draftNoticeMessage } from "../draftNotice.js";
|
|
5
|
+
import { useRestoreDraft } from "../useRestoreDraft.js";
|
|
6
|
+
import { c } from "react/compiler-runtime";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { toast } from "@camox/ui/toaster";
|
|
10
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
11
|
+
import { Spinner } from "@camox/ui/spinner";
|
|
12
|
+
|
|
13
|
+
//#region src/features/studio/components/DraftNotices.tsx
|
|
14
|
+
/**
|
|
15
|
+
* Says why the studio shows Live when the draft a member opened, or was in, can't be shown. A
|
|
16
|
+
* draft that's only archived can come back (ADR 0046), so a dialog says so and offers to restore
|
|
17
|
+
* it; anything else is a toast. Opening the link restores nothing by itself.
|
|
18
|
+
*/
|
|
19
|
+
function DraftNotices() {
|
|
20
|
+
const $ = c(34);
|
|
21
|
+
const draftScope = useDraftScope();
|
|
22
|
+
const [archived, setArchived] = React.useState(null);
|
|
23
|
+
let t0;
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[0] !== draftScope) {
|
|
26
|
+
t0 = () => draftScope.onNotice((notice) => {
|
|
27
|
+
if (notice.reason === "archived") setArchived(notice);
|
|
28
|
+
else toast(draftNoticeMessage(notice));
|
|
29
|
+
});
|
|
30
|
+
t1 = [draftScope];
|
|
31
|
+
$[0] = draftScope;
|
|
32
|
+
$[1] = t0;
|
|
33
|
+
$[2] = t1;
|
|
34
|
+
} else {
|
|
35
|
+
t0 = $[1];
|
|
36
|
+
t1 = $[2];
|
|
37
|
+
}
|
|
38
|
+
React.useEffect(t0, t1);
|
|
39
|
+
const { projectUuid } = React.useContext(AuthContext);
|
|
40
|
+
let t2;
|
|
41
|
+
if ($[3] !== projectUuid) {
|
|
42
|
+
t2 = reads.project({ projectUuid });
|
|
43
|
+
$[3] = projectUuid;
|
|
44
|
+
$[4] = t2;
|
|
45
|
+
} else t2 = $[4];
|
|
46
|
+
const { data: project } = useReadQuery(t2);
|
|
47
|
+
let t3;
|
|
48
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
+
t3 = { onRestored: () => setArchived(null) };
|
|
50
|
+
$[5] = t3;
|
|
51
|
+
} else t3 = $[5];
|
|
52
|
+
const { restore, restoring } = useRestoreDraft(project?.id, t3);
|
|
53
|
+
const t4 = archived !== null;
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[6] !== restoring) {
|
|
56
|
+
t5 = (open) => {
|
|
57
|
+
if (!open && !restoring) setArchived(null);
|
|
58
|
+
};
|
|
59
|
+
$[6] = restoring;
|
|
60
|
+
$[7] = t5;
|
|
61
|
+
} else t5 = $[7];
|
|
62
|
+
let t6;
|
|
63
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t6 = /* @__PURE__ */ jsx(AlertDialogTitle, { children: "This draft is archived" });
|
|
65
|
+
$[8] = t6;
|
|
66
|
+
} else t6 = $[8];
|
|
67
|
+
let t7;
|
|
68
|
+
if ($[9] !== archived) {
|
|
69
|
+
t7 = archived && draftNoticeMessage(archived);
|
|
70
|
+
$[9] = archived;
|
|
71
|
+
$[10] = t7;
|
|
72
|
+
} else t7 = $[10];
|
|
73
|
+
let t8;
|
|
74
|
+
if ($[11] !== t7) {
|
|
75
|
+
t8 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t6, /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [t7, " Restore it to pick up where it stopped."] })] });
|
|
76
|
+
$[11] = t7;
|
|
77
|
+
$[12] = t8;
|
|
78
|
+
} else t8 = $[12];
|
|
79
|
+
const t9 = restoring !== void 0;
|
|
80
|
+
let t10;
|
|
81
|
+
if ($[13] !== t9) {
|
|
82
|
+
t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
83
|
+
variant: "outline",
|
|
84
|
+
size: "default",
|
|
85
|
+
disabled: t9,
|
|
86
|
+
children: "Stay on Live"
|
|
87
|
+
});
|
|
88
|
+
$[13] = t9;
|
|
89
|
+
$[14] = t10;
|
|
90
|
+
} else t10 = $[14];
|
|
91
|
+
const t11 = restoring !== void 0 || !project;
|
|
92
|
+
let t12;
|
|
93
|
+
if ($[15] !== archived || $[16] !== restore) {
|
|
94
|
+
t12 = () => {
|
|
95
|
+
if (archived) restore(archived.draftId);
|
|
96
|
+
};
|
|
97
|
+
$[15] = archived;
|
|
98
|
+
$[16] = restore;
|
|
99
|
+
$[17] = t12;
|
|
100
|
+
} else t12 = $[17];
|
|
101
|
+
let t13;
|
|
102
|
+
if ($[18] !== restoring) {
|
|
103
|
+
t13 = restoring !== void 0 ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
104
|
+
$[18] = restoring;
|
|
105
|
+
$[19] = t13;
|
|
106
|
+
} else t13 = $[19];
|
|
107
|
+
let t14;
|
|
108
|
+
if ($[20] !== t11 || $[21] !== t12 || $[22] !== t13) {
|
|
109
|
+
t14 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
110
|
+
disabled: t11,
|
|
111
|
+
onClick: t12,
|
|
112
|
+
children: [t13, "Restore"]
|
|
113
|
+
});
|
|
114
|
+
$[20] = t11;
|
|
115
|
+
$[21] = t12;
|
|
116
|
+
$[22] = t13;
|
|
117
|
+
$[23] = t14;
|
|
118
|
+
} else t14 = $[23];
|
|
119
|
+
let t15;
|
|
120
|
+
if ($[24] !== t10 || $[25] !== t14) {
|
|
121
|
+
t15 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, t14] });
|
|
122
|
+
$[24] = t10;
|
|
123
|
+
$[25] = t14;
|
|
124
|
+
$[26] = t15;
|
|
125
|
+
} else t15 = $[26];
|
|
126
|
+
let t16;
|
|
127
|
+
if ($[27] !== t15 || $[28] !== t8) {
|
|
128
|
+
t16 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, t15] });
|
|
129
|
+
$[27] = t15;
|
|
130
|
+
$[28] = t8;
|
|
131
|
+
$[29] = t16;
|
|
132
|
+
} else t16 = $[29];
|
|
133
|
+
let t17;
|
|
134
|
+
if ($[30] !== t16 || $[31] !== t4 || $[32] !== t5) {
|
|
135
|
+
t17 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
136
|
+
open: t4,
|
|
137
|
+
onOpenChange: t5,
|
|
138
|
+
children: t16
|
|
139
|
+
});
|
|
140
|
+
$[30] = t16;
|
|
141
|
+
$[31] = t4;
|
|
142
|
+
$[32] = t5;
|
|
143
|
+
$[33] = t17;
|
|
144
|
+
} else t17 = $[33];
|
|
145
|
+
return t17;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
export { DraftNotices };
|