Skip to content

Commit

Permalink
feat(plugin): enable early access features for self-hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminshafii committed Apr 19, 2024
1 parent 23affaa commit b249ff6
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/FileOrganizerSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ import FileOrganizer from "./index";
export class FileOrganizerSettingTab extends PluginSettingTab {
plugin: FileOrganizer;

private async sendSecretApiRequest(jsonPayload: {
code: string;
}): Promise<any> {
const url = `${this.plugin.settings.defaultServerUrl}/api/secret`;
try {
const response = await requestUrl({
url: url,
method: "POST",
body: JSON.stringify(jsonPayload),
headers: {
Authorization: `Bearer ${this.plugin.settings.API_KEY}`,
"Content-Type": "application/json",
},
});
return response;
} catch (error) {
console.error("Error sending secret API request:", error);
throw error; // Rethrow to handle it outside this function if needed
}
}

constructor(app: App, plugin: FileOrganizer) {
super(app, plugin);
this.plugin = plugin;
Expand Down Expand Up @@ -194,8 +215,8 @@ export class FileOrganizerSettingTab extends PluginSettingTab {
const jsonPayload = {
code: value,
};
const url = `${this.plugin.settings.defaultServerUrl}/api/secret`;
try {
const url = `${this.plugin.settings.defaultServerUrl}/api/secret`;
const response = await requestUrl({
url: url,
method: "POST",
Expand Down Expand Up @@ -233,9 +254,11 @@ export class FileOrganizerSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
if (!value) {
customServerSetting.settingEl.hide();
this.plugin.settings.enableEarlyAccess = false;
return;
}
customServerSetting.settingEl.show();
this.plugin.settings.enableEarlyAccess = true;
})
);

Expand Down Expand Up @@ -278,7 +301,6 @@ export class FileOrganizerSettingTab extends PluginSettingTab {
new Setting(containerEl)
.setName("AI Assistant (available in early access)")
.setDesc("A sidebar that gives you more control in your file management.")
.addToggle((toggle) => toggle.setDisabled(true));

new Setting(containerEl)
.setName("Experimental: Describe workflow (in progress)")
Expand Down

0 comments on commit b249ff6

Please sign in to comment.