Skip to content

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

fix(web): clarify sharing states and close dialogs on navigation

tianma-if590150d3eab2
diff --git a/apps/web/src/components/NotebookTreeItem.tsx b/apps/web/src/components/NotebookTreeItem.tsx
index 8cfa7894..b1d05c9e 100644
--- a/apps/web/src/components/NotebookTreeItem.tsx
+++ b/apps/web/src/components/NotebookTreeItem.tsx
@@ -67,7 +67,15 @@ export const NotebookTreeItem = ({
}) => {
const { t } = useTranslation();
const [shareOpen, setShareOpen] = useState(false);
- const publicNotebook = inheritedPublic || Boolean(sharedNotebookIds?.has(node.id));
+ const directlyShared = Boolean(sharedNotebookIds?.has(node.id));
+ const publicNotebook = inheritedPublic || directlyShared;
+ const shareActionLabel = t(
+ directlyShared
+ ? "sharing.manage"
+ : inheritedPublic
+ ? "sharing.notebookInheritedAction"
+ : "sharing.notebookTitle",
+ );
const open = !collapsedNotebookIds.has(node.id);
const hasChildren = node.children.length > 0;
const showsSplitCount = !showDescendantNotes && hasChildren;
@@ -351,7 +359,7 @@ export const NotebookTreeItem = ({
type="button"
onClick={event => { event.stopPropagation(); setActionsOpen(false); setShareOpen(true); }}
>
- <Share2 className="h-4 w-4" />{t("sharing.notebookTitle")}
+ <Share2 className="h-4 w-4" />{shareActionLabel}
</button>
{isInbox ? (
<>
@@ -416,7 +424,7 @@ export const NotebookTreeItem = ({
{t("notebookTree.rename")}
</ContextMenuItem>
<ContextMenuItem className="flex h-9 items-center gap-2 px-3 text-xs cursor-pointer" onClick={() => setShareOpen(true)}>
- <Share2 className="h-4 w-4" />{t("sharing.notebookTitle")}
+ <Share2 className="h-4 w-4" />{shareActionLabel}
</ContextMenuItem>
{isInbox ? (
<>
diff --git a/apps/web/src/components/dialogs/ShareMemoDialog.tsx b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
index d0c8f2df..bfebc20e 100644
--- a/apps/web/src/components/dialogs/ShareMemoDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
@@ -7,7 +7,7 @@ import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { SharePasswordControls } from "./SharePasswordControls";
-import { SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
+import { SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME, SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
import { api, getConfiguredDesktopApiBaseUrl } from "@/lib/api";
import { copyTextToClipboard } from "@/lib/clipboard";
@@ -139,7 +139,7 @@ export const ShareMemoDialog = ({
<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 self-end sm:self-auto"
+ className={`min-w-28 shrink-0 self-end sm:self-auto ${copyState === "copied" && copyTarget === "link" ? SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME : ""}`}
aria-live="polite"
onClick={() =>
void copyValue(
@@ -185,7 +185,7 @@ export const ShareMemoDialog = ({
</div>
) : (
<Button
- className="w-full"
+ className={`w-full ${SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME}`}
variant="solid"
disabled={isWorking}
onClick={() => {
@@ -203,6 +203,7 @@ export const ShareMemoDialog = ({
<div className="pt-1 text-center">
<Link
to="/settings?tab=sharing"
+ onClick={() => onOpenChange(false)}
className="inline-flex items-center text-xs text-muted-foreground hover:text-foreground underline underline-offset-4"
>
{t("sharing.viewAll")}
diff --git a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
index 6386d967..7e508bbb 100644
--- a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
@@ -12,7 +12,7 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { SharePasswordControls } from "./SharePasswordControls";
-import { SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
+import { SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME, SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
import { Input } from "@/components/ui/input";
import { api, getConfiguredDesktopApiBaseUrl } from "@/lib/api";
import { copyTextToClipboard } from "@/lib/clipboard";
@@ -122,29 +122,25 @@ export const ShareNotebookDialog = ({
<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")}
+ {t(share ? "sharing.manage" : inherited ? "sharing.notebookInheritedAction" : "sharing.notebookTitle")}
</DialogTitle>
<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>
- {inherited ? (
- <p className="text-xs text-amber-700">
- {t("sharing.notebookInheritedHint")}
- </p>
- ) : null}
-
{query.isPending ? (
<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 ? (
<div className="space-y-3.5">
+ <p className="text-xs leading-5 text-slate-600">
+ {t(share.passwordProtected ? "sharing.notebookProtectedScopeHint" : "sharing.notebookScopeHint")}
+ </p>
+ {inherited ? (
+ <p className="text-xs leading-5 text-slate-600">{t("sharing.notebookInheritedHint")}</p>
+ ) : null}
<div className="flex flex-col gap-2 sm:flex-row">
<Input
value={shareUrl}
@@ -154,7 +150,7 @@ export const ShareNotebookDialog = ({
/>
<Button
variant={copyState === "copied" ? "solid" : copyState === "error" ? "danger" : "outline"}
- className="min-w-28 shrink-0 self-end sm:self-auto"
+ className={`min-w-28 shrink-0 self-end sm:self-auto ${copyState === "copied" ? SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME : ""}`}
aria-live="polite"
onClick={() => void handlePrimaryCopy()}
>
@@ -203,10 +199,10 @@ export const ShareNotebookDialog = ({
</div>
) : !query.isError ? (
<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()}>
+ <p className="text-xs leading-6 text-slate-600">{t(inherited ? "sharing.notebookInheritedOnlyHint" : "sharing.notebookScopeHint")}</p>
+ <Button className={`w-full ${SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME}`} 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")}
+ {t(inherited ? "sharing.notebookCreateIndependent" : "sharing.create")}
</Button>
</div>
) : null}
@@ -230,6 +226,7 @@ export const ShareNotebookDialog = ({
<div className="pt-1 text-center">
<Link
to="/settings?tab=sharing"
+ onClick={() => onOpenChange(false)}
className="inline-flex items-center text-xs text-muted-foreground hover:text-foreground underline underline-offset-4"
>
{t("sharing.viewAll")}
diff --git a/apps/web/src/components/dialogs/SharePasswordControls.tsx b/apps/web/src/components/dialogs/SharePasswordControls.tsx
index 2684742a..65818ebd 100644
--- a/apps/web/src/components/dialogs/SharePasswordControls.tsx
+++ b/apps/web/src/components/dialogs/SharePasswordControls.tsx
@@ -2,6 +2,7 @@ import { Check, Copy, LoaderCircle, RefreshCw } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
+import { SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME } from "./share-dialog-layout";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@@ -63,7 +64,7 @@ export const SharePasswordControls = ({
<Button
variant={copyState === "copied" && copyTarget === "password" ? "solid" : "outline"}
size="icon"
- className="h-9 w-9 shrink-0"
+ className={`h-9 w-9 shrink-0 ${copyState === "copied" && copyTarget === "password" ? SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME : ""}`}
disabled={!password}
aria-label={t("sharing.passwordCopy")}
onClick={() => void copyValue("password", password)}
diff --git a/apps/web/src/components/dialogs/share-dialog-layout.ts b/apps/web/src/components/dialogs/share-dialog-layout.ts
index 94cdeb76..5a4122fd 100644
--- a/apps/web/src/components/dialogs/share-dialog-layout.ts
+++ b/apps/web/src/components/dialogs/share-dialog-layout.ts
@@ -1 +1,4 @@
export const SHARE_DIALOG_WIDTH_CLASS_NAME = "w-[calc(100%-2rem)] max-w-[576px]";
+
+export const SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME =
+ "border-slate-900 bg-slate-900 hover:border-slate-800 hover:bg-slate-800";
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 220c8d54..fdcfd868 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -2573,6 +2573,8 @@ export const enUS = {
notebookPasswordRequiredHint: "This shared notebook is password-protected. Enter the password to view its directory, notes, and attachments.",
notebookScopeHint: "Anyone with the link can view this notebook, including sub-notebooks and attachments. Content updates automatically.",
notebookInheritedHint: "This notebook is also shared through a parent. These settings do not affect the parent link.",
+ notebookInheritedOnlyHint: "Already shared via the parent link. You can create a separate link with independent settings.",
+ notebookCreateIndependent: "Create separate share link",
notebookRevokeHint: "Revoking disables this link. Other shares remain active.",
notebookPublic: "Public notebook (including sub-notebooks and future content)",
notebookContents: "Contents",
@@ -2600,6 +2602,7 @@ export const enUS = {
afterSync: "Share note after sync",
active: "Shared",
manage: "Manage sharing",
+ notebookInheritedAction: "Shared via parent",
title: "Share note",
description: "Anyone with the link can view the latest saved version of this note without signing in.",
descriptionProtected: "Anyone with the link must enter the password to view the latest saved version of this note.",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index e28b9278..b63a8fc4 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -2562,6 +2562,8 @@ export const ja = {
notebookPasswordRequiredHint: "この共有ノートブックはパスワードで保護されています。パスワードを入力すると、目次、ノート、添付ファイルを閲覧できます。",
notebookScopeHint: "リンクがあれば、子ノートブックや添付ファイルを含めて閲覧できます。内容は自動更新されます。",
notebookInheritedHint: "親ノートブックからも共有されています。ここでの設定は親のリンクには影響しません。",
+ notebookInheritedOnlyHint: "親ノートブックのリンクで共有中です。設定を個別に管理する共有リンクも作成できます。",
+ notebookCreateIndependent: "個別の共有リンクを作成",
notebookRevokeHint: "解除するとこのリンクは無効になります。他の共有は継続します。",
notebookPublic: "公開ノートブック(子ノートブックと今後の内容を含む)",
notebookContents: "目次",
@@ -2589,6 +2591,7 @@ export const ja = {
afterSync: "同期後にノートを共有",
active: "共有中",
manage: "共有を管理",
+ notebookInheritedAction: "親ノートブック経由で共有中",
title: "ノートを共有",
description: "リンクを持つ人は、サインインなしでこのノートの最新の保存版を閲覧できます。",
descriptionProtected: "リンクを持つ人は、パスワードを入力するとこのノートの最新の保存版を閲覧できます。",
diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.ts
index d606ddb3..b90cdbc7 100644
--- a/packages/shared/src/i18n/pl.ts
+++ b/packages/shared/src/i18n/pl.ts
@@ -2562,6 +2562,8 @@ export const pl = {
notebookPasswordRequiredHint: "Ten udostępniony notatnik jest chroniony hasłem. Wpisz hasło, aby zobaczyć spis treści, notatki i załączniki.",
notebookScopeHint: "Każdy z linkiem może przeglądać notatnik, podnotatniki i załączniki. Treść aktualizuje się automatycznie.",
notebookInheritedHint: "Notatnik jest też udostępniony przez notatnik nadrzędny. Te ustawienia nie wpływają na link nadrzędny.",
+ notebookInheritedOnlyHint: "Już udostępniony przez link notatnika nadrzędnego. Możesz utworzyć osobny link z niezależnymi ustawieniami.",
+ notebookCreateIndependent: "Utwórz osobny link udostępniania",
notebookRevokeHint: "Cofnięcie wyłącza ten link. Inne udostępnienia pozostają aktywne.",
notebookPublic: "Publiczny notatnik (z podnotatnikami i przyszłą treścią)",
notebookContents: "Spis treści",
@@ -2589,6 +2591,7 @@ export const pl = {
afterSync: "Udostępnij notatkę po synchronizacji",
active: "Udostępniona",
manage: "Zarządzaj udostępnianiem",
+ notebookInheritedAction: "Udostępniony przez notatnik nadrzędny",
title: "Udostępnij notatkę",
description: "Każdy, kto ma link, może bez logowania wyświetlić najnowszą zapisaną wersję tej notatki.",
descriptionProtected: "Każdy, kto ma link, musi wpisać hasło, aby wyświetlić najnowszą zapisaną wersję tej notatki.",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 847aecfa..75f28023 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -2571,6 +2571,8 @@ export const zhCN = {
notebookPasswordRequiredHint: "这个分享笔记本受密码保护。输入密码后即可查看目录、笔记和附件。",
notebookScopeHint: "持有链接即可查看整个笔记本(含子笔记本和附件),内容变更自动同步。",
notebookInheritedHint: "此笔记本也通过上级分享,此处的设置不影响上级链接。",
+ notebookInheritedOnlyHint: "已通过父级链接分享。可另建独立链接,设置不影响父级分享。",
+ notebookCreateIndependent: "创建独立分享链接",
notebookRevokeHint: "取消后此链接失效,其他分享不受影响。",
notebookPublic: "公开笔记本(包含子笔记本及新增内容)",
notebookContents: "目录",
@@ -2598,6 +2600,7 @@ export const zhCN = {
afterSync: "同步后可分享笔记",
active: "正在分享",
manage: "管理分享",
+ notebookInheritedAction: "随父级分享",
title: "分享笔记",
description: "任何获得链接的人无需登录,即可查看这篇笔记最新保存的内容。",
descriptionProtected: "获得链接的人需要输入密码后,才能查看这篇笔记最新保存的内容。",