chore: Disable account switcher for single-account users (#10768)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useAccount } from 'dashboard/composables/useAccount';
|
||||
import { useMapGetter } from 'dashboard/composables/store';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -19,6 +20,12 @@ const { accountId, currentAccount } = useAccount();
|
||||
const currentUser = useMapGetter('getCurrentUser');
|
||||
const globalConfig = useMapGetter('globalConfig/get');
|
||||
|
||||
const userAccounts = useMapGetter('getUserAccounts');
|
||||
|
||||
const showAccountSwitcher = computed(
|
||||
() => userAccounts.value.length > 1 && currentAccount.value.name
|
||||
);
|
||||
|
||||
const onChangeAccount = newId => {
|
||||
const accountUrl = `/app/accounts/${newId}/dashboard`;
|
||||
window.location.href = accountUrl;
|
||||
@@ -37,9 +44,14 @@ const emitNewAccount = () => {
|
||||
:data-account-id="accountId"
|
||||
aria-haspopup="listbox"
|
||||
aria-controls="account-options"
|
||||
class="flex items-center gap-2 justify-between w-full rounded-lg hover:bg-n-alpha-1 px-2"
|
||||
:class="{ 'bg-n-alpha-1': isOpen }"
|
||||
@click="toggle"
|
||||
class="flex items-center gap-2 justify-between w-full rounded-lg px-2"
|
||||
:class="[
|
||||
isOpen && 'bg-n-alpha-1',
|
||||
showAccountSwitcher
|
||||
? 'hover:bg-n-alpha-1 cursor-pointer'
|
||||
: 'cursor-default',
|
||||
]"
|
||||
@click="() => showAccountSwitcher && toggle()"
|
||||
>
|
||||
<span
|
||||
class="text-sm font-medium leading-5 text-n-slate-12 truncate"
|
||||
@@ -49,13 +61,14 @@ const emitNewAccount = () => {
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="showAccountSwitcher"
|
||||
aria-hidden="true"
|
||||
class="i-lucide-chevron-down size-4 text-n-slate-10 flex-shrink-0"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
<DropdownBody class="min-w-80 z-50">
|
||||
<DropdownSection :title="t('SIDEBAR_ITEMS.SWITCH_WORKSPACE')">
|
||||
<DropdownBody v-if="showAccountSwitcher" class="min-w-80 z-50">
|
||||
<DropdownSection :title="t('SIDEBAR_ITEMS.SWITCH_ACCOUNT')">
|
||||
<DropdownItem
|
||||
v-for="account in currentUser.accounts"
|
||||
:id="`account-${account.id}`"
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
"SIDEBAR_ITEMS": {
|
||||
"CHANGE_AVAILABILITY_STATUS": "Change",
|
||||
"CHANGE_ACCOUNTS": "Switch account",
|
||||
"SWITCH_WORKSPACE": "Switch workspace",
|
||||
"SWITCH_ACCOUNT": "Switch account",
|
||||
"CONTACT_SUPPORT": "Contact support",
|
||||
"SELECTOR_SUBTITLE": "Select an account from the following list",
|
||||
"PROFILE_SETTINGS": "Profile settings",
|
||||
|
||||
Reference in New Issue
Block a user