Add Save and Update

4167fe3d2b807f4a77977df29fc0feb65f2e67e6

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +18 -2Showing whitespace changes
public/css/popup.css+2 -0
@@ -149,10 +149,12 @@ body.no-blur .popup[open]::backdrop {
149 box-shadow: 0 0 5px var(--white20a);149 box-shadow: 0 0 5px var(--white20a);
150}150}
151151
152.menu_button.primary,
152.menu_button.popup-button-ok {153.menu_button.popup-button-ok {
153 background-color: var(--crimson70a);154 background-color: var(--crimson70a);
154}155}
155156
157.menu_button.primary:hover,
156.menu_button.popup-button-ok:hover {158.menu_button.popup-button-ok:hover {
157 background-color: var(--crimson-hover);159 background-color: var(--crimson-hover);
158}160}
public/scripts/extensions/connection-manager/index.js+16 -2
@@ -1,6 +1,6 @@
1import { event_types, eventSource, main_api, saveSettingsDebounced } from '../../../script.js';1import { event_types, eventSource, main_api, saveSettingsDebounced } from '../../../script.js';
2import { extension_settings, renderExtensionTemplateAsync } from '../../extensions.js';2import { extension_settings, renderExtensionTemplateAsync } from '../../extensions.js';
3import { callGenericPopup, Popup, POPUP_TYPE } from '../../popup.js';3import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js';
4import { SlashCommand } from '../../slash-commands/SlashCommand.js';4import { SlashCommand } from '../../slash-commands/SlashCommand.js';
5import { SlashCommandAbortController } from '../../slash-commands/SlashCommandAbortController.js';5import { SlashCommandAbortController } from '../../slash-commands/SlashCommandAbortController.js';
6import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';6import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
@@ -523,6 +523,7 @@ async function renderDetailsContent(detailsContent) {
523 profile.exclude = [];523 profile.exclude = [];
524 }524 }
525525
526 let saveChanges = false;
526 const commands = profile.mode === 'cc' ? CC_COMMANDS : TC_COMMANDS;527 const commands = profile.mode === 'cc' ? CC_COMMANDS : TC_COMMANDS;
527 const settings = commands.reduce((acc, command) => {528 const settings = commands.reduce((acc, command) => {
528 const fancyName = FANCY_NAMES[command];529 const fancyName = FANCY_NAMES[command];
@@ -530,7 +531,16 @@ async function renderDetailsContent(detailsContent) {
530 return acc;531 return acc;
531 }, {});532 }, {});
532 const template = $(await renderExtensionTemplateAsync(MODULE_NAME, 'edit', { name: profile.name, settings }));533 const template = $(await renderExtensionTemplateAsync(MODULE_NAME, 'edit', { name: profile.name, settings }));
533 const newName = await callGenericPopup(template, POPUP_TYPE.INPUT, profile.name);534 const newName = await callGenericPopup(template, POPUP_TYPE.INPUT, profile.name, {
535 customButtons: [{
536 text: 'Save and Update',
537 classes: ['primary'],
538 result: POPUP_RESULT.AFFIRMATIVE,
539 action: () => {
540 saveChanges = true;
541 },
542 }],
543 });
534544
535 if (!newName) {545 if (!newName) {
536 return;546 return;
@@ -550,8 +560,12 @@ async function renderDetailsContent(detailsContent) {
550 for (const command of newExcludeList) {560 for (const command of newExcludeList) {
551 delete profile[command];561 delete profile[command];
552 }562 }
563 if (saveChanges) {
564 await updateConnectionProfile(profile);
565 } else {
553 toastr.info('Press "Update" to record them into the profile.', 'Included settings list updated');566 toastr.info('Press "Update" to record them into the profile.', 'Included settings list updated');
554 }567 }
568 }
555569
556 if (profile.name !== newName) {570 if (profile.name !== newName) {
557 toastr.success('Connection profile renamed.');571 toastr.success('Connection profile renamed.');