From 5dba4fa448b9e40ecf23283373862c736d510228 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:12:44 +0300 Subject: [PATCH] Update SD extension to new popup --- .../scripts/extensions/stable-diffusion/index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index 49f5e2d78..cfff05c8d 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -3,7 +3,6 @@ import { systemUserName, hideSwipeButtons, showSwipeButtons, - callPopup, getRequestHeaders, event_types, eventSource, @@ -29,10 +28,9 @@ import { getMultimodalCaption } from '../shared.js'; import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js'; import { SlashCommand } from '../../slash-commands/SlashCommand.js'; import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; -import { resolveVariable } from '../../variables.js'; import { debounce_timeout } from '../../constants.js'; -import { commonEnumProviders } from '../../slash-commands/SlashCommandCommonEnumsProvider.js'; import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js'; +import { POPUP_TYPE, callGenericPopup } from '../../popup.js'; export { MODULE_NAME }; const MODULE_NAME = 'sd'; @@ -572,7 +570,7 @@ async function onDeleteStyleClick() { return; } - const confirmed = await callPopup(`Are you sure you want to delete the style "${selectedStyle}"?`, 'confirm', '', { okButton: 'Delete' }); + const confirmed = await callGenericPopup(`Are you sure you want to delete the style "${selectedStyle}"?`, POPUP_TYPE.CONFIRM, '', { okButton: 'Delete', cancelButton: 'Cancel' }); if (!confirmed) { return; @@ -601,7 +599,7 @@ async function onDeleteStyleClick() { } async function onSaveStyleClick() { - const userInput = await callPopup('Enter style name:', 'input', '', { okButton: 'Save' }); + const userInput = await callGenericPopup('Enter style name:', POPUP_TYPE.INPUT); if (!userInput) { return; @@ -670,7 +668,7 @@ async function refinePrompt(prompt, allowExpand, isNegative = false) { if (extension_settings.sd.refine_mode) { const text = isNegative ? '

Review and edit the negative prompt:

' : '

Review and edit the prompt:

'; - const refinedPrompt = await callPopup(text + 'Press "Cancel" to abort the image generation.', 'input', prompt.trim(), { rows: 5, okButton: 'Continue' }); + const refinedPrompt = await callGenericPopup(text + 'Press "Cancel" to abort the image generation.', POPUP_TYPE.INPUT, prompt.trim(), { rows: 5, okButton: 'Continue' }); if (refinedPrompt) { return refinedPrompt; @@ -2978,7 +2976,7 @@ async function onComfyOpenWorkflowEditorClick() { }), })).json(); const editorHtml = $(await $.get('scripts/extensions/stable-diffusion/comfyWorkflowEditor.html')); - const popupResult = callPopup(editorHtml, 'confirm', undefined, { okButton: 'Save', wide: true, large: true, rows: 1 }); + const popupResult = callGenericPopup(editorHtml, POPUP_TYPE.CONFIRM, '', { okButton: 'Save', cancelButton: 'Cancel', wide: true, large: true }); const checkPlaceholders = () => { workflow = $('#sd_comfy_workflow_editor_workflow').val().toString(); $('.sd_comfy_workflow_editor_placeholder_list > li[data-placeholder]').each(function (idx) { @@ -3058,7 +3056,7 @@ async function onComfyOpenWorkflowEditorClick() { } async function onComfyNewWorkflowClick() { - let name = await callPopup('

Workflow name:

', 'input'); + let name = await callGenericPopup('Workflow name:', POPUP_TYPE.INPUT); if (!name) { return; } @@ -3085,7 +3083,7 @@ async function onComfyNewWorkflowClick() { } async function onComfyDeleteWorkflowClick() { - const confirm = await callPopup('Delete the workflow? This action is irreversible.', 'confirm'); + const confirm = await callGenericPopup('Delete the workflow? This action is irreversible.', POPUP_TYPE.CONFIRM, '', { okButton: 'Delete', cancelButton: 'Cancel' }); if (!confirm) { return; }