diff --git a/.changeset/35936-kanban-open-mode.md b/.changeset/35936-kanban-open-mode.md new file mode 100644 index 00000000000..c4b44911fae --- /dev/null +++ b/.changeset/35936-kanban-open-mode.md @@ -0,0 +1,14 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/console': patch +'@object-ui/i18n': patch +--- + +fix(console): Studio's kanban card "Click to open" offers only Default and "Don't open" + +Clause-②: no +Metadata-protocol: none + +On an object's list the record name opens the full page and the hover icon opens the side panel, so `navigation.mode` `drawer`, `page` and `new_window` parse there and change nothing; only `none` still counts. The kanban card section of Studio's list-view inspector offered all four. It now offers Default (no key) and "Don't open" (`none`). A view that already stores `drawer`, `page` or `new_window` shows that value flagged "(deprecated)" in the select, and picking Default removes the key. Opening such a view writes nothing. The spec is unchanged, and page blocks that carry `navigation` keep every mode. + +The studio catalogue drops the three labels nothing reads any more: `engine.studio.inspector.listView.kanbanCard.mode.drawer`, `.mode.page` and `.mode.newWindow`. diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx index 6dd6b443a22..222e503bd32 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectListViewInspector.tsx @@ -102,7 +102,7 @@ import { } from '@object-ui/data-objectstack'; import { stripReadDecorations } from '@objectstack/spec/kernel'; import { NavigationModeSchema, resolveI18nLabel, type I18nLabel, type NavigationMode } from '@objectstack/spec/ui'; -import { InspectorReorderButtons, InspectorShell } from '../metadata-admin/inspectors/_shared.js'; +import { flagUnknownValue, InspectorReorderButtons, InspectorShell } from '../metadata-admin/inspectors/_shared.js'; import { FieldsListEditor } from '../metadata-admin/previews/FieldsListEditor.js'; import { FieldListRowNameOnHover } from '../metadata-admin/previews/ViewColumnPanes.js'; import { useObjectFields } from '../metadata-admin/previews/useObjectFields.js'; @@ -1060,18 +1060,17 @@ const KANBAN_FIELDS_LABEL_ID = 'studio-list-view-kanban-fields'; const UNSET = '__unset__'; /** - * The copy of each `navigation.mode` the spec declares (`NavigationModeSchema`). - * Keyed by the spec's own union, so a member the spec adds or retires is a - * compile error here — `modal`, `split` and `popover` left with - * objectstack#26677 (a side-by-side pane is a reader's preference, not - * metadata). + * The `navigation.mode` values the click-to-open select offers, besides the + * default (no key): only `none`. On an object's list the key is deprecated + * (objectstack#35854) — the record name opens the full page and the hover icon + * the side panel, for every reader — so `drawer`, `page` and `new_window` + * still parse and change nothing, and offering them would let an author pick a + * setting the board ignores. A stored one is drawn, flagged deprecated, so it + * can be seen and cleared; opening the view writes nothing. */ -const NAVIGATION_MODE_LABEL_KEYS: Record = { - drawer: 'engine.studio.inspector.listView.kanbanCard.mode.drawer', - page: 'engine.studio.inspector.listView.kanbanCard.mode.page', - new_window: 'engine.studio.inspector.listView.kanbanCard.mode.newWindow', - none: 'engine.studio.inspector.listView.kanbanCard.mode.none', -}; +const OFFERED_NAVIGATION_MODES: ReadonlyArray<{ mode: NavigationMode; labelKey: string }> = [ + { mode: 'none', labelKey: 'engine.studio.inspector.listView.kanbanCard.mode.none' }, +]; /** * objectui#12725 — the 看板卡片 section of a kanban view: what each card on @@ -1083,8 +1082,8 @@ const NAVIGATION_MODE_LABEL_KEYS: Record = { * show on cards"), ordered; * - title → `kanban.titleField`, optional: empty removes the key, and the * card shows the record's display name, as the spec describes; - * - click to open → `navigation.mode` (`NavigationModeSchema`); the default - * removes the key; + * - click to open → `navigation.mode`, offering only `none` + * ({@link OFFERED_NAVIGATION_MODES}); the default removes the key; * - group by → `kanban.groupByField`, required by the spec. Every field of * the object is offered: the spec's check refuses only a padded name, and * a field's name is never padded. @@ -1222,17 +1221,24 @@ function KanbanCardSection({ - - {t('engine.studio.inspector.listView.kanbanCard.openDefault', locale)} - - {mode && !NavigationModeSchema.options.includes(mode as never) && ( + {/* A stored value the select does not offer: drawn first and flagged, + as `InspectorSelectField` draws one (objectui#8488), so the + trigger never goes blank and 默认 below clears it. */} + {mode && !OFFERED_NAVIGATION_MODES.some((o) => o.mode === mode) && ( - {mode} + + {NavigationModeSchema.options.includes(mode as never) + ? flagUnknownValue(mode, t('engine.form.deprecated', locale), locale) + : mode} + )} - {NavigationModeSchema.options.map((m) => ( - - {t(NAVIGATION_MODE_LABEL_KEYS[m], locale)} + + {t('engine.studio.inspector.listView.kanbanCard.openDefault', locale)} + + {OFFERED_NAVIGATION_MODES.map((o) => ( + + {t(o.labelKey, locale)} ))} diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.kanbanCardSelection-12725.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.kanbanCardSelection-12725.test.tsx index 323fe561b0d..479c951fa7c 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.kanbanCardSelection-12725.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.kanbanCardSelection-12725.test.tsx @@ -46,6 +46,7 @@ const NAV = [ { id: 'nav_board', type: 'object', label: 'Board', objectName: 'showcase_task', viewName: 'board' }, { id: 'nav_tasks', type: 'object', label: 'Tasks', objectName: 'showcase_task' }, { id: 'nav_bare', type: 'object', label: 'Bare board', objectName: 'showcase_task', viewName: 'bare' }, + { id: 'nav_legacy', type: 'object', label: 'Legacy board', objectName: 'showcase_task', viewName: 'legacy' }, ]; const OBJECT_DEF = { @@ -86,6 +87,15 @@ const BARE_VIEW = { }, }; +/** A kanban view that stores a click-to-open mode an object's list ignores (objectstack#35854). */ +const LEGACY_VIEW = { + name: 'showcase_task.legacy', + object: 'showcase_task', + viewKind: 'list', + label: 'Legacy board', + config: { ...BOARD_VIEW.config, navigation: { mode: 'drawer' } }, +}; + /** The object's default list view: a grid. */ const DEFAULT_VIEW = { name: 'showcase_task.default', @@ -138,6 +148,9 @@ const mockClient = { if (type === 'view' && name === BARE_VIEW.name) { return { code: null, overlay: BARE_VIEW, overlayScope: 'env', effective: BARE_VIEW }; } + if (type === 'view' && name === LEGACY_VIEW.name) { + return { code: null, overlay: LEGACY_VIEW, overlayScope: 'env', effective: LEGACY_VIEW }; + } if (type === 'view' && name === DEFAULT_VIEW.name) { return { code: null, overlay: DEFAULT_VIEW, overlayScope: 'env', effective: DEFAULT_VIEW }; } @@ -305,8 +318,11 @@ function outlinedCard(): string | null { return /data-kanban-card="([^"]+)"/.exec(rule)?.[1] ?? null; } -/** Open the rail's nth `object · showcase_task` entry (0: the board, 1: the default grid, 2: the bare board). */ -async function openLeaf(index: 0 | 1 | 2) { +/** + * Open the rail's nth `object · showcase_task` entry (0: the board, 1: the + * default grid, 2: the bare board, 3: the legacy board). + */ +async function openLeaf(index: 0 | 1 | 2 | 3) { renderSurface(); const leaves = await screen.findAllByTitle('object · showcase_task', undefined, { timeout: 4000 }); fireEvent.click(leaves[index]); @@ -508,12 +524,12 @@ describe('the kanban card section writes only its spec keys (objectui#12725)', ( expectSpecValid(lastSavedBoardBody()!); }); - it('click to open writes navigation.mode, over the spec modes', async () => { + it('click to open writes navigation.mode: none', async () => { await openCardProps(); const open = within(cardSection() as HTMLElement).getByLabelText(t('engine.studio.inspector.listView.kanbanCard.open', 'en')); - await pick(open, t('engine.studio.inspector.listView.kanbanCard.mode.drawer', 'en')); + await pick(open, t('engine.studio.inspector.listView.kanbanCard.mode.none', 'en')); - await waitFor(() => expect(lastSavedBoardBody()?.navigation).toEqual({ mode: 'drawer' }), { timeout: 4000 }); + await waitFor(() => expect(lastSavedBoardBody()?.navigation).toEqual({ mode: 'none' }), { timeout: 4000 }); unchangedApart(lastSavedBoardBody()!, ['navigation']); expectSpecValid(lastSavedBoardBody()!); }); @@ -532,6 +548,52 @@ describe('the kanban card section writes only its spec keys (objectui#12725)', ( }); }); +describe("click to open offers only the default and none on an object's list (objectstack#35936)", () => { + /** Open the nth board leaf, select a card, and return the click-to-open trigger. */ + async function openTrigger(index: 0 | 3): Promise { + await openLeaf(index); + await waitFor(() => expect(cardSection()).not.toBeNull(), { timeout: 4000 }); + fireEvent.click(await card('Bob')); + await waitFor(() => expect(slot()).toHaveAttribute('data-mode', 'props')); + return within(cardSection() as HTMLElement).getByLabelText(t('engine.studio.inspector.listView.kanbanCard.open', 'en')); + } + + /** The names of the options the open select lists. */ + async function optionNames(trigger: HTMLElement): Promise { + fireEvent.keyDown(trigger, { key: 'ArrowDown' }); + await screen.findByRole('listbox'); + return screen.getAllByRole('option').map((o) => o.textContent ?? ''); + } + + const DEFAULT = t('engine.studio.inspector.listView.kanbanCard.openDefault', 'en'); + const NONE = t('engine.studio.inspector.listView.kanbanCard.mode.none', 'en'); + const STORED_DRAWER = tFormat('engine.form.flaggedValue', 'en', { value: 'drawer', flag: t('engine.form.deprecated', 'en') }); + + it('a view with no stored mode is offered exactly the default and none', async () => { + const open = await openTrigger(0); + expect(await optionNames(open)).toEqual([DEFAULT, NONE]); + }); + + it('a stored drawer shows flagged deprecated, beside the default and none, and opening writes nothing', async () => { + const open = await openTrigger(3); + expect(open).toHaveTextContent(STORED_DRAWER); + expect(await optionNames(open)).toEqual([STORED_DRAWER, DEFAULT, NONE]); + // Past the pillar's autosave debounce (`useDraftAutoSave`): a write would have been sent by now. + await new Promise((resolve) => setTimeout(resolve, 1700)); + expect(lastSavedBoardBody(LEGACY_VIEW.name)).toBeNull(); + }); + + it('the default clears a stored drawer, and the rest of the body is untouched', async () => { + const open = await openTrigger(3); + await pick(open, DEFAULT); + + await waitFor(() => expect(lastSavedBoardBody(LEGACY_VIEW.name)).not.toBeNull(), { timeout: 4000 }); + const body = lastSavedBoardBody(LEGACY_VIEW.name)!; + expect(body).toEqual(BOARD_VIEW.config); + expectSpecValid(body); + }); +}); + describe('a kanban view with no kanban block (objectui#12725)', () => { it('the title and the card fields wait for the group-by field, which writes the block with no card fields', async () => { await openLeaf(2); diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 9a2314c9e6a..8db062eb1fb 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -4599,9 +4599,6 @@ const STUDIO_EN: Record = { 'engine.studio.inspector.listView.kanbanCard.titleRecordName': 'Record name', 'engine.studio.inspector.listView.kanbanCard.open': 'Click to open', 'engine.studio.inspector.listView.kanbanCard.openDefault': 'Default', - 'engine.studio.inspector.listView.kanbanCard.mode.page': 'Record page', - 'engine.studio.inspector.listView.kanbanCard.mode.drawer': 'Side drawer', - 'engine.studio.inspector.listView.kanbanCard.mode.newWindow': 'New window', 'engine.studio.inspector.listView.kanbanCard.mode.none': "Don't open", 'engine.studio.inspector.listView.kanbanCard.groupBy': 'Group by field', 'engine.studio.inspector.listView.kanbanCard.pickField': 'Pick a field', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 05d4a4743d9..6c86b45b191 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -4133,9 +4133,6 @@ const STUDIO_ZH: Record = { 'engine.studio.inspector.listView.kanbanCard.titleRecordName': '记录名称', 'engine.studio.inspector.listView.kanbanCard.open': '点击打开', 'engine.studio.inspector.listView.kanbanCard.openDefault': '默认', - 'engine.studio.inspector.listView.kanbanCard.mode.page': '记录页', - 'engine.studio.inspector.listView.kanbanCard.mode.drawer': '侧边抽屉', - 'engine.studio.inspector.listView.kanbanCard.mode.newWindow': '新窗口', 'engine.studio.inspector.listView.kanbanCard.mode.none': '不打开', 'engine.studio.inspector.listView.kanbanCard.groupBy': '分组字段', 'engine.studio.inspector.listView.kanbanCard.pickField': '选择字段',