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): show the table form button as live while it accepts responses

tianma-if850c1af1b5cc
diff --git a/apps/web/src/components/TableEditorPane.tsx b/apps/web/src/components/TableEditorPane.tsx
index ce9bd6fc..0393b742 100644
--- a/apps/web/src/components/TableEditorPane.tsx
+++ b/apps/web/src/components/TableEditorPane.tsx
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useRef, useState } from "react";
+import { useQuery } from "@tanstack/react-query";
import { flexRender, getCoreRowModel, useReactTable, type ColumnDef } from "@tanstack/react-table";
import { ChevronLeft, Download, Form, Paperclip, Plus, TableProperties, Trash2, X } from "lucide-react";
import { useTranslation } from "react-i18next";
@@ -393,6 +394,14 @@ export const TableEditorPane = ({
const [saveError, setSaveError] = useState<string | null>(null);
const [saveFailed, setSaveFailed] = useState(false);
const [formOpen, setFormOpen] = useState(false);
+ const formQuery = useQuery({
+ queryKey: ["table-form", memo.id],
+ queryFn: () => api.getTableForm(memo.id),
+ enabled: !isLocalMemoId(memo.id),
+ retry: false,
+ refetchOnWindowFocus: false,
+ });
+ const formAccepting = formQuery.data?.form?.enabled === true;
const [editSessionReady, setEditSessionReady] = useState(false);
const memoRef = useRef(memo);
const titleRef = useRef(title);
@@ -640,12 +649,19 @@ export const TableEditorPane = ({
{saveLabel ? <span className={saveError ? "text-xs text-rose-600" : "text-xs text-slate-400"}>{saveLabel}</span> : null}
<Tooltip>
<TooltipTrigger asChild>
- <Button type="button" variant="outline" size="sm" disabled={readOnly} onClick={() => setFormOpen(true)}>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={readOnly}
+ className={formAccepting ? "border-emerald-200 bg-emerald-50 text-emerald-700 hover:border-emerald-300 hover:bg-emerald-100 hover:text-emerald-800" : undefined}
+ onClick={() => setFormOpen(true)}
+ >
<Form className="h-4 w-4" />
- {t("structuredTable.openForm")}
+ {t(formAccepting ? "structuredTable.formLive" : "structuredTable.openForm")}
</Button>
</TooltipTrigger>
- <TooltipContent>{t("structuredTable.openFormTooltip")}</TooltipContent>
+ <TooltipContent>{t(formAccepting ? "structuredTable.formLiveTooltip" : "structuredTable.openFormTooltip")}</TooltipContent>
</Tooltip>
<Button type="button" variant="outline" size="sm" onClick={exportCsv}>
<Download className="h-4 w-4" />
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 02209866..ace76610 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -313,6 +313,8 @@ export const enUS = {
editField: "Edit field {{name}}",
openForm: "Form Collection",
openFormTooltip: "Share a form link to collect responses as table records.",
+ formLive: "Collecting",
+ formLiveTooltip: "Accepting responses. Open to copy the link or stop collection.",
form: {
title: "Form Collection",
description: "Share a form link for others to fill out. Submissions are added as new table records, and respondents cannot view existing rows.",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index edd7f188..245aaa2c 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -313,6 +313,8 @@ export const ja = {
editField: "フィールド {{name}} を編集",
openForm: "フォーム収集",
openFormTooltip: "フォームのリンクを共有して回答を収集し、自動的にテーブルレコードとして追加します。",
+ formLive: "収集中",
+ formLiveTooltip: "回答を受け付けています。開くとリンクのコピーや受付停止ができます。",
form: {
title: "フォーム収集",
description: "フォームのリンクを共有して回答してもらうと、提出内容が新しい行として自動追加されます。回答者は既存のデータを閲覧できません。",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 9484eb5f..20587950 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -313,6 +313,8 @@ export const zhCN = {
editField: "编辑字段 {{name}}",
openForm: "表单收集",
openFormTooltip: "分享表单链接收集填写,提交后自动沉淀为表格记录",
+ formLive: "收集中",
+ formLiveTooltip: "正在接受填写。点开可以复制链接或停止收集。",
form: {
title: "表单收集",
description: "分享表单链接给他人填写,提交内容会自动追加为一条新记录,填写人无法查看已有数据。",