mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 09:24:23 +08:00
Currently the AI features settings pages show site settings in one big list, making it difficult to navigate. Each setting also needs to be saved individually. This converts all AI feature settings pages to use FormKit with settings grouped by theme... for example, AI Helper (/admin/plugins/discourse-ai/ai-features/5/edit) has 4 groups: Access & Permissions, Enabled Features, Automation, Personas. Now these settings are all saved together as a single form, with the setting field component acting as a bridge to site settings. Also includes: - Fixes FormKit warning for unsaved changes from subroutes (the back button wasn't working) - Adds `@route` support to breadcrumbs (helps fix the unsaved changes issue above) - Hides "(optional)" labels on all fields via scoped CSS (temporary, eventually needs a feature in FormKit) Setting groups are managed in `ai-feature-setting-groups.js` Example before/after for the AI Helper settings... Before: <img width="573" alt="image" src="https://github.com/user-attachments/assets/679eb40b-5c33-4815-9b45-c988333d9db0" /> <img width="616" alt="image" src="https://github.com/user-attachments/assets/58822b9f-66a0-451b-89ce-ab63e5c73164" /> After: <img width="415" alt="image" src="https://github.com/user-attachments/assets/8ba019b6-afe1-488a-bc52-f0ed68dcc3d5" /> <img width="988" alt="image" src="https://github.com/user-attachments/assets/8a7f4091-9d95-47aa-a479-510f77bd703d" />
82 lines
2.6 KiB
JavaScript
Vendored
82 lines
2.6 KiB
JavaScript
Vendored
import { module, test } from "qunit";
|
|
import { getSettingGroupsForFeature } from "discourse/plugins/discourse-ai/discourse/lib/ai-feature-setting-groups";
|
|
|
|
module("Unit | Lib | ai-feature-setting-groups", function () {
|
|
test("returns correct groups for ai_helper", function (assert) {
|
|
const groups = getSettingGroupsForFeature("ai_helper");
|
|
|
|
assert.strictEqual(groups.length, 4, "ai_helper should have 4 groups");
|
|
assert.strictEqual(
|
|
groups[0].key,
|
|
"access_permissions",
|
|
"first group should be access_permissions"
|
|
);
|
|
|
|
assert.true(
|
|
groups[0].settings.includes("ai_helper_enabled"),
|
|
"access_permissions should include ai_helper_enabled"
|
|
);
|
|
});
|
|
|
|
test("returns correct groups for embeddings", function (assert) {
|
|
const groups = getSettingGroupsForFeature("embeddings");
|
|
|
|
assert.strictEqual(groups.length, 3, "embeddings should have 3 groups");
|
|
assert.strictEqual(
|
|
groups[0].key,
|
|
"model_settings",
|
|
"first group should be model_settings"
|
|
);
|
|
});
|
|
|
|
test("returns correct groups for bot", function (assert) {
|
|
const groups = getSettingGroupsForFeature("bot");
|
|
|
|
assert.strictEqual(groups.length, 4, "bot should have 4 groups");
|
|
assert.strictEqual(
|
|
groups[0].key,
|
|
"settings",
|
|
"first group should be settings"
|
|
);
|
|
});
|
|
|
|
test("returns correct groups for summarization", function (assert) {
|
|
const groups = getSettingGroupsForFeature("summarization");
|
|
|
|
assert.strictEqual(groups.length, 3, "summarization should have 3 groups");
|
|
});
|
|
|
|
test("returns correct groups for search", function (assert) {
|
|
const groups = getSettingGroupsForFeature("search");
|
|
|
|
assert.strictEqual(groups.length, 1, "search should have 1 group");
|
|
});
|
|
|
|
test("returns correct groups for translation", function (assert) {
|
|
const groups = getSettingGroupsForFeature("translation");
|
|
|
|
assert.strictEqual(groups.length, 3, "translation should have 3 groups");
|
|
});
|
|
|
|
test("returns correct groups for discord", function (assert) {
|
|
const groups = getSettingGroupsForFeature("discord");
|
|
|
|
assert.strictEqual(groups.length, 2, "discord should have 2 groups");
|
|
});
|
|
|
|
test("returns correct groups for inference", function (assert) {
|
|
const groups = getSettingGroupsForFeature("inference");
|
|
|
|
assert.strictEqual(groups.length, 4, "inference should have 4 groups");
|
|
});
|
|
|
|
test("returns empty array for unknown feature", function (assert) {
|
|
const groups = getSettingGroupsForFeature("unknown_feature");
|
|
|
|
assert.strictEqual(
|
|
groups.length,
|
|
0,
|
|
"unknown feature should return empty array"
|
|
);
|
|
});
|
|
});
|