Skip to content

A platform for community discussion. Free, open, simple.

FIX: Disable chat "Show all channels" button while the filter saves (#44707)

David Taylor36a0a0295e62
diff --git a/frontend/discourse/app/ui-kit/d-empty-state.gjs b/frontend/discourse/app/ui-kit/d-empty-state.gjs
index 9b920558f2d..8799f43a7af 100644
--- a/frontend/discourse/app/ui-kit/d-empty-state.gjs
+++ b/frontend/discourse/app/ui-kit/d-empty-state.gjs
@@ -31,6 +31,7 @@ const DEmptyState = <template>
<DButton
class="btn-primary"
@action={{@ctaAction}}
+ @disabled={{@ctaDisabled}}
@href={{@ctaHref}}
@icon={{@ctaIcon}}
@route={{@ctaRoute}}
diff --git a/frontend/discourse/tests/integration/ui-kit/d-empty-state-test.gjs b/frontend/discourse/tests/integration/ui-kit/d-empty-state-test.gjs
index 9c9c7bb6bf5..c7e38866750 100644
--- a/frontend/discourse/tests/integration/ui-kit/d-empty-state-test.gjs
+++ b/frontend/discourse/tests/integration/ui-kit/d-empty-state-test.gjs
@@ -16,4 +16,14 @@ module("Integration | ui-kit | DEmptyState", function (hooks) {
assert.dom("[data-test-title]").exists();
assert.dom("[data-test-body]").exists();
});
+
+ test("@ctaDisabled", async function (assert) {
+ await render(
+ <template>
+ <DEmptyState @ctaDisabled={{true}} @ctaLabel="Show all" />
+ </template>
+ );
+
+ assert.dom(".empty-state__cta .btn").isDisabled();
+ });
});
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-channel-list-filter-empty-state.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-channel-list-filter-empty-state.gjs
index 01ac869a125..50975649f07 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-channel-list-filter-empty-state.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-sidebar-channel-list-filter-empty-state.gjs
@@ -9,17 +9,24 @@ export default class ChatSidebarChannelListFilterEmptyState extends Component {
@service chatChannelListPreferences;
@service sidebarState;
+ get section() {
+ return this.args.section ?? "channels";
+ }
+
+ get isSaving() {
+ return this.chatChannelListPreferences.isSavingFilterFor(this.section);
+ }
+
@action
showAll() {
- this.chatChannelListPreferences.showAllChannels(
- this.args.section ?? "channels"
- );
+ this.chatChannelListPreferences.showAllChannels(this.section);
}
<template>
{{#unless this.sidebarState.filter}}
<DEmptyState
@ctaAction={{this.showAll}}
+ @ctaDisabled={{this.isSaving}}
@ctaLabel={{i18n "chat.channel_list.empty.show_all"}}
@identifier="empty-channels-list"
@svgContent={{ChatZero}}