Change asset load confirm to new popup

This commit is contained in:
Wolfsblvt 2024-07-10 20:10:16 +02:00
parent ec10090cd4
commit 75d4a06ae6
2 changed files with 10 additions and 17 deletions

View File

@ -1,9 +0,0 @@
<div class="m-b-1">
Are you sure you want to connect to '{{url}}'?
</div>
<div class="flex-container justifyCenter">
<label class="checkbox_label" for="assets-remember">
<input type="checkbox" id="assets-remember">
Don't ask again for this URL
</label>
</div>

View File

@ -5,7 +5,7 @@ TODO:
import { getRequestHeaders, callPopup, processDroppedFiles, eventSource, event_types } from '../../../script.js'; import { getRequestHeaders, callPopup, processDroppedFiles, eventSource, event_types } from '../../../script.js';
import { deleteExtension, extensionNames, getContext, installExtension, renderExtensionTemplateAsync } from '../../extensions.js'; import { deleteExtension, extensionNames, getContext, installExtension, renderExtensionTemplateAsync } from '../../extensions.js';
import { POPUP_TYPE, callGenericPopup } from '../../popup.js'; import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
import { executeSlashCommands } from '../../slash-commands.js'; import { executeSlashCommands } from '../../slash-commands.js';
import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js'; import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js';
export { MODULE_NAME }; export { MODULE_NAME };
@ -424,16 +424,18 @@ jQuery(async () => {
const rememberKey = `Assets_SkipConfirm_${getStringHash(url)}`; const rememberKey = `Assets_SkipConfirm_${getStringHash(url)}`;
const skipConfirm = localStorage.getItem(rememberKey) === 'true'; const skipConfirm = localStorage.getItem(rememberKey) === 'true';
const template = await renderExtensionTemplateAsync(MODULE_NAME, 'confirm', { url }); const confirmation = skipConfirm || await Popup.show.confirm('Loading Asset List', `<span>Are you sure you want to connect to the following url?</span><var>${url}</var>`, {
const confirmation = skipConfirm || await callPopup(template, 'confirm'); customInputs: [{ id: 'assets-remember', label: 'Don\'t ask again for this URL' }],
onClose: popup => {
if (popup.result) {
const rememberValue = popup.inputResults.get('assets-remember');
localStorage.setItem(rememberKey, String(rememberValue));
}
},
});
if (confirmation) { if (confirmation) {
try { try {
if (!skipConfirm) {
const rememberValue = Boolean($('#assets-remember').prop('checked'));
localStorage.setItem(rememberKey, String(rememberValue));
}
console.debug(DEBUG_PREFIX, 'Confimation, loading assets...'); console.debug(DEBUG_PREFIX, 'Confimation, loading assets...');
downloadAssetsList(url); downloadAssetsList(url);
connectButton.removeClass('fa-plug-circle-exclamation'); connectButton.removeClass('fa-plug-circle-exclamation');