mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Add default confirm dialog (#2114)
This commit is contained in:
39
README.md
39
README.md
@@ -61,10 +61,10 @@ Stable releases are published bi-weekly in the ComfyUI main repository.
|
|||||||
<details>
|
<details>
|
||||||
<summary>v1.5: Native translation (i18n)</summary>
|
<summary>v1.5: Native translation (i18n)</summary>
|
||||||
|
|
||||||
ComfyUI now includes built-in translation support, replacing the need for third-party translation extensions. Select your language
|
ComfyUI now includes built-in translation support, replacing the need for third-party translation extensions. Select your language
|
||||||
in `Comfy > Locale > Language` to translate the interface into English, Chinese (Simplified), Russian, Japanese, or Korean. This native
|
in `Comfy > Locale > Language` to translate the interface into English, Chinese (Simplified), Russian, Japanese, or Korean. This native
|
||||||
implementation offers better performance, reliability, and maintainability compared to previous solutions.<br>
|
implementation offers better performance, reliability, and maintainability compared to previous solutions.<br>
|
||||||
|
|
||||||
More details available here: https://blog.comfy.org/p/native-localization-support-i18n
|
More details available here: https://blog.comfy.org/p/native-localization-support-i18n
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -230,11 +230,18 @@ https://github.com/user-attachments/assets/c142c43f-2fe9-4030-8196-b3bfd4c6977d
|
|||||||
### Developer APIs
|
### Developer APIs
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>v1.6.13: Prompt dialog</summary>
|
<summary>v1.6.13: prompt/confirm/alert replacements for ComfyUI desktop</summary>
|
||||||
|
|
||||||
`window.prompt` is not available in ComfyUI desktop's electron environment. Please use the following API to show a prompt dialog.
|
Several browser-only APIs are not available in ComfyUI desktop's electron environment.
|
||||||
|
|
||||||
|
- `window.prompt`
|
||||||
|
- `window.confirm`
|
||||||
|
- `window.alert`
|
||||||
|
|
||||||
|
Please use the following APIs as replacements.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// window.prompt
|
||||||
window['app'].extensionManager.dialog
|
window['app'].extensionManager.dialog
|
||||||
.prompt({
|
.prompt({
|
||||||
title: 'Test Prompt',
|
title: 'Test Prompt',
|
||||||
@@ -247,6 +254,28 @@ window['app'].extensionManager.dialog
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
```js
|
||||||
|
// window.confirm
|
||||||
|
window['app'].extensionManager.dialog
|
||||||
|
.confirm({
|
||||||
|
title: 'Test Confirm',
|
||||||
|
message: 'Test Confirm Message'
|
||||||
|
})
|
||||||
|
.then((value: boolean) => {
|
||||||
|
// Do something with the value user entered
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```js
|
||||||
|
// window.alert
|
||||||
|
window['app'].extensionManager.toast
|
||||||
|
.addAlert("Test Alert")
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|||||||
@@ -177,5 +177,23 @@ test.describe('Topbar commands', () => {
|
|||||||
'Hello, world!'
|
'Hello, world!'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Should allow showing a confirmation dialog', async ({
|
||||||
|
comfyPage
|
||||||
|
}) => {
|
||||||
|
await comfyPage.page.evaluate(() => {
|
||||||
|
window['app'].extensionManager.dialog
|
||||||
|
.confirm({
|
||||||
|
title: 'Test Confirm',
|
||||||
|
message: 'Test Confirm Message'
|
||||||
|
})
|
||||||
|
.then((value: boolean) => {
|
||||||
|
window['value'] = value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
await comfyPage.confirmDialog.click('confirm')
|
||||||
|
expect(await comfyPage.page.evaluate(() => window['value'])).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -91,11 +91,13 @@ class ConfirmDialog {
|
|||||||
public readonly delete: Locator
|
public readonly delete: Locator
|
||||||
public readonly overwrite: Locator
|
public readonly overwrite: Locator
|
||||||
public readonly reject: Locator
|
public readonly reject: Locator
|
||||||
|
public readonly confirm: Locator
|
||||||
|
|
||||||
constructor(public readonly page: Page) {
|
constructor(public readonly page: Page) {
|
||||||
this.delete = page.locator('button.p-button[aria-label="Delete"]')
|
this.delete = page.locator('button.p-button[aria-label="Delete"]')
|
||||||
this.overwrite = page.locator('button.p-button[aria-label="Overwrite"]')
|
this.overwrite = page.locator('button.p-button[aria-label="Overwrite"]')
|
||||||
this.reject = page.locator('button.p-button[aria-label="Cancel"]')
|
this.reject = page.locator('button.p-button[aria-label="Cancel"]')
|
||||||
|
this.confirm = page.locator('button.p-button[aria-label="Confirm"]')
|
||||||
}
|
}
|
||||||
|
|
||||||
async click(locator: KeysOfType<ConfirmDialog, Locator>) {
|
async click(locator: KeysOfType<ConfirmDialog, Locator>) {
|
||||||
|
|||||||
@@ -13,7 +13,14 @@
|
|||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
v-if="type === 'delete'"
|
v-if="type === 'default'"
|
||||||
|
:label="$t('g.confirm')"
|
||||||
|
severity="primary"
|
||||||
|
@click="onConfirm"
|
||||||
|
icon="pi pi-check"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
v-else-if="type === 'delete'"
|
||||||
:label="$t('g.delete')"
|
:label="$t('g.delete')"
|
||||||
severity="danger"
|
severity="danger"
|
||||||
@click="onConfirm"
|
@click="onConfirm"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import type { ExecutionErrorWsMessage } from '@/types/apiTypes'
|
|||||||
import type { MissingNodeType } from '@/types/comfy'
|
import type { MissingNodeType } from '@/types/comfy'
|
||||||
|
|
||||||
export type ConfirmationDialogType =
|
export type ConfirmationDialogType =
|
||||||
|
| 'default'
|
||||||
| 'overwrite'
|
| 'overwrite'
|
||||||
| 'delete'
|
| 'delete'
|
||||||
| 'dirtyClose'
|
| 'dirtyClose'
|
||||||
@@ -121,16 +122,16 @@ export const useDialogService = () => {
|
|||||||
*/
|
*/
|
||||||
async function confirm({
|
async function confirm({
|
||||||
title,
|
title,
|
||||||
type,
|
|
||||||
message,
|
message,
|
||||||
|
type = 'default',
|
||||||
itemList = []
|
itemList = []
|
||||||
}: {
|
}: {
|
||||||
/** Dialog heading */
|
/** Dialog heading */
|
||||||
title: string
|
title: string
|
||||||
/** Pre-configured dialog type */
|
|
||||||
type: ConfirmationDialogType
|
|
||||||
/** The main message body */
|
/** The main message body */
|
||||||
message: string
|
message: string
|
||||||
|
/** Pre-configured dialog type */
|
||||||
|
type?: ConfirmationDialogType
|
||||||
/** Displayed as an unorderd list immediately below the message body */
|
/** Displayed as an unorderd list immediately below the message body */
|
||||||
itemList?: string[]
|
itemList?: string[]
|
||||||
}): Promise<boolean | null> {
|
}): Promise<boolean | null> {
|
||||||
|
|||||||
Reference in New Issue
Block a user