Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/components/queue/job/JobGroupsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onBeforeUnmount, ref, watch } from 'vue'

import QueueJobItem from '@/components/queue/job/QueueJobItem.vue'
import type { JobGroup, JobListItem } from '@/composables/queue/useJobList'

defineProps<{ displayedJobGroups: JobGroup[] }>()
const props = defineProps<{ displayedJobGroups: JobGroup[] }>()

const emit = defineEmits<{
(e: 'cancelItem', item: JobListItem): void
Expand Down Expand Up @@ -89,4 +89,26 @@ const onDetailsLeave = (jobId: string) => {
hideTimer.value = null
}, 150)
}

const resetActiveDetails = () => {
clearHideTimer()
clearShowTimer()
activeDetailsId.value = null
}

watch(
() => props.displayedJobGroups,
(groups) => {
const activeId = activeDetailsId.value
if (!activeId) return

const hasActiveJob = groups.some((group) =>
group.items.some((item) => item.id === activeId)
)

if (!hasActiveJob) resetActiveDetails()
}
)

onBeforeUnmount(resetActiveDetails)
</script>
18 changes: 15 additions & 3 deletions src/components/queue/job/QueueJobItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
size="sm"
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
:aria-label="t('g.delete')"
@click.stop="emit('delete')"
@click.stop="onDeleteClick"
>
<i class="icon-[lucide--trash-2] size-4" />
</IconButton>
Expand All @@ -150,7 +150,7 @@
size="sm"
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
:aria-label="t('g.cancel')"
@click.stop="emit('cancel')"
@click.stop="onCancelClick"
>
<i class="icon-[lucide--x] size-4" />
</IconButton>
Expand Down Expand Up @@ -190,7 +190,7 @@
size="sm"
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
:aria-label="t('g.cancel')"
@click.stop="emit('cancel')"
@click.stop="onCancelClick"
>
<i class="icon-[lucide--x] size-4" />
</IconButton>
Expand Down Expand Up @@ -355,6 +355,18 @@ const computedShowClear = computed(() => {
return props.state !== 'completed'
})

const emitDetailsLeave = () => emit('details-leave', props.jobId)

const onCancelClick = () => {
emitDetailsLeave()
emit('cancel')
}

const onDeleteClick = () => {
emitDetailsLeave()
emit('delete')
}

const onContextMenu = (event: MouseEvent) => {
const shouldShowMenu = props.showMenu !== undefined ? props.showMenu : true
if (shouldShowMenu) emit('menu', event)
Expand Down
Loading