Files
n8n-enterprise-unlocked/packages/frontend/editor-ui/src/composables/useProjectPages.ts
2025-07-31 13:07:00 +02:00

30 lines
836 B
TypeScript

import { computed, reactive } from 'vue';
import { useRoute } from 'vue-router';
import { VIEWS } from '@/constants';
/**
* This composable holds reusable logic that detects the current page type
*/
export const useProjectPages = () => {
const route = useRoute();
// Project pages have a projectId in the route params
const isProjectsSubPage = computed(() => route.params?.projectId !== undefined);
// Overview pages don't
const isOverviewSubPage = computed(() => route.params?.projectId === undefined);
// Shared pages are identified by specific route names
const isSharedSubPage = computed(
() =>
route.name === VIEWS.SHARED_WITH_ME ||
route.name === VIEWS.SHARED_WORKFLOWS ||
route.name === VIEWS.SHARED_CREDENTIALS,
);
return reactive({
isOverviewSubPage,
isSharedSubPage,
isProjectsSubPage,
});
};