Expose dialogService to extensionManager (#2113)

This commit is contained in:
Chenlei Hu
2024-12-31 17:01:37 -05:00
committed by GitHub
parent 0b3c0cc0c9
commit 174a9a114a
11 changed files with 66 additions and 18 deletions

View File

@@ -84,7 +84,7 @@ export const useDialogService = () => {
})
}
async function showPromptDialog({
async function prompt({
title,
message,
defaultValue = ''
@@ -119,7 +119,7 @@ export const useDialogService = () => {
* `false` if denied (e.g. no in yes/no/cancel), or
* `null` if the dialog is cancelled or closed
*/
async function showConfirmationDialog({
async function confirm({
title,
type,
message,
@@ -161,7 +161,7 @@ export const useDialogService = () => {
showAboutDialog,
showExecutionErrorDialog,
showTemplateWorkflowsDialog,
showPromptDialog,
showConfirmationDialog
prompt,
confirm
}
}

View File

@@ -22,7 +22,7 @@ export const useWorkflowService = () => {
async function getFilename(defaultName: string): Promise<string | null> {
if (settingStore.get('Comfy.PromptFilename')) {
let filename = await dialogService.showPromptDialog({
let filename = await dialogService.prompt({
title: t('workflowService.exportWorkflow'),
message: t('workflowService.enterFilename') + ':',
defaultValue: defaultName
@@ -60,7 +60,7 @@ export const useWorkflowService = () => {
* @param workflow The workflow to save
*/
const saveWorkflowAs = async (workflow: ComfyWorkflow) => {
const newFilename = await dialogService.showPromptDialog({
const newFilename = await dialogService.prompt({
title: t('workflowService.saveWorkflow'),
message: t('workflowService.enterFilename') + ':',
defaultValue: workflow.filename
@@ -72,7 +72,7 @@ export const useWorkflowService = () => {
const existingWorkflow = workflowStore.getWorkflowByPath(newPath)
if (existingWorkflow && !existingWorkflow.isTemporary) {
const res = await dialogService.showConfirmationDialog({
const res = await dialogService.confirm({
title: t('sideToolbar.workflowTab.confirmOverwriteTitle'),
type: 'overwrite',
message: t('sideToolbar.workflowTab.confirmOverwrite'),
@@ -181,7 +181,7 @@ export const useWorkflowService = () => {
}
if (workflow.isModified && options.warnIfUnsaved) {
const confirmed = await dialogService.showConfirmationDialog({
const confirmed = await dialogService.confirm({
title: t('sideToolbar.workflowTab.dirtyCloseTitle'),
type: 'dirtyClose',
message: t('sideToolbar.workflowTab.dirtyClose'),
@@ -225,7 +225,7 @@ export const useWorkflowService = () => {
let confirmed: boolean | null = bypassConfirm || silent
if (!confirmed) {
confirmed = await dialogService.showConfirmationDialog({
confirmed = await dialogService.confirm({
title: t('sideToolbar.workflowTab.confirmDeleteTitle'),
type: 'delete',
message: t('sideToolbar.workflowTab.confirmDelete'),