Add buttons to remove SD/translate secrets
| @@ -30,7 +30,7 @@ import { SlashCommand } from '../../slash-commands/SlashCommand.js'; | ||
| 30 | 30 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| 31 | 31 | import { debounce_timeout } from '../../constants.js'; |
| 32 | 32 | import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js'; |
| 33 | 33 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js'; |
| 34 | 34 | export { MODULE_NAME }; |
| 35 | 35 | |
| 36 | 36 | const MODULE_NAME = 'sd'; |
| @@ -1097,7 +1097,18 @@ function onComfyWorkflowChange() { | ||
| 1097 | 1097 | |
| 1098 | 1098 | async function onStabilityKeyClick() { |
| 1099 | 1099 | const popupText = 'Stability AI API Key:'; |
| 1100 | 1100 | const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT);, '', { |
| 1101 | + customButtons: [{ | |
| 1102 | + text: 'Remove Key', | |
| 1103 | + appendAtEnd: true, | |
| 1104 | + result: POPUP_RESULT.NEGATIVE, | |
| 1105 | + action: async () => { | |
| 1106 | + await writeSecret(SECRET_KEYS.STABILITY, ''); | |
| 1107 | + toastr.success('API Key removed'); | |
| 1108 | + await loadSettingOptions(); | |
| 1109 | + }, | |
| 1110 | + }], | |
| 1111 | + }); | |
| 1101 | 1112 | |
| 1102 | 1113 | if (!key) { |
| 1103 | 1114 | return; |
| @@ -2693,15 +2704,15 @@ async function generateBlockEntropyImage(prompt, negativePrompt, signal) { | ||
| 2693 | 2704 | |
| 2694 | 2705 | if (result.ok) { |
| 2695 | 2706 | const data = await result.json(); |
| 2696 | - | |
| 2707 | + | |
| 2697 | 2708 | // Default format is 'jpg' |
| 2698 | 2709 | let format = 'jpg'; |
| 2699 | - | |
| 2710 | + | |
| 2700 | 2711 | // Check if a format is specified in the result |
| 2701 | 2712 | if (data.format) { |
| 2702 | 2713 | format = data.format.toLowerCase(); |
| 2703 | 2714 | } |
| 2704 | - | |
| 2715 | + | |
| 2705 | 2716 | return { format: format, data: data.images[0] }; |
| 2706 | 2717 | } else { |
| 2707 | 2718 | const text = await result.text(); |
| @@ -10,7 +10,7 @@ import { | ||
| 10 | 10 | updateMessageBlock, |
| 11 | 11 | } from '../../../script.js'; |
| 12 | 12 | import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js'; |
| 13 | 13 | import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from '../../popup.js'; |
| 14 | 14 | import { findSecret, secret_state, writeSecret } from '../../secrets.js'; |
| 15 | 15 | import { SlashCommand } from '../../slash-commands/SlashCommand.js'; |
| 16 | 16 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| @@ -621,7 +621,18 @@ jQuery(async () => { | ||
| 621 | 621 | const secretKey = extension_settings.translate.provider + '_url'; |
| 622 | 622 | const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : ''; |
| 623 | 623 | |
| 624 | 624 | const url = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedUrl);,{ |
| 625 | + customButtons: [{ | |
| 626 | + text: 'Remove URL', | |
| 627 | + appendAtEnd: true, | |
| 628 | + result: POPUP_RESULT.NEGATIVE, | |
| 629 | + action: async () => { | |
| 630 | + await writeSecret(secretKey, ''); | |
| 631 | + toastr.success('API URL removed'); | |
| 632 | + $('#translate_url_button').toggleClass('success', !!secret_state[secretKey]); | |
| 633 | + }, | |
| 634 | + }], | |
| 635 | + }); | |
| 625 | 636 | |
| 626 | 637 | if (url == false || url == '') { |
| 627 | 638 | return; |