From 970b768bf25ae438ef9943af8bbbdc4f58289926 Mon Sep 17 00:00:00 2001
From: andrewwallacespeckle
Date: Tue, 3 Jun 2025 15:39:14 +0200
Subject: [PATCH] Update DefaultSeat.vue
---
.../workspaces/security/DefaultSeat.vue | 57 +++++++++----------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/packages/frontend-2/components/settings/workspaces/security/DefaultSeat.vue b/packages/frontend-2/components/settings/workspaces/security/DefaultSeat.vue
index add96ec79..925ae0a6c 100644
--- a/packages/frontend-2/components/settings/workspaces/security/DefaultSeat.vue
+++ b/packages/frontend-2/components/settings/workspaces/security/DefaultSeat.vue
@@ -10,7 +10,7 @@
Select default
@@ -36,7 +35,7 @@
@@ -64,7 +63,6 @@ import type {
import { SeatTypes } from '@speckle/shared'
import { workspaceUpdateDefaultSeatTypeMutation } from '~/lib/workspaces/graphql/mutations'
import { useMixpanel } from '~/lib/core/composables/mp'
-import { useWorkspacePlan } from '~/lib/workspaces/composables/plan'
const props = defineProps<{
workspace: SettingsWorkspacesSecurity_WorkspaceFragment
@@ -75,35 +73,30 @@ const { mutate: updateDefaultSeatType } = useMutation(
workspaceUpdateDefaultSeatTypeMutation
)
const { triggerNotification } = useGlobalToast()
-const { isPaidPlan } = useWorkspacePlan(props.workspace.slug)
-const internalDefaultSeatType = ref(props.workspace.defaultSeatType)
+const currentSeatType = ref(props.workspace.defaultSeatType)
const showConfirmSeatTypeDialog = ref(false)
-const pendingSeatType = ref()
+const pendingNewSeatType = ref()
-const onChange = (newVal: WorkspaceSeatType | WorkspaceSeatType[] | undefined) => {
- if (!newVal) return
+const seatTypeModel = computed({
+ get: () => currentSeatType.value,
+ set: (newValue: WorkspaceSeatType) => {
+ handleSeatTypeChange(newValue)
+ }
+})
- const seatTypeValue = Array.isArray(newVal) ? newVal[0] : newVal
- if (!seatTypeValue) return
+const handleSeatTypeChange = (newValue: WorkspaceSeatType) => {
+ if (newValue === currentSeatType.value) return
- const currentSeatType = props.workspace.defaultSeatType
- if (seatTypeValue === currentSeatType) return
-
- // If setting to Editor with auto-join enabled on paid plan, show confirmation
- if (
- seatTypeValue === SeatTypes.Editor &&
- props.workspace.discoverabilityAutoJoinEnabled &&
- isPaidPlan.value
- ) {
+ // If setting to Editor with auto-join enabled, show confirmation
+ if (newValue === SeatTypes.Editor && props.workspace.discoverabilityAutoJoinEnabled) {
+ pendingNewSeatType.value = newValue
showConfirmSeatTypeDialog.value = true
- pendingSeatType.value = seatTypeValue
- internalDefaultSeatType.value = props.workspace.defaultSeatType
return
}
-
- applySeatTypeChange(seatTypeValue)
+ // Otherwise, apply the change directly
+ applySeatTypeChange(newValue)
}
const applySeatTypeChange = async (seatTypeValue: WorkspaceSeatType) => {
@@ -115,7 +108,7 @@ const applySeatTypeChange = async (seatTypeValue: WorkspaceSeatType) => {
}).catch(convertThrowIntoFetchResult)
if (result?.data) {
- internalDefaultSeatType.value = seatTypeValue
+ currentSeatType.value = seatTypeValue
triggerNotification({
type: ToastNotificationType.Success,
@@ -134,14 +127,14 @@ const applySeatTypeChange = async (seatTypeValue: WorkspaceSeatType) => {
}
const handleSeatTypeConfirm = async () => {
- if (!pendingSeatType.value) return
- await applySeatTypeChange(pendingSeatType.value)
- pendingSeatType.value = undefined
+ if (!pendingNewSeatType.value) return
+ await applySeatTypeChange(pendingNewSeatType.value)
+ pendingNewSeatType.value = undefined
}
const handleSeatTypeCancel = () => {
- pendingSeatType.value = undefined
- internalDefaultSeatType.value = props.workspace.defaultSeatType
+ pendingNewSeatType.value = undefined
+ showConfirmSeatTypeDialog.value = false
}
const defaultSeatTypeOptions: WorkspaceSeatType[] = Object.values(SeatTypes)
@@ -149,7 +142,9 @@ const defaultSeatTypeOptions: WorkspaceSeatType[] = Object.values(SeatTypes)
watch(
() => props.workspace.defaultSeatType,
(newVal) => {
- internalDefaultSeatType.value = newVal
+ if (newVal) {
+ currentSeatType.value = newVal
+ }
}
)