MCPcopy Create free account
hub / github.com/bytebase/bytebase / worksheetsForView

Function worksheetsForView

frontend/src/views/sql-editor/Sheet/context.ts:620–643  ·  view source on GitHub ↗
(view: SheetViewMode)

Source from the content-addressed store, hash-verified

618};
619
620const worksheetsForView = (view: SheetViewMode): Worksheet[] => {
621 if (view !== "my" && view !== "shared") return [];
622 const filter = useSheetContextStore.getState().filter;
623 const project = getSQLEditorEditorState().project;
624 // SQLEditorLayout awaits `loadCurrentUser()` in its bootstrap, so by the
625 // time worksheets land here the app-store `currentUser` is populated.
626 // Empty `email` falls through to creator `"users/"`, which matches no
627 // worksheets — they'd render as Shared rather than Mine, same fallback
628 // the previous Pinia path had.
629 const email = useAppStore.getState().currentUser?.email ?? "";
630 const creator = `users/${email}`;
631 let list = useAppStore
632 .getState()
633 .worksheetList()
634 .filter((sheet) => {
635 if (sheet.project !== project) return false;
636 const mine = sheet.creator === creator;
637 return view === "my" ? mine : !mine;
638 });
639 if (filter.onlyShowStarred) {
640 list = list.filter((sheet) => sheet.starred);
641 }
642 return list;
643};
644
645const sheetLikeItemsForView = (view: SheetViewMode): WorksheetLikeItem[] => {
646 if (view === "draft") {

Callers 1

sheetLikeItemsForViewFunction · 0.85

Calls 1

getSQLEditorEditorStateFunction · 0.90

Tested by

no test coverage detected