Line data Source code
1 16 : <template>
2 : <div ref="root" class="contents">
3 : <ComfyQueueButton v-if="gate === 'none'" />
4 : <Button
5 : v-else
6 : :tooltip="t('actionbar.partnerRunGate.signInCaption')"
7 : tooltip-side="bottom"
8 : variant="secondary"
9 : size="unset"
10 : class="h-8 gap-1.5 rounded-lg px-4"
11 : data-testid="partner-sign-in-to-run-button"
12 : aria-describedby="partner-run-gate-caption"
13 : @click="openPartnerSignInDialog"
14 : >
15 : <i class="icon-[lucide--log-in]" aria-hidden="true" />
16 : {{ t('actionbar.partnerRunGate.signInToRun') }}
17 : </Button>
18 : </div>
19 : </template>
20 :
21 : <script setup lang="ts">
22 : import { nextTick, useTemplateRef, watch } from 'vue'
23 : import { useI18n } from 'vue-i18n'
24 :
25 : import ComfyQueueButton from '@/components/actionbar/ComfyRunButton/ComfyQueueButton.vue'
26 : import Button from '@comfyorg/design-system/button/Button'
27 : import { usePartnerNodesRunGate } from '@/platform/billing/composables/usePartnerNodesRunGate'
28 : import { useAuthDialogs } from '@/composables/auth/useAuthDialogs'
29 :
30 1999 : const { t } = useI18n()
31 1999 : const { gate, partnerNodes } = usePartnerNodesRunGate()
32 1999 : const { showApiNodesSignInDialog } = useAuthDialogs()
33 1999 : const root = useTemplateRef<HTMLElement>('root')
34 :
35 : // Signing in swaps the focused gated button for the queue button, which would
36 : // otherwise drop keyboard focus to <body>.
37 1999 : watch(gate, async () => {
38 : const hadFocus = root.value?.contains(document.activeElement)
39 28 : if (!hadFocus) return
40 1 : await nextTick()
41 28 : root.value?.querySelector('button')?.focus()
42 : })
43 :
44 1 : function openPartnerSignInDialog() {
45 1 : void showApiNodesSignInDialog(
46 : partnerNodes.value.map((node) => node.displayName)
47 : )
48 : }
49 : </script>
|