Line data Source code
1 : import { storeToRefs } from 'pinia'
2 : import { computed } from 'vue'
3 : import { useI18n } from 'vue-i18n'
4 :
5 : import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
6 :
7 2355 : const REFUSAL_KEYS = {
8 : organization_managed: 'workspaceSwitcher.managedByOrganization',
9 : owned_workspace_limit: 'workspaceSwitcher.maxWorkspacesReached',
10 : unknown: 'workspaceSwitcher.cannotCreateWorkspace'
11 : } as const
12 :
13 : /** The notice shown in place of creating a workspace, or null when creation is allowed. */
14 2 : export function useCreateWorkspaceRefusal() {
15 2 : const { t } = useI18n()
16 2 : const { createWorkspaceRefusal, maxOwnedWorkspaces } = storeToRefs(
17 : useTeamWorkspaceStore()
18 : )
19 :
20 2 : return computed(() =>
21 : createWorkspaceRefusal.value
22 : ? t(
23 : REFUSAL_KEYS[createWorkspaceRefusal.value],
24 : { max: maxOwnedWorkspaces.value },
25 : maxOwnedWorkspaces.value ?? 0
26 : )
27 : : null
28 : )
29 : }
|