DEV: Fix minor js issues (#48)
1. Add missing `pluginId` to `modifyClass` calls 2. Replace deprecated `site-settings:main` lookups with `service:site-settings` 3. Use "kebab-case" for initializer names
This commit is contained in:
parent
daacd2ffe3
commit
f6c30e8df9
|
@ -29,11 +29,10 @@ function initializeChatChannelSummary(api) {
|
|||
}
|
||||
|
||||
export default {
|
||||
name: "discourse_ai-chat_channel_summary",
|
||||
name: "discourse-ai-chat-channel-summary",
|
||||
|
||||
initialize(container) {
|
||||
const settings = container.lookup("site-settings:main");
|
||||
|
||||
const settings = container.lookup("service:site-settings");
|
||||
const summarizationEnabled =
|
||||
settings.discourse_ai_enabled && settings.ai_summarization_enabled;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal";
|
|||
|
||||
function initializeComposerAIHelper(api) {
|
||||
api.modifyClass("component:composer-editor", {
|
||||
pluginId: "discourse-ai",
|
||||
|
||||
actions: {
|
||||
extraButtons(toolbar) {
|
||||
this._super(toolbar);
|
||||
|
@ -48,20 +50,20 @@ function initializeComposerAIHelper(api) {
|
|||
}
|
||||
|
||||
export default {
|
||||
name: "discourse_ai-composer-helper",
|
||||
name: "discourse-ai-composer-helper",
|
||||
|
||||
initialize(container) {
|
||||
const settings = container.lookup("site-settings:main");
|
||||
const settings = container.lookup("service:site-settings");
|
||||
const user = container.lookup("service:current-user");
|
||||
|
||||
const helperEnabled =
|
||||
settings.discourse_ai_enabled && settings.composer_ai_helper_enabled;
|
||||
|
||||
const allowedGroups = settings.ai_helper_allowed_groups
|
||||
.split("|")
|
||||
.map(parseInt);
|
||||
let canUseAssistant =
|
||||
user && user.groups.some((g) => allowedGroups.includes(g.id));
|
||||
const canUseAssistant = user?.groups.some((g) =>
|
||||
allowedGroups.includes(g.id)
|
||||
);
|
||||
|
||||
if (helperEnabled && canUseAssistant) {
|
||||
withPluginApi("1.6.0", initializeComposerAIHelper);
|
||||
|
|
|
@ -50,11 +50,10 @@ function initializeSemanticSearch(api) {
|
|||
}
|
||||
|
||||
export default {
|
||||
name: "discourse_ai-full-page-semantic-search",
|
||||
name: "discourse-ai-full-page-semantic-search",
|
||||
|
||||
initialize(container) {
|
||||
const settings = container.lookup("site-settings:main");
|
||||
|
||||
const settings = container.lookup("service:site-settings");
|
||||
const semanticSearch = settings.ai_embeddings_semantic_search_enabled;
|
||||
|
||||
if (settings.ai_embeddings_enabled && semanticSearch) {
|
||||
|
|
|
@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal";
|
|||
|
||||
function initializeTopicSummary(api) {
|
||||
api.modifyClass("component:scrolling-post-stream", {
|
||||
pluginId: "discourse-ai",
|
||||
|
||||
showAiSummary() {
|
||||
showModal("ai-summary").setProperties({
|
||||
targetId: this.posts["posts"][0].topic_id,
|
||||
|
@ -28,11 +30,10 @@ function initializeTopicSummary(api) {
|
|||
}
|
||||
|
||||
export default {
|
||||
name: "discourse_ai-topic_summary",
|
||||
name: "discourse-ai-topic-summary",
|
||||
|
||||
initialize(container) {
|
||||
const settings = container.lookup("site-settings:main");
|
||||
|
||||
const settings = container.lookup("service:site-settings");
|
||||
const summarizationEnabled =
|
||||
settings.discourse_ai_enabled && settings.ai_summarization_enabled;
|
||||
|
||||
|
|
Loading…
Reference in New Issue