Merge pull request #2509 from SillyTavern/preset-manager-popups

Preset manager popups
This commit is contained in:
Cohee 2024-07-12 01:17:05 +03:00 committed by GitHub
commit dcb416cb00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 13 deletions

View File

@ -1,6 +1,5 @@
import {
amount_gen,
callPopup,
characters,
eventSource,
event_types,
@ -19,6 +18,7 @@ import {
import { groups, selected_group } from './group-chats.js';
import { instruct_presets } from './instruct-mode.js';
import { kai_settings } from './kai-settings.js';
import { Popup } from './popup.js';
import { context_presets, getContextSettings, power_user } from './power-user.js';
import { SlashCommand } from './slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js';
@ -165,11 +165,8 @@ class PresetManager {
async savePresetAs() {
const inputValue = this.getSelectedPresetName();
const popupText = `
<h3>Preset name:</h3>
${!this.isNonGenericApi() ? '<h4>Hint: Use a character/group name to bind preset to a specific chat.</h4>' : ''}`;
const name = await callPopup(popupText, 'input', inputValue);
const popupText = !this.isNonGenericApi() ? '<h4>Hint: Use a character/group name to bind preset to a specific chat.</h4>' : '';
const name = await Popup.show.input('Preset name:', popupText, inputValue);
if (!name) {
console.log('Preset name not provided');
return;
@ -372,7 +369,7 @@ class PresetManager {
if (Object.keys(preset_names).length) {
const nextPresetName = Object.keys(preset_names)[0];
const newValue = preset_names[nextPresetName];
$(this.select).find(`option[value="${newValue}"]`).attr('selected', true);
$(this.select).find(`option[value="${newValue}"]`).attr('selected', 'true');
$(this.select).trigger('change');
}
@ -597,8 +594,7 @@ export async function initPresetManager() {
return;
}
const confirm = await callPopup('Delete the preset? This action is irreversible and your current settings will be overwritten.', 'confirm');
const confirm = await Popup.show.confirm('Delete the preset?', 'This action is irreversible and your current settings will be overwritten.');
if (!confirm) {
return;
}
@ -641,8 +637,7 @@ export async function initPresetManager() {
return;
}
const confirm = await callPopup('<h3>Are you sure?</h3>Resetting a <b>default preset</b> will restore the default settings.', 'confirm');
const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a <b>default preset</b> will restore the default settings.');
if (!confirm) {
return;
}
@ -653,8 +648,7 @@ export async function initPresetManager() {
presetManager.selectPreset(option);
toastr.success('Default preset restored');
} else {
const confirm = await callPopup('<h3>Are you sure?</h3>Resetting a <b>custom preset</b> will restore to the last saved state.', 'confirm');
const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a <b>custom preset</b> will restore to the last saved state.');
if (!confirm) {
return;
}