FIX: Hide summarization button from anons (#70)

This commit is contained in:
Roman Rizzi 2023-05-18 12:34:49 -03:00 committed by GitHub
parent 261fe13599
commit ba65d42940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 9 deletions

View File

@ -33,6 +33,9 @@ export default {
name: "discourse-ai-topic-summary", name: "discourse-ai-topic-summary",
initialize(container) { initialize(container) {
const user = container.lookup("service:current-user");
if (user) {
const settings = container.lookup("service:site-settings"); const settings = container.lookup("service:site-settings");
const summarizationEnabled = const summarizationEnabled =
settings.discourse_ai_enabled && settings.ai_summarization_enabled; settings.discourse_ai_enabled && settings.ai_summarization_enabled;
@ -40,5 +43,6 @@ export default {
if (summarizationEnabled) { if (summarizationEnabled) {
withPluginApi("1.6.0", initializeTopicSummary); withPluginApi("1.6.0", initializeTopicSummary);
} }
}
}, },
}; };

View File

@ -8,7 +8,3 @@
min-height: 200px; min-height: 200px;
} }
} }
.topic-ai-summarization {
margin-left: 10px;
}

View File

@ -0,0 +1,3 @@
.topic-ai-summarization {
margin-left: 10px;
}

View File

@ -0,0 +1,9 @@
.toggle-summary {
button {
width: 100%;
}
.topic-ai-summarization {
margin-top: 10px;
}
}

View File

@ -13,7 +13,11 @@ gem "tiktoken_ruby", "0.0.5", platform: RUBY_PLATFORM
enabled_site_setting :discourse_ai_enabled enabled_site_setting :discourse_ai_enabled
register_asset "stylesheets/modules/ai-helper/common/ai-helper.scss" register_asset "stylesheets/modules/ai-helper/common/ai-helper.scss"
register_asset "stylesheets/modules/summarization/common/summarization.scss" register_asset "stylesheets/modules/summarization/common/summarization.scss"
register_asset "stylesheets/modules/summarization/desktop/summarization.scss", :desktop
register_asset "stylesheets/modules/summarization/mobile/summarization.scss", :mobile
register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss" register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss"
module ::DiscourseAi module ::DiscourseAi