From c7650576845dca33ee3e4ef2beb44e0ad635f6c0 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sun, 8 Sep 2024 01:18:44 +0200 Subject: [PATCH] Disable buttons on option --- public/scripts/extensions/connection-manager/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/scripts/extensions/connection-manager/index.js b/public/scripts/extensions/connection-manager/index.js index 583738f72..7f30a8cc7 100644 --- a/public/scripts/extensions/connection-manager/index.js +++ b/public/scripts/extensions/connection-manager/index.js @@ -354,6 +354,13 @@ async function renderDetailsContent(detailsContent) { const profiles = document.getElementById('connection_profiles'); renderConnectionProfiles(profiles); + function toggleProfileSpecificButtons() { + const profileId = extension_settings.connectionManager.selectedProfile; + const profileSpecificButtons = ['update_connection_profile', 'reload_connection_profile', 'delete_connection_profile']; + profileSpecificButtons.forEach(id => document.getElementById(id).classList.toggle('disabled', !profileId)); + } + toggleProfileSpecificButtons(); + profiles.addEventListener('change', async function () { const selectedProfile = profiles.selectedOptions[0]; if (!selectedProfile) { @@ -367,6 +374,8 @@ async function renderDetailsContent(detailsContent) { saveSettingsDebounced(); await renderDetailsContent(detailsContent); + toggleProfileSpecificButtons(); + // None option selected if (!profileId) { await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, NONE);