refactor(catalog): unify commands and embed guarded catalog workspace
This commit is contained in:
1 parent
16f35568f5
commit
193b6686a9
57 files changed
+3268
-728
No files matched your search
@@ -59,6 +59,7 @@ const initialState: CatalogManagerState = {
|
||||
// ── Actions ───────────────────────────────────────────────────
|
||||
|
||||
export type CatalogAction =
|
||||
| { type: "RESTORE_SELECTION"; rootId: number | null; pageId: number | null }
|
||||
| { type: "SET_ROOT_PAGES"; pages: RootTab[] }
|
||||
| { type: "SET_LOADING_ROOT"; loading: boolean }
|
||||
| { type: "SET_ACTIVE_TAB"; id: number | null }
|
||||
@@ -93,14 +94,33 @@ function reducer(
|
||||
action: CatalogAction,
|
||||
): CatalogManagerState {
|
||||
switch (action.type) {
|
||||
case "RESTORE_SELECTION":
|
||||
return {
|
||||
...state,
|
||||
activeTabId:
|
||||
action.rootId ?? state.rootPages[0]?.id ?? state.activeTabId,
|
||||
selectedPageId: action.pageId,
|
||||
focusedId: action.pageId,
|
||||
editorDirty: false,
|
||||
multiSelectedIds: new Set(),
|
||||
ancestors: [],
|
||||
};
|
||||
case "SET_ROOT_PAGES":
|
||||
return { ...state, rootPages: action.pages, loadingRoot: false };
|
||||
return {
|
||||
...state,
|
||||
rootPages: action.pages,
|
||||
loadingRoot: false,
|
||||
activeTabId: action.pages.some((page) => page.id === state.activeTabId)
|
||||
? state.activeTabId
|
||||
: (action.pages[0]?.id ?? null),
|
||||
};
|
||||
case "SET_LOADING_ROOT":
|
||||
return { ...state, loadingRoot: action.loading };
|
||||
case "SET_ACTIVE_TAB":
|
||||
return {
|
||||
...state,
|
||||
activeTabId: action.id,
|
||||
editorDirty: false,
|
||||
selectedPageId: null,
|
||||
multiSelectedIds: new Set(),
|
||||
focusedId: null,
|
||||
@@ -110,6 +130,7 @@ function reducer(
|
||||
return {
|
||||
...state,
|
||||
selectedPageId: action.id,
|
||||
editorDirty: false,
|
||||
multiSelectedIds: new Set(),
|
||||
focusedId: action.id,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user