chore: Hide assistant switcher on paywall screen (#12875)

This commit is contained in:
Sivin Varghese
2025-11-17 09:58:59 +05:30
committed by GitHub
parent 6ae5e67b52
commit 2c4e65d68e
3 changed files with 22 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { OnClickOutside } from '@vueuse/components'; import { OnClickOutside } from '@vueuse/components';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useMapGetter } from 'dashboard/composables/store.js'; import { useMapGetter } from 'dashboard/composables/store.js';
import { usePolicy } from 'dashboard/composables/usePolicy'; import { usePolicy } from 'dashboard/composables/usePolicy';
import Button from 'dashboard/components-next/button/Button.vue'; import Button from 'dashboard/components-next/button/Button.vue';
@@ -69,6 +70,8 @@ const props = defineProps({
const emit = defineEmits(['click', 'close', 'update:currentPage']); const emit = defineEmits(['click', 'close', 'update:currentPage']);
const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const { shouldShowPaywall } = usePolicy(); const { shouldShowPaywall } = usePolicy();
@@ -76,14 +79,16 @@ const showAssistantSwitcherDropdown = ref(false);
const createAssistantDialogRef = ref(null); const createAssistantDialogRef = ref(null);
const assistants = useMapGetter('captainAssistants/getRecords'); const assistants = useMapGetter('captainAssistants/getRecords');
const uiFlags = useMapGetter('captainAssistants/getUIFlags');
const currentAssistantId = computed(() => route.params.assistantId); const currentAssistantId = computed(() => route.params.assistantId);
const isFetchingAssistants = computed(() => uiFlags.value?.fetchingList);
const activeAssistantName = computed(() => { const activeAssistantName = computed(() => {
return ( return (
assistants.value?.find( assistants.value?.find(
assistant => assistant.id === Number(currentAssistantId.value) assistant => assistant.id === Number(currentAssistantId.value)
)?.name || '' )?.name || t('CAPTAIN.ASSISTANT_SWITCHER.NEW_ASSISTANT')
); );
}); });
@@ -118,15 +123,18 @@ const handleCreateAssistant = () => {
> >
<div class="flex gap-3 items-center"> <div class="flex gap-3 items-center">
<BackButton v-if="backUrl" :back-url="backUrl" /> <BackButton v-if="backUrl" :back-url="backUrl" />
<div v-if="showAssistantSwitcher" class="flex items-center gap-2"> <div
v-if="showAssistantSwitcher && !showPaywall"
class="flex items-center gap-2"
>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span <span
v-if="activeAssistantName" v-if="!isFetchingAssistants"
class="text-xl font-medium truncate text-n-slate-12" class="text-xl font-medium truncate text-n-slate-12"
> >
{{ activeAssistantName }} {{ activeAssistantName }}
</span> </span>
<div v-if="activeAssistantName" class="relative group"> <div class="relative group">
<OnClickOutside <OnClickOutside
@trigger="showAssistantSwitcherDropdown = false" @trigger="showAssistantSwitcherDropdown = false"
> >
@@ -135,6 +143,8 @@ const handleCreateAssistant = () => {
variant="ghost" variant="ghost"
color="slate" color="slate"
size="xs" size="xs"
:disabled="isFetchingAssistants"
:is-loading="isFetchingAssistants"
class="rounded-md group-hover:bg-n-slate-3 hover:bg-n-slate-3 [&>span]:size-4" class="rounded-md group-hover:bg-n-slate-3 hover:bg-n-slate-3 [&>span]:size-4"
@click="toggleAssistantSwitcher" @click="toggleAssistantSwitcher"
/> />
@@ -151,7 +161,7 @@ const handleCreateAssistant = () => {
</div> </div>
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<div <div
v-if="showAssistantSwitcher && headerTitle" v-if="showAssistantSwitcher && !showPaywall && headerTitle"
class="w-0.5 h-4 rounded-2xl bg-n-weak" class="w-0.5 h-4 rounded-2xl bg-n-weak"
/> />
<span <span

View File

@@ -139,5 +139,10 @@ const openCreateAssistantDialog = () => {
/> />
</Button> </Button>
</div> </div>
<div v-else class="flex flex-col items-center gap-2 px-4 py-3">
<p class="text-sm text-n-slate-11">
{{ t('CAPTAIN.ASSISTANT_SWITCHER.EMPTY_LIST') }}
</p>
</div>
</div> </div>
</template> </template>

View File

@@ -348,7 +348,8 @@
"ASSISTANT_SWITCHER": { "ASSISTANT_SWITCHER": {
"ASSISTANTS": "Assistants", "ASSISTANTS": "Assistants",
"SWITCH_ASSISTANT": "Switch between assistants", "SWITCH_ASSISTANT": "Switch between assistants",
"NEW_ASSISTANT": "Create Assistant" "NEW_ASSISTANT": "Create Assistant",
"EMPTY_LIST": "No assistants found, please create one to get started"
}, },
"COPILOT": { "COPILOT": {
"TITLE": "Copilot", "TITLE": "Copilot",