From 92d401bc1f2f6a7da509c04a4713e0349d0c33a0 Mon Sep 17 00:00:00 2001 From: matevip Date: Wed, 10 Jun 2026 17:46:19 +0800 Subject: [PATCH] fix(wiki): keep raw-materials & recent-activity readable for read-only viewers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KB workspace split into a reading view (pages + graph) and a manage view (raw materials, config, transformations, advanced, recent-activity snapshot) gated behind manage:wiki. That moved the raw-materials and recent-activity surfaces — which read-only viewers (view:wiki without manage:wiki) could previously browse — entirely behind the management gate, silently dropping their access. Re-surface both in the reading-view segmented toggle for viewers who lack a management view. Managers keep the focused pages/graph toggle and still reach these surfaces through the management view, so nothing is duplicated for them. The content panels already render by activeTab, so this only widens the reading toggle and the activeTab/readingTab types. --- .../views/Wiki/components/WikiWorkspace.vue | 21 ++++++++-- .../Wiki/components/WikiWorkspaceHeader.vue | 39 ++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/mateclaw-ui/src/views/Wiki/components/WikiWorkspace.vue b/mateclaw-ui/src/views/Wiki/components/WikiWorkspace.vue index aa8773c8..1155d051 100644 --- a/mateclaw-ui/src/views/Wiki/components/WikiWorkspace.vue +++ b/mateclaw-ui/src/views/Wiki/components/WikiWorkspace.vue @@ -4,7 +4,7 @@ :kb="kb" :mode="store.workspaceMode" :can-manage="canManageWiki" - :reading-tab="activeTab === 'graph' ? 'graph' : 'pages'" + :reading-tab="readingTab" @back="store.backToLibrary()" @switch-mode="store.setWorkspaceMode($event)" @switch-reading="activeTab = $event" @@ -114,9 +114,24 @@ const workspace = useWorkspaceStore() // the processing-config and transformations tabs are management surfaces. const canManageWiki = computed(() => workspace.can('manage:wiki')) -const activeTab = ref('pages') +// Reading-view surfaces (driven by the header toggle) vs management-only surfaces +// (driven by the manage-view tab strip). 'raw' and 'hotCache' appear in both: in +// the reading toggle for read-only viewers, and in the management tab strip for +// managers — so the union spans every key activeTab can take. +type ReadingTab = 'pages' | 'graph' | 'raw' | 'hotCache' +type WikiTab = ReadingTab | 'config' | 'transformations' | 'advanced' + +const activeTab = ref('pages') const brokenPanelOpen = ref(false) +// Narrow activeTab to the reading subset for the header toggle's highlight. In +// browse mode activeTab is always a reading key; the management-only keys map to +// 'pages' as a harmless default (the toggle isn't rendered in manage mode). +const readingTab = computed(() => { + const t = activeTab.value + return t === 'graph' || t === 'raw' || t === 'hotCache' ? t : 'pages' +}) + // When a page becomes the currentPage (e.g. via the global wikilink click // handler that lands on /wiki?kbId=X&slug=Y), switch the tab to 'pages' so // the viewer is the thing the user sees. Only meaningful in the reading view — @@ -129,7 +144,7 @@ watch(() => store.currentPage, (page) => { // header's segmented control instead, so it has no tabs here. Entry into manage // mode is gated by manage:wiki, but guard here too so a read-only viewer never // sees management tabs even if the mode is somehow forced. -const tabs = computed(() => { +const tabs = computed<{ key: WikiTab; label: string }[]>(() => { if (!canManageWiki.value) return [] return [ { key: 'raw', label: t('wiki.rawMaterials') }, diff --git a/mateclaw-ui/src/views/Wiki/components/WikiWorkspaceHeader.vue b/mateclaw-ui/src/views/Wiki/components/WikiWorkspaceHeader.vue index 4c0957ea..6f0ecdfe 100644 --- a/mateclaw-ui/src/views/Wiki/components/WikiWorkspaceHeader.vue +++ b/mateclaw-ui/src/views/Wiki/components/WikiWorkspaceHeader.vue @@ -41,6 +41,37 @@ {{ t('wiki.graph.tab') }} + +