Skip to content

Commit 6d80cd3

Browse files
committed
Move ai assistant settings to its own section
1 parent b73113f commit 6d80cd3

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import settingsPage from "components/settingsPage";
2+
import appSettings from "lib/settings";
3+
4+
export default function aiassistantSettings() {
5+
const title = "Ai Assistant Settings";
6+
const values = appSettings.value;
7+
const items = [
8+
{
9+
key: "aiApiKey",
10+
text: "API Key",
11+
value: values.aiApiKey,
12+
prompt: "API Key",
13+
info: "Enter your API key here.",
14+
},
15+
{
16+
key: "aiModel",
17+
text: "Model",
18+
value: values.aiModel,
19+
prompt: "Model",
20+
info: "Enter your AI model here.",
21+
},
22+
];
23+
24+
return settingsPage(title, items, callback);
25+
26+
/**
27+
* Callback for settings page when an item is clicked
28+
* @param {string} key
29+
* @param {string} value
30+
*/
31+
function callback(key, value) {
32+
switch (key) {
33+
default:
34+
appSettings.update({
35+
[key]: value,
36+
});
37+
break;
38+
}
39+
}
40+
}

src/settings/appSettings.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ export default function otherSettings() {
7171
value: values.console,
7272
select: [appSettings.CONSOLE_LEGACY, appSettings.CONSOLE_ERUDA],
7373
},
74-
{
75-
key: "aiApiKey",
76-
text: "AI Assistant API Key",
77-
value: values.aiApiKey,
78-
prompt: "AI Assistant API Key",
79-
},
80-
{
81-
key: "aiModel",
82-
text: "AI Assistant Model",
83-
value: values.aiModel,
84-
prompt: "AI Assistant Model",
85-
},
8674
{
8775
key: "keyboardMode",
8876
text: strings["keyboard mode"],

src/settings/mainSettings.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Sponsors from "pages/sponsors";
1212
import themeSetting from "pages/themeSetting";
1313
import helpers from "utils/helpers";
1414
import About from "../pages/about";
15+
import aiassistantSettings from "./aiassistantSettings.js";
1516
import otherSettings from "./appSettings";
1617
import backupRestore from "./backupRestore";
1718
import editorSettings from "./editorSettings";
@@ -79,19 +80,25 @@ export default function mainSettings() {
7980
key: "reset",
8081
text: strings["restore default settings"],
8182
icon: "historyrestore",
82-
index: 6,
83+
index: 7,
8384
},
8485
{
8586
key: "preview-settings",
8687
text: strings["preview settings"],
8788
icon: "play_arrow",
8889
index: 4,
8990
},
91+
{
92+
key: "ai-assistant-settings",
93+
text: "Ai Assistant Settings",
94+
icon: "licons robot",
95+
index: 5,
96+
},
9097
{
9198
key: "terminal-settings",
9299
text: `${strings["terminal settings"]}`,
93100
icon: "licons terminal",
94-
index: 5,
101+
index: 6,
95102
},
96103
{
97104
key: "editSettings",
@@ -124,6 +131,7 @@ export default function mainSettings() {
124131
case "backup-restore":
125132
case "editor-settings":
126133
case "preview-settings":
134+
case "ai-assistant-settings":
127135
case "terminal-settings":
128136
appSettings.uiSettings[key].show();
129137
break;
@@ -198,5 +206,6 @@ export default function mainSettings() {
198206
appSettings.uiSettings["scroll-settings"] = scrollSettings();
199207
appSettings.uiSettings["search-settings"] = searchSettings();
200208
appSettings.uiSettings["preview-settings"] = previewSettings();
209+
appSettings.uiSettings["ai-assistant-settings"] = aiassistantSettings();
201210
appSettings.uiSettings["terminal-settings"] = terminalSettings();
202211
}

0 commit comments

Comments
 (0)