diff --git a/frontend/src/stores/projects.ts b/frontend/src/stores/projects.ts index a22aefa1e..9e929d1d9 100644 --- a/frontend/src/stores/projects.ts +++ b/frontend/src/stores/projects.ts @@ -44,6 +44,24 @@ export const useProjectStore = defineStore('project', () => { return (id: IProject['id']) => projectsArray.value.filter(p => p.parentProjectId === id) }) + const getAncestors = computed(() => { + return (project: IProject): IProject[] => { + if (typeof project === 'undefined') { + return [] + } + + if (!project?.parentProjectId) { + return [project] + } + + const parentProject = projects.value[project.parentProjectId] + return [ + ...(parentProject ? getAncestors.value(parentProject) : []), + project, + ] + } + }) + const findProjectByExactname = computed(() => { return (name: string) => { const project = projectsArray.value.find(l => { @@ -201,22 +219,6 @@ export const useProjectStore = defineStore('project', () => { return loadedProjects } - - function getAncestors(project: IProject): IProject[] { - if (typeof project === 'undefined') { - return [] - } - - if (!project?.parentProjectId) { - return [project] - } - - const parentProject = projects.value[project.parentProjectId] - return [ - ...(parentProject ? getAncestors(parentProject) : []), - project, - ] - } function setProjectView(view: IProjectView) { const views = [...projects.value[view.projectId].views]