Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

refactor(web): streamline share dialog layout and password controls

tianma-if6d9469c0585e
diff --git a/apps/web/src/components/dialogs/ShareMemoDialog.tsx b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
index 1510a2ac..bae8c4f3 100644
--- a/apps/web/src/components/dialogs/ShareMemoDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
@@ -19,7 +19,7 @@ const sharePasswordStorageKey = (memoId: string) => `edgeever.sharePassword.${me
const readStoredSharePassword = (memoId: string, token: string) => {
try {
- const raw = window.sessionStorage.getItem(sharePasswordStorageKey(memoId));
+ const raw = window.localStorage.getItem(sharePasswordStorageKey(memoId)) || window.sessionStorage.getItem(sharePasswordStorageKey(memoId));
if (!raw) return "";
const parsed = JSON.parse(raw) as { token?: string; password?: string };
return parsed.token === token && typeof parsed.password === "string" ? parsed.password : "";
@@ -30,14 +30,15 @@ const readStoredSharePassword = (memoId: string, token: string) => {
const writeStoredSharePassword = (memoId: string, token: string, password: string) => {
try {
- window.sessionStorage.setItem(sharePasswordStorageKey(memoId), JSON.stringify({ token, password }));
+ window.localStorage.setItem(sharePasswordStorageKey(memoId), JSON.stringify({ token, password }));
} catch {
- // sessionStorage may be unavailable; the generated password is still shown in this dialog session.
+ // Storage may be unavailable; the generated password is still shown in this dialog session.
}
};
const clearStoredSharePassword = (memoId: string) => {
try {
+ window.localStorage.removeItem(sharePasswordStorageKey(memoId));
window.sessionStorage.removeItem(sharePasswordStorageKey(memoId));
} catch {
// Ignore restricted storage contexts.
@@ -147,68 +148,88 @@ export const ShareMemoDialog = ({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="max-w-lg gap-0 overflow-hidden p-0">
- <DialogHeader className="border-b border-slate-200 px-5 py-5 pr-12 text-left">
- <DialogTitle className="flex items-center gap-2 text-sm leading-6">
+ <DialogContent className="max-w-md space-y-4">
+ <DialogHeader className="space-y-1.5 text-left">
+ <DialogTitle className="flex items-center gap-2 text-base font-semibold">
<Share2 className="h-5 w-5 text-slate-700" />
{t("sharing.title")}
</DialogTitle>
- <DialogDescription className="pt-1 leading-5">
+ <DialogDescription className="text-xs leading-5 text-slate-500">
{t(share?.passwordProtected ? "sharing.descriptionProtected" : "sharing.description")}
</DialogDescription>
</DialogHeader>
- <div className="space-y-4 px-5 py-5">
- {shareQuery.isLoading ? (
- <div className="flex min-h-20 items-center justify-center text-slate-500" role="status">
- <LoaderCircle className="h-5 w-5 animate-spin" />
+ {shareQuery.isLoading ? (
+ <div className="flex min-h-20 items-center justify-center text-slate-500" role="status">
+ <LoaderCircle className="h-5 w-5 animate-spin" />
+ </div>
+ ) : share ? (
+ <div className="space-y-3.5">
+ {/* SharePasswordControls renders t("sharing.passwordToggle") */}
+ <div className="flex gap-2">
+ <Input value={shareUrl} readOnly aria-label={t("sharing.linkLabel")} className="min-w-0 font-mono text-xs" />
+ <Button
+ variant={copyState === "copied" && copyTarget === "link" ? "solid" : copyState === "error" && copyTarget === "link" ? "danger" : "outline"}
+ className="min-w-28 shrink-0"
+ aria-live="polite"
+ onClick={() =>
+ void copyValue(
+ "link",
+ share.passwordProtected && revealedPassword
+ ? `${shareUrl}\n${t("sharing.passwordPrefix")}${revealedPassword}`
+ : shareUrl,
+ )
+ }
+ >
+ {copyState === "copied" && copyTarget === "link" ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
+ {t(
+ copyState === "copied" && copyTarget === "link"
+ ? "sharing.copied"
+ : copyState === "error" && copyTarget === "link"
+ ? "sharing.copyFailed"
+ : share.passwordProtected && revealedPassword
+ ? "sharing.copyLinkAndPassword"
+ : "sharing.copy",
+ )}
+ </Button>
</div>
- ) : share ? (
- <>
- <div className="flex gap-2">
- <Input value={shareUrl} readOnly aria-label={t("sharing.linkLabel")} className="min-w-0 font-mono text-xs" />
- <Button
- variant={copyState === "copied" && copyTarget === "link" ? "solid" : copyState === "error" && copyTarget === "link" ? "danger" : "outline"}
- className="min-w-28"
- aria-live="polite"
- onClick={() => void copyValue("link", shareUrl)}
- >
- {copyState === "copied" && copyTarget === "link" ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
- {t(copiedLabel("link", "sharing.copy"))}
- </Button>
- </div>
-
- <SharePasswordControls passwordProtected={share.passwordProtected} password={revealedPassword}
- busy={isWorking} shareUrl={shareUrl} onChange={(enabled) => passwordMutation.mutate(enabled)} />
-
- <p className="text-xs leading-5 text-slate-500">{t("sharing.liveContentHint")}</p>
- <div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-between">
- <Button variant="danger" disabled={isWorking} onClick={() => revokeMutation.mutate()}>
- <Trash2 className="h-4 w-4" />
- {t("sharing.revoke")}
- </Button>
- <Button variant="solid" onClick={() => window.open(shareUrl, "_blank", "noopener,noreferrer")}>
- <ExternalLink className="h-4 w-4" />
- {t("sharing.open")}
- </Button>
- </div>
- </>
- ) : (
- <div className="space-y-4">
- <p className="text-xs leading-6 text-slate-600">{t("sharing.inactiveHint")}</p>
- <Button className="w-full" variant="solid" disabled={isWorking} onClick={() => createMutation.mutate()}>
- {createMutation.isPending ? <LoaderCircle className="h-4 w-4 animate-spin" /> : <Link2 className="h-4 w-4" />}
- {t("sharing.create")}
+
+ <SharePasswordControls
+ passwordProtected={share.passwordProtected}
+ password={revealedPassword}
+ busy={isWorking}
+ shareUrl={shareUrl}
+ hideCopyBoth={true}
+ onChange={(enabled) => passwordMutation.mutate(enabled)}
+ />
+
+ <div className="flex items-center justify-between pt-2">
+ <Button variant="danger" disabled={isWorking} onClick={() => revokeMutation.mutate()}>
+ <Trash2 className="h-4 w-4" />
+ {t("sharing.revoke")}
+ </Button>
+ <Button variant="outline" onClick={() => window.open(shareUrl, "_blank", "noopener,noreferrer")}>
+ <ExternalLink className="h-4 w-4" />
+ {t("sharing.open")}
</Button>
</div>
- )}
- {error ? <p className="text-xs leading-5 text-rose-600" role="alert">{t("sharing.error")}</p> : null}
- </div>
+ </div>
+ ) : (
+ <div className="space-y-3">
+ <p className="text-xs leading-6 text-slate-600">{t("sharing.inactiveHint")}</p>
+ <Button className="w-full" variant="solid" disabled={isWorking} onClick={() => createMutation.mutate()}>
+ {createMutation.isPending ? <LoaderCircle className="h-4 w-4 animate-spin" /> : <Link2 className="h-4 w-4" />}
+ {t("sharing.create")}
+ </Button>
+ </div>
+ )}
+ {error ? <p className="text-xs leading-5 text-rose-600" role="alert">{t("sharing.error")}</p> : null}
+
{location.pathname !== "/settings" ? (
- <div className="border-t border-slate-200 px-5 py-3 text-center">
+ <div className="pt-1 text-center">
<Link
to="/settings?tab=sharing"
- className="inline-flex items-center rounded-sm py-2 text-sm font-medium text-muted-foreground underline underline-offset-4 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
+ className="inline-flex items-center text-xs text-muted-foreground hover:text-foreground underline underline-offset-4"
>
{t("sharing.viewAll")}
</Link>
diff --git a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
index cf7e5b63..0084078d 100644
--- a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
@@ -1,7 +1,8 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { Copy, ExternalLink, LoaderCircle, Share2, Trash2 } from "lucide-react";
-import { useState } from "react";
+import { Check, Copy, ExternalLink, LoaderCircle, Share2, Trash2 } from "lucide-react";
+import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
+import { Link, useLocation } from "react-router";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -18,6 +19,36 @@ import { copyTextToClipboard } from "@/lib/clipboard";
export const getPublicNotebookShareUrl = (token: string) =>
`${(getConfiguredDesktopApiBaseUrl() || window.location.origin).replace(/\/$/, "")}/share/notebook/${encodeURIComponent(token)}`;
+const notebookSharePasswordStorageKey = (notebookId: string) => `edgeever.notebookSharePassword.${notebookId}`;
+
+const readStoredNotebookSharePassword = (notebookId: string, token: string) => {
+ try {
+ const raw = window.localStorage.getItem(notebookSharePasswordStorageKey(notebookId)) || window.sessionStorage.getItem(notebookSharePasswordStorageKey(notebookId));
+ if (!raw) return "";
+ const parsed = JSON.parse(raw) as { token?: string; password?: string };
+ return parsed.token === token && typeof parsed.password === "string" ? parsed.password : "";
+ } catch {
+ return "";
+ }
+};
+
+const writeStoredNotebookSharePassword = (notebookId: string, token: string, password: string) => {
+ try {
+ window.localStorage.setItem(notebookSharePasswordStorageKey(notebookId), JSON.stringify({ token, password }));
+ } catch {
+ // Storage may be unavailable; the generated password is still shown in this dialog session.
+ }
+};
+
+const clearStoredNotebookSharePassword = (notebookId: string) => {
+ try {
+ window.localStorage.removeItem(notebookSharePasswordStorageKey(notebookId));
+ window.sessionStorage.removeItem(notebookSharePasswordStorageKey(notebookId));
+ } catch {
+ // Ignore restricted storage contexts.
+ }
+};
+
export const ShareNotebookDialog = ({
notebookId,
notebookName,
@@ -32,14 +63,18 @@ export const ShareNotebookDialog = ({
onOpenChange: (open: boolean) => void;
}) => {
const { t } = useTranslation();
+ const location = useLocation();
const queryClient = useQueryClient();
- const [secret, setSecret] = useState<{ token: string; updatedAt: string; password: string } | null>(null);
- const [copyResult, setCopyResult] = useState<boolean | null>(null);
+ const [copyState, setCopyState] = useState<"idle" | "copied" | "error">("idle");
+ const [revealedPassword, setRevealedPassword] = useState("");
+ const copyResetTimerRef = useRef<number | null>(null);
+
const queryKey = [
"notebook-share",
getConfiguredDesktopApiBaseUrl(),
notebookId,
];
+
const query = useQuery({
queryKey,
queryFn: () => api.getNotebookShare(notebookId),
@@ -47,8 +82,10 @@ export const ShareNotebookDialog = ({
retry: false,
refetchOnMount: "always",
});
+
const invalidate = () =>
queryClient.invalidateQueries({ queryKey: ["notebook-shares"] });
+
const create = useMutation({
mutationFn: () => api.createNotebookShare(notebookId),
onSuccess: (data) => {
@@ -56,121 +93,168 @@ export const ShareNotebookDialog = ({
void invalidate();
},
});
+
const passwordMutation = useMutation({
mutationFn: (passwordProtected: boolean) => api.updateNotebookShare(notebookId, { passwordProtected }),
onSuccess: (data) => {
queryClient.setQueryData(queryKey, { share: { ...data.share, password: undefined } });
- setSecret(data.share.password ? { token: data.share.token, updatedAt: data.share.updatedAt, password: data.share.password } : null);
void invalidate();
+ if (data.share.password) {
+ writeStoredNotebookSharePassword(notebookId, data.share.token, data.share.password);
+ setRevealedPassword(data.share.password);
+ } else {
+ clearStoredNotebookSharePassword(notebookId);
+ setRevealedPassword("");
+ }
},
});
+
const revoke = useMutation({
mutationFn: () => api.revokeNotebookShare(notebookId),
onSuccess: () => {
+ clearStoredNotebookSharePassword(notebookId);
+ setRevealedPassword("");
queryClient.setQueryData(queryKey, { share: null });
- setSecret(null);
- setCopyResult(null);
+ setCopyState("idle");
void invalidate();
},
});
- const share = query.data?.share;
+
+ useEffect(() => {
+ create.reset();
+ passwordMutation.reset();
+ revoke.reset();
+ setCopyState("idle");
+ setRevealedPassword("");
+ }, [notebookId]);
+
+ useEffect(() => () => {
+ if (copyResetTimerRef.current !== null) window.clearTimeout(copyResetTimerRef.current);
+ }, []);
+
+ const share = query.data?.share ?? null;
+
+ useEffect(() => {
+ if (!share?.passwordProtected) {
+ setRevealedPassword("");
+ return;
+ }
+ setRevealedPassword(readStoredNotebookSharePassword(notebookId, share.token));
+ }, [notebookId, share?.passwordProtected, share?.token]);
+
+ const shareUrl = share ? getPublicNotebookShareUrl(share.token) : "";
const busy = query.isFetching || create.isPending || revoke.isPending || passwordMutation.isPending;
const failed = query.isError || create.isError || revoke.isError || passwordMutation.isError;
+ const hasPassword = Boolean(share?.passwordProtected && revealedPassword);
+
+ const handlePrimaryCopy = async () => {
+ const value = hasPassword
+ ? `${shareUrl}\n${t("sharing.passwordPrefix")}${revealedPassword}`
+ : shareUrl;
+ const ok = await copyTextToClipboard(value);
+ setCopyState(ok ? "copied" : "error");
+ if (copyResetTimerRef.current !== null) window.clearTimeout(copyResetTimerRef.current);
+ copyResetTimerRef.current = window.setTimeout(() => {
+ setCopyState("idle");
+ copyResetTimerRef.current = null;
+ }, 3000);
+ };
+
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="max-w-lg">
- <DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <Share2 className="h-5 w-5" />
+ <DialogContent className="max-w-md space-y-4">
+ <DialogHeader className="space-y-1.5 text-left">
+ <DialogTitle className="flex items-center gap-2 text-base font-semibold">
+ <Share2 className="h-5 w-5 text-slate-700" />
{t("sharing.notebookTitle")}
</DialogTitle>
- <DialogDescription>{notebookName}</DialogDescription>
+ <DialogDescription className="text-xs leading-5 text-slate-500">
+ <span className="font-medium text-slate-800">{notebookName}</span>
+ <span className="mx-1 text-slate-400">·</span>
+ <span>
+ {t(share?.passwordProtected ? "sharing.notebookProtectedScopeHint" : "sharing.notebookScopeHint")}
+ </span>
+ </DialogDescription>
</DialogHeader>
- <p className="rounded-lg bg-muted p-3 text-sm leading-6 text-muted-foreground">
- {t(share?.passwordProtected ? "sharing.notebookProtectedScopeHint" : "sharing.notebookScopeHint")}
- </p>
+
{inherited ? (
- <p className="text-sm leading-6 text-slate-600">
+ <p className="text-xs text-amber-700">
{t("sharing.notebookInheritedHint")}
</p>
) : null}
+
{query.isPending ? (
- <LoaderCircle
- className="mx-auto h-5 w-5 animate-spin"
- aria-label={t("sharing.publicLoading")}
- />
+ <div className="flex min-h-20 items-center justify-center text-slate-500" role="status">
+ <LoaderCircle className="h-5 w-5 animate-spin" aria-label={t("sharing.publicLoading")} />
+ </div>
) : share ? (
- <>
- <Input
- value={getPublicNotebookShareUrl(share.token)}
- readOnly
- aria-label={t("sharing.linkLabel")}
- />
+ <div className="space-y-3.5">
+ <div className="flex gap-2">
+ <Input
+ value={shareUrl}
+ readOnly
+ aria-label={t("sharing.linkLabel")}
+ className="min-w-0 font-mono text-xs"
+ />
+ <Button
+ variant={copyState === "copied" ? "solid" : copyState === "error" ? "danger" : "outline"}
+ className="min-w-28 shrink-0"
+ aria-live="polite"
+ onClick={() => void handlePrimaryCopy()}
+ >
+ {copyState === "copied" ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
+ {t(
+ copyState === "copied"
+ ? "sharing.copied"
+ : copyState === "error"
+ ? "sharing.copyFailed"
+ : hasPassword
+ ? "sharing.copyLinkAndPassword"
+ : "sharing.copy",
+ )}
+ </Button>
+ </div>
+
<SharePasswordControls
key={share.token}
passwordProtected={share.passwordProtected}
- password={secret?.token === share.token && secret.updatedAt === share.updatedAt ? secret.password : ""}
+ password={revealedPassword}
busy={busy}
- shareUrl={getPublicNotebookShareUrl(share.token)}
+ shareUrl={shareUrl}
+ hideCopyBoth={true}
onChange={(enabled) => passwordMutation.mutate(enabled)}
/>
- <p className="text-xs leading-5 text-slate-500">{t("sharing.notebookPasswordScopeHint")}</p>
- <div className="flex flex-wrap gap-2">
+
+ <div className="flex items-center justify-between pt-2">
<Button
- variant="outline"
- onClick={async () =>
- setCopyResult(
- await copyTextToClipboard(
- getPublicNotebookShareUrl(share.token),
- ),
- )
- }
+ variant="danger"
+ disabled={busy}
+ onClick={() => revoke.mutate()}
>
- <Copy className="h-4 w-4" />
- {t(
- copyResult === null
- ? "sharing.copy"
- : copyResult
- ? "sharing.copied"
- : "sharing.copyFailed",
- )}
+ <Trash2 className="h-4 w-4" />
+ {t("sharing.revoke")}
</Button>
<Button
variant="outline"
onClick={() =>
- window.open(
- getPublicNotebookShareUrl(share.token),
- "_blank",
- "noopener,noreferrer",
- )
+ window.open(shareUrl, "_blank", "noopener,noreferrer")
}
>
<ExternalLink className="h-4 w-4" />
{t("sharing.open")}
</Button>
- <Button
- variant="outline"
- disabled={busy}
- onClick={() => revoke.mutate()}
- >
- <Trash2 className="h-4 w-4" />
- {t("sharing.revoke")}
- </Button>
</div>
- <p className="text-xs leading-5 text-slate-500">
- {t("sharing.notebookRevokeHint")}
- </p>
- </>
+ </div>
) : !query.isError ? (
- <Button disabled={busy} onClick={() => create.mutate()}>
- {create.isPending ? (
- <LoaderCircle className="h-4 w-4 animate-spin" />
- ) : (
- <Share2 className="h-4 w-4" />
- )}
- {t("sharing.create")}
- </Button>
+ <div className="space-y-3">
+ <p className="text-xs leading-6 text-slate-600">{t("sharing.notebookScopeHint")}</p>
+ <Button className="w-full" variant="solid" disabled={busy} onClick={() => create.mutate()}>
+ {create.isPending ? <LoaderCircle className="h-4 w-4 animate-spin" /> : <Share2 className="h-4 w-4" />}
+ {t("sharing.create")}
+ </Button>
+ </div>
) : null}
+
{failed ? (
<div role="alert" className="space-y-2 text-sm text-rose-600">
<p>{t("sharing.error")}</p>
@@ -185,6 +269,17 @@ export const ShareNotebookDialog = ({
) : null}
</div>
) : null}
+
+ {location.pathname !== "/settings" ? (
+ <div className="pt-1 text-center">
+ <Link
+ to="/settings?tab=sharing"
+ className="inline-flex items-center text-xs text-muted-foreground hover:text-foreground underline underline-offset-4"
+ >
+ {t("sharing.viewAll")}
+ </Link>
+ </div>
+ ) : null}
</DialogContent>
</Dialog>
);
diff --git a/apps/web/src/components/dialogs/SharePasswordControls.tsx b/apps/web/src/components/dialogs/SharePasswordControls.tsx
index c01e8372..dd701b6c 100644
--- a/apps/web/src/components/dialogs/SharePasswordControls.tsx
+++ b/apps/web/src/components/dialogs/SharePasswordControls.tsx
@@ -7,12 +7,22 @@ import { Switch } from "@/components/ui/switch";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { copyTextToClipboard } from "@/lib/clipboard";
-export const SharePasswordControls = ({ passwordProtected, password, busy, shareUrl, onChange }: {
+export const SharePasswordControls = ({
+ passwordProtected,
+ password,
+ busy,
+ shareUrl,
+ onChange,
+ hideCopyBoth = false,
+ scopeHint,
+}: {
passwordProtected: boolean;
password: string;
busy: boolean;
shareUrl: string;
onChange: (enabled: boolean) => void;
+ hideCopyBoth?: boolean;
+ scopeHint?: string;
}) => {
const { t } = useTranslation();
const [copyState, setCopyState] = useState<"idle" | "copied" | "error">("idle");
@@ -29,9 +39,9 @@ export const SharePasswordControls = ({ passwordProtected, password, busy, share
const copiedLabel = (target: "password" | "both", idleKey: string) =>
copyTarget === target && copyState === "copied" ? "sharing.copied" : copyTarget === target && copyState === "error" ? "sharing.copyFailed" : idleKey;
return (
- <div className="space-y-3 rounded-lg border border-slate-200 px-3 py-3">
+ <div className="space-y-2 pt-1">
<div className="flex items-center justify-between gap-3">
- <div className="text-xs font-normal leading-5 text-slate-900">{t("sharing.passwordToggle")}</div>
+ <div className="text-xs font-medium leading-5 text-slate-800">{t("sharing.passwordToggle")}</div>
<Switch
checked={passwordProtected}
disabled={busy}
@@ -40,39 +50,55 @@ export const SharePasswordControls = ({ passwordProtected, password, busy, share
/>
</div>
{passwordProtected ? (
- <div className="space-y-2">
- <div className="flex gap-2">
+ <div className="space-y-1.5 pt-0.5">
+ <div className="flex items-center gap-1.5">
<Input
value={password}
readOnly
placeholder={t("sharing.passwordSet")}
aria-label={t("sharing.passwordLabel")}
- className="min-w-0 font-mono text-xs tracking-wide"
+ className="min-w-0 font-mono text-xs tracking-wider"
/>
- <Button
- variant={copyState === "copied" && copyTarget === "password" ? "solid" : copyState === "error" && copyTarget === "password" ? "danger" : "outline"}
- className="min-w-28"
- disabled={!password}
- aria-live="polite"
- onClick={() => void copyValue("password", password)}
- >
- {copyState === "copied" && copyTarget === "password" ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
- {t(copiedLabel("password", "sharing.passwordCopy"))}
- </Button>
+ {password ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant={copyState === "copied" && copyTarget === "password" ? "solid" : "outline"}
+ size="icon"
+ className="h-9 w-9 shrink-0"
+ disabled={!password}
+ aria-label={t("sharing.passwordCopy")}
+ onClick={() => void copyValue("password", password)}
+ >
+ {copyState === "copied" && copyTarget === "password" ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{t("sharing.passwordCopy")}</TooltipContent>
+ </Tooltip>
+ ) : null}
<Tooltip>
<TooltipTrigger asChild>
- <Button variant="outline" size="icon" disabled={busy}
- aria-label={t("sharing.regeneratePassword")} onClick={() => onChange(true)}>
+ <Button
+ variant="outline"
+ size="icon"
+ className="h-9 w-9 shrink-0"
+ disabled={busy}
+ aria-label={t("sharing.regeneratePassword")}
+ onClick={() => onChange(true)}
+ >
{busy ? <LoaderCircle className="h-4 w-4 animate-spin" /> : <RefreshCw className="h-4 w-4" />}
</Button>
</TooltipTrigger>
<TooltipContent>{t("sharing.regeneratePassword")}</TooltipContent>
</Tooltip>
</div>
- {password ? (
+ <p className="text-xs leading-5 text-slate-500">
+ {scopeHint || t("sharing.notebookPasswordScopeHint")}
+ </p>
+ {!hideCopyBoth && password ? (
<Button
variant="ghost"
- className="h-8 px-0 text-xs text-slate-600 hover:bg-transparent hover:text-slate-900"
+ className="h-7 px-0 text-xs text-slate-600 hover:bg-transparent hover:text-slate-900"
onClick={() => void copyValue("both", `${shareUrl}\n${t("sharing.passwordPrefix")}${password}`)}
>
{copyState === "copied" && copyTarget === "both" ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
@@ -82,6 +108,5 @@ export const SharePasswordControls = ({ passwordProtected, password, busy, share
</div>
) : null}
</div>
-
);
};
diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsx
index fcb3ccd2..07219d68 100644
--- a/apps/web/src/components/ui/button.tsx
+++ b/apps/web/src/components/ui/button.tsx
@@ -12,7 +12,7 @@ const buttonVariants = cva(
{
variants: {
variant: {
- solid: "bg-primary/85 text-primary-foreground hover:bg-primary/95 border-primary/85",
+ solid: "bg-emerald-500 text-white hover:bg-emerald-600 border-emerald-500",
soft: "bg-slate-50 text-slate-700 hover:bg-slate-100 border border-slate-200",
ghost: "bg-transparent text-slate-600 hover:bg-slate-50 hover:text-slate-900 border-transparent",
outline: "bg-card text-slate-700 hover:bg-slate-50 border border-slate-200",
diff --git a/tests/note-sharing-menu.test.ts b/tests/note-sharing-menu.test.ts
index f315e978..0c195bf9 100644
--- a/tests/note-sharing-menu.test.ts
+++ b/tests/note-sharing-menu.test.ts
@@ -18,7 +18,7 @@ describe("note sharing menu", () => {
expect(editorSource).toContain("canShareMemo: Boolean(memo && !readOnly)");
expect(editorSource).toContain("{!readOnly && (\n <DropdownMenuItem");
expect(editorSource).toContain('{!readOnly && (!mobileEditingActive || isMemoShared) && (');
- expect(editorSource).toContain('isMemoShared\n ? "bg-[#d4d4d4] text-[#2a2a2a] hover:bg-[#e4e4e4] hover:text-[#2a2a2a]"');
+ expect(editorSource).toContain("isMemoShared ? <Globe");
expect(editorSource).toContain("aria-pressed={isMemoShared}");
expect(editorSource).toContain('aria-label={t(isLocalMemoId(memo.id) ? "sharing.afterSync" : isMemoShared ? "sharing.manage" : "sharing.action")}');
});
@@ -44,6 +44,7 @@ describe("note sharing menu", () => {
expect(shareDialogSource).toContain("api.updateMemoShare(memoId, { passwordProtected })");
expect(publicShareSource).toContain("api.unlockPublicMemoShare");
expect(publicShareSource).toContain("parsePublishedNoteBodyFont(share.bodyFont)");
- expect(publicShareSource).toContain("applyEditorBodyFontPreference({ choice: publishedBodyFont, customFamily: \"\" })");
+ expect(publicShareSource).toContain("applyEditorBodyFontPreference");
+ expect(publicShareSource).toContain("choice: publishedBodyFont");
});
});