Add config hint

This commit is contained in:
Cohee 2024-04-12 23:18:43 +03:00
parent 2fbcbe86d2
commit 2e14132a20
2 changed files with 17 additions and 5 deletions

View File

@ -2,10 +2,13 @@
<div> <div>
<h2 class="marginBot10 flex-container"> <h2 class="marginBot10 flex-container">
<span>Hi,</span><span class="userName margin0"></span> <span>Hi,</span><span class="userName margin0"></span>
<div class="userChangeNameButton right_menu_button" title="Change display name."> <div data-require-accounts class="userChangeNameButton right_menu_button" title="Change display name.">
<i class="fa-fw fa-solid fa-pencil fa-xs"></i> <i class="fa-fw fa-solid fa-pencil fa-xs"></i>
</div> </div>
</h2> </h2>
<div class="accountsDisabledHint" style="display: none;">
To enable multi-account features, restart the SillyTavern server with <code>enableUserAccounts</code> set to true in the config.yaml file.
</div>
</div> </div>
<div> <div>
<h3> <h3>
@ -47,7 +50,7 @@
Account Actions Account Actions
</h3> </h3>
<div class="flex-container flexFlowColumn flexNoGap"> <div class="flex-container flexFlowColumn flexNoGap">
<div class="flex-container"> <div data-require-accounts class="flex-container">
<div class="userChangePasswordButton menu_button menu_button_icon" title="Change your password."> <div class="userChangePasswordButton menu_button menu_button_icon" title="Change your password.">
<i class="fa-fw fa-solid fa-key"></i> <i class="fa-fw fa-solid fa-key"></i>
<span data-i18n="Change Password">Change Password</span> <span data-i18n="Change Password">Change Password</span>

View File

@ -7,6 +7,7 @@ import { humanFileSize } from './utils.js';
* @type {import('../../src/users.js').UserViewModel} Logged in user * @type {import('../../src/users.js').UserViewModel} Logged in user
*/ */
export let currentUser = null; export let currentUser = null;
export let accountsEnabled = false;
/** /**
* Enable or disable user account controls in the UI. * Enable or disable user account controls in the UI.
@ -14,12 +15,15 @@ export let currentUser = null;
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
export async function setUserControls(isEnabled) { export async function setUserControls(isEnabled) {
accountsEnabled = isEnabled;
if (!isEnabled) { if (!isEnabled) {
$('#account_controls').hide(); $('#logout_button').hide();
$('#admin_button').hide();
return; return;
} }
$('#account_controls').show(); $('#logout_button').show();
await getCurrentUser(); await getCurrentUser();
} }
@ -50,7 +54,7 @@ async function getCurrentUser() {
} }
currentUser = await response.json(); currentUser = await response.json();
$('#admin_button').toggle(isAdmin()); $('#admin_button').toggle(accountsEnabled && isAdmin());
} catch (error) { } catch (error) {
console.error('Error getting current user:', error); console.error('Error getting current user:', error);
} }
@ -621,6 +625,11 @@ async function openUserProfile() {
}); });
template.find('.userResetSettingsButton').on('click', () => resetSettings(currentUser.handle, () => location.reload())); template.find('.userResetSettingsButton').on('click', () => resetSettings(currentUser.handle, () => location.reload()));
if (!accountsEnabled) {
template.find('[data-require-accounts]').hide();
template.find('.accountsDisabledHint').show();
}
const popupOptions = { const popupOptions = {
okButton: 'Close', okButton: 'Close',
wide: false, wide: false,