mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Backport of #9543 to core/1.41.
Cherry-pick of merge commit 725a0a2b applied cleanly.
**Original PR:** https://github.com/Comfy-Org/ComfyUI_frontend/pull/9543
**Pipeline ticket:** 15e1f241-efaa-4fe5-88ca-4ccc7bfb3345
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9562-backport-core-1-41-fix-remove-timeouts-from-error-toasts-so-they-persist-until-dismiss-31d6d73d365081caa825ff32ca622b2c)
by [Unito](https://www.unito.io)
116 lines
2.8 KiB
Vue
116 lines
2.8 KiB
Vue
<template>
|
|
<!-- Tasks -->
|
|
<section class="my-4">
|
|
<template v-if="filter.tasks.length === 0">
|
|
<!-- Empty filter -->
|
|
<Divider />
|
|
<p class="w-full text-center text-neutral-400">
|
|
{{ $t('maintenance.allOk') }}
|
|
</p>
|
|
</template>
|
|
|
|
<template v-else>
|
|
<!-- Display: List -->
|
|
<table
|
|
v-if="displayAsList === PrimeIcons.LIST"
|
|
class="w-full border-collapse border-hidden"
|
|
>
|
|
<TaskListItem
|
|
v-for="task in filter.tasks"
|
|
:key="task.id"
|
|
:task
|
|
@execute="(event) => confirmButton(event, task)"
|
|
/>
|
|
</table>
|
|
|
|
<!-- Display: Cards -->
|
|
<template v-else>
|
|
<div class="pad-y my-4 flex flex-wrap justify-evenly gap-8">
|
|
<TaskCard
|
|
v-for="task in filter.tasks"
|
|
:key="task.id"
|
|
:task
|
|
@execute="(event) => confirmButton(event, task)"
|
|
/>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<ConfirmPopup />
|
|
</section>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { PrimeIcons } from '@primevue/core/api'
|
|
import { useConfirm, useToast } from 'primevue'
|
|
import ConfirmPopup from 'primevue/confirmpopup'
|
|
import Divider from 'primevue/divider'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import { useMaintenanceTaskStore } from '@/stores/maintenanceTaskStore'
|
|
import type {
|
|
MaintenanceFilter,
|
|
MaintenanceTask
|
|
} from '@/types/desktop/maintenanceTypes'
|
|
|
|
import TaskCard from './TaskCard.vue'
|
|
import TaskListItem from './TaskListItem.vue'
|
|
|
|
const { t } = useI18n()
|
|
const toast = useToast()
|
|
const confirm = useConfirm()
|
|
const taskStore = useMaintenanceTaskStore()
|
|
|
|
// Properties
|
|
defineProps<{
|
|
displayAsList: string
|
|
filter: MaintenanceFilter
|
|
}>()
|
|
|
|
const executeTask = async (task: MaintenanceTask) => {
|
|
let message: string | undefined
|
|
|
|
try {
|
|
// Success
|
|
if ((await taskStore.execute(task)) === true) return
|
|
|
|
message = t('maintenance.error.taskFailed')
|
|
} catch (error) {
|
|
message = (error as Error)?.message
|
|
}
|
|
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: t('maintenance.error.toastTitle'),
|
|
detail: message ?? t('maintenance.error.defaultDescription')
|
|
})
|
|
}
|
|
|
|
// Commands
|
|
const confirmButton = async (event: MouseEvent, task: MaintenanceTask) => {
|
|
if (!task.requireConfirm) {
|
|
await executeTask(task)
|
|
return
|
|
}
|
|
|
|
confirm.require({
|
|
target: event.currentTarget as HTMLElement,
|
|
message: task.confirmText ?? t('maintenance.confirmTitle'),
|
|
icon: 'pi pi-exclamation-circle',
|
|
rejectProps: {
|
|
label: t('g.cancel'),
|
|
severity: 'secondary',
|
|
outlined: true
|
|
},
|
|
acceptProps: {
|
|
label: task.button?.text ?? t('g.save'),
|
|
severity: task.severity ?? 'primary'
|
|
},
|
|
// TODO: Not awaited.
|
|
accept: async () => {
|
|
await executeTask(task)
|
|
}
|
|
})
|
|
}
|
|
</script>
|