Line data Source code
1 : <script setup lang="ts">
2 : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
3 : import { useI18n } from 'vue-i18n'
4 :
5 : import Loader from '@/components/loader/Loader.vue'
6 : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
7 : import Button from '@comfyorg/design-system/button/Button'
8 : import { useCommandStore } from '@/platform/keybindings/commandStore'
9 : import { useQueueStore } from '@/stores/queueStore'
10 :
11 : const { queueCount } = defineProps<{
12 : queueCount: number
13 : }>()
14 :
15 2355 : const { t } = useI18n()
16 0 : const commandStore = useCommandStore()
17 0 : const queueStore = useQueueStore()
18 :
19 0 : function clearQueue(close: () => void) {
20 0 : void commandStore.execute('Comfy.ClearPendingTasks')
21 0 : close()
22 : }
23 0 : </script>
24 : <template>
25 0 : <div
26 : class="relative shrink-0 border-2 border-transparent p-1"
27 : data-testid="linear-job"
28 : >
29 : <PopoverRoot v-slot="{ close }">
30 : <PopoverTrigger as-child>
31 : <Button
32 : :tooltip="t('linearMode.queue.clickToClear')"
33 : :aria-label="t('linearMode.queue.clickToClear')"
34 : variant="textonly"
35 : size="unset"
36 : class="flex size-10 rounded-sm bg-secondary"
37 : >
38 : <Loader
39 : :variant="
40 : queueStore.runningTasks.length ? 'loader-circle' : 'loader'
41 : "
42 : size="sm"
43 : class="text-muted-foreground"
44 : />
45 : </Button>
46 : </PopoverTrigger>
47 : <PopoverContent
48 : side="top"
49 : :side-offset="5"
50 : dismiss-on-viewport-change
51 : class="w-auto rounded-lg border-border/50 p-2 shadow-sm"
52 : @focus-outside.prevent
53 : >
54 : <Button
55 : :disabled="queueCount === 0"
56 : variant="textonly"
57 : class="px-4 text-sm text-destructive"
58 : @click="clearQueue(close)"
59 : >
60 : <i class="icon-[lucide--list-x]" />
61 : {{ t('linearMode.queue.clear') }}
62 : </Button>
63 : </PopoverContent>
64 : </PopoverRoot>
65 : <div
66 : v-if="queueCount > 1"
67 : aria-hidden="true"
68 : data-testid="linear-job-badge"
69 : class="absolute top-0 right-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary text-xs text-foreground"
70 : v-text="queueCount"
71 : />
72 : </div>
73 : </template>
|