chore: phase 2 and 3 refactors
This commit is contained in:
25
TODO.md
25
TODO.md
@@ -179,16 +179,17 @@ Pure tab-policy helpers that decide:
|
|||||||
- [x] Update/expand contract tests for unified activity behavior and `ActivityBar` integration.
|
- [x] Update/expand contract tests for unified activity behavior and `ActivityBar` integration.
|
||||||
|
|
||||||
## Phase 2 — Normalize Sidebar Mounting + Ownership Mapping
|
## Phase 2 — Normalize Sidebar Mounting + Ownership Mapping
|
||||||
- Introduce a sidebar view registry mapping in one place.
|
- [x] Introduce a sidebar view registry mapping in one place.
|
||||||
- Pick one global mounting strategy (A or B) and apply to all sidebars.
|
- [x] Pick one global mounting strategy (A or B) and apply to all sidebars.
|
||||||
- If needed, add explicit state persistence for remount-safe UX.
|
- [x] Add explicit state persistence for remount-safe sidebar section UX where needed.
|
||||||
- Introduce unified section activation API and migrate `SettingsNav`/`TagsNav` to use it.
|
- [x] Introduce unified section activation API and migrate `SettingsNav`/`TagsNav` to use it.
|
||||||
|
|
||||||
## Phase 3 — Centralize Editor/Tab Management (expanded)
|
## Phase 3 — Centralize Editor/Tab Management (expanded)
|
||||||
- Implement shared tab policy layer for all editor tabs.
|
- [x] Implement shared tab policy layer for singleton tool tabs.
|
||||||
- Centralize singleton tab policies (`settings`, `tags`, `style`, `documentation`, etc.).
|
- [x] Centralize singleton tab policies (`settings`, `tags`, `style`, `documentation`, `metadata-diff`, `site-validation`).
|
||||||
- Centralize transient/pin lifecycle rules (including promotion behavior).
|
- Centralize transient/pin lifecycle rules (including promotion behavior).
|
||||||
- Remove duplicated tab-open logic from sidebars/nav components where possible.
|
- Remove duplicated tab-open logic from sidebars/nav components where possible.
|
||||||
|
- [x] Ensure site-validation tab reopens with persisted last report and refreshes only on explicit validation trigger.
|
||||||
|
|
||||||
### Editor Tab Management Variations (current analysis)
|
### Editor Tab Management Variations (current analysis)
|
||||||
1. **Singleton, pinned tool tabs**
|
1. **Singleton, pinned tool tabs**
|
||||||
@@ -232,7 +233,7 @@ Pure tab-policy helpers that decide:
|
|||||||
- [x] Implement a unified section activation API for editor/tool sections.
|
- [x] Implement a unified section activation API for editor/tool sections.
|
||||||
- [x] Choose global sidebar mounting variant: **B conditional mount**.
|
- [x] Choose global sidebar mounting variant: **B conditional mount**.
|
||||||
- [x] Define sidebar action rule: section clicks always activate/open corresponding editor.
|
- [x] Define sidebar action rule: section clicks always activate/open corresponding editor.
|
||||||
- [ ] Migrate existing `SettingsNav`/`TagsNav` auto-open + delayed scroll to the unified section activation API that enforces this rule.
|
- [x] Migrate existing `SettingsNav`/`TagsNav` auto-open + delayed scroll to the unified section activation API that enforces this rule.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -244,4 +245,12 @@ Pure tab-policy helpers that decide:
|
|||||||
- [x] Decision captured: sidebar mounting strategy Variant B (conditional mount).
|
- [x] Decision captured: sidebar mounting strategy Variant B (conditional mount).
|
||||||
- [x] Decision captured: sidebar section actions always activate/open corresponding editor.
|
- [x] Decision captured: sidebar section actions always activate/open corresponding editor.
|
||||||
- [x] Phase 1b complete: removed `sidebar-or-tab`, unified activity click behavior, and updated tests.
|
- [x] Phase 1b complete: removed `sidebar-or-tab`, unified activity click behavior, and updated tests.
|
||||||
- [ ] Next implementation slice: Phase 2 (sidebar registry + unified section activation API migration).
|
- [x] Added `Edit Preferences` menu item (`CmdOrCtrl+,`) to open preferences editor directly.
|
||||||
|
- [x] Phase 2 slice complete: added shared section activation API and migrated `SettingsNav`/`TagsNav`.
|
||||||
|
- [x] Phase 2 slice complete: normalized posts/pages sidebar rendering to Variant B conditional mount.
|
||||||
|
- [x] Phase 2 slice complete: introduced canonical sidebar view registry and applied it across navigation/store/sidebar mapping.
|
||||||
|
- [x] Phase 2 slice complete: persisted settings/tags active section selection for remount-safe UX.
|
||||||
|
- [x] Phase 3 slice complete: added singleton tab policy helper and migrated menu/sidebar singleton tool openings to it.
|
||||||
|
- [x] Phase 3 slice complete: site validation report is persisted per project and reloaded by `SiteValidationView`.
|
||||||
|
- [x] Phase 3 slice complete: site validation view refreshes via explicit `bds:site-validation-updated` event (no auto-validate on mount).
|
||||||
|
- [ ] Next implementation slice: Phase 3 continuation (centralize non-singleton tab lifecycle/promotion rules).
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"menu.item.selectAll": "Alles auswählen",
|
"menu.item.selectAll": "Alles auswählen",
|
||||||
"menu.item.find": "Suchen",
|
"menu.item.find": "Suchen",
|
||||||
"menu.item.replace": "Ersetzen",
|
"menu.item.replace": "Ersetzen",
|
||||||
|
"menu.item.editPreferences": "Einstellungen bearbeiten",
|
||||||
"menu.item.viewPosts": "Beiträge",
|
"menu.item.viewPosts": "Beiträge",
|
||||||
"menu.item.viewMedia": "Medien",
|
"menu.item.viewMedia": "Medien",
|
||||||
"menu.item.toggleSidebar": "Seitenleiste umschalten",
|
"menu.item.toggleSidebar": "Seitenleiste umschalten",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"menu.item.selectAll": "Select All",
|
"menu.item.selectAll": "Select All",
|
||||||
"menu.item.find": "Find",
|
"menu.item.find": "Find",
|
||||||
"menu.item.replace": "Replace",
|
"menu.item.replace": "Replace",
|
||||||
|
"menu.item.editPreferences": "Edit Preferences",
|
||||||
"menu.item.viewPosts": "Posts",
|
"menu.item.viewPosts": "Posts",
|
||||||
"menu.item.viewMedia": "Media",
|
"menu.item.viewMedia": "Media",
|
||||||
"menu.item.toggleSidebar": "Toggle Sidebar",
|
"menu.item.toggleSidebar": "Toggle Sidebar",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"menu.item.selectAll": "Seleccionar todo",
|
"menu.item.selectAll": "Seleccionar todo",
|
||||||
"menu.item.find": "Buscar",
|
"menu.item.find": "Buscar",
|
||||||
"menu.item.replace": "Reemplazar",
|
"menu.item.replace": "Reemplazar",
|
||||||
|
"menu.item.editPreferences": "Editar preferencias",
|
||||||
"menu.item.viewPosts": "Entradas",
|
"menu.item.viewPosts": "Entradas",
|
||||||
"menu.item.viewMedia": "Medios",
|
"menu.item.viewMedia": "Medios",
|
||||||
"menu.item.toggleSidebar": "Alternar barra lateral",
|
"menu.item.toggleSidebar": "Alternar barra lateral",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"menu.item.selectAll": "Tout sélectionner",
|
"menu.item.selectAll": "Tout sélectionner",
|
||||||
"menu.item.find": "Rechercher",
|
"menu.item.find": "Rechercher",
|
||||||
"menu.item.replace": "Remplacer",
|
"menu.item.replace": "Remplacer",
|
||||||
|
"menu.item.editPreferences": "Modifier les préférences",
|
||||||
"menu.item.viewPosts": "Articles",
|
"menu.item.viewPosts": "Articles",
|
||||||
"menu.item.viewMedia": "Médias",
|
"menu.item.viewMedia": "Médias",
|
||||||
"menu.item.toggleSidebar": "Basculer la barre latérale",
|
"menu.item.toggleSidebar": "Basculer la barre latérale",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"menu.item.selectAll": "Seleziona tutto",
|
"menu.item.selectAll": "Seleziona tutto",
|
||||||
"menu.item.find": "Trova",
|
"menu.item.find": "Trova",
|
||||||
"menu.item.replace": "Sostituisci",
|
"menu.item.replace": "Sostituisci",
|
||||||
|
"menu.item.editPreferences": "Modifica preferenze",
|
||||||
"menu.item.viewPosts": "Post",
|
"menu.item.viewPosts": "Post",
|
||||||
"menu.item.viewMedia": "Contenuti media",
|
"menu.item.viewMedia": "Contenuti media",
|
||||||
"menu.item.toggleSidebar": "Attiva/disattiva barra laterale",
|
"menu.item.toggleSidebar": "Attiva/disattiva barra laterale",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export type AppMenuAction =
|
|||||||
| 'selectAll'
|
| 'selectAll'
|
||||||
| 'find'
|
| 'find'
|
||||||
| 'replace'
|
| 'replace'
|
||||||
|
| 'editPreferences'
|
||||||
| 'viewPosts'
|
| 'viewPosts'
|
||||||
| 'viewMedia'
|
| 'viewMedia'
|
||||||
| 'toggleSidebar'
|
| 'toggleSidebar'
|
||||||
@@ -89,6 +90,7 @@ export const APP_MENU_GROUPS: AppMenuGroupDefinition[] = [
|
|||||||
{ label: '', action: 'edit-separator-3', separator: true },
|
{ label: '', action: 'edit-separator-3', separator: true },
|
||||||
{ label: 'menu.item.find', action: 'find', accelerator: 'CmdOrCtrl+F' },
|
{ label: 'menu.item.find', action: 'find', accelerator: 'CmdOrCtrl+F' },
|
||||||
{ label: 'menu.item.replace', action: 'replace', accelerator: 'CmdOrCtrl+H' },
|
{ label: 'menu.item.replace', action: 'replace', accelerator: 'CmdOrCtrl+H' },
|
||||||
|
{ label: 'menu.item.editPreferences', action: 'editPreferences', accelerator: 'CmdOrCtrl+,' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -143,6 +145,7 @@ export const APP_MENU_ACTION_EVENT_MAP: Partial<Record<AppMenuAction, string>> =
|
|||||||
save: 'menu:save',
|
save: 'menu:save',
|
||||||
find: 'menu:find',
|
find: 'menu:find',
|
||||||
replace: 'menu:replace',
|
replace: 'menu:replace',
|
||||||
|
editPreferences: 'menu:editPreferences',
|
||||||
viewPosts: 'menu:viewPosts',
|
viewPosts: 'menu:viewPosts',
|
||||||
viewMedia: 'menu:viewMedia',
|
viewMedia: 'menu:viewMedia',
|
||||||
toggleSidebar: 'menu:toggleSidebar',
|
toggleSidebar: 'menu:toggleSidebar',
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import React, { useEffect } from 'react';
|
|||||||
import { ActivityBar, Sidebar, Editor, StatusBar, Panel, TabBar, ToastContainer, showToast, ResizablePanel, WindowTitleBar } from './components';
|
import { ActivityBar, Sidebar, Editor, StatusBar, Panel, TabBar, ToastContainer, showToast, ResizablePanel, WindowTitleBar } from './components';
|
||||||
import { useAppStore, PostData, MediaData, TaskProgress } from './store';
|
import { useAppStore, PostData, MediaData, TaskProgress } from './store';
|
||||||
import { loadTabsForProject, saveTabsForProject } from './utils';
|
import { loadTabsForProject, saveTabsForProject } from './utils';
|
||||||
|
import { openSingletonToolTab } from './navigation/tabPolicy';
|
||||||
|
import { persistSiteValidationReport } from './navigation/siteValidationPersistence';
|
||||||
import { ensureRendererPicoThemeStylesheet, getRendererPicoTheme } from './utils/picoTheme';
|
import { ensureRendererPicoThemeStylesheet, getRendererPicoTheme } from './utils/picoTheme';
|
||||||
import { useI18n } from './i18n';
|
import { useI18n } from './i18n';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
@@ -224,6 +226,12 @@ const App: React.FC = () => {
|
|||||||
}) || (() => {})
|
}) || (() => {})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
unsubscribers.push(
|
||||||
|
window.electronAPI?.on('menu:editPreferences', () => {
|
||||||
|
openSingletonToolTab(openTab, 'settings');
|
||||||
|
}) || (() => {})
|
||||||
|
);
|
||||||
|
|
||||||
// Rebuild events - clear store on start, reload on complete
|
// Rebuild events - clear store on start, reload on complete
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
window.electronAPI?.on('posts:rebuildStarted', () => {
|
window.electronAPI?.on('posts:rebuildStarted', () => {
|
||||||
@@ -288,8 +296,7 @@ const App: React.FC = () => {
|
|||||||
|
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
window.electronAPI?.on('menu:metadataDiff', () => {
|
window.electronAPI?.on('menu:metadataDiff', () => {
|
||||||
// Open metadata diff tool tab
|
openSingletonToolTab(openTab, 'metadata-diff');
|
||||||
openTab({ id: 'metadata-diff', type: 'metadata-diff', title: tr('app.metadataDiff') });
|
|
||||||
}) || (() => {})
|
}) || (() => {})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -306,7 +313,23 @@ const App: React.FC = () => {
|
|||||||
|
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
window.electronAPI?.on('menu:validateSite', () => {
|
window.electronAPI?.on('menu:validateSite', () => {
|
||||||
openTab({ id: 'site-validation-report', type: 'site-validation', isTransient: true });
|
const validateAndOpen = async () => {
|
||||||
|
try {
|
||||||
|
const report = await window.electronAPI?.blog.validateSite();
|
||||||
|
const projectId = useAppStore.getState().activeProject?.id;
|
||||||
|
if (projectId && report) {
|
||||||
|
persistSiteValidationReport(projectId, report);
|
||||||
|
window.dispatchEvent(new CustomEvent('bds:site-validation-updated', {
|
||||||
|
detail: { projectId },
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
openSingletonToolTab(openTab, 'site-validation');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Site validation failed:', error);
|
||||||
|
showToast.error(tr('siteValidation.error.validate'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
void validateAndOpen();
|
||||||
}) || (() => {})
|
}) || (() => {})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -331,7 +354,7 @@ const App: React.FC = () => {
|
|||||||
|
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
window.electronAPI?.on('menu:openDocumentation', () => {
|
window.electronAPI?.on('menu:openDocumentation', () => {
|
||||||
openTab({ id: 'documentation', type: 'documentation', isTransient: false });
|
openSingletonToolTab(openTab, 'documentation');
|
||||||
}) || (() => {})
|
}) || (() => {})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ import { showToast } from '../Toast';
|
|||||||
import { getContrastColor, groupPostsByStatus } from '../../utils';
|
import { getContrastColor, groupPostsByStatus } from '../../utils';
|
||||||
import type { ChatConversation, ImportDefinitionData } from '../../types/electron';
|
import type { ChatConversation, ImportDefinitionData } from '../../types/electron';
|
||||||
import { GitSidebar } from '../GitSidebar/GitSidebar';
|
import { GitSidebar } from '../GitSidebar/GitSidebar';
|
||||||
|
import { scrollToSettingsSection, SettingsCategory } from '../SettingsView/SettingsView';
|
||||||
|
import { scrollToTagsSection, TagsCategory } from '../TagsView';
|
||||||
|
import { activateSidebarSection } from '../../navigation/sectionActivation';
|
||||||
|
import { getPersistedSidebarSection, setPersistedSidebarSection } from '../../navigation/sidebarUiPersistence';
|
||||||
|
import { openSingletonToolTab } from '../../navigation/tabPolicy';
|
||||||
|
import type { SidebarView } from '../../navigation/sidebarViewRegistry';
|
||||||
import { useI18n } from '../../i18n';
|
import { useI18n } from '../../i18n';
|
||||||
import './Sidebar.css';
|
import './Sidebar.css';
|
||||||
|
|
||||||
@@ -1218,24 +1224,27 @@ const MediaList: React.FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
import { scrollToSettingsSection, SettingsCategory } from '../SettingsView/SettingsView';
|
|
||||||
import { scrollToTagsSection, TagsCategory } from '../TagsView';
|
|
||||||
|
|
||||||
const TagsNav: React.FC = () => {
|
const TagsNav: React.FC = () => {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { tabs, activeTabId, openTab } = useAppStore();
|
const { tabs, activeTabId, openTab } = useAppStore();
|
||||||
const [activeSection, setActiveSection] = useState<TagsCategory | null>(null);
|
const [activeSection, setActiveSection] = useState<TagsCategory | null>(() => {
|
||||||
|
const persisted = getPersistedSidebarSection('tags');
|
||||||
|
if (persisted === 'cloud' || persisted === 'manage' || persisted === 'merge') {
|
||||||
|
return persisted;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
const isTagsTabActive = tabs.some(t => t.type === 'tags' && t.id === activeTabId);
|
const isTagsTabActive = tabs.some(t => t.type === 'tags' && t.id === activeTabId);
|
||||||
|
|
||||||
const handleNavClick = (category: TagsCategory) => {
|
const handleNavClick = (category: TagsCategory) => {
|
||||||
if (!isTagsTabActive) {
|
|
||||||
openTab({ type: 'tags', id: 'tags', isTransient: false });
|
|
||||||
}
|
|
||||||
setActiveSection(category);
|
setActiveSection(category);
|
||||||
setTimeout(() => {
|
setPersistedSidebarSection('tags', category);
|
||||||
scrollToTagsSection(category);
|
activateSidebarSection({
|
||||||
}, isTagsTabActive ? 0 : 100);
|
isEditorTabActive: isTagsTabActive,
|
||||||
|
ensureEditorTabActive: () => openSingletonToolTab(openTab, 'tags'),
|
||||||
|
activateSection: () => scrollToTagsSection(category),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -1276,26 +1285,30 @@ const TagsNav: React.FC = () => {
|
|||||||
const SettingsNav: React.FC = () => {
|
const SettingsNav: React.FC = () => {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { tabs, activeTabId, openTab } = useAppStore();
|
const { tabs, activeTabId, openTab } = useAppStore();
|
||||||
const [activeSection, setActiveSection] = useState<SettingsCategory | null>(null);
|
const [activeSection, setActiveSection] = useState<SettingsCategory | null>(() => {
|
||||||
|
const persisted = getPersistedSidebarSection('settings');
|
||||||
|
if (persisted === 'project' || persisted === 'editor' || persisted === 'content' || persisted === 'ai' || persisted === 'publishing' || persisted === 'data') {
|
||||||
|
return persisted;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
// Check if settings panel is currently active
|
// Check if settings panel is currently active
|
||||||
const isSettingsTabActive = tabs.some(t => t.type === 'settings' && t.id === activeTabId);
|
const isSettingsTabActive = tabs.some(t => t.type === 'settings' && t.id === activeTabId);
|
||||||
const isStyleTabActive = tabs.some(t => t.type === 'style' && t.id === activeTabId);
|
const isStyleTabActive = tabs.some(t => t.type === 'style' && t.id === activeTabId);
|
||||||
|
|
||||||
const handleNavClick = (category: SettingsCategory) => {
|
const handleNavClick = (category: SettingsCategory) => {
|
||||||
// If settings panel is not open or not active, open it first
|
|
||||||
if (!isSettingsTabActive) {
|
|
||||||
openTab({ type: 'settings', id: 'settings', isTransient: false });
|
|
||||||
}
|
|
||||||
setActiveSection(category);
|
setActiveSection(category);
|
||||||
// Use setTimeout to allow panel to open before scrolling
|
setPersistedSidebarSection('settings', category);
|
||||||
setTimeout(() => {
|
activateSidebarSection({
|
||||||
scrollToSettingsSection(category);
|
isEditorTabActive: isSettingsTabActive,
|
||||||
}, isSettingsTabActive ? 0 : 100);
|
ensureEditorTabActive: () => openSingletonToolTab(openTab, 'settings'),
|
||||||
|
activateSection: () => scrollToSettingsSection(category),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleStyleClick = () => {
|
const handleStyleClick = () => {
|
||||||
openTab({ type: 'style', id: 'style', isTransient: false });
|
openSingletonToolTab(openTab, 'style');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -1666,34 +1679,20 @@ export const Sidebar: React.FC = () => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sidebarViewMap: Record<SidebarView, React.ReactNode> = {
|
||||||
|
posts: <PostsList mode="posts" isActive={true} />,
|
||||||
|
pages: <PostsList mode="pages" isActive={true} />,
|
||||||
|
media: <MediaList />,
|
||||||
|
settings: <SettingsNav />,
|
||||||
|
tags: <TagsNav />,
|
||||||
|
chat: <ChatList />,
|
||||||
|
import: <ImportList />,
|
||||||
|
git: <GitSidebar />,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sidebar">
|
<div className="sidebar">
|
||||||
<div
|
{sidebarViewMap[activeView]}
|
||||||
style={{
|
|
||||||
display: activeView === 'posts' ? 'flex' : 'none',
|
|
||||||
flexDirection: 'column',
|
|
||||||
flex: 1,
|
|
||||||
minHeight: 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PostsList mode="posts" isActive={activeView === 'posts'} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: activeView === 'pages' ? 'flex' : 'none',
|
|
||||||
flexDirection: 'column',
|
|
||||||
flex: 1,
|
|
||||||
minHeight: 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PostsList mode="pages" isActive={activeView === 'pages'} />
|
|
||||||
</div>
|
|
||||||
{activeView === 'media' && <MediaList />}
|
|
||||||
{activeView === 'settings' && <SettingsNav />}
|
|
||||||
{activeView === 'tags' && <TagsNav />}
|
|
||||||
{activeView === 'chat' && <ChatList />}
|
|
||||||
{activeView === 'import' && <ImportList />}
|
|
||||||
{activeView === 'git' && <GitSidebar />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
|
import { useAppStore } from '../../store';
|
||||||
import { showToast } from '../Toast';
|
import { showToast } from '../Toast';
|
||||||
import { useI18n } from '../../i18n';
|
import { useI18n } from '../../i18n';
|
||||||
|
import { getPersistedSiteValidationReport } from '../../navigation/siteValidationPersistence';
|
||||||
import './SiteValidationView.css';
|
import './SiteValidationView.css';
|
||||||
|
|
||||||
type SiteValidationReport = {
|
type SiteValidationReport = {
|
||||||
@@ -20,27 +22,43 @@ type SiteValidationApplyResult = {
|
|||||||
|
|
||||||
export const SiteValidationView: React.FC = () => {
|
export const SiteValidationView: React.FC = () => {
|
||||||
const { t: tr } = useI18n();
|
const { t: tr } = useI18n();
|
||||||
|
const { activeProject } = useAppStore();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isApplying, setIsApplying] = useState(false);
|
const [isApplying, setIsApplying] = useState(false);
|
||||||
const [report, setReport] = useState<SiteValidationReport | null>(null);
|
const [report, setReport] = useState<SiteValidationReport | null>(null);
|
||||||
|
|
||||||
const loadReport = async () => {
|
const loadPersistedReport = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await window.electronAPI.blog.validateSite();
|
const projectId = activeProject?.id;
|
||||||
setReport(result as SiteValidationReport);
|
if (!projectId) {
|
||||||
} catch (error) {
|
setReport(null);
|
||||||
console.error('Site validation failed:', error);
|
return;
|
||||||
showToast.error(tr('siteValidation.error.validate'));
|
}
|
||||||
setReport(null);
|
|
||||||
|
const persistedReport = getPersistedSiteValidationReport(projectId);
|
||||||
|
setReport(persistedReport);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadReport();
|
loadPersistedReport();
|
||||||
}, []);
|
}, [activeProject?.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = (event: Event) => {
|
||||||
|
const detail = (event as CustomEvent<{ projectId?: string }>).detail;
|
||||||
|
if (!activeProject?.id || detail?.projectId !== activeProject.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadPersistedReport();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('bds:site-validation-updated', handler);
|
||||||
|
return () => window.removeEventListener('bds:site-validation-updated', handler);
|
||||||
|
}, [activeProject?.id]);
|
||||||
|
|
||||||
const canApply = useMemo(() => {
|
const canApply = useMemo(() => {
|
||||||
if (!report) return false;
|
if (!report) return false;
|
||||||
@@ -59,7 +77,6 @@ export const SiteValidationView: React.FC = () => {
|
|||||||
rendered: result.renderedUrlCount,
|
rendered: result.renderedUrlCount,
|
||||||
deleted: result.deletedUrlCount,
|
deleted: result.deletedUrlCount,
|
||||||
}));
|
}));
|
||||||
await loadReport();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Applying site validation failed:', error);
|
console.error('Applying site validation failed:', error);
|
||||||
showToast.error(tr('siteValidation.error.apply'));
|
showToast.error(tr('siteValidation.error.apply'));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Tab } from '../store/appStore';
|
import type { Tab } from '../store/appStore';
|
||||||
|
import type { SidebarView } from './sidebarViewRegistry';
|
||||||
|
|
||||||
export type ActivityId = 'posts' | 'pages' | 'media' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
|
export type ActivityId = 'posts' | 'pages' | 'media' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
|
||||||
export type SidebarView = 'posts' | 'pages' | 'media' | 'settings' | 'tags' | 'chat' | 'import' | 'git';
|
|
||||||
|
|
||||||
export interface ActivitySnapshot {
|
export interface ActivitySnapshot {
|
||||||
activeView: SidebarView;
|
activeView: SidebarView;
|
||||||
|
|||||||
29
src/renderer/navigation/sectionActivation.ts
Normal file
29
src/renderer/navigation/sectionActivation.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export interface ActivateSidebarSectionOptions {
|
||||||
|
isEditorTabActive: boolean;
|
||||||
|
ensureEditorTabActive: () => void;
|
||||||
|
activateSection: () => void;
|
||||||
|
delayWhenOpeningEditorMs?: number;
|
||||||
|
schedule?: (callback: () => void, delayMs: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function activateSidebarSection(options: ActivateSidebarSectionOptions): void {
|
||||||
|
const {
|
||||||
|
isEditorTabActive,
|
||||||
|
ensureEditorTabActive,
|
||||||
|
activateSection,
|
||||||
|
delayWhenOpeningEditorMs = 100,
|
||||||
|
schedule,
|
||||||
|
} = options;
|
||||||
|
|
||||||
|
const runLater = schedule ?? ((callback: () => void, delayMs: number) => {
|
||||||
|
window.setTimeout(callback, delayMs);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isEditorTabActive) {
|
||||||
|
ensureEditorTabActive();
|
||||||
|
runLater(activateSection, delayWhenOpeningEditorMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
runLater(activateSection, 0);
|
||||||
|
}
|
||||||
24
src/renderer/navigation/sidebarUiPersistence.ts
Normal file
24
src/renderer/navigation/sidebarUiPersistence.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
type SidebarSectionOwner = 'settings' | 'tags';
|
||||||
|
|
||||||
|
const SIDEBAR_SECTION_KEY_PREFIX = 'bds-sidebar-section';
|
||||||
|
|
||||||
|
function getStorageKey(owner: SidebarSectionOwner): string {
|
||||||
|
return `${SIDEBAR_SECTION_KEY_PREFIX}:${owner}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPersistedSidebarSection(owner: SidebarSectionOwner): string | null {
|
||||||
|
try {
|
||||||
|
const value = localStorage.getItem(getStorageKey(owner));
|
||||||
|
return value || null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setPersistedSidebarSection(owner: SidebarSectionOwner, sectionId: string): void {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(getStorageKey(owner), sectionId);
|
||||||
|
} catch {
|
||||||
|
// Ignore storage failures
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/renderer/navigation/sidebarViewRegistry.ts
Normal file
18
src/renderer/navigation/sidebarViewRegistry.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export const SIDEBAR_VIEW_REGISTRY = [
|
||||||
|
'posts',
|
||||||
|
'pages',
|
||||||
|
'media',
|
||||||
|
'settings',
|
||||||
|
'tags',
|
||||||
|
'chat',
|
||||||
|
'import',
|
||||||
|
'git',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type SidebarView = (typeof SIDEBAR_VIEW_REGISTRY)[number];
|
||||||
|
|
||||||
|
export const DEFAULT_SIDEBAR_VIEW: SidebarView = 'posts';
|
||||||
|
|
||||||
|
export function isSidebarView(value: string): value is SidebarView {
|
||||||
|
return (SIDEBAR_VIEW_REGISTRY as readonly string[]).includes(value);
|
||||||
|
}
|
||||||
27
src/renderer/navigation/siteValidationPersistence.ts
Normal file
27
src/renderer/navigation/siteValidationPersistence.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import type { SiteValidationReport } from '../../main/shared/electronApi';
|
||||||
|
|
||||||
|
const SITE_VALIDATION_REPORT_PREFIX = 'bds-site-validation-report';
|
||||||
|
|
||||||
|
function getStorageKey(projectId: string): string {
|
||||||
|
return `${SITE_VALIDATION_REPORT_PREFIX}:${projectId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function persistSiteValidationReport(projectId: string, report: SiteValidationReport): void {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(getStorageKey(projectId), JSON.stringify(report));
|
||||||
|
} catch {
|
||||||
|
// Ignore persistence failures.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPersistedSiteValidationReport(projectId: string): SiteValidationReport | null {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(getStorageKey(projectId));
|
||||||
|
if (!raw) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return JSON.parse(raw) as SiteValidationReport;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/renderer/navigation/tabPolicy.ts
Normal file
35
src/renderer/navigation/tabPolicy.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import type { TabType } from '../store/appStore';
|
||||||
|
|
||||||
|
export type SingletonToolTabKey =
|
||||||
|
| 'settings'
|
||||||
|
| 'tags'
|
||||||
|
| 'style'
|
||||||
|
| 'documentation'
|
||||||
|
| 'metadata-diff'
|
||||||
|
| 'site-validation';
|
||||||
|
|
||||||
|
export interface CanonicalTabSpec {
|
||||||
|
type: TabType;
|
||||||
|
id: string;
|
||||||
|
isTransient: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SINGLETON_TOOL_TAB_REGISTRY: Record<SingletonToolTabKey, CanonicalTabSpec> = {
|
||||||
|
settings: { type: 'settings', id: 'settings', isTransient: false },
|
||||||
|
tags: { type: 'tags', id: 'tags', isTransient: false },
|
||||||
|
style: { type: 'style', id: 'style', isTransient: false },
|
||||||
|
documentation: { type: 'documentation', id: 'documentation', isTransient: false },
|
||||||
|
'metadata-diff': { type: 'metadata-diff', id: 'metadata-diff', isTransient: false },
|
||||||
|
'site-validation': { type: 'site-validation', id: 'site-validation', isTransient: false },
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getSingletonToolTabSpec(key: SingletonToolTabKey): CanonicalTabSpec {
|
||||||
|
return SINGLETON_TOOL_TAB_REGISTRY[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function openSingletonToolTab(
|
||||||
|
openTab: (tab: CanonicalTabSpec) => void,
|
||||||
|
key: SingletonToolTabKey,
|
||||||
|
): void {
|
||||||
|
openTab(getSingletonToolTabSpec(key));
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { persist } from 'zustand/middleware';
|
import { persist } from 'zustand/middleware';
|
||||||
import type { DeleteReference, ConfirmDeleteDetails } from '../components/ConfirmDeleteModal';
|
import type { DeleteReference, ConfirmDeleteDetails } from '../components/ConfirmDeleteModal';
|
||||||
|
import type { SidebarView } from '../navigation/sidebarViewRegistry';
|
||||||
import type {
|
import type {
|
||||||
ProjectData,
|
ProjectData,
|
||||||
PostData,
|
PostData,
|
||||||
@@ -58,7 +59,7 @@ interface AppState {
|
|||||||
activeTabId: string | null;
|
activeTabId: string | null;
|
||||||
|
|
||||||
// UI State
|
// UI State
|
||||||
activeView: 'posts' | 'pages' | 'media' | 'settings' | 'tags' | 'chat' | 'import' | 'git';
|
activeView: SidebarView;
|
||||||
sidebarVisible: boolean;
|
sidebarVisible: boolean;
|
||||||
panelVisible: boolean;
|
panelVisible: boolean;
|
||||||
panelActiveTab: PanelTab;
|
panelActiveTab: PanelTab;
|
||||||
@@ -107,7 +108,7 @@ interface AppState {
|
|||||||
restoreTabState: (state: TabState) => void;
|
restoreTabState: (state: TabState) => void;
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
setActiveView: (view: 'posts' | 'pages' | 'media' | 'settings' | 'tags' | 'chat' | 'import' | 'git') => void;
|
setActiveView: (view: SidebarView) => void;
|
||||||
toggleSidebar: () => void;
|
toggleSidebar: () => void;
|
||||||
togglePanel: () => void;
|
togglePanel: () => void;
|
||||||
setPanelActiveTab: (tab: PanelTab) => void;
|
setPanelActiveTab: (tab: PanelTab) => void;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ describe('Pages shortcut UI', () => {
|
|||||||
expect(window.electronAPI.posts.filter).not.toHaveBeenCalledWith({ categories: ['page'] });
|
expect(window.electronAPI.posts.filter).not.toHaveBeenCalledWith({ categories: ['page'] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses a flex-height wrapper for active posts/pages sidebar view', async () => {
|
it('conditionally mounts only the active posts/pages sidebar content', async () => {
|
||||||
useAppStore.setState({
|
useAppStore.setState({
|
||||||
activeView: 'posts',
|
activeView: 'posts',
|
||||||
sidebarVisible: true,
|
sidebarVisible: true,
|
||||||
@@ -153,8 +153,7 @@ describe('Pages shortcut UI', () => {
|
|||||||
expect(await screen.findByText('POSTS')).toBeInTheDocument();
|
expect(await screen.findByText('POSTS')).toBeInTheDocument();
|
||||||
|
|
||||||
const wrappers = container.querySelectorAll('.sidebar > div');
|
const wrappers = container.querySelectorAll('.sidebar > div');
|
||||||
expect(wrappers.length).toBeGreaterThanOrEqual(2);
|
expect(wrappers.length).toBe(1);
|
||||||
expect((wrappers[0] as HTMLElement).style.display).toBe('flex');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('opens style tab from settings sidebar navigation', async () => {
|
it('opens style tab from settings sidebar navigation', async () => {
|
||||||
|
|||||||
@@ -51,4 +51,16 @@ describe('Help menu documentation entry', () => {
|
|||||||
it('maps Validate Site to a renderer menu event', () => {
|
it('maps Validate Site to a renderer menu event', () => {
|
||||||
expect(APP_MENU_ACTION_EVENT_MAP.validateSite).toBe('menu:validateSite');
|
expect(APP_MENU_ACTION_EVENT_MAP.validateSite).toBe('menu:validateSite');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('includes Edit Preferences action in Edit menu with comma shortcut', () => {
|
||||||
|
const editGroup = APP_MENU_GROUPS.find((group) => group.label === 'Edit');
|
||||||
|
const preferencesItem = editGroup?.items.find((item) => item.action === 'editPreferences');
|
||||||
|
|
||||||
|
expect(preferencesItem).toBeDefined();
|
||||||
|
expect(preferencesItem?.accelerator).toContain(',');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maps Edit Preferences to a renderer menu event', () => {
|
||||||
|
expect(APP_MENU_ACTION_EVENT_MAP.editPreferences).toBe('menu:editPreferences');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
40
tests/renderer/navigation/sectionActivation.test.ts
Normal file
40
tests/renderer/navigation/sectionActivation.test.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
import { activateSidebarSection } from '../../../src/renderer/navigation/sectionActivation';
|
||||||
|
|
||||||
|
describe('sectionActivation', () => {
|
||||||
|
it('opens editor first and delays section activation when editor is not active', () => {
|
||||||
|
const ensureEditor = vi.fn();
|
||||||
|
const activateSection = vi.fn();
|
||||||
|
const schedule = vi.fn((callback: () => void) => callback());
|
||||||
|
|
||||||
|
activateSidebarSection({
|
||||||
|
isEditorTabActive: false,
|
||||||
|
ensureEditorTabActive: ensureEditor,
|
||||||
|
activateSection,
|
||||||
|
schedule,
|
||||||
|
delayWhenOpeningEditorMs: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(ensureEditor).toHaveBeenCalledTimes(1);
|
||||||
|
expect(schedule).toHaveBeenCalledTimes(1);
|
||||||
|
expect(schedule).toHaveBeenCalledWith(expect.any(Function), 100);
|
||||||
|
expect(activateSection).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('activates section immediately when editor tab is already active', () => {
|
||||||
|
const ensureEditor = vi.fn();
|
||||||
|
const activateSection = vi.fn();
|
||||||
|
const schedule = vi.fn((callback: () => void) => callback());
|
||||||
|
|
||||||
|
activateSidebarSection({
|
||||||
|
isEditorTabActive: true,
|
||||||
|
ensureEditorTabActive: ensureEditor,
|
||||||
|
activateSection,
|
||||||
|
schedule,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(ensureEditor).not.toHaveBeenCalled();
|
||||||
|
expect(schedule).toHaveBeenCalledWith(expect.any(Function), 0);
|
||||||
|
expect(activateSection).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
14
tests/renderer/navigation/sidebarUiPersistence.test.ts
Normal file
14
tests/renderer/navigation/sidebarUiPersistence.test.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { getPersistedSidebarSection, setPersistedSidebarSection } from '../../../src/renderer/navigation/sidebarUiPersistence';
|
||||||
|
|
||||||
|
describe('sidebarUiPersistence', () => {
|
||||||
|
it('persists and reads section ids by sidebar key', () => {
|
||||||
|
setPersistedSidebarSection('settings', 'project');
|
||||||
|
|
||||||
|
expect(getPersistedSidebarSection('settings')).toBe('project');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null for missing persisted section', () => {
|
||||||
|
expect(getPersistedSidebarSection('tags')).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
30
tests/renderer/navigation/sidebarViewRegistry.test.ts
Normal file
30
tests/renderer/navigation/sidebarViewRegistry.test.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import {
|
||||||
|
DEFAULT_SIDEBAR_VIEW,
|
||||||
|
SIDEBAR_VIEW_REGISTRY,
|
||||||
|
isSidebarView,
|
||||||
|
} from '../../../src/renderer/navigation/sidebarViewRegistry';
|
||||||
|
|
||||||
|
describe('sidebarViewRegistry', () => {
|
||||||
|
it('defines all supported sidebar views in one canonical registry', () => {
|
||||||
|
expect(SIDEBAR_VIEW_REGISTRY).toEqual([
|
||||||
|
'posts',
|
||||||
|
'pages',
|
||||||
|
'media',
|
||||||
|
'settings',
|
||||||
|
'tags',
|
||||||
|
'chat',
|
||||||
|
'import',
|
||||||
|
'git',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses posts as default sidebar view', () => {
|
||||||
|
expect(DEFAULT_SIDEBAR_VIEW).toBe('posts');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('validates sidebar view values', () => {
|
||||||
|
expect(isSidebarView('tags')).toBe(true);
|
||||||
|
expect(isSidebarView('unknown')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
27
tests/renderer/navigation/siteValidationPersistence.test.ts
Normal file
27
tests/renderer/navigation/siteValidationPersistence.test.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import type { SiteValidationReport } from '../../../src/main/shared/electronApi';
|
||||||
|
import {
|
||||||
|
getPersistedSiteValidationReport,
|
||||||
|
persistSiteValidationReport,
|
||||||
|
} from '../../../src/renderer/navigation/siteValidationPersistence';
|
||||||
|
|
||||||
|
const report: SiteValidationReport = {
|
||||||
|
sitemapPath: '/tmp/sitemap.xml',
|
||||||
|
sitemapChanged: false,
|
||||||
|
missingUrlPaths: ['/foo'],
|
||||||
|
extraUrlPaths: ['/bar'],
|
||||||
|
expectedUrlCount: 10,
|
||||||
|
existingHtmlUrlCount: 9,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('siteValidationPersistence', () => {
|
||||||
|
it('persists and loads site validation report by project', () => {
|
||||||
|
persistSiteValidationReport('project-1', report);
|
||||||
|
|
||||||
|
expect(getPersistedSiteValidationReport('project-1')).toEqual(report);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null when project has no persisted report', () => {
|
||||||
|
expect(getPersistedSiteValidationReport('missing-project')).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
25
tests/renderer/navigation/tabPolicy.test.ts
Normal file
25
tests/renderer/navigation/tabPolicy.test.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { getSingletonToolTabSpec, openSingletonToolTab } from '../../../src/renderer/navigation/tabPolicy';
|
||||||
|
|
||||||
|
describe('tabPolicy', () => {
|
||||||
|
it('provides canonical singleton tab specs', () => {
|
||||||
|
expect(getSingletonToolTabSpec('settings')).toEqual({ type: 'settings', id: 'settings', isTransient: false });
|
||||||
|
expect(getSingletonToolTabSpec('tags')).toEqual({ type: 'tags', id: 'tags', isTransient: false });
|
||||||
|
expect(getSingletonToolTabSpec('style')).toEqual({ type: 'style', id: 'style', isTransient: false });
|
||||||
|
expect(getSingletonToolTabSpec('documentation')).toEqual({ type: 'documentation', id: 'documentation', isTransient: false });
|
||||||
|
expect(getSingletonToolTabSpec('metadata-diff')).toEqual({ type: 'metadata-diff', id: 'metadata-diff', isTransient: false });
|
||||||
|
expect(getSingletonToolTabSpec('site-validation')).toEqual({ type: 'site-validation', id: 'site-validation', isTransient: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('opens singleton tool tabs using canonical tab spec', () => {
|
||||||
|
const openTab = (tab: { type: string; id: string; isTransient: boolean }) => {
|
||||||
|
captured = tab;
|
||||||
|
};
|
||||||
|
|
||||||
|
let captured: { type: string; id: string; isTransient: boolean } | null = null;
|
||||||
|
|
||||||
|
openSingletonToolTab(openTab, 'site-validation');
|
||||||
|
|
||||||
|
expect(captured).toEqual({ type: 'site-validation', id: 'site-validation', isTransient: false });
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user