@backmatter/studio 0.0.17 → 0.0.19
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/chunks/{UiKitApp-D7vllRQE.js → UiKitApp-B1ANqCac.js} +528 -481
- package/dist/chunks/{WorkspaceRoutes-DH1LD-2Q.js → WorkspaceRoutes-BHNGrf-j.js} +24955 -24119
- package/dist/chunks/{dashboard-Dsaeud2x.js → dashboard-b-W6dGm5.js} +586 -565
- package/dist/chunks/{index-CGMqw2NH.js → index-HYioDjux.js} +104 -104
- package/dist/dashboard.js +2 -2
- package/dist/index.js +166 -159
- package/dist/site-widget.css +25 -6
- package/dist/site-widget.js +6925 -6840
- package/dist/studio.css +171 -42
- package/package.json +2 -2
- package/src/api.ts +44 -1
- package/src/chat/ChatMessage.tsx +4 -4
- package/src/chat/ChatProvider.tsx +6 -0
- package/src/chat/chat-helpers.ts +54 -2
- package/src/chrome/CommandPalette.tsx +3 -3
- package/src/chrome/ContentExplorerSidebar.tsx +421 -74
- package/src/chrome/WorkspaceStatusBar.tsx +24 -24
- package/src/chrome/commit-error.ts +48 -60
- package/src/chrome/commit-failure.tsx +2 -2
- package/src/chrome/content-path-tree.ts +4 -0
- package/src/chrome/explorer-row-menu.ts +28 -0
- package/src/chrome/folder-create-context.ts +14 -0
- package/src/chrome/use-publish-check.ts +75 -0
- package/src/{pages/code-session-routes.ts → content-routes.ts} +6 -6
- package/src/fields/FieldControl.tsx +198 -64
- package/src/fields/LinkFieldInput.tsx +315 -0
- package/src/fields/choose-field-input.ts +5 -0
- package/src/fields/link-targets.ts +60 -0
- package/src/host-path.ts +13 -0
- package/src/pages/CodeSessionPage.tsx +6 -241
- package/src/pages/DocEditorPage.tsx +121 -178
- package/src/pages/EmbedPublishPage.tsx +13 -5
- package/src/pages/GithubConnectPage.tsx +1 -1
- package/src/pages/LoginPage.tsx +67 -5
- package/src/pages/MediaFieldInput.tsx +712 -37
- package/src/pages/MediaGalleryPage.tsx +69 -5
- package/src/pages/PreviewAddress.tsx +293 -0
- package/src/pages/WorkspaceHomePage.tsx +1 -1
- package/src/pages/code-session-boot.ts +0 -12
- package/src/pages/media-selection.ts +79 -0
- package/src/pages/ui-kit/colors.tsx +2 -0
- package/src/pages/ui-kit/fields.tsx +60 -0
- package/src/styles/themes.ts +2 -0
- package/src/styles/tokens.stylex.ts +1 -0
- package/src/ui/Button.tsx +14 -0
- package/src/ui/Field.tsx +12 -1
- package/src/ui/Input.tsx +191 -97
- package/src/ui/popup.ts +13 -6
|
@@ -3,6 +3,8 @@ import { Snake } from "loading-dev";
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useOutletContext, useParams, useSearchParams, Link, useNavigate } from "react-router";
|
|
5
5
|
import * as stylex from "@stylexjs/stylex";
|
|
6
|
+
import { matchRoute, repoPathFromModel } from "@backmatter/core";
|
|
7
|
+
import { problemText } from "../chrome/commit-error";
|
|
6
8
|
import {
|
|
7
9
|
fetchDoc,
|
|
8
10
|
fetchDocs,
|
|
@@ -21,6 +23,7 @@ import {
|
|
|
21
23
|
import { FieldControl } from "../fields/FieldControl";
|
|
22
24
|
import { loadRelationDocuments } from "../fields/load-relation-documents";
|
|
23
25
|
import { omitField } from "../fields/omit-field";
|
|
26
|
+
import { linkDocumentTypes } from "../fields/link-targets";
|
|
24
27
|
import { relationTargets } from "../fields/relation-targets";
|
|
25
28
|
import { useReplicaState } from "../replica/useReplica";
|
|
26
29
|
import { useSetEditorActions } from "../chrome/EditorActionsContext";
|
|
@@ -33,10 +36,8 @@ import {
|
|
|
33
36
|
type EditorSelection,
|
|
34
37
|
} from "../chrome/EditorFocusContext";
|
|
35
38
|
import { useSetEditorStatus } from "../chrome/EditorStatusContext";
|
|
36
|
-
import { modifierSymbol } from "../chrome/hotkeys";
|
|
37
|
-
import { ReloadIcon } from "../chrome/icons";
|
|
38
39
|
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
39
|
-
import { Button
|
|
40
|
+
import { Button } from "../ui/Button";
|
|
40
41
|
import { ConfirmDialog } from "../ui/ConfirmDialog";
|
|
41
42
|
import { Field } from "../ui/Field";
|
|
42
43
|
import { Input, Textarea } from "../ui/Input";
|
|
@@ -50,6 +51,8 @@ import {
|
|
|
50
51
|
persistPreviewPct,
|
|
51
52
|
readPreviewPct,
|
|
52
53
|
} from "./preview-split";
|
|
54
|
+
import { routesForContentFiles } from "../content-routes";
|
|
55
|
+
import { PreviewAddress } from "./PreviewAddress";
|
|
53
56
|
import { PreviewSizeSwitch, PreviewViewport } from "./PreviewSize";
|
|
54
57
|
import { persistPreviewSize, readPreviewSize, type PreviewSize } from "./preview-size";
|
|
55
58
|
import {
|
|
@@ -82,10 +85,6 @@ import {
|
|
|
82
85
|
const AUTOSAVE_MS = 400;
|
|
83
86
|
const hover = "@media (hover: hover)";
|
|
84
87
|
|
|
85
|
-
const spin = stylex.keyframes({
|
|
86
|
-
to: { transform: "rotate(360deg)" },
|
|
87
|
-
});
|
|
88
|
-
|
|
89
88
|
const pulse = stylex.keyframes({
|
|
90
89
|
"0%": { opacity: 0.4 },
|
|
91
90
|
"50%": { opacity: 1 },
|
|
@@ -111,10 +110,7 @@ function formatApiError(err: unknown): string {
|
|
|
111
110
|
if (!(err instanceof Error)) return "Request failed";
|
|
112
111
|
const apiErr = err as ApiError;
|
|
113
112
|
if (apiErr.code === "forbidden") return "You do not have permission to edit content.";
|
|
114
|
-
|
|
115
|
-
return err.message.replace(/^validation:\s*/, "Validation failed: ");
|
|
116
|
-
}
|
|
117
|
-
return err.message;
|
|
113
|
+
return problemText(err, err.message);
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
function isNotFound(err: unknown): err is ApiError {
|
|
@@ -137,9 +133,9 @@ function emptyFrontmatter(model: SchemaPayload["models"][number] | undefined) {
|
|
|
137
133
|
/** Status-bar label for the doc's state against the branch HEAD. */
|
|
138
134
|
export function docStatusLabel(status: DocStatus | null): string | null {
|
|
139
135
|
if (status === null) return null;
|
|
140
|
-
if (status === "clean") return "
|
|
136
|
+
if (status === "clean") return "up to date";
|
|
141
137
|
if (status === "conflict") return "conflict";
|
|
142
|
-
return "
|
|
138
|
+
return "unpublished";
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
type SaveState = "idle" | "dirty" | "saving" | "saved" | "error";
|
|
@@ -183,6 +179,9 @@ export function DocEditorPage() {
|
|
|
183
179
|
for (const type of relationTargets(fields, models, objects)) {
|
|
184
180
|
targets.add(type);
|
|
185
181
|
}
|
|
182
|
+
for (const type of linkDocumentTypes(fields, models, objects)) {
|
|
183
|
+
targets.add(type);
|
|
184
|
+
}
|
|
186
185
|
}
|
|
187
186
|
return [...targets].sort();
|
|
188
187
|
}, [model, blocks, richtext, models, objects]);
|
|
@@ -226,7 +225,6 @@ export function DocEditorPage() {
|
|
|
226
225
|
async () => {},
|
|
227
226
|
);
|
|
228
227
|
const revertRef = useRef<() => Promise<void>>(async () => {});
|
|
229
|
-
const mod = modifierSymbol();
|
|
230
228
|
|
|
231
229
|
const hydrated = useRef(false);
|
|
232
230
|
const saveGen = useRef(0);
|
|
@@ -246,6 +244,9 @@ export function DocEditorPage() {
|
|
|
246
244
|
editEpochRef.current = editEpoch;
|
|
247
245
|
|
|
248
246
|
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
|
247
|
+
const docIdentity = `${type}\0${slug}`;
|
|
248
|
+
const [browse, setBrowse] = useState<{ doc: string; path: string } | null>(null);
|
|
249
|
+
const browsedPath = browse?.doc === docIdentity ? browse.path : null;
|
|
249
250
|
const isPage = docFormat === "page";
|
|
250
251
|
const detailNames = fieldNames.filter((name) => fieldKinds[name] !== "blocks");
|
|
251
252
|
const blocksField =
|
|
@@ -268,18 +269,28 @@ export function DocEditorPage() {
|
|
|
268
269
|
branch,
|
|
269
270
|
tree,
|
|
270
271
|
});
|
|
272
|
+
const framePath = browsedPath ?? previewPath;
|
|
273
|
+
// Each document is the content file its model path names. A deleted document is gone.
|
|
274
|
+
const previewRoutes = routesForContentFiles(
|
|
275
|
+
models,
|
|
276
|
+
replica.docs(workspaceId).flatMap((doc) => {
|
|
277
|
+
if (doc.status === "deleted") return [];
|
|
278
|
+
const model = models.find((item) => item.type === doc.type);
|
|
279
|
+
return model ? [repoPathFromModel(model, doc.slug)] : [];
|
|
280
|
+
}),
|
|
281
|
+
);
|
|
271
282
|
|
|
272
283
|
useEffect(() => {
|
|
273
|
-
if (!frameIdentity || !
|
|
284
|
+
if (!frameIdentity || !framePath || !workspaceId || !siteUrl) {
|
|
274
285
|
setPreviewUrl(null);
|
|
275
286
|
return;
|
|
276
287
|
}
|
|
277
288
|
if (studioIsOnSite(siteUrl, window.location.origin)) {
|
|
278
|
-
setPreviewUrl(onSitePreviewUrl(siteUrl,
|
|
289
|
+
setPreviewUrl(onSitePreviewUrl(siteUrl, framePath));
|
|
279
290
|
return;
|
|
280
291
|
}
|
|
281
292
|
let cancelled = false;
|
|
282
|
-
void createPreviewTicket(workspaceId, { redirect:
|
|
293
|
+
void createPreviewTicket(workspaceId, { redirect: framePath, branch, tree })
|
|
283
294
|
.then((res) => {
|
|
284
295
|
if (!cancelled) setPreviewUrl(previewEnableUrl(siteUrl, res.ticket));
|
|
285
296
|
})
|
|
@@ -289,7 +300,7 @@ export function DocEditorPage() {
|
|
|
289
300
|
return () => {
|
|
290
301
|
cancelled = true;
|
|
291
302
|
};
|
|
292
|
-
}, [frameIdentity,
|
|
303
|
+
}, [frameIdentity, framePath, workspaceId, siteUrl, branch, tree]);
|
|
293
304
|
|
|
294
305
|
useEffect(() => {
|
|
295
306
|
if (relationTargetTypes.length === 0) {
|
|
@@ -488,6 +499,17 @@ export function DocEditorPage() {
|
|
|
488
499
|
setPreviewKey((k) => k + 1);
|
|
489
500
|
}
|
|
490
501
|
|
|
502
|
+
function onPreviewPath(next: string) {
|
|
503
|
+
const pathname = next.split(/[?#]/, 1)[0] || "/";
|
|
504
|
+
const doc = matchRoute(models, pathname);
|
|
505
|
+
if (doc && (doc.type !== type || doc.slug !== slug)) {
|
|
506
|
+
navigate(contentDocPath(workspace.slug, doc.type, doc.slug));
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (next === framePath) remountPreview();
|
|
510
|
+
setBrowse({ doc: docIdentity, path: next });
|
|
511
|
+
}
|
|
512
|
+
|
|
491
513
|
function choosePreviewSize(size: PreviewSize) {
|
|
492
514
|
setPreviewSize(size);
|
|
493
515
|
persistPreviewSize(size);
|
|
@@ -765,7 +787,7 @@ export function DocEditorPage() {
|
|
|
765
787
|
saveGen.current += 1;
|
|
766
788
|
try {
|
|
767
789
|
await revertDoc(workspaceId, type, slug);
|
|
768
|
-
setStatus("Reverted to the
|
|
790
|
+
setStatus("Reverted to the branch's version");
|
|
769
791
|
notifyTreeChanged({ workspaceId, type, slug, status: "clean" });
|
|
770
792
|
await reload();
|
|
771
793
|
remountPreview();
|
|
@@ -786,11 +808,11 @@ export function DocEditorPage() {
|
|
|
786
808
|
await resolveDoc(workspaceId, type, slug, strategy);
|
|
787
809
|
notifyTreeChanged();
|
|
788
810
|
if (strategy === "theirs") {
|
|
789
|
-
setStatus("Took the
|
|
811
|
+
setStatus("Took the branch's version");
|
|
790
812
|
await reload();
|
|
791
813
|
remountPreview();
|
|
792
814
|
} else {
|
|
793
|
-
setStatus("Kept your version; it will overwrite theirs
|
|
815
|
+
setStatus("Kept your version; it will overwrite theirs when you publish");
|
|
794
816
|
const data = await fetchDoc(workspaceId, type, slug);
|
|
795
817
|
setDocStatus(data.doc.status);
|
|
796
818
|
}
|
|
@@ -814,7 +836,9 @@ export function DocEditorPage() {
|
|
|
814
836
|
? "Unsaved"
|
|
815
837
|
: saveState === "error"
|
|
816
838
|
? "Save failed"
|
|
817
|
-
:
|
|
839
|
+
: saveState === "saved"
|
|
840
|
+
? "Saved"
|
|
841
|
+
: null;
|
|
818
842
|
const saveTone = saveState === "error" ? "danger" : "muted";
|
|
819
843
|
|
|
820
844
|
persistRef.current = persist;
|
|
@@ -865,7 +889,7 @@ export function DocEditorPage() {
|
|
|
865
889
|
open={confirmRevert}
|
|
866
890
|
onOpenChange={setConfirmRevert}
|
|
867
891
|
title="Revert this file?"
|
|
868
|
-
description="Your
|
|
892
|
+
description="Your unpublished changes to this document will be dropped and the version on the branch reloaded."
|
|
869
893
|
confirmLabel="Revert"
|
|
870
894
|
destructive
|
|
871
895
|
onConfirm={() => void onRevert()}
|
|
@@ -881,32 +905,7 @@ export function DocEditorPage() {
|
|
|
881
905
|
style={{ ...previewSx.style, flexBasis: `${previewPct}%` }}
|
|
882
906
|
>
|
|
883
907
|
<div {...stylex.props(styles.previewBar)}>
|
|
884
|
-
<div {...stylex.props(styles.
|
|
885
|
-
<Tooltip label={previewLoading ? "Loading preview…" : "Reload preview"}>
|
|
886
|
-
<button
|
|
887
|
-
type="button"
|
|
888
|
-
aria-label={previewLoading ? "Preview loading" : "Reload preview"}
|
|
889
|
-
aria-busy={previewLoading || undefined}
|
|
890
|
-
onClick={remountPreview}
|
|
891
|
-
{...stylex.props(styles.reloadBtn)}
|
|
892
|
-
>
|
|
893
|
-
<span
|
|
894
|
-
{...stylex.props(
|
|
895
|
-
styles.reloadIcon,
|
|
896
|
-
previewLoading && styles.reloadSpinning,
|
|
897
|
-
)}
|
|
898
|
-
>
|
|
899
|
-
<ReloadIcon />
|
|
900
|
-
</span>
|
|
901
|
-
</button>
|
|
902
|
-
</Tooltip>
|
|
903
|
-
<span {...stylex.props(styles.url)} title={previewUrl ?? undefined}>
|
|
904
|
-
{previewUrl
|
|
905
|
-
? previewUrl.replace(/^https?:\/\//, "")
|
|
906
|
-
: !siteUrl
|
|
907
|
-
? "No site URL"
|
|
908
|
-
: "Loading checkout…"}
|
|
909
|
-
</span>
|
|
908
|
+
<div {...stylex.props(styles.previewLead)}>
|
|
910
909
|
{previewLive === "rendered" ? (
|
|
911
910
|
<span {...stylex.props(styles.previewLive)}>Updated</span>
|
|
912
911
|
) : null}
|
|
@@ -927,15 +926,21 @@ export function DocEditorPage() {
|
|
|
927
926
|
</button>
|
|
928
927
|
) : null}
|
|
929
928
|
</div>
|
|
930
|
-
<
|
|
931
|
-
|
|
932
|
-
{
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
{
|
|
938
|
-
|
|
929
|
+
<PreviewAddress
|
|
930
|
+
path={framePath ?? (!siteUrl ? "No site URL" : "Loading checkout…")}
|
|
931
|
+
enabled={previewUrl !== null}
|
|
932
|
+
liveHref={liveUrl}
|
|
933
|
+
routes={previewRoutes}
|
|
934
|
+
routesPending={!replica.ready}
|
|
935
|
+
onPath={onPreviewPath}
|
|
936
|
+
onReload={remountPreview}
|
|
937
|
+
onOpen={() => {
|
|
938
|
+
if (previewUrl) window.open(previewUrl, "_blank", "noopener,noreferrer");
|
|
939
|
+
}}
|
|
940
|
+
/>
|
|
941
|
+
<div {...stylex.props(styles.sizeSwitch)}>
|
|
942
|
+
<PreviewSizeSwitch size={previewSize} onSize={choosePreviewSize} />
|
|
943
|
+
</div>
|
|
939
944
|
</div>
|
|
940
945
|
{previewUrl ? (
|
|
941
946
|
<PreviewViewport size={previewSize} dragging={dragging}>
|
|
@@ -999,48 +1004,17 @@ export function DocEditorPage() {
|
|
|
999
1004
|
<section {...stylex.props(styles.editor)}>
|
|
1000
1005
|
<div {...stylex.props(styles.editorColumn, !showPreview && styles.editorColumnSolo)}>
|
|
1001
1006
|
<div {...stylex.props(styles.toolbar)}>
|
|
1002
|
-
<
|
|
1003
|
-
<
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
</div>
|
|
1007
|
+
<h1 {...stylex.props(styles.docTitle)}>
|
|
1008
|
+
<span {...stylex.props(styles.docType)}>{type}</span>
|
|
1009
|
+
<span {...stylex.props(styles.docSlug)}>{slug}</span>
|
|
1010
|
+
</h1>
|
|
1007
1011
|
<div {...stylex.props(styles.actions)}>
|
|
1008
|
-
<Tooltip label={`Save (${mod}S)`}>
|
|
1009
|
-
<Button
|
|
1010
|
-
size="sm"
|
|
1011
|
-
variant="secondary"
|
|
1012
|
-
disabled={busy !== null || saveState === "saving"}
|
|
1013
|
-
aria-keyshortcuts="Meta+S Control+S"
|
|
1014
|
-
onClick={() => void persist("manual")}
|
|
1015
|
-
>
|
|
1016
|
-
Save
|
|
1017
|
-
</Button>
|
|
1018
|
-
</Tooltip>
|
|
1019
|
-
{showPreview ? (
|
|
1020
|
-
<>
|
|
1021
|
-
<ButtonLink
|
|
1022
|
-
size="sm"
|
|
1023
|
-
variant="secondary"
|
|
1024
|
-
href={previewUrl ?? undefined}
|
|
1025
|
-
disabled={!previewUrl}
|
|
1026
|
-
>
|
|
1027
|
-
Preview
|
|
1028
|
-
</ButtonLink>
|
|
1029
|
-
<ButtonLink
|
|
1030
|
-
size="sm"
|
|
1031
|
-
variant="secondary"
|
|
1032
|
-
href={liveUrl ?? undefined}
|
|
1033
|
-
disabled={!liveUrl}
|
|
1034
|
-
>
|
|
1035
|
-
View live
|
|
1036
|
-
</ButtonLink>
|
|
1037
|
-
</>
|
|
1038
|
-
) : null}
|
|
1039
1012
|
{hasTreeCopy ? (
|
|
1040
|
-
<Tooltip label="Drop your
|
|
1013
|
+
<Tooltip label="Drop your unpublished changes to this file">
|
|
1041
1014
|
<Button
|
|
1042
1015
|
size="sm"
|
|
1043
|
-
variant="
|
|
1016
|
+
variant="ghost"
|
|
1017
|
+
muted
|
|
1044
1018
|
disabled={busy !== null}
|
|
1045
1019
|
onClick={() => setConfirmRevert(true)}
|
|
1046
1020
|
>
|
|
@@ -1059,8 +1033,8 @@ export function DocEditorPage() {
|
|
|
1059
1033
|
This file changed on {branch ?? "the branch"} since you started editing.
|
|
1060
1034
|
</Text>
|
|
1061
1035
|
<Text size="sm" tone="muted">
|
|
1062
|
-
|
|
1063
|
-
version
|
|
1036
|
+
Publishing is blocked until you pick a side. Keep mine overwrites their
|
|
1037
|
+
version when you next publish; take theirs drops your edits.
|
|
1064
1038
|
</Text>
|
|
1065
1039
|
</div>
|
|
1066
1040
|
<div {...stylex.props(styles.conflictActions)}>
|
|
@@ -1230,74 +1204,34 @@ const styles = stylex.create({
|
|
|
1230
1204
|
flexShrink: 0,
|
|
1231
1205
|
flexDirection: "column",
|
|
1232
1206
|
overflow: "hidden",
|
|
1233
|
-
backgroundColor: colors.
|
|
1207
|
+
backgroundColor: colors.bgApp,
|
|
1234
1208
|
},
|
|
1235
1209
|
previewBar: {
|
|
1236
|
-
display: "
|
|
1237
|
-
|
|
1210
|
+
display: "grid",
|
|
1211
|
+
gridTemplateColumns: "1fr minmax(0, 520px) 1fr",
|
|
1238
1212
|
alignItems: "center",
|
|
1239
|
-
|
|
1213
|
+
flexShrink: 0,
|
|
1240
1214
|
gap: space.md,
|
|
1215
|
+
height: "44px",
|
|
1216
|
+
boxSizing: "border-box",
|
|
1241
1217
|
paddingInline: space.md,
|
|
1242
|
-
paddingBlock: space.sm,
|
|
1243
1218
|
borderBottomWidth: 1,
|
|
1244
1219
|
borderBottomStyle: "solid",
|
|
1245
1220
|
borderBottomColor: colors.border,
|
|
1221
|
+
backgroundColor: colors.bgSurface,
|
|
1246
1222
|
fontSize: type.xs,
|
|
1247
1223
|
color: colors.textMuted,
|
|
1248
1224
|
},
|
|
1249
|
-
|
|
1225
|
+
previewLead: {
|
|
1250
1226
|
display: "flex",
|
|
1251
|
-
minWidth: 0,
|
|
1252
|
-
flex: 1,
|
|
1253
1227
|
alignItems: "center",
|
|
1254
1228
|
gap: space.sm,
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
display: "inline-flex",
|
|
1258
|
-
flexShrink: 0,
|
|
1259
|
-
alignItems: "center",
|
|
1260
|
-
justifyContent: "center",
|
|
1261
|
-
width: 22,
|
|
1262
|
-
height: 22,
|
|
1263
|
-
padding: 0,
|
|
1264
|
-
borderWidth: 0,
|
|
1265
|
-
borderRadius: radius.sm,
|
|
1266
|
-
backgroundColor: "transparent",
|
|
1267
|
-
color: colors.textMuted,
|
|
1268
|
-
cursor: "pointer",
|
|
1269
|
-
touchAction: "manipulation",
|
|
1270
|
-
[hover]: {
|
|
1271
|
-
":hover": {
|
|
1272
|
-
backgroundColor: colors.bgHover,
|
|
1273
|
-
color: colors.text,
|
|
1274
|
-
},
|
|
1275
|
-
},
|
|
1276
|
-
":focus-visible": {
|
|
1277
|
-
outlineWidth: 2,
|
|
1278
|
-
outlineStyle: "solid",
|
|
1279
|
-
outlineColor: colors.focus,
|
|
1280
|
-
outlineOffset: 1,
|
|
1281
|
-
},
|
|
1282
|
-
},
|
|
1283
|
-
reloadIcon: {
|
|
1284
|
-
display: "inline-flex",
|
|
1285
|
-
},
|
|
1286
|
-
reloadSpinning: {
|
|
1287
|
-
animationName: spin,
|
|
1288
|
-
animationDuration: "700ms",
|
|
1289
|
-
animationTimingFunction: "linear",
|
|
1290
|
-
animationIterationCount: "infinite",
|
|
1291
|
-
"@media (prefers-reduced-motion: reduce)": {
|
|
1292
|
-
animationName: "none",
|
|
1293
|
-
animationDuration: "0s",
|
|
1294
|
-
},
|
|
1295
|
-
},
|
|
1296
|
-
url: {
|
|
1229
|
+
minWidth: 0,
|
|
1230
|
+
justifySelf: "start",
|
|
1297
1231
|
overflow: "hidden",
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1232
|
+
},
|
|
1233
|
+
sizeSwitch: {
|
|
1234
|
+
justifySelf: "end",
|
|
1301
1235
|
},
|
|
1302
1236
|
previewLive: {
|
|
1303
1237
|
flexShrink: 0,
|
|
@@ -1310,28 +1244,21 @@ const styles = stylex.create({
|
|
|
1310
1244
|
editPage: {
|
|
1311
1245
|
flexShrink: 0,
|
|
1312
1246
|
borderWidth: 0,
|
|
1313
|
-
borderRadius:
|
|
1247
|
+
borderRadius: radius.sm,
|
|
1314
1248
|
backgroundColor: colors.bgHover,
|
|
1315
1249
|
color: colors.text,
|
|
1316
1250
|
cursor: "pointer",
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
},
|
|
1321
|
-
badge: {
|
|
1322
|
-
flexShrink: 0,
|
|
1323
|
-
borderWidth: 1,
|
|
1324
|
-
borderStyle: "solid",
|
|
1325
|
-
borderColor: colors.border,
|
|
1326
|
-
borderRadius: 4,
|
|
1251
|
+
font: "inherit",
|
|
1252
|
+
fontSize: type.xs,
|
|
1253
|
+
fontWeight: 500,
|
|
1327
1254
|
paddingInline: space.sm,
|
|
1328
|
-
paddingBlock:
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1255
|
+
paddingBlock: "2px",
|
|
1256
|
+
":focus-visible": {
|
|
1257
|
+
outlineWidth: 2,
|
|
1258
|
+
outlineStyle: "solid",
|
|
1259
|
+
outlineColor: colors.focus,
|
|
1260
|
+
outlineOffset: 1,
|
|
1261
|
+
},
|
|
1335
1262
|
},
|
|
1336
1263
|
conflictBanner: {
|
|
1337
1264
|
display: "flex",
|
|
@@ -1454,23 +1381,39 @@ const styles = stylex.create({
|
|
|
1454
1381
|
toolbar: {
|
|
1455
1382
|
display: "flex",
|
|
1456
1383
|
flexShrink: 0,
|
|
1457
|
-
flexWrap: "wrap",
|
|
1458
1384
|
alignItems: "center",
|
|
1459
1385
|
justifyContent: "space-between",
|
|
1460
|
-
gap: space.
|
|
1386
|
+
gap: space.lg,
|
|
1461
1387
|
paddingInline: space.lg,
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
borderBottomStyle: "solid",
|
|
1465
|
-
borderBottomColor: colors.border,
|
|
1388
|
+
paddingTop: space.lg,
|
|
1389
|
+
paddingBottom: space.sm,
|
|
1466
1390
|
},
|
|
1467
|
-
|
|
1391
|
+
docTitle: {
|
|
1392
|
+
display: "flex",
|
|
1393
|
+
alignItems: "baseline",
|
|
1394
|
+
gap: space.sm,
|
|
1468
1395
|
minWidth: 0,
|
|
1396
|
+
margin: 0,
|
|
1397
|
+
fontSize: type.lg,
|
|
1398
|
+
fontWeight: 500,
|
|
1399
|
+
lineHeight: 1.3,
|
|
1400
|
+
},
|
|
1401
|
+
docType: {
|
|
1402
|
+
flexShrink: 0,
|
|
1403
|
+
color: colors.textMuted,
|
|
1404
|
+
fontWeight: 400,
|
|
1405
|
+
},
|
|
1406
|
+
docSlug: {
|
|
1407
|
+
minWidth: 0,
|
|
1408
|
+
overflow: "hidden",
|
|
1409
|
+
textOverflow: "ellipsis",
|
|
1410
|
+
whiteSpace: "nowrap",
|
|
1469
1411
|
},
|
|
1470
1412
|
actions: {
|
|
1471
1413
|
display: "flex",
|
|
1472
|
-
|
|
1473
|
-
|
|
1414
|
+
flexShrink: 0,
|
|
1415
|
+
alignItems: "center",
|
|
1416
|
+
gap: space.xs,
|
|
1474
1417
|
},
|
|
1475
1418
|
formWrap: {
|
|
1476
1419
|
minHeight: 0,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type CommitErrorView,
|
|
24
24
|
} from "../chrome/commit-error";
|
|
25
25
|
import { CommitFailureNotice } from "../chrome/commit-failure";
|
|
26
|
+
import { publishButtonState, publishCheckKey, usePublishCheck } from "../chrome/use-publish-check";
|
|
26
27
|
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
27
28
|
import { popup } from "../ui/popup";
|
|
28
29
|
import { canPublish } from "../workspace/permissions";
|
|
@@ -118,6 +119,13 @@ export function EmbedPublishPage({
|
|
|
118
119
|
const changes = git?.changes ?? [];
|
|
119
120
|
const conflictCount = countConflicts(git);
|
|
120
121
|
const action = statusBarAction(conflictCount, canPublish(role));
|
|
122
|
+
const { failure: publishCheck, checking } = usePublishCheck(
|
|
123
|
+
workspaceId,
|
|
124
|
+
action === "commit",
|
|
125
|
+
publishCheckKey(changes),
|
|
126
|
+
);
|
|
127
|
+
const shownFailure = commitFailure ?? publishCheck;
|
|
128
|
+
const publishButton = publishButtonState({ committing, checking, failure: publishCheck });
|
|
121
129
|
const conflicts = useMemo(
|
|
122
130
|
() => changes.filter((doc) => doc.status === "conflict"),
|
|
123
131
|
[changes],
|
|
@@ -219,12 +227,12 @@ export function EmbedPublishPage({
|
|
|
219
227
|
? "Nothing to publish"
|
|
220
228
|
: `${changes.length} ${changes.length === 1 ? "file" : "files"} → ${branch}`}
|
|
221
229
|
</p>
|
|
222
|
-
{
|
|
230
|
+
{shownFailure ? <CommitFailureNotice failure={shownFailure} /> : null}
|
|
223
231
|
{changes.length > 0 ? (
|
|
224
232
|
<ul {...stylex.props(styles.files)}>
|
|
225
233
|
{changes.map((doc) => {
|
|
226
234
|
const invalid =
|
|
227
|
-
problemsForRef(
|
|
235
|
+
problemsForRef(shownFailure, `${doc.type}/${doc.slug}`).length > 0;
|
|
228
236
|
return (
|
|
229
237
|
<li key={changeKey(doc)}>
|
|
230
238
|
<div {...stylex.props(styles.file)}>
|
|
@@ -245,7 +253,7 @@ export function EmbedPublishPage({
|
|
|
245
253
|
value={message}
|
|
246
254
|
onChange={(event) => setMessage(event.target.value)}
|
|
247
255
|
placeholder={placeholder}
|
|
248
|
-
aria-label="
|
|
256
|
+
aria-label="Publish message"
|
|
249
257
|
autoComplete="off"
|
|
250
258
|
spellCheck={false}
|
|
251
259
|
data-no-ring
|
|
@@ -260,10 +268,10 @@ export function EmbedPublishPage({
|
|
|
260
268
|
) : (
|
|
261
269
|
<button
|
|
262
270
|
type="submit"
|
|
263
|
-
disabled={
|
|
271
|
+
disabled={action !== "commit" || publishButton.disabled}
|
|
264
272
|
{...stylex.props(styles.submit)}
|
|
265
273
|
>
|
|
266
|
-
{
|
|
274
|
+
{publishButton.label}
|
|
267
275
|
</button>
|
|
268
276
|
)}
|
|
269
277
|
</div>
|
|
@@ -110,7 +110,7 @@ export function GithubConnectPage() {
|
|
|
110
110
|
</BackLink>
|
|
111
111
|
}
|
|
112
112
|
title="Choose repository"
|
|
113
|
-
description="Select the repo this workspace will
|
|
113
|
+
description="Select the repo this workspace will publish to."
|
|
114
114
|
/>
|
|
115
115
|
{error ? <Text tone="danger">{error}</Text> : null}
|
|
116
116
|
{repos.length === 0 ? (
|