- Added resetBrowserHistory functionality to contextController for better state management. - Improved handling of custom root states in customRootsController, including resetting labels and paths. - Removed unused refreshCustomRoots from scopeController. - Updated sidebarController to provide more context in asset status updates. - Introduced new folder details section in the sidebar to display folder metadata. - Created pinned folders popover view for better folder management. - Implemented custom status dot themes for improved visual feedback in asset status. - Added folder info endpoint in the backend to retrieve folder statistics and metadata.
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
export function createScopeController({
|
|
state,
|
|
tabButtons,
|
|
customMenuBtn,
|
|
customPopover,
|
|
popovers,
|
|
reloadGrid,
|
|
onChanged = null,
|
|
onScopeChanged = null,
|
|
onBeforeReload = null
|
|
}) {
|
|
let scopeSwitchSeq = 0;
|
|
|
|
const setActiveTabStyles = () => {
|
|
const buttons = Object.values(tabButtons || {});
|
|
buttons.forEach((b) => {
|
|
const scope = b?.dataset?.scope;
|
|
const active = scope === state.scope;
|
|
b?.classList?.toggle?.("is-active", active);
|
|
});
|
|
|
|
customMenuBtn.style.display = "none";
|
|
customPopover.style.display = "none";
|
|
popovers.close(customPopover);
|
|
};
|
|
|
|
const setScope = async (scope) => {
|
|
const requestedSeq = ++scopeSwitchSeq;
|
|
const allowed = new Set(["output", "outputs", "input", "inputs", "all", "custom"]);
|
|
const normalized = String(scope || "").toLowerCase();
|
|
if (!allowed.has(normalized)) return;
|
|
|
|
// Switching scope exits any active collection view.
|
|
state.collectionId = "";
|
|
state.collectionName = "";
|
|
|
|
state.scope = normalized === "outputs" ? "output" : normalized === "inputs" ? "input" : normalized;
|
|
// Scope switch should reset folder context to avoid stale filtering behavior.
|
|
state.subfolder = "";
|
|
state.currentFolderRelativePath = "";
|
|
if (state.scope !== "custom") {
|
|
state.customRootId = "";
|
|
}
|
|
|
|
setActiveTabStyles();
|
|
try {
|
|
onChanged?.();
|
|
} catch {}
|
|
try {
|
|
await onScopeChanged?.(state);
|
|
} catch {}
|
|
if (requestedSeq !== scopeSwitchSeq) return;
|
|
try {
|
|
await onBeforeReload?.(state);
|
|
} catch {}
|
|
if (requestedSeq !== scopeSwitchSeq) return;
|
|
await reloadGrid();
|
|
};
|
|
|
|
return { setScope, setActiveTabStyles };
|
|
}
|
|
|