MCPcopy
hub / github.com/remotely-save/remotely-save / onOpen

Method onOpen

src/settings.ts:214–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212 }
213
214 onOpen() {
215 const { contentEl } = this;
216
217 const t = (x: TransItemType, vars?: any) => {
218 return this.plugin.i18n.t(x, vars);
219 };
220
221 contentEl.createEl("h2", { text: t("modal_remotebasedir_title") });
222 t("modal_remotebasedir_shortdesc")
223 .split("\n")
224 .forEach((val, idx) => {
225 contentEl.createEl("p", {
226 text: val,
227 });
228 });
229
230 if (
231 this.newRemoteBaseDir === "" ||
232 this.newRemoteBaseDir === this.app.vault.getName()
233 ) {
234 new Setting(contentEl)
235 .addButton((button) => {
236 button.setButtonText(
237 t("modal_remotebasedir_secondconfirm_vaultname")
238 );
239 button.onClick(async () => {
240 // in the settings, the value is reset to the special case ""
241 this.plugin.settings[this.service].remoteBaseDir = "";
242 await this.plugin.saveSettings();
243 new Notice(t("modal_remotebasedir_notice"));
244 this.close();
245 });
246 button.setClass("remotebasedir-second-confirm");
247 })
248 .addButton((button) => {
249 button.setButtonText(t("goback"));
250 button.onClick(() => {
251 this.close();
252 });
253 });
254 } else if (checkHasSpecialCharForDir(this.newRemoteBaseDir)) {
255 contentEl.createEl("p", {
256 text: t("modal_remotebasedir_invaliddirhint"),
257 });
258 new Setting(contentEl).addButton((button) => {
259 button.setButtonText(t("goback"));
260 button.onClick(() => {
261 this.close();
262 });
263 });
264 } else {
265 new Setting(contentEl)
266 .addButton((button) => {
267 button.setButtonText(t("modal_remotebasedir_secondconfirm_change"));
268 button.onClick(async () => {
269 this.plugin.settings[this.service].remoteBaseDir =
270 this.newRemoteBaseDir;
271 await this.plugin.saveSettings();

Callers

nothing calls this directly

Calls 2

saveSettingsMethod · 0.80

Tested by

no test coverage detected