Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/locales/ar/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "إنشاء مساحة عمل جديدة",
"failedToSwitch": "فشل في تبديل مساحة العمل",
"managedByOrganization": "تدير مؤسستك مساحات العمل الخاصة بك، لذا لا يمكنك إنشاء واحدة.",
"maxWorkspacesReached": "يمكنك امتلاك ١٠ مساحات عمل فقط. احذف واحدة لإنشاء مساحة جديدة.",
"maxWorkspacesReached": "يمكنك امتلاك {max} مساحات عمل فقط. احذف واحدة لإنشاء مساحة جديدة.",
"personal": "شخصي",
"roleMember": "عضو",
"roleOwner": "المالك",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Arbeitsbereich erstellen",
"failedToSwitch": "Arbeitsbereich konnte nicht gewechselt werden",
"managedByOrganization": "Ihre Organisation verwaltet Ihre Workspaces, daher können Sie keinen erstellen.",
"maxWorkspacesReached": "Sie können nur 10 Arbeitsbereiche besitzen. Löschen Sie einen, um einen neuen zu erstellen.",
"maxWorkspacesReached": "Sie können nur {max} Arbeitsbereiche besitzen. Löschen Sie einen, um einen neuen zu erstellen.",
"personal": "Persönlich",
"roleMember": "Mitglied",
"roleOwner": "Inhaber",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4112,7 +4112,7 @@
"roleOwner": "Owner",
"roleMember": "Member",
"createWorkspace": "Create a workspace",
"maxWorkspacesReached": "You can only own 10 workspaces. Delete one to create a new one.",
"maxWorkspacesReached": "You can only own {max} workspace. Delete it to create a new one. | You can only own {max} workspaces. Delete one to create a new one.",
"managedByOrganization": "Your organization manages your workspaces, so you can't create one.",
"cannotCreateWorkspace": "You can't create a workspace on this account right now.",
"failedToSwitch": "Failed to switch workspace"
Expand Down
2 changes: 1 addition & 1 deletion src/locales/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Crear nuevo espacio de trabajo",
"failedToSwitch": "No se pudo cambiar el espacio de trabajo",
"managedByOrganization": "Tu organización administra tus espacios de trabajo, por lo que no puedes crear uno.",
"maxWorkspacesReached": "Solo puedes ser propietario de 10 espacios de trabajo. Elimina uno para crear uno nuevo.",
"maxWorkspacesReached": "Solo puedes ser propietario de {max} espacios de trabajo. Elimina uno para crear uno nuevo.",
"personal": "Personal",
"roleMember": "Miembro",
"roleOwner": "Propietario",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/fa/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "ایجاد محیط کاری جدید",
"failedToSwitch": "تغییر فضای کاری ناموفق بود",
"managedByOrganization": "سازمان شما workspaceهایتان را مدیریت می‌کند؛ بنابراین نمی‌توانید workspace جدیدی ایجاد کنید.",
"maxWorkspacesReached": "شما فقط می‌توانید مالک ۱۰ محیط کاری باشید. برای ایجاد محیط کاری جدید، یکی را حذف کنید.",
"maxWorkspacesReached": "شما فقط می‌توانید مالک {max} محیط کاری باشید. برای ایجاد محیط کاری جدید، یکی را حذف کنید.",
"personal": "شخصی",
"roleMember": "عضو",
"roleOwner": "مالک",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Créer un nouvel espace de travail",
"failedToSwitch": "Échec du changement d’espace de travail",
"managedByOrganization": "Votre organisation gère vos espaces de travail, vous ne pouvez donc pas en créer.",
"maxWorkspacesReached": "Vous ne pouvez posséder que 10 espaces de travail. Supprimez-en un pour en créer un nouveau.",
"maxWorkspacesReached": "Vous ne pouvez posséder que {max} espaces de travail. Supprimez-en un pour en créer un nouveau.",
"personal": "Personnel",
"roleMember": "Membre",
"roleOwner": "Propriétaire",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/he/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "יצירת סביבת עבודה חדשה",
"failedToSwitch": "המעבר לסביבת העבודה נכשל",
"managedByOrganization": "הארגון שלך מנהל את סביבות העבודה שלך, ולכן אין באפשרותך ליצור אחת.",
"maxWorkspacesReached": "ניתן להיות בעלים של 10 סביבות עבודה בלבד. מחק אחת כדי ליצור חדשה.",
"maxWorkspacesReached": "ניתן להיות בעלים של {max} סביבות עבודה בלבד. מחק אחת כדי ליצור חדשה.",
"personal": "אישי",
"roleMember": "חבר",
"roleOwner": "בעלים",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Crea un workspace",
"failedToSwitch": "Cambio workspace non riuscito",
"managedByOrganization": "La tua organizzazione gestisce i tuoi workspace, quindi non puoi crearne uno.",
"maxWorkspacesReached": "Puoi possedere solo 10 workspace. Elimina uno per crearne uno nuovo.",
"maxWorkspacesReached": "Puoi possedere solo {max} workspace. Elimina uno per crearne uno nuovo.",
"personal": "Personale",
"roleMember": "Membro",
"roleOwner": "Proprietario",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "新しいワークスペースを作成",
"failedToSwitch": "ワークスペースの切り替えに失敗しました",
"managedByOrganization": "組織がワークスペースを管理しているため、新しいワークスペースを作成できません。",
"maxWorkspacesReached": "所有できるワークスペースは10個までです。新しく作成するには1つ削除してください。",
"maxWorkspacesReached": "所有できるワークスペースは{max}個までです。新しく作成するには1つ削除してください。",
"personal": "個人用",
"roleMember": "メンバー",
"roleOwner": "オーナー",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/ko/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "새 워크스페이스 만들기",
"failedToSwitch": "워크스페이스 전환에 실패했습니다",
"managedByOrganization": "조직에서 워크스페이스를 관리하므로 새로 만들 수 없습니다.",
"maxWorkspacesReached": "최대 10개의 워크스페이스만 소유할 수 있습니다. 새로 만들려면 하나를 삭제하세요.",
"maxWorkspacesReached": "최대 {max}개의 워크스페이스만 소유할 수 있습니다. 새로 만들려면 하나를 삭제하세요.",
"personal": "개인",
"roleMember": "멤버",
"roleOwner": "소유자",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/pt-BR/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Criar novo espaço de trabalho",
"failedToSwitch": "Falha ao trocar de espaço de trabalho",
"managedByOrganization": "Sua organização gerencia seus espaços de trabalho, portanto você não pode criar um.",
"maxWorkspacesReached": "Você só pode possuir 10 espaços de trabalho. Exclua um para criar um novo.",
"maxWorkspacesReached": "Você só pode possuir {max} espaços de trabalho. Exclua um para criar um novo.",
"personal": "Pessoal",
"roleMember": "Membro",
"roleOwner": "Proprietário",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Создать новое рабочее пространство",
"failedToSwitch": "Не удалось переключить рабочее пространство",
"managedByOrganization": "Ваша организация управляет вашими рабочими пространствами, поэтому вы не можете создать новое.",
"maxWorkspacesReached": "Вы можете владеть только 10 рабочими пространствами. Удалите одно, чтобы создать новое.",
"maxWorkspacesReached": "Вы можете владеть только {max} рабочими пространствами. Удалите одно, чтобы создать новое.",
"personal": "Личное",
"roleMember": "Участник",
"roleOwner": "Владелец",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/tr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "Yeni çalışma alanı oluştur",
"failedToSwitch": "Çalışma alanı değiştirilemedi",
"managedByOrganization": "Kuruluşunuz çalışma alanlarınızı yönettiği için çalışma alanı oluşturamazsınız.",
"maxWorkspacesReached": "Yalnızca 10 çalışma alanına sahip olabilirsiniz. Yeni bir tane oluşturmak için birini silin.",
"maxWorkspacesReached": "Yalnızca {max} çalışma alanına sahip olabilirsiniz. Yeni bir tane oluşturmak için birini silin.",
"personal": "Kişisel",
"roleMember": "Üye",
"roleOwner": "Sahip",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh-TW/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "建立新工作區",
"failedToSwitch": "切換工作區失敗",
"managedByOrganization": "您的組織管理您的工作區,因此您無法建立工作區。",
"maxWorkspacesReached": "您最多只能擁有 10 個工作區。請刪除一個以建立新工作區。",
"maxWorkspacesReached": "您最多只能擁有 {max} 個工作區。請刪除一個以建立新工作區。",
"personal": "個人",
"roleMember": "成員",
"roleOwner": "擁有者",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@
"createWorkspace": "创建新工作区",
"failedToSwitch": "切换工作区失败",
"managedByOrganization": "您的组织管理您的工作区,因此您无法创建工作区。",
"maxWorkspacesReached": "您最多只能拥有10个工作区。请删除一个以创建新工作区。",
"maxWorkspacesReached": "您最多只能拥有{max}个工作区。请删除一个以创建新工作区。",
"personal": "个人",
"roleMember": "成员",
"roleOwner": "所有者",
Expand Down
56 changes: 31 additions & 25 deletions src/platform/account/components/WorkspaceSwitcherPopover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const i18n = createI18n({
'Runs that use partner nodes spend credits from this workspace. Unlike on Cloud, every workspace saves to your usual output folder.',
createWorkspace: 'Create a team workspace',
maxWorkspacesReached:
'You can only own 10 workspaces. Delete one to create a new one.',
'You can only own {max} workspace. Delete it to create a new one. | You can only own {max} workspaces. Delete one to create a new one.',
managedByOrganization:
"Your organization manages your workspaces, so you can't create one.",
cannotCreateWorkspace:
Expand Down Expand Up @@ -275,32 +275,38 @@ describe('WorkspaceSwitcherPopover', () => {
expect(list).not.toContainElement(createWorkspaceButton)
})

it('says why creation is off when an organization manages the workspaces', async () => {
const store = useTeamWorkspaceStore()
store.$patch({
serverRefusesCreation: true,
workspacesManagedByOrganization: true
})
const { emitted } = renderComponent()

await userEvent.click(
screen.getByText(/Your organization manages your workspaces/)
)

expect(screen.queryByText('Create a team workspace')).toBeNull()
expect(emitted().create).toBeUndefined()
})
it.for([
{
reason: 'organization_managed',
notice: /Your organization manages your workspaces/
},
{
reason: 'owned_workspace_limit',
notice: /You can only own 25 workspaces/
},
{
reason: 'owned_workspace_limit',
max: 1,
notice: /You can only own 1 workspace\. Delete it/
},
{ reason: undefined, notice: /can't create a workspace on this account/ }
] as const)(
'renders the served refusal ($reason) in place of creating',
async ({ reason, notice, max = 25 }) => {
const store = useTeamWorkspaceStore()
store.$patch({
serverRefusesCreation: true,
creationDeniedReason: reason,
maxOwnedWorkspaces: max
})
const { emitted } = renderComponent()

it('does not blame an organization when the server gives no reason', () => {
const store = useTeamWorkspaceStore()
store.$patch({ serverRefusesCreation: true })
renderComponent()
await userEvent.click(screen.getByText(notice))

expect(
screen.getByText(/can't create a workspace on this account/)
).toBeInTheDocument()
expect(screen.queryByText(/Your organization manages/)).toBeNull()
})
expect(screen.queryByText('Create a team workspace')).toBeNull()
expect(emitted().create).toBeUndefined()
}
)

it('hides the create-workspace footer on non-cloud distributions', () => {
distributionMocks.isCloud = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('TeamWorkspacesDialogContent', () => {
workspaceStore = useTeamWorkspaceStore(pinia)
workspaceStore.workspaces = []
workspaceStore.serverRefusesCreation = false
workspaceStore.workspacesManagedByOrganization = false
workspaceStore.creationDeniedReason = undefined
})

describe('workspace listing', () => {
Expand Down Expand Up @@ -207,52 +207,39 @@ describe('TeamWorkspacesDialogContent', () => {
).toBeNull()
}

it('replaces the create form with the organization notice', () => {
setOwnedWorkspaces()
workspaceStore.serverRefusesCreation = true
workspaceStore.workspacesManagedByOrganization = true
mountComponent()
expectNoCreateControls()
expect(
screen.getByText('workspaceSwitcher.managedByOrganization')
).toBeInTheDocument()
expect(screen.getByText('Team Alpha')).toBeInTheDocument()
})

it('explains the owned-workspace limit', () => {
workspaceStore.workspaces = Array.from({ length: 10 }, (_, i) =>
createTeamWorkspace({ id: `ws-${i}`, name: `Team ${i}`, role: 'owner' })
)
mountComponent()
expectNoCreateControls()
expect(
screen.getByText('workspaceSwitcher.maxWorkspacesReached')
).toBeInTheDocument()
})

it('uses neutral copy when the server refuses without a known reason', () => {
setOwnedWorkspaces()
workspaceStore.serverRefusesCreation = true
mountComponent()
expectNoCreateControls()
expect(
screen.getByText('workspaceSwitcher.cannotCreateWorkspace')
).toBeInTheDocument()
})
it.for([
{
reason: 'organization_managed',
notice: 'workspaceSwitcher.managedByOrganization'
},
{
reason: 'owned_workspace_limit',
notice: 'workspaceSwitcher.maxWorkspacesReached'
},
{ reason: undefined, notice: 'workspaceSwitcher.cannotCreateWorkspace' }
] as const)(
'replaces the create form with the served $reason notice',
({ reason, notice }) => {
setOwnedWorkspaces()
workspaceStore.serverRefusesCreation = true
workspaceStore.creationDeniedReason = reason
mountComponent()
expectNoCreateControls()
expect(screen.getByText(notice)).toBeInTheDocument()
expect(screen.getByText('Team Alpha')).toBeInTheDocument()
}
)

it('keeps a server refusal neutral at the owned-workspace limit', () => {
it('keeps the create form when the server allows creation at any owned count', () => {
workspaceStore.workspaces = Array.from({ length: 10 }, (_, i) =>
createTeamWorkspace({ id: `ws-${i}`, name: `Team ${i}`, role: 'owner' })
)
workspaceStore.serverRefusesCreation = true
mountComponent()
expectNoCreateControls()
expect(
screen.getByText('workspaceSwitcher.cannotCreateWorkspace')
screen.getByRole('button', {
name: 'teamWorkspacesDialog.createWorkspace'
})
).toBeInTheDocument()
expect(
screen.queryByText('workspaceSwitcher.maxWorkspacesReached')
).toBeNull()
})
})

Expand Down
14 changes: 10 additions & 4 deletions src/platform/workspace/composables/useCreateWorkspaceRefusal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ import { useI18n } from 'vue-i18n'
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'

const REFUSAL_KEYS = {
organization: 'workspaceSwitcher.managedByOrganization',
limit: 'workspaceSwitcher.maxWorkspacesReached',
organization_managed: 'workspaceSwitcher.managedByOrganization',
owned_workspace_limit: 'workspaceSwitcher.maxWorkspacesReached',
unknown: 'workspaceSwitcher.cannotCreateWorkspace'
} as const

/** The notice shown in place of creating a workspace, or null when creation is allowed. */
export function useCreateWorkspaceRefusal() {
const { t } = useI18n()
const { createWorkspaceRefusal } = storeToRefs(useTeamWorkspaceStore())
const { createWorkspaceRefusal, maxOwnedWorkspaces } = storeToRefs(
useTeamWorkspaceStore()
)

return computed(() =>
createWorkspaceRefusal.value
? t(REFUSAL_KEYS[createWorkspaceRefusal.value])
? t(
REFUSAL_KEYS[createWorkspaceRefusal.value],
{ max: maxOwnedWorkspaces.value },
maxOwnedWorkspaces.value ?? 0
)
: null
)
}
Loading
Loading