mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary
Remove `life` (timeout) property from all error-severity toast calls so
they persist until manually dismissed, preventing users from missing
important error messages.
## Changes
- **What**: Removed `life` property from 86 error toast calls across 46
files. Error toasts now use PrimeVue's default behavior (no
auto-dismiss). Non-error toasts (success, warn, info) are unchanged.
- Also fixed a pre-existing lint issue in `TaskListPanel.vue` (`import {
t } from '@/i18n'` → `useI18n()`)
## Review Focus
- One conditional toast in `useMediaAssetActions.ts` intentionally keeps
`life` because its severity alternates between `warn` and `error`
Fixes
https://www.notion.so/comfy-org/Implement-Remove-timeouts-for-all-error-toasts-31b6d73d365081cead54fddc77ae7c3d
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9543-fix-remove-timeouts-from-error-toasts-so-they-persist-until-dismissed-31c6d73d365081fa8d30f6366e9bfe38)
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>
|