From 17bc56070a7c6d26367302689f47b00a6e3ce52b Mon Sep 17 00:00:00 2001 From: andrewwallacespeckle Date: Tue, 27 May 2025 16:01:20 +0200 Subject: [PATCH] If last domain was removed, disable all domain features --- .../settings/workspaces/[slug]/security.vue | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/packages/frontend-2/pages/settings/workspaces/[slug]/security.vue b/packages/frontend-2/pages/settings/workspaces/[slug]/security.vue index ef3fa1242..31372e988 100644 --- a/packages/frontend-2/pages/settings/workspaces/[slug]/security.vue +++ b/packages/frontend-2/pages/settings/workspaces/[slug]/security.vue @@ -26,11 +26,7 @@ class="border-x border-b first:border-t first:rounded-t-lg border-outline-2 last:rounded-b-lg p-6 py-4 flex items-center" >

@{{ domain.domain }}

- + Delete @@ -434,4 +430,37 @@ const handleJoinPolicyConfirm = async () => { }) } } + +watch( + () => workspaceDomains.value.length, + async (newLength) => { + // If last domain was removed, disable all domain features + if (newLength === 0 && workspace.value?.id) { + if (workspace.value.discoverabilityEnabled) { + await updateDiscoverability({ + input: { + id: workspace.value.id, + discoverabilityEnabled: false + } + }) + } + if (workspace.value.discoverabilityAutoJoinEnabled) { + await updateAutoJoin({ + input: { + id: workspace.value.id, + discoverabilityAutoJoinEnabled: false + } + }) + } + if (workspace.value.domainBasedMembershipProtectionEnabled) { + await updateDomainProtection({ + input: { + id: workspace.value.id, + domainBasedMembershipProtectionEnabled: false + } + }) + } + } + } +)