Add buttons to remove SD/translate secrets
| @@ -30,7 +30,7 @@ import { SlashCommand } from '../../slash-commands/SlashCommand.js'; | |||
| 30 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; | 30 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| 31 | import { debounce_timeout } from '../../constants.js'; | 31 | import { debounce_timeout } from '../../constants.js'; |
| 32 | import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js'; | 32 | import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js'; |
| 33 | import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js'; | 33 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js'; |
| 34 | export { MODULE_NAME }; | 34 | export { MODULE_NAME }; |
| 35 | 35 | ||
| 36 | const MODULE_NAME = 'sd'; | 36 | const MODULE_NAME = 'sd'; |
| @@ -1097,7 +1097,18 @@ function onComfyWorkflowChange() { | |||
| 1097 | 1097 | ||
| 1098 | async function onStabilityKeyClick() { | 1098 | async function onStabilityKeyClick() { |
| 1099 | const popupText = 'Stability AI API Key:'; | 1099 | const popupText = 'Stability AI API Key:'; |
| 1100 | const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT); | 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 | if (!key) { | 1113 | if (!key) { |
| 1103 | return; | 1114 | return; |
| @@ -10,7 +10,7 @@ import { | |||
| 10 | updateMessageBlock, | 10 | updateMessageBlock, |
| 11 | } from '../../../script.js'; | 11 | } from '../../../script.js'; |
| 12 | import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js'; | 12 | import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js'; |
| 13 | import { POPUP_TYPE, callGenericPopup } from '../../popup.js'; | 13 | import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from '../../popup.js'; |
| 14 | import { findSecret, secret_state, writeSecret } from '../../secrets.js'; | 14 | import { findSecret, secret_state, writeSecret } from '../../secrets.js'; |
| 15 | import { SlashCommand } from '../../slash-commands/SlashCommand.js'; | 15 | import { SlashCommand } from '../../slash-commands/SlashCommand.js'; |
| 16 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; | 16 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| @@ -621,7 +621,18 @@ jQuery(async () => { | |||
| 621 | const secretKey = extension_settings.translate.provider + '_url'; | 621 | const secretKey = extension_settings.translate.provider + '_url'; |
| 622 | const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : ''; | 622 | const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : ''; |
| 623 | 623 | ||
| 624 | const url = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedUrl); | 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 | if (url == false || url == '') { | 637 | if (url == false || url == '') { |
| 627 | return; | 638 | return; |