Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 6dc7632

Browse files
committed
FEATURE: Configure persona backed features in admin panel
1 parent 5ed0990 commit 6dc7632

File tree

9 files changed

+167
-0
lines changed

9 files changed

+167
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import DiscourseRoute from "discourse/routes/discourse";
2+
3+
export default class AdminPluginsShowDiscourseAiFeaturesEdit extends DiscourseRoute {
4+
model() {
5+
// todo
6+
}
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ajax } from "discourse/lib/ajax";
2+
import DiscourseRoute from "discourse/routes/discourse";
3+
4+
export default class AdminPluginsShowDiscourseAiFeatures extends DiscourseRoute {
5+
async model() {
6+
const { ai_features } = await ajax(
7+
`/admin/plugins/discourse-ai/ai-features.json`
8+
);
9+
return ai_features;
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import RouteTemplate from "ember-route-template";
2+
3+
export default RouteTemplate(
4+
<template>
5+
<h1>AI Features EDIT</h1>
6+
</template>
7+
);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import Component from "@glimmer/component";
2+
import { service } from "@ember/service";
3+
import RouteTemplate from "ember-route-template";
4+
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
5+
import DButton from "discourse/components/d-button";
6+
import DPageSubheader from "discourse/components/d-page-subheader";
7+
import { i18n } from "discourse-i18n";
8+
9+
export default RouteTemplate(
10+
class extends Component {
11+
@service adminPluginNavManager;
12+
13+
<template>
14+
<DBreadcrumbsItem
15+
@path="/admin/plugins/{{this.adminPluginNavManager.currentPlugin.name}}/ai-features"
16+
@label={{i18n "discourse_ai.features.short_title"}}
17+
/>
18+
<section class="ai-feature-list-editor admin-detail">
19+
<DPageSubheader
20+
@titleLabel={{i18n "discourse_ai.features.short_title"}}
21+
@descriptionLabel={{i18n "discourse_ai.features.description"}}
22+
@learnMoreUrl="todo"
23+
/>
24+
25+
<div class="ai-feature-list-editor__configured-features">
26+
<h3>Configured Features</h3>
27+
<table class="d-admin-table">
28+
<thead>
29+
<tr>
30+
<th>Name</th>
31+
<th>Persona</th>
32+
<th>Groups</th>
33+
<th></th>
34+
</tr>
35+
</thead>
36+
37+
<tbody>
38+
{{#each @model as |feature|}}
39+
{{!-- {{log feature}} --}}
40+
<tr class="ai-features-list__row d-admin-row__content">
41+
<td class="d-admin-row__overview">
42+
<strong>{{feature.name}}</strong><br />
43+
{{feature.description}}
44+
</td>
45+
<td class="d-admin-row__detail">
46+
{{feature.persona}}
47+
</td>
48+
<td></td>
49+
<td class="d-admin-row_controls">
50+
<DButton @translatedLabel="Edit" />
51+
</td>
52+
</tr>
53+
{{/each}}
54+
</tbody>
55+
</table>
56+
</div>
57+
58+
{{! <div class="ai-feature-list-editor__unconfigured-features">
59+
<h3>Unconfigured Features</h3>
60+
</div> }}
61+
</section>
62+
</template>
63+
}
64+
);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# frozen_string_literal: true
2+
3+
module DiscourseAi
4+
module Admin
5+
class AiFeaturesController < ::Admin::AdminController
6+
requires_plugin ::DiscourseAi::PLUGIN_NAME
7+
8+
def index
9+
render json: persona_backed_features
10+
end
11+
12+
def edit
13+
end
14+
15+
def update
16+
end
17+
18+
def destroy
19+
end
20+
21+
private
22+
23+
# Eventually we may move this to an active record model
24+
def persona_backed_features
25+
# TODO: WIP just getting data rn, will cleanup AiPersona call later...
26+
[
27+
{
28+
name: "Summaries",
29+
description:
30+
"Makes a summarization button available that allows visitors to summarize topics.",
31+
# persona: AiPersona.find_by(id: SiteSetting.ai_summarization_persona),
32+
persona: "Foo",
33+
enabled: SiteSetting.ai_summarization_enabled,
34+
},
35+
{
36+
name: "Short Summaries",
37+
description: "Adds the ability to view short summaries of topics on the topic list.",
38+
# persona: AiPersona.find_by(id: SiteSetting.ai_summary_gists_persona),
39+
persona: "Bar",
40+
enabled: SiteSetting.ai_summary_gists_enabled,
41+
},
42+
{
43+
name: "Discobot Discoveries",
44+
description: "",
45+
# persona: AiPersona.find_by(id: SiteSetting.ai_bot_discover_persona),
46+
persona: "Baz",
47+
enabled: SiteSetting.ai_bot_enabled,
48+
},
49+
{
50+
name: "Discord Search",
51+
description: "Adds the ability to search Discord channels.",
52+
# persona: AiPersona.find_by(id: SiteSetting.ai_discord_search_persona),
53+
persona: "Qux",
54+
enabled: "",
55+
},
56+
]
57+
end
58+
end
59+
end
60+
end

assets/javascripts/discourse/admin-discourse-ai-plugin-route-map.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ export default {
2929
this.route("edit", { path: "/:id/edit" });
3030
}
3131
);
32+
33+
this.route("discourse-ai-features", { path: "ai-features" }, function () {
34+
this.route("edit", { path: "/:id/edit" });
35+
});
3236
},
3337
};

assets/javascripts/initializers/admin-plugin-configuration-nav.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export default {
4141
route: "adminPlugins.show.discourse-ai-spam",
4242
description: "discourse_ai.spam.spam_description",
4343
},
44+
{
45+
label: "discourse_ai.features.short_title",
46+
route: "adminPlugins.show.discourse-ai-features",
47+
description: "discourse_ai.features.description",
48+
},
4449
]);
4550
});
4651
},

config/locales/client.en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ en:
164164
discourse_ai:
165165
title: "AI"
166166

167+
features:
168+
short_title: "Features"
169+
description: "These are the AI features available to visitors on your site. These can be configured to use specific personas and LLMs, and can be access controlled by groups."
170+
167171
modals:
168172
select_option: "Select an option..."
169173

config/routes.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
controller: "discourse_ai/admin/ai_embeddings" do
111111
collection { get :test }
112112
end
113+
114+
resources :ai_features,
115+
only: %i[index edit update destroy],
116+
path: "ai-features",
117+
controller: "discourse_ai/admin/ai_features"
113118
end
114119
end
115120

0 commit comments

Comments
 (0)