From cc447a1ae34466e6c92ba59a387165f4c213a326 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 29 Oct 2024 16:27:23 +0100 Subject: [PATCH] DEV: Simplify TopicNotificationsButton (#29465) --- .../app/components/topic-footer-buttons.hbs | 1 + .../app/components/topic-timeline.hbs | 1 - .../components/topic-timeline/container.hbs | 7 +-- .../components/topic-timeline/container.js | 15 +++--- .../discourse/app/templates/topic.hbs | 1 - .../topic-notifications-button-test.gjs | 20 ++++---- .../components/topic-notifications-button.gjs | 48 +++++++------------ .../molecules/topic-notifications.hbs | 6 ++- 8 files changed, 42 insertions(+), 57 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs index c3dc60b5fbb..edca533a29e 100644 --- a/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs +++ b/app/assets/javascripts/discourse/app/components/topic-footer-buttons.hbs @@ -92,6 +92,7 @@ {{#if this.showNotificationsButton}} diff --git a/app/assets/javascripts/discourse/app/components/topic-timeline.hbs b/app/assets/javascripts/discourse/app/components/topic-timeline.hbs index 9c5a6e61218..4d2ea493b1a 100644 --- a/app/assets/javascripts/discourse/app/components/topic-timeline.hbs +++ b/app/assets/javascripts/discourse/app/components/topic-timeline.hbs @@ -12,7 +12,6 @@ @jumpToIndex={{@jumpToIndex}} @jumpToPostPrompt={{@jumpToPostPrompt}} @fullscreen={{@fullscreen}} - @mobileView={{@mobileView}} @toggleMultiSelect={{@toggleMultiSelect}} @showTopicSlowModeUpdate={{@showTopicSlowModeUpdate}} @showTopReplies={{@showTopReplies}} diff --git a/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs b/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs index eb7f3e0bcf8..95b10182fd5 100644 --- a/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs +++ b/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs @@ -173,12 +173,7 @@ {{/if}} {{#if this.currentUser}} - + {{/if}} {{else}} - + ); assert.strictEqual( @@ -74,7 +74,7 @@ module( }); await render(); assert.strictEqual( @@ -89,7 +89,7 @@ module( const topic = buildTopic.call(this, { level: 2 }); await render(); assert @@ -105,7 +105,7 @@ module( state.topic = buildTopic.call(this, { level: 2 }); await render(); state.topic = buildTopic.call(this, { level: 3, reason: 999 }); @@ -128,7 +128,7 @@ module( }); await render(); assert @@ -148,7 +148,7 @@ module( }); await render(); assert @@ -168,7 +168,7 @@ module( }); await render(); assert @@ -188,7 +188,7 @@ module( }); await render(); assert @@ -208,7 +208,7 @@ module( }); await render(); assert @@ -228,7 +228,7 @@ module( }); await render(); assert diff --git a/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.gjs b/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.gjs index fb7ca4e6014..6b2223602cd 100644 --- a/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.gjs +++ b/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.gjs @@ -20,18 +20,6 @@ export default class TopicNotificationsButton extends Component { return this.args.topic.get("details.notification_level"); } - get appendReason() { - return this.args.appendReason ?? true; - } - - get showFullTitle() { - return this.args.showFullTitle ?? true; - } - - get showCaret() { - return this.args.showCaret ?? true; - } - get reasonText() { const topic = this.args.topic; const level = topic.get("details.notification_level") ?? 1; @@ -97,6 +85,16 @@ export default class TopicNotificationsButton extends Component { return false; } + get conditionalWrapper() { + if (this.args.expanded) { + return ; + } else { + return ; + } + } + @action async changeTopicNotificationLevel(levelId) { if (levelId === this.notificationLevel) { @@ -114,34 +112,22 @@ export default class TopicNotificationsButton extends Component { } diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.hbs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.hbs index dfe67058db1..78327167263 100644 --- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.hbs +++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.hbs @@ -1,3 +1,7 @@ + + + + - + \ No newline at end of file