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 {
|
export default {
|
||||||
name: "discourse_ai-chat_channel_summary",
|
name: "discourse-ai-chat-channel-summary",
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const settings = container.lookup("site-settings:main");
|
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;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal";
|
||||||
|
|
||||||
function initializeComposerAIHelper(api) {
|
function initializeComposerAIHelper(api) {
|
||||||
api.modifyClass("component:composer-editor", {
|
api.modifyClass("component:composer-editor", {
|
||||||
|
pluginId: "discourse-ai",
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
extraButtons(toolbar) {
|
extraButtons(toolbar) {
|
||||||
this._super(toolbar);
|
this._super(toolbar);
|
||||||
|
@ -48,20 +50,20 @@ function initializeComposerAIHelper(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "discourse_ai-composer-helper",
|
name: "discourse-ai-composer-helper",
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const settings = container.lookup("site-settings:main");
|
const settings = container.lookup("service:site-settings");
|
||||||
const user = container.lookup("service:current-user");
|
const user = container.lookup("service:current-user");
|
||||||
|
|
||||||
const helperEnabled =
|
const helperEnabled =
|
||||||
settings.discourse_ai_enabled && settings.composer_ai_helper_enabled;
|
settings.discourse_ai_enabled && settings.composer_ai_helper_enabled;
|
||||||
|
|
||||||
const allowedGroups = settings.ai_helper_allowed_groups
|
const allowedGroups = settings.ai_helper_allowed_groups
|
||||||
.split("|")
|
.split("|")
|
||||||
.map(parseInt);
|
.map(parseInt);
|
||||||
let canUseAssistant =
|
const canUseAssistant = user?.groups.some((g) =>
|
||||||
user && user.groups.some((g) => allowedGroups.includes(g.id));
|
allowedGroups.includes(g.id)
|
||||||
|
);
|
||||||
|
|
||||||
if (helperEnabled && canUseAssistant) {
|
if (helperEnabled && canUseAssistant) {
|
||||||
withPluginApi("1.6.0", initializeComposerAIHelper);
|
withPluginApi("1.6.0", initializeComposerAIHelper);
|
||||||
|
|
|
@ -50,11 +50,10 @@ function initializeSemanticSearch(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "discourse_ai-full-page-semantic-search",
|
name: "discourse-ai-full-page-semantic-search",
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const settings = container.lookup("site-settings:main");
|
const settings = container.lookup("service:site-settings");
|
||||||
|
|
||||||
const semanticSearch = settings.ai_embeddings_semantic_search_enabled;
|
const semanticSearch = settings.ai_embeddings_semantic_search_enabled;
|
||||||
|
|
||||||
if (settings.ai_embeddings_enabled && semanticSearch) {
|
if (settings.ai_embeddings_enabled && semanticSearch) {
|
||||||
|
|
|
@ -3,6 +3,8 @@ import showModal from "discourse/lib/show-modal";
|
||||||
|
|
||||||
function initializeTopicSummary(api) {
|
function initializeTopicSummary(api) {
|
||||||
api.modifyClass("component:scrolling-post-stream", {
|
api.modifyClass("component:scrolling-post-stream", {
|
||||||
|
pluginId: "discourse-ai",
|
||||||
|
|
||||||
showAiSummary() {
|
showAiSummary() {
|
||||||
showModal("ai-summary").setProperties({
|
showModal("ai-summary").setProperties({
|
||||||
targetId: this.posts["posts"][0].topic_id,
|
targetId: this.posts["posts"][0].topic_id,
|
||||||
|
@ -28,11 +30,10 @@ function initializeTopicSummary(api) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "discourse_ai-topic_summary",
|
name: "discourse-ai-topic-summary",
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const settings = container.lookup("site-settings:main");
|
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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue