From 52e9d3298ac722dd1a7bdc0c84466a64d24e9ca8 Mon Sep 17 00:00:00 2001 From: fyears Date: Sun, 21 Nov 2021 23:54:50 +0800 Subject: [PATCH] hide webdav yet --- src/main.ts | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 14ce81a..a5d2b5c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,6 +36,7 @@ interface RemotelySavePluginSettings { webdav: WebdavConfig; password: string; serviceType: SUPPORTED_SERVICES_TYPE; + enableExperimentService: boolean; } const DEFAULT_SETTINGS: RemotelySavePluginSettings = { @@ -43,6 +44,7 @@ const DEFAULT_SETTINGS: RemotelySavePluginSettings = { webdav: DEFAULT_WEBDAV_CONFIG, password: "", serviceType: "s3", + enableExperimentService: false, }; export default class RemotelySavePlugin extends Plugin { @@ -294,6 +296,28 @@ class RemotelySaveSettingTab extends PluginSettingTab { // we need to create the div in advance of s3Div and webdavDiv const serviceChooserDiv = generalDiv.createEl("div"); + serviceChooserDiv.onClickEvent((x) => { + if (x.detail === 5) { + if (this.plugin.settings.serviceType === "webdav") { + new Notice( + "You've enabled hidden unstable experimental webdav support before. Nothing changes." + ); + } else if (!this.plugin.settings.enableExperimentService) { + this.plugin.settings.enableExperimentService = true; + this.plugin.saveSettings(); + new Notice( + "You've enabled hidden unstable experimental webdav support. Reopen settings again and try webdav with caution." + ); + } else if (this.plugin.settings.enableExperimentService) { + this.plugin.settings.enableExperimentService = false; + this.plugin.saveSettings(); + new Notice( + "You've disabled hidden unstable experimental webdav support. Reopen settings again." + ); + } + } + }); + const s3Div = containerEl.createEl("div", { cls: "s3-hide" }); s3Div.toggleClass("s3-hide", this.plugin.settings.serviceType !== "s3"); s3Div.createEl("h2", { text: "S3 (-compatible) Service" }); @@ -523,8 +547,18 @@ class RemotelySaveSettingTab extends PluginSettingTab { .setName("Choose service") .setDesc("Choose a service, by default s3") .addDropdown(async (dropdown) => { - dropdown.addOption("s3", "s3 (more mature)"); - dropdown.addOption("webdav", "webdav (experimental)"); + const currService = this.plugin.settings.serviceType; + const enableExperimentService = + this.plugin.settings.enableExperimentService; + + dropdown.addOption("s3", "s3 (-compatible)"); + if (currService === "webdav" || enableExperimentService) { + dropdown.addOption("webdav", "webdav (experimental)"); + if (!enableExperimentService) { + this.plugin.settings.enableExperimentService = true; + await this.plugin.saveSettings(); + } + } dropdown .setValue(this.plugin.settings.serviceType) .onChange(async (val: SUPPORTED_SERVICES_TYPE) => {