@backmatter/studio 0.0.18 → 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-DkuQBiQZ.js → UiKitApp-B1ANqCac.js} +528 -481
- package/dist/chunks/{WorkspaceRoutes-DVvb3N-V.js → WorkspaceRoutes-BHNGrf-j.js} +24371 -23915
- package/dist/chunks/{dashboard-B4FITg6c.js → dashboard-b-W6dGm5.js} +586 -565
- package/dist/chunks/{index-CegtXnEI.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 +159 -36
- package/package.json +2 -2
- package/src/api.ts +41 -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/fields/FieldControl.tsx +173 -62
- package/src/pages/DocEditorPage.tsx +47 -64
- 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 +155 -63
- package/src/pages/MediaGalleryPage.tsx +56 -3
- package/src/pages/PreviewAddress.tsx +30 -0
- package/src/pages/WorkspaceHomePage.tsx +1 -1
- 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
|
@@ -4,7 +4,7 @@ import * as stylex from "@stylexjs/stylex";
|
|
|
4
4
|
import { documentLabel, matchesWhere } from "@backmatter/core";
|
|
5
5
|
import type { SchemaField } from "../api";
|
|
6
6
|
import { resolveFieldInput, useStudioDefinition } from "../define-studio";
|
|
7
|
-
import { colors,
|
|
7
|
+
import { colors, space } from "../styles/tokens.stylex";
|
|
8
8
|
import { Input, Select, Textarea } from "../ui/Input";
|
|
9
9
|
import { MediaFieldInput } from "../pages/MediaFieldInput";
|
|
10
10
|
import { chooseFieldInput } from "./choose-field-input";
|
|
@@ -415,6 +415,110 @@ function commitNumber(raw: string, onChange: (value: unknown) => void): void {
|
|
|
415
415
|
onChange(parsed);
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
function sliderPercent(value: number, min: number, max: number): number {
|
|
419
|
+
const span = max - min;
|
|
420
|
+
if (span === 0) return 0;
|
|
421
|
+
return ((value - min) / span) * 100;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function withStyle(
|
|
425
|
+
props: ReturnType<typeof stylex.props>,
|
|
426
|
+
extra: { width?: string; left?: string },
|
|
427
|
+
): ReturnType<typeof stylex.props> {
|
|
428
|
+
return { ...props, style: { ...props.style, ...extra } };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function SliderField({
|
|
432
|
+
name,
|
|
433
|
+
min,
|
|
434
|
+
max,
|
|
435
|
+
step,
|
|
436
|
+
value,
|
|
437
|
+
readOnly,
|
|
438
|
+
onChange,
|
|
439
|
+
}: {
|
|
440
|
+
name: string;
|
|
441
|
+
min: number;
|
|
442
|
+
max: number;
|
|
443
|
+
step: number | "any";
|
|
444
|
+
value: unknown;
|
|
445
|
+
readOnly?: boolean;
|
|
446
|
+
onChange: (value: unknown) => void;
|
|
447
|
+
}) {
|
|
448
|
+
const numeric = typeof value === "number" ? value : value === "" ? NaN : Number(value);
|
|
449
|
+
const rangeValue = Number.isFinite(numeric) ? clamp(numeric, min, max) : min;
|
|
450
|
+
const storedText = value == null || value === "" ? "" : String(value);
|
|
451
|
+
const [draft, setDraft] = useState<string | null>(null);
|
|
452
|
+
const textValue = draft ?? storedText;
|
|
453
|
+
const percent = sliderPercent(rangeValue, min, max);
|
|
454
|
+
const thumbLeft = `calc(7px + (100% - 14px) * ${percent / 100})`;
|
|
455
|
+
const [keyFocus, setKeyFocus] = useState(false);
|
|
456
|
+
const [hot, setHot] = useState(false);
|
|
457
|
+
const fill = stylex.props(styles.sliderFill);
|
|
458
|
+
const thumb = stylex.props(
|
|
459
|
+
styles.sliderThumb,
|
|
460
|
+
hot && !readOnly && styles.sliderThumbHot,
|
|
461
|
+
keyFocus && styles.sliderThumbFocus,
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
return (
|
|
465
|
+
<div {...stylex.props(styles.sliderRow)}>
|
|
466
|
+
<div
|
|
467
|
+
{...stylex.props(styles.sliderTrack, readOnly && styles.sliderTrackDisabled)}
|
|
468
|
+
onPointerEnter={(event) => {
|
|
469
|
+
if (event.pointerType === "mouse") setHot(true);
|
|
470
|
+
}}
|
|
471
|
+
onPointerLeave={() => setHot(false)}
|
|
472
|
+
>
|
|
473
|
+
<div {...stylex.props(styles.sliderRail)} aria-hidden>
|
|
474
|
+
<div {...withStyle(fill, { width: `${percent}%` })} />
|
|
475
|
+
</div>
|
|
476
|
+
<div aria-hidden {...withStyle(thumb, { left: thumbLeft })} />
|
|
477
|
+
<input
|
|
478
|
+
type="range"
|
|
479
|
+
min={min}
|
|
480
|
+
max={max}
|
|
481
|
+
step={step}
|
|
482
|
+
value={String(rangeValue)}
|
|
483
|
+
disabled={readOnly}
|
|
484
|
+
aria-valuemin={min}
|
|
485
|
+
aria-valuemax={max}
|
|
486
|
+
aria-valuenow={rangeValue}
|
|
487
|
+
aria-valuetext={textValue === "" ? "empty" : textValue}
|
|
488
|
+
{...stylex.props(styles.sliderRange)}
|
|
489
|
+
onFocus={(event) => {
|
|
490
|
+
setKeyFocus(event.currentTarget.matches(":focus-visible"));
|
|
491
|
+
}}
|
|
492
|
+
onBlur={() => setKeyFocus(false)}
|
|
493
|
+
onChange={(event) => {
|
|
494
|
+
if (readOnly) return;
|
|
495
|
+
setDraft(null);
|
|
496
|
+
onChange(Number(event.target.value));
|
|
497
|
+
}}
|
|
498
|
+
/>
|
|
499
|
+
</div>
|
|
500
|
+
<div {...stylex.props(styles.sliderValue)}>
|
|
501
|
+
<Input
|
|
502
|
+
value={textValue}
|
|
503
|
+
inputMode="decimal"
|
|
504
|
+
readOnly={readOnly}
|
|
505
|
+
disabled={readOnly}
|
|
506
|
+
spellCheck={false}
|
|
507
|
+
autoComplete="off"
|
|
508
|
+
aria-label={`${name} value`}
|
|
509
|
+
onBlur={() => setDraft(null)}
|
|
510
|
+
onChange={(event) => {
|
|
511
|
+
if (readOnly) return;
|
|
512
|
+
const raw = event.target.value;
|
|
513
|
+
setDraft(raw);
|
|
514
|
+
commitNumber(raw, onChange);
|
|
515
|
+
}}
|
|
516
|
+
/>
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
418
522
|
export function FieldControl({
|
|
419
523
|
name,
|
|
420
524
|
field,
|
|
@@ -481,44 +585,16 @@ export function FieldControl({
|
|
|
481
585
|
}
|
|
482
586
|
|
|
483
587
|
if (kind === "slider" && typeof field.min === "number" && typeof field.max === "number") {
|
|
484
|
-
const min = field.min;
|
|
485
|
-
const max = field.max;
|
|
486
|
-
const step = typeof field.step === "number" ? field.step : "any";
|
|
487
|
-
const numeric = typeof value === "number" ? value : value === "" ? NaN : Number(value);
|
|
488
|
-
const rangeValue = Number.isFinite(numeric) ? clamp(numeric, min, max) : min;
|
|
489
|
-
const textValue = value == null || value === "" ? "" : String(value);
|
|
490
588
|
return (
|
|
491
|
-
<
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
aria-valuemax={max}
|
|
501
|
-
aria-valuenow={rangeValue}
|
|
502
|
-
{...stylex.props(styles.range)}
|
|
503
|
-
onChange={(event) => {
|
|
504
|
-
if (readOnly) return;
|
|
505
|
-
onChange(Number(event.target.value));
|
|
506
|
-
}}
|
|
507
|
-
/>
|
|
508
|
-
<input
|
|
509
|
-
type="text"
|
|
510
|
-
inputMode="decimal"
|
|
511
|
-
value={textValue}
|
|
512
|
-
readOnly={readOnly}
|
|
513
|
-
disabled={readOnly}
|
|
514
|
-
aria-label={`${name} value`}
|
|
515
|
-
{...stylex.props(styles.sliderText)}
|
|
516
|
-
onChange={(event) => {
|
|
517
|
-
if (readOnly) return;
|
|
518
|
-
commitNumber(event.target.value, onChange);
|
|
519
|
-
}}
|
|
520
|
-
/>
|
|
521
|
-
</div>
|
|
589
|
+
<SliderField
|
|
590
|
+
name={name}
|
|
591
|
+
min={field.min}
|
|
592
|
+
max={field.max}
|
|
593
|
+
step={typeof field.step === "number" ? field.step : "any"}
|
|
594
|
+
value={value}
|
|
595
|
+
readOnly={readOnly}
|
|
596
|
+
onChange={onChange}
|
|
597
|
+
/>
|
|
522
598
|
);
|
|
523
599
|
}
|
|
524
600
|
|
|
@@ -684,39 +760,74 @@ const styles = stylex.create({
|
|
|
684
760
|
sliderRow: {
|
|
685
761
|
display: "flex",
|
|
686
762
|
alignItems: "center",
|
|
687
|
-
gap: space.
|
|
763
|
+
gap: space.lg,
|
|
688
764
|
},
|
|
689
|
-
|
|
765
|
+
sliderTrack: {
|
|
766
|
+
position: "relative",
|
|
690
767
|
flex: 1,
|
|
691
768
|
minWidth: 0,
|
|
692
|
-
height: "
|
|
769
|
+
height: "32px",
|
|
770
|
+
display: "flex",
|
|
771
|
+
alignItems: "center",
|
|
772
|
+
touchAction: "manipulation",
|
|
773
|
+
},
|
|
774
|
+
sliderTrackDisabled: {
|
|
775
|
+
opacity: 0.55,
|
|
776
|
+
},
|
|
777
|
+
sliderRail: {
|
|
778
|
+
position: "absolute",
|
|
779
|
+
left: "7px",
|
|
780
|
+
right: "7px",
|
|
781
|
+
height: "2px",
|
|
782
|
+
borderRadius: "999px",
|
|
783
|
+
backgroundColor: colors.border,
|
|
784
|
+
pointerEvents: "none",
|
|
785
|
+
},
|
|
786
|
+
sliderFill: {
|
|
787
|
+
height: "100%",
|
|
788
|
+
borderRadius: "999px",
|
|
789
|
+
backgroundColor: colors.text,
|
|
790
|
+
},
|
|
791
|
+
sliderThumb: {
|
|
792
|
+
position: "absolute",
|
|
793
|
+
top: "50%",
|
|
794
|
+
boxSizing: "border-box",
|
|
795
|
+
width: "14px",
|
|
796
|
+
height: "14px",
|
|
797
|
+
borderRadius: "999px",
|
|
798
|
+
borderWidth: "1.5px",
|
|
799
|
+
borderStyle: "solid",
|
|
800
|
+
borderColor: colors.text,
|
|
801
|
+
backgroundColor: colors.bgSurface,
|
|
802
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.16)",
|
|
803
|
+
transform: "translate(-50%, -50%)",
|
|
804
|
+
pointerEvents: "none",
|
|
805
|
+
},
|
|
806
|
+
sliderThumbHot: {
|
|
807
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.28)",
|
|
808
|
+
},
|
|
809
|
+
sliderThumbFocus: {
|
|
810
|
+
boxShadow: `0 0 0 2px ${colors.bgSurface}, 0 0 0 4px ${colors.focus}`,
|
|
811
|
+
},
|
|
812
|
+
sliderRange: {
|
|
813
|
+
position: "absolute",
|
|
814
|
+
left: "7px",
|
|
815
|
+
top: 0,
|
|
816
|
+
width: "calc(100% - 14px)",
|
|
817
|
+
height: "100%",
|
|
693
818
|
margin: 0,
|
|
694
|
-
|
|
819
|
+
opacity: 0,
|
|
695
820
|
cursor: "pointer",
|
|
821
|
+
appearance: "none",
|
|
822
|
+
touchAction: "manipulation",
|
|
823
|
+
":disabled": {
|
|
824
|
+
cursor: "default",
|
|
825
|
+
},
|
|
696
826
|
},
|
|
697
|
-
|
|
698
|
-
boxSizing: "border-box",
|
|
827
|
+
sliderValue: {
|
|
699
828
|
width: "4.5rem",
|
|
700
829
|
flexShrink: 0,
|
|
701
|
-
minHeight: "32px",
|
|
702
|
-
paddingInline: space.md,
|
|
703
|
-
paddingBlock: space.sm,
|
|
704
|
-
borderRadius: radius.md,
|
|
705
|
-
borderWidth: 1,
|
|
706
|
-
borderStyle: "solid",
|
|
707
|
-
borderColor: colors.border,
|
|
708
|
-
backgroundColor: colors.bgInput,
|
|
709
|
-
color: colors.text,
|
|
710
|
-
fontSize: type.md,
|
|
711
830
|
fontVariantNumeric: "tabular-nums",
|
|
712
|
-
outline: "none",
|
|
713
|
-
":focus": {
|
|
714
|
-
borderColor: colors.focus,
|
|
715
|
-
outlineWidth: 2,
|
|
716
|
-
outlineStyle: "solid",
|
|
717
|
-
outlineColor: colors.focus,
|
|
718
|
-
outlineOffset: -1,
|
|
719
|
-
},
|
|
720
831
|
},
|
|
721
832
|
colorRow: {
|
|
722
833
|
display: "flex",
|
|
@@ -4,6 +4,7 @@ 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
6
|
import { matchRoute, repoPathFromModel } from "@backmatter/core";
|
|
7
|
+
import { problemText } from "../chrome/commit-error";
|
|
7
8
|
import {
|
|
8
9
|
fetchDoc,
|
|
9
10
|
fetchDocs,
|
|
@@ -35,9 +36,8 @@ import {
|
|
|
35
36
|
type EditorSelection,
|
|
36
37
|
} from "../chrome/EditorFocusContext";
|
|
37
38
|
import { useSetEditorStatus } from "../chrome/EditorStatusContext";
|
|
38
|
-
import { modifierSymbol } from "../chrome/hotkeys";
|
|
39
39
|
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
40
|
-
import { Button
|
|
40
|
+
import { Button } from "../ui/Button";
|
|
41
41
|
import { ConfirmDialog } from "../ui/ConfirmDialog";
|
|
42
42
|
import { Field } from "../ui/Field";
|
|
43
43
|
import { Input, Textarea } from "../ui/Input";
|
|
@@ -110,10 +110,7 @@ function formatApiError(err: unknown): string {
|
|
|
110
110
|
if (!(err instanceof Error)) return "Request failed";
|
|
111
111
|
const apiErr = err as ApiError;
|
|
112
112
|
if (apiErr.code === "forbidden") return "You do not have permission to edit content.";
|
|
113
|
-
|
|
114
|
-
return err.message.replace(/^validation:\s*/, "Validation failed: ");
|
|
115
|
-
}
|
|
116
|
-
return err.message;
|
|
113
|
+
return problemText(err, err.message);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
function isNotFound(err: unknown): err is ApiError {
|
|
@@ -136,9 +133,9 @@ function emptyFrontmatter(model: SchemaPayload["models"][number] | undefined) {
|
|
|
136
133
|
/** Status-bar label for the doc's state against the branch HEAD. */
|
|
137
134
|
export function docStatusLabel(status: DocStatus | null): string | null {
|
|
138
135
|
if (status === null) return null;
|
|
139
|
-
if (status === "clean") return "
|
|
136
|
+
if (status === "clean") return "up to date";
|
|
140
137
|
if (status === "conflict") return "conflict";
|
|
141
|
-
return "
|
|
138
|
+
return "unpublished";
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
type SaveState = "idle" | "dirty" | "saving" | "saved" | "error";
|
|
@@ -228,7 +225,6 @@ export function DocEditorPage() {
|
|
|
228
225
|
async () => {},
|
|
229
226
|
);
|
|
230
227
|
const revertRef = useRef<() => Promise<void>>(async () => {});
|
|
231
|
-
const mod = modifierSymbol();
|
|
232
228
|
|
|
233
229
|
const hydrated = useRef(false);
|
|
234
230
|
const saveGen = useRef(0);
|
|
@@ -791,7 +787,7 @@ export function DocEditorPage() {
|
|
|
791
787
|
saveGen.current += 1;
|
|
792
788
|
try {
|
|
793
789
|
await revertDoc(workspaceId, type, slug);
|
|
794
|
-
setStatus("Reverted to the
|
|
790
|
+
setStatus("Reverted to the branch's version");
|
|
795
791
|
notifyTreeChanged({ workspaceId, type, slug, status: "clean" });
|
|
796
792
|
await reload();
|
|
797
793
|
remountPreview();
|
|
@@ -812,11 +808,11 @@ export function DocEditorPage() {
|
|
|
812
808
|
await resolveDoc(workspaceId, type, slug, strategy);
|
|
813
809
|
notifyTreeChanged();
|
|
814
810
|
if (strategy === "theirs") {
|
|
815
|
-
setStatus("Took the
|
|
811
|
+
setStatus("Took the branch's version");
|
|
816
812
|
await reload();
|
|
817
813
|
remountPreview();
|
|
818
814
|
} else {
|
|
819
|
-
setStatus("Kept your version; it will overwrite theirs
|
|
815
|
+
setStatus("Kept your version; it will overwrite theirs when you publish");
|
|
820
816
|
const data = await fetchDoc(workspaceId, type, slug);
|
|
821
817
|
setDocStatus(data.doc.status);
|
|
822
818
|
}
|
|
@@ -840,7 +836,9 @@ export function DocEditorPage() {
|
|
|
840
836
|
? "Unsaved"
|
|
841
837
|
: saveState === "error"
|
|
842
838
|
? "Save failed"
|
|
843
|
-
:
|
|
839
|
+
: saveState === "saved"
|
|
840
|
+
? "Saved"
|
|
841
|
+
: null;
|
|
844
842
|
const saveTone = saveState === "error" ? "danger" : "muted";
|
|
845
843
|
|
|
846
844
|
persistRef.current = persist;
|
|
@@ -891,7 +889,7 @@ export function DocEditorPage() {
|
|
|
891
889
|
open={confirmRevert}
|
|
892
890
|
onOpenChange={setConfirmRevert}
|
|
893
891
|
title="Revert this file?"
|
|
894
|
-
description="Your
|
|
892
|
+
description="Your unpublished changes to this document will be dropped and the version on the branch reloaded."
|
|
895
893
|
confirmLabel="Revert"
|
|
896
894
|
destructive
|
|
897
895
|
onConfirm={() => void onRevert()}
|
|
@@ -931,6 +929,7 @@ export function DocEditorPage() {
|
|
|
931
929
|
<PreviewAddress
|
|
932
930
|
path={framePath ?? (!siteUrl ? "No site URL" : "Loading checkout…")}
|
|
933
931
|
enabled={previewUrl !== null}
|
|
932
|
+
liveHref={liveUrl}
|
|
934
933
|
routes={previewRoutes}
|
|
935
934
|
routesPending={!replica.ready}
|
|
936
935
|
onPath={onPreviewPath}
|
|
@@ -1005,48 +1004,17 @@ export function DocEditorPage() {
|
|
|
1005
1004
|
<section {...stylex.props(styles.editor)}>
|
|
1006
1005
|
<div {...stylex.props(styles.editorColumn, !showPreview && styles.editorColumnSolo)}>
|
|
1007
1006
|
<div {...stylex.props(styles.toolbar)}>
|
|
1008
|
-
<
|
|
1009
|
-
<
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
</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>
|
|
1013
1011
|
<div {...stylex.props(styles.actions)}>
|
|
1014
|
-
<Tooltip label={`Save (${mod}S)`}>
|
|
1015
|
-
<Button
|
|
1016
|
-
size="sm"
|
|
1017
|
-
variant="secondary"
|
|
1018
|
-
disabled={busy !== null || saveState === "saving"}
|
|
1019
|
-
aria-keyshortcuts="Meta+S Control+S"
|
|
1020
|
-
onClick={() => void persist("manual")}
|
|
1021
|
-
>
|
|
1022
|
-
Save
|
|
1023
|
-
</Button>
|
|
1024
|
-
</Tooltip>
|
|
1025
|
-
{showPreview ? (
|
|
1026
|
-
<>
|
|
1027
|
-
<ButtonLink
|
|
1028
|
-
size="sm"
|
|
1029
|
-
variant="secondary"
|
|
1030
|
-
href={previewUrl ?? undefined}
|
|
1031
|
-
disabled={!previewUrl}
|
|
1032
|
-
>
|
|
1033
|
-
Preview
|
|
1034
|
-
</ButtonLink>
|
|
1035
|
-
<ButtonLink
|
|
1036
|
-
size="sm"
|
|
1037
|
-
variant="secondary"
|
|
1038
|
-
href={liveUrl ?? undefined}
|
|
1039
|
-
disabled={!liveUrl}
|
|
1040
|
-
>
|
|
1041
|
-
View live
|
|
1042
|
-
</ButtonLink>
|
|
1043
|
-
</>
|
|
1044
|
-
) : null}
|
|
1045
1012
|
{hasTreeCopy ? (
|
|
1046
|
-
<Tooltip label="Drop your
|
|
1013
|
+
<Tooltip label="Drop your unpublished changes to this file">
|
|
1047
1014
|
<Button
|
|
1048
1015
|
size="sm"
|
|
1049
|
-
variant="
|
|
1016
|
+
variant="ghost"
|
|
1017
|
+
muted
|
|
1050
1018
|
disabled={busy !== null}
|
|
1051
1019
|
onClick={() => setConfirmRevert(true)}
|
|
1052
1020
|
>
|
|
@@ -1065,8 +1033,8 @@ export function DocEditorPage() {
|
|
|
1065
1033
|
This file changed on {branch ?? "the branch"} since you started editing.
|
|
1066
1034
|
</Text>
|
|
1067
1035
|
<Text size="sm" tone="muted">
|
|
1068
|
-
|
|
1069
|
-
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.
|
|
1070
1038
|
</Text>
|
|
1071
1039
|
</div>
|
|
1072
1040
|
<div {...stylex.props(styles.conflictActions)}>
|
|
@@ -1415,22 +1383,37 @@ const styles = stylex.create({
|
|
|
1415
1383
|
flexShrink: 0,
|
|
1416
1384
|
alignItems: "center",
|
|
1417
1385
|
justifyContent: "space-between",
|
|
1418
|
-
gap: space.
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
borderBottomWidth: 1,
|
|
1423
|
-
borderBottomStyle: "solid",
|
|
1424
|
-
borderBottomColor: colors.border,
|
|
1425
|
-
backgroundColor: colors.bgSurface,
|
|
1386
|
+
gap: space.lg,
|
|
1387
|
+
paddingInline: space.lg,
|
|
1388
|
+
paddingTop: space.lg,
|
|
1389
|
+
paddingBottom: space.sm,
|
|
1426
1390
|
},
|
|
1427
|
-
|
|
1391
|
+
docTitle: {
|
|
1392
|
+
display: "flex",
|
|
1393
|
+
alignItems: "baseline",
|
|
1394
|
+
gap: space.sm,
|
|
1428
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",
|
|
1429
1411
|
},
|
|
1430
1412
|
actions: {
|
|
1431
1413
|
display: "flex",
|
|
1432
1414
|
flexShrink: 0,
|
|
1433
|
-
|
|
1415
|
+
alignItems: "center",
|
|
1416
|
+
gap: space.xs,
|
|
1434
1417
|
},
|
|
1435
1418
|
formWrap: {
|
|
1436
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 ? (
|
package/src/pages/LoginPage.tsx
CHANGED
|
@@ -11,6 +11,12 @@ import { Text } from "../ui/Text";
|
|
|
11
11
|
|
|
12
12
|
const hover = "@media (hover: hover)";
|
|
13
13
|
|
|
14
|
+
const legal = {
|
|
15
|
+
terms: "https://backmatter.app/legal/terms",
|
|
16
|
+
privacy: "https://backmatter.app/legal/privacy",
|
|
17
|
+
dpa: "https://backmatter.app/legal/dpa",
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
14
20
|
export function LoginPage() {
|
|
15
21
|
const [params] = useSearchParams();
|
|
16
22
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -22,6 +28,8 @@ export function LoginPage() {
|
|
|
22
28
|
const [password, setPassword] = useState("");
|
|
23
29
|
const [name, setName] = useState("");
|
|
24
30
|
const [mode, setMode] = useState<"signin" | "signup">("signin");
|
|
31
|
+
const [accepted, setAccepted] = useState(false);
|
|
32
|
+
const signupBlocked = mode === "signup" && !accepted;
|
|
25
33
|
|
|
26
34
|
useEffect(() => {
|
|
27
35
|
void fetchAuthConfig()
|
|
@@ -95,6 +103,26 @@ export function LoginPage() {
|
|
|
95
103
|
<div {...stylex.props(styles.actions)}>
|
|
96
104
|
{error ? <Text tone="danger">{error}</Text> : null}
|
|
97
105
|
{notice ? <Text tone="muted">{notice}</Text> : null}
|
|
106
|
+
<p {...stylex.props(styles.legal)}>
|
|
107
|
+
By continuing you agree to the{" "}
|
|
108
|
+
<a href={legal.terms} {...stylex.props(styles.legalLink)}>Terms</a> and the{" "}
|
|
109
|
+
<a href={legal.dpa} {...stylex.props(styles.legalLink)}>Data Processing Agreement</a>,
|
|
110
|
+
and you acknowledge the{" "}
|
|
111
|
+
<a href={legal.privacy} {...stylex.props(styles.legalLink)}>Privacy policy</a>.
|
|
112
|
+
A consumer who asks us to start the service now loses the 14-day right of withdrawal
|
|
113
|
+
once it has begun.
|
|
114
|
+
</p>
|
|
115
|
+
{mode === "signup" ? (
|
|
116
|
+
<label {...stylex.props(styles.accept)}>
|
|
117
|
+
<input
|
|
118
|
+
type="checkbox"
|
|
119
|
+
checked={accepted}
|
|
120
|
+
onChange={(event) => setAccepted(event.target.checked)}
|
|
121
|
+
{...stylex.props(styles.checkbox)}
|
|
122
|
+
/>
|
|
123
|
+
<span>I agree, and I ask Backmatter to start the service now.</span>
|
|
124
|
+
</label>
|
|
125
|
+
) : null}
|
|
98
126
|
<form onSubmit={(e) => void onPassword(e)} {...stylex.props(styles.form)}>
|
|
99
127
|
{mode === "signup" ? (
|
|
100
128
|
<input
|
|
@@ -125,15 +153,19 @@ export function LoginPage() {
|
|
|
125
153
|
autoComplete={mode === "signup" ? "new-password" : "current-password"}
|
|
126
154
|
{...stylex.props(styles.field)}
|
|
127
155
|
/>
|
|
128
|
-
<button
|
|
156
|
+
<button
|
|
157
|
+
type="submit"
|
|
158
|
+
disabled={busy || signupBlocked}
|
|
159
|
+
{...stylex.props(styles.cta, (busy || signupBlocked) && styles.ctaDisabled)}
|
|
160
|
+
>
|
|
129
161
|
{mode === "signup" ? "Create account" : "Sign in"}
|
|
130
162
|
</button>
|
|
131
163
|
</form>
|
|
132
164
|
<button
|
|
133
165
|
type="button"
|
|
134
|
-
disabled={busy || !email}
|
|
166
|
+
disabled={busy || !email || signupBlocked}
|
|
135
167
|
onClick={() => void onMagicLink()}
|
|
136
|
-
{...stylex.props(styles.secondary, (busy || !email) && styles.ctaDisabled)}
|
|
168
|
+
{...stylex.props(styles.secondary, (busy || !email || signupBlocked) && styles.ctaDisabled)}
|
|
137
169
|
>
|
|
138
170
|
Email me a magic link
|
|
139
171
|
</button>
|
|
@@ -147,9 +179,9 @@ export function LoginPage() {
|
|
|
147
179
|
</button>
|
|
148
180
|
<button
|
|
149
181
|
type="button"
|
|
150
|
-
disabled={busy || github !== true}
|
|
182
|
+
disabled={busy || github !== true || signupBlocked}
|
|
151
183
|
onClick={() => void onGithub()}
|
|
152
|
-
{...stylex.props(styles.cta, (busy || github !== true) && styles.ctaDisabled)}
|
|
184
|
+
{...stylex.props(styles.cta, (busy || github !== true || signupBlocked) && styles.ctaDisabled)}
|
|
153
185
|
>
|
|
154
186
|
<GithubIcon size={18} />
|
|
155
187
|
Continue with GitHub
|
|
@@ -332,4 +364,34 @@ const styles = stylex.create({
|
|
|
332
364
|
fontSize: type.sm,
|
|
333
365
|
color: colors.textMuted,
|
|
334
366
|
},
|
|
367
|
+
legal: {
|
|
368
|
+
margin: 0,
|
|
369
|
+
fontSize: type.sm,
|
|
370
|
+
lineHeight: 1.5,
|
|
371
|
+
color: colors.textMuted,
|
|
372
|
+
textAlign: "left",
|
|
373
|
+
},
|
|
374
|
+
legalLink: {
|
|
375
|
+
color: colors.text,
|
|
376
|
+
textUnderlineOffset: "2px",
|
|
377
|
+
},
|
|
378
|
+
accept: {
|
|
379
|
+
display: "flex",
|
|
380
|
+
width: "100%",
|
|
381
|
+
gap: space.sm,
|
|
382
|
+
alignItems: "flex-start",
|
|
383
|
+
minHeight: "44px",
|
|
384
|
+
textAlign: "left",
|
|
385
|
+
fontSize: type.sm,
|
|
386
|
+
lineHeight: 1.5,
|
|
387
|
+
color: colors.text,
|
|
388
|
+
cursor: "pointer",
|
|
389
|
+
},
|
|
390
|
+
checkbox: {
|
|
391
|
+
width: "18px",
|
|
392
|
+
height: "18px",
|
|
393
|
+
marginTop: "2px",
|
|
394
|
+
flexShrink: 0,
|
|
395
|
+
accentColor: "#fafafa",
|
|
396
|
+
},
|
|
335
397
|
});
|