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

View File

@@ -1,6 +1,5 @@
import { import {
amount_gen, amount_gen,
callPopup,
characters, characters,
eventSource, eventSource,
event_types, event_types,
@@ -19,6 +18,7 @@ import {
import { groups, selected_group } from './group-chats.js'; import { groups, selected_group } from './group-chats.js';
import { instruct_presets } from './instruct-mode.js'; import { instruct_presets } from './instruct-mode.js';
import { kai_settings } from './kai-settings.js'; import { kai_settings } from './kai-settings.js';
import { Popup } from './popup.js';
import { context_presets, getContextSettings, power_user } from './power-user.js'; import { context_presets, getContextSettings, power_user } from './power-user.js';
import { SlashCommand } from './slash-commands/SlashCommand.js'; import { SlashCommand } from './slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js'; import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js';
@@ -165,11 +165,8 @@ class PresetManager {
async savePresetAs() { async savePresetAs() {
const inputValue = this.getSelectedPresetName(); const inputValue = this.getSelectedPresetName();
const popupText = ` const popupText = !this.isNonGenericApi() ? '<h4>Hint: Use a character/group name to bind preset to a specific chat.</h4>' : '';
<h3>Preset name:</h3> const name = await Popup.show.input('Preset name:', popupText, inputValue);
${!this.isNonGenericApi() ? '<h4>Hint: Use a character/group name to bind preset to a specific chat.</h4>' : ''}`;
const name = await callPopup(popupText, 'input', inputValue);
if (!name) { if (!name) {
console.log('Preset name not provided'); console.log('Preset name not provided');
return; return;
@@ -372,7 +369,7 @@ class PresetManager {
if (Object.keys(preset_names).length) { if (Object.keys(preset_names).length) {
const nextPresetName = Object.keys(preset_names)[0]; const nextPresetName = Object.keys(preset_names)[0];
const newValue = preset_names[nextPresetName]; 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'); $(this.select).trigger('change');
} }
@@ -597,8 +594,7 @@ export async function initPresetManager() {
return; 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) { if (!confirm) {
return; return;
} }
@@ -641,8 +637,7 @@ export async function initPresetManager() {
return; 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) { if (!confirm) {
return; return;
} }
@@ -653,8 +648,7 @@ export async function initPresetManager() {
presetManager.selectPreset(option); presetManager.selectPreset(option);
toastr.success('Default preset restored'); toastr.success('Default preset restored');
} else { } 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) { if (!confirm) {
return; return;
} }