This commit is contained in:
fyears
2024-06-22 21:03:43 +08:00
parent 690f56945a
commit cc0a286471
37 changed files with 1165 additions and 140 deletions
+52 -14
View File
@@ -21,6 +21,7 @@ import type {
} from "./baseTypes";
import cloneDeep from "lodash/cloneDeep";
import { generateAzureBlobStorageSettingsPart } from "../pro/src/settingsAzureBlobStorage";
import { generateBoxSettingsPart } from "../pro/src/settingsBox";
import { generateGoogleDriveSettingsPart } from "../pro/src/settingsGoogleDrive";
import { generateKoofrSettingsPart } from "../pro/src/settingsKoofr";
@@ -290,7 +291,7 @@ export class ChangeRemoteBaseDirModal extends Modal {
* s3 is special and do not necessarily the same as others
* thus a new Modal here
*/
class ChangeRemotePrefixModal extends Modal {
class ChangeS3RemotePrefixModal extends Modal {
readonly plugin: RemotelySavePlugin;
readonly newRemotePrefix: string;
constructor(app: App, plugin: RemotelySavePlugin, newRemotePrefix: string) {
@@ -306,8 +307,8 @@ class ChangeRemotePrefixModal extends Modal {
return this.plugin.i18n.t(x, vars);
};
contentEl.createEl("h2", { text: t("modal_remoteprefix_title") });
t("modal_remoteprefix_shortdesc")
contentEl.createEl("h2", { text: t("modal_remoteprefix_s3_title") });
t("modal_remoteprefix_s3_shortdesc")
.split("\n")
.forEach((val, idx) => {
contentEl.createEl("p", {
@@ -316,7 +317,7 @@ class ChangeRemotePrefixModal extends Modal {
});
contentEl.createEl("p", {
text: t("modal_remoteprefix_tosave", { prefix: this.newRemotePrefix }),
text: t("modal_remoteprefix_s3_tosave", { prefix: this.newRemotePrefix }),
});
if (
@@ -325,12 +326,12 @@ class ChangeRemotePrefixModal extends Modal {
) {
new Setting(contentEl)
.addButton((button) => {
button.setButtonText(t("modal_remoteprefix_secondconfirm_empty"));
button.setButtonText(t("modal_remoteprefix_s3_secondconfirm_empty"));
button.onClick(async () => {
// in the settings, the value is reset to the special case ""
this.plugin.settings.s3.remotePrefix = "";
await this.plugin.saveSettings();
new Notice(t("modal_remoteprefix_notice"));
new Notice(t("modal_remoteprefix_s3_notice"));
this.close();
});
button.setClass("remoteprefix-second-confirm");
@@ -344,14 +345,14 @@ class ChangeRemotePrefixModal extends Modal {
} else {
new Setting(contentEl)
.addButton((button) => {
button.setButtonText(t("modal_remoteprefix_secondconfirm_change"));
button.setButtonText(t("modal_remoteprefix_s3_secondconfirm_change"));
button.onClick(async () => {
this.plugin.settings.s3.remotePrefix = this.newRemotePrefix;
await this.plugin.saveSettings();
new Notice(t("modal_remoteprefix_notice"));
new Notice(t("modal_remoteprefix_s3_notice"));
this.close();
});
button.setClass("remoteprefix-second-confirm");
button.setClass("remoteprefix-s3-second-confirm");
})
.addButton((button) => {
button.setButtonText(t("goback"));
@@ -801,7 +802,7 @@ const getEyesElements = () => {
};
};
const wrapTextWithPasswordHide = (text: TextComponent) => {
export const wrapTextWithPasswordHide = (text: TextComponent) => {
const { eye, eyeOff } = getEyesElements();
const hider = text.inputEl.insertAdjacentElement("afterend", createSpan())!;
// the init type of hider is "hidden" === eyeOff === password
@@ -1054,8 +1055,8 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
let newS3RemotePrefix = this.plugin.settings.s3.remotePrefix || "";
new Setting(s3Div)
.setName(t("settings_remoteprefix"))
.setDesc(t("settings_remoteprefix_desc"))
.setName(t("settings_remoteprefix_s3"))
.setDesc(t("settings_remoteprefix_s3_desc"))
.addText((text) =>
text
.setPlaceholder("")
@@ -1067,7 +1068,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
.addButton((button) => {
button.setButtonText(t("confirm"));
button.onClick(() => {
new ChangeRemotePrefixModal(
new ChangeS3RemotePrefixModal(
this.app,
this.plugin,
simpleTransRemotePrefix(newS3RemotePrefix.trim())
@@ -1873,6 +1874,22 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
this.plugin.saveSettings()
);
//////////////////////////////////////////////////
// below for Azure Blob Storage
//////////////////////////////////////////////////
const {
azureBlobStorageDiv,
azureBlobStorageAllowedToUsedDiv,
azureBlobStorageNotShowUpHintSetting,
} = generateAzureBlobStorageSettingsPart(
containerEl,
t,
this.app,
this.plugin,
() => this.plugin.saveSettings()
);
//////////////////////////////////////////////////
// below for general chooser (part 2/2)
//////////////////////////////////////////////////
@@ -1899,6 +1916,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
t("settings_chooseservice_yandexdisk")
);
dropdown.addOption("koofr", t("settings_chooseservice_koofr"));
dropdown.addOption(
"azureblobstorage",
t("settings_chooseservice_azureblobstorage")
);
dropdown
.setValue(this.plugin.settings.serviceType)
@@ -1944,6 +1965,11 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
"koofr-hide",
this.plugin.settings.serviceType !== "koofr"
);
azureBlobStorageDiv.toggleClass(
"azureblobstorage-hide",
this.plugin.settings.serviceType !== "azureblobstorage"
);
await this.plugin.saveSettings();
});
});
@@ -2542,6 +2568,16 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
button.onClick(async () => {
new ExportSettingsQrCodeModal(this.app, this.plugin, "koofr").open();
});
})
.addButton(async (button) => {
button.setButtonText(t("settings_export_azureblobstorage_button"));
button.onClick(async () => {
new ExportSettingsQrCodeModal(
this.app,
this.plugin,
"azureblobstorage"
).open();
});
});
let importSettingVal = "";
@@ -2616,7 +2652,9 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
yandexDiskAllowedToUsedDiv,
yandexDiskNotShowUpHintSetting,
koofrAllowedToUsedDiv,
koofrNotShowUpHintSetting
koofrNotShowUpHintSetting,
azureBlobStorageAllowedToUsedDiv,
azureBlobStorageNotShowUpHintSetting
);
//////////////////////////////////////////////////