@@ -9880,6 +9880,19 @@ function initToolSelect(
98809880 } else {
98819881 warnBox.textContent = "";
98829882 }
9883+
9884+ // Update the Select All button text to show count
9885+ // Re-query the button by ID to ensure we get the current button (not a stale reference)
9886+ if (selectBtnId) {
9887+ const currentSelectBtn = document.getElementById(selectBtnId);
9888+ if (currentSelectBtn) {
9889+ if (count > 0) {
9890+ currentSelectBtn.textContent = `Select All (${count})`;
9891+ } else {
9892+ currentSelectBtn.textContent = "Select All";
9893+ }
9894+ }
9895+ }
98839896 } catch (error) {
98849897 console.error("Error updating tool select:", error);
98859898 }
@@ -9927,7 +9940,6 @@ function initToolSelect(
99279940
99289941 newSelectBtn.addEventListener("click", async () => {
99299942 // Disable button and show loading state
9930- const originalText = newSelectBtn.textContent;
99319943 newSelectBtn.disabled = true;
99329944 newSelectBtn.textContent = "Selecting all tools...";
99339945
@@ -10010,16 +10022,11 @@ function initToolSelect(
1001010022 allToolIds.forEach((id) => editSel.add(String(id)));
1001110023
1001210024 update();
10013-
10014- newSelectBtn.textContent = `✓ All ${allToolIds.length} tools selected`;
10015- setTimeout(() => {
10016- newSelectBtn.textContent = originalText;
10017- }, 2000);
1001810025 } catch (error) {
1001910026 console.error("Error in Select All:", error);
1002010027 alert("Failed to select all tools. Please try again.");
1002110028 newSelectBtn.disabled = false;
10022- newSelectBtn.textContent = originalText;
10029+ update(); // Reset button text via update()
1002310030 } finally {
1002410031 newSelectBtn.disabled = false;
1002510032 }
@@ -10309,6 +10316,18 @@ function initResourceSelect(
1030910316 } else {
1031010317 warnBox.textContent = "";
1031110318 }
10319+
10320+ // Update the Select All button text to show count
10321+ if (selectBtnId) {
10322+ const currentSelectBtn = document.getElementById(selectBtnId);
10323+ if (currentSelectBtn) {
10324+ if (count > 0) {
10325+ currentSelectBtn.textContent = `Select All (${count})`;
10326+ } else {
10327+ currentSelectBtn.textContent = "Select All";
10328+ }
10329+ }
10330+ }
1031210331 } catch (error) {
1031310332 console.error("Error updating resource select:", error);
1031410333 }
@@ -10355,7 +10374,6 @@ function initResourceSelect(
1035510374 selectBtn.parentNode.replaceChild(newSelectBtn, selectBtn);
1035610375
1035710376 newSelectBtn.addEventListener("click", async () => {
10358- const originalText = newSelectBtn.textContent;
1035910377 newSelectBtn.disabled = true;
1036010378 newSelectBtn.textContent = "Selecting all resources...";
1036110379
@@ -10438,14 +10456,11 @@ function initResourceSelect(
1043810456 allIds.forEach((id) => editSel.add(String(id)));
1043910457
1044010458 update();
10441-
10442- newSelectBtn.textContent = `✓ All ${allIds.length} resources selected`;
10443- setTimeout(() => {
10444- newSelectBtn.textContent = originalText;
10445- }, 2000);
1044610459 } catch (error) {
1044710460 console.error("Error selecting all resources:", error);
1044810461 alert("Failed to select all resources. Please try again.");
10462+ newSelectBtn.disabled = false;
10463+ update(); // Reset button text via update()
1044910464 } finally {
1045010465 newSelectBtn.disabled = false;
1045110466 }
@@ -10724,6 +10739,18 @@ function initPromptSelect(
1072410739 } else {
1072510740 warnBox.textContent = "";
1072610741 }
10742+
10743+ // Update the Select All button text to show count
10744+ if (selectBtnId) {
10745+ const currentSelectBtn = document.getElementById(selectBtnId);
10746+ if (currentSelectBtn) {
10747+ if (count > 0) {
10748+ currentSelectBtn.textContent = `Select All (${count})`;
10749+ } else {
10750+ currentSelectBtn.textContent = "Select All";
10751+ }
10752+ }
10753+ }
1072710754 } catch (error) {
1072810755 console.error("Error updating prompt select:", error);
1072910756 }
@@ -10769,7 +10796,6 @@ function initPromptSelect(
1076910796 newSelectBtn.dataset.listenerAttached = "true";
1077010797 selectBtn.parentNode.replaceChild(newSelectBtn, selectBtn);
1077110798 newSelectBtn.addEventListener("click", async () => {
10772- const originalText = newSelectBtn.textContent;
1077310799 newSelectBtn.disabled = true;
1077410800 newSelectBtn.textContent = "Selecting all prompts...";
1077510801
@@ -10852,14 +10878,11 @@ function initPromptSelect(
1085210878 allIds.forEach((id) => editSel.add(String(id)));
1085310879
1085410880 update();
10855-
10856- newSelectBtn.textContent = `✓ All ${allIds.length} prompts selected`;
10857- setTimeout(() => {
10858- newSelectBtn.textContent = originalText;
10859- }, 2000);
1086010881 } catch (error) {
1086110882 console.error("Error selecting all prompts:", error);
1086210883 alert("Failed to select all prompts. Please try again.");
10884+ newSelectBtn.disabled = false;
10885+ update(); // Reset button text via update()
1086310886 } finally {
1086410887 newSelectBtn.disabled = false;
1086510888 }
@@ -11118,6 +11141,18 @@ function initGatewaySelect(
1111811141 } else {
1111911142 warnBox.textContent = "";
1112011143 }
11144+
11145+ // Update the Select All button text to show count
11146+ if (selectBtnId) {
11147+ const currentSelectBtn = document.getElementById(selectBtnId);
11148+ if (currentSelectBtn) {
11149+ if (count > 0) {
11150+ currentSelectBtn.textContent = `Select All (${count})`;
11151+ } else {
11152+ currentSelectBtn.textContent = "Select All";
11153+ }
11154+ }
11155+ }
1112111156 } catch (error) {
1112211157 console.error("Error updating gateway select:", error);
1112311158 }
@@ -11165,7 +11200,6 @@ function initGatewaySelect(
1116511200
1116611201 newSelectBtn.addEventListener("click", async () => {
1116711202 // Disable button and show loading state
11168- const originalText = newSelectBtn.textContent;
1116911203 newSelectBtn.disabled = true;
1117011204 newSelectBtn.textContent = "Selecting all gateways...";
1117111205
@@ -11258,18 +11292,13 @@ function initGatewaySelect(
1125811292
1125911293 update();
1126011294
11261- newSelectBtn.textContent = `✓ All ${allGatewayIds.length} gateways selected`;
11262- setTimeout(() => {
11263- newSelectBtn.textContent = originalText;
11264- }, 2000);
11265-
1126611295 // Reload associated items after selecting all
1126711296 reloadAssociatedItems();
1126811297 } catch (error) {
1126911298 console.error("Error in Select All:", error);
1127011299 alert("Failed to select all gateways. Please try again.");
1127111300 newSelectBtn.disabled = false;
11272- newSelectBtn.textContent = originalText;
11301+ update(); // Reset button text via update()
1127311302 } finally {
1127411303 newSelectBtn.disabled = false;
1127511304 }
0 commit comments