+6
-2
@@ -4,9 +4,9 @@
|
||||
|
||||
Remotely Save has some "pro features", which users have to pay for using them.
|
||||
|
||||
## Sign Up / Sign In
|
||||
## Sign Up / Sign In And Connect
|
||||
|
||||
Please go to <https://remotelysave.com> to sign up and sign in an account firstly.
|
||||
See the tutorial about your PRO account [here](../docs/pro/README.md).
|
||||
|
||||
## Smart Conflict
|
||||
|
||||
@@ -14,6 +14,10 @@ Basic (free) version can detect conflicts, but users have to choose to keep newe
|
||||
|
||||
PRO (paid) feature "Smart Conflict" gives users one more option: merge small markdown files, or duplicate large markdown files or non-markdown files.
|
||||
|
||||
## Sync With Google Drive
|
||||
|
||||
PRO (paid) feature "sync with Google Drive" allows users to to sync with Google Drive. Tutorials and limitations are documented [here](../docs/remote_services/googledrive/README.md).
|
||||
|
||||
## License
|
||||
|
||||
The codes or files or subfolders inside the current folder (`pro` in the repo), are released under "source available" license: "PolyForm Strict License 1.0.0".
|
||||
|
||||
+36
-10
@@ -246,13 +246,7 @@ export const checkProRunnableAndFixInplace = async (
|
||||
pluginVersion: string,
|
||||
saveUpdatedConfigFunc: () => Promise<any> | undefined
|
||||
): Promise<true> => {
|
||||
// if no pro features are used, we are good to go, no checking
|
||||
if (
|
||||
featuresToCheck.contains("feature-smart_conflict") &&
|
||||
config.conflictAction !== "smart_conflict"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
console.debug(`checkProRunnableAndFixInplace`);
|
||||
|
||||
// many checks if status is valid
|
||||
|
||||
@@ -280,6 +274,8 @@ export const checkProRunnableAndFixInplace = async (
|
||||
}
|
||||
}
|
||||
|
||||
const errorMsgs = [];
|
||||
|
||||
// check for the features
|
||||
if (featuresToCheck.contains("feature-smart_conflict")) {
|
||||
if (config.conflictAction === "smart_conflict") {
|
||||
@@ -288,15 +284,45 @@ export const checkProRunnableAndFixInplace = async (
|
||||
(x) => x.featureName === "feature-smart_conflict"
|
||||
).length === 1
|
||||
) {
|
||||
return true;
|
||||
// good to go
|
||||
} else {
|
||||
throw Error(
|
||||
errorMsgs.push(
|
||||
`You're trying to use "smart conflict" PRO feature but you haven't subscribe to it.`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
// good to go
|
||||
}
|
||||
}
|
||||
|
||||
if (featuresToCheck.contains("feature-google_drive")) {
|
||||
console.debug(
|
||||
`checking "feature-google_drive", serviceType=${config.serviceType}`
|
||||
);
|
||||
console.debug(
|
||||
`enabledProFeatures=${JSON.stringify(config.pro.enabledProFeatures)}`
|
||||
);
|
||||
|
||||
if (config.serviceType === "googledrive") {
|
||||
if (
|
||||
config.pro.enabledProFeatures.filter(
|
||||
(x) => x.featureName === "feature-google_drive"
|
||||
).length === 1
|
||||
) {
|
||||
// good to go
|
||||
} else {
|
||||
errorMsgs.push(
|
||||
`You're trying to use "sync with Google Drive" PRO feature but you haven't subscribe to it.`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// good to go
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMsgs.length !== 0) {
|
||||
throw Error(errorMsgs.join("\n\n"));
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
+13
-13
@@ -213,7 +213,7 @@ export class FakeFsGoogleDrive extends FakeFs {
|
||||
});
|
||||
|
||||
const k1: { files: File[] } = await k.json();
|
||||
console.debug(k1);
|
||||
// console.debug(k1);
|
||||
if (k1.files.length > 0) {
|
||||
// yeah we find it
|
||||
this.baseDirID = k1.files[0].id!;
|
||||
@@ -308,11 +308,11 @@ export class FakeFsGoogleDrive extends FakeFs {
|
||||
id: f.id,
|
||||
folderPath: f.keyRaw,
|
||||
};
|
||||
console.debug(
|
||||
`looping result of _walkFolder(${id},${folderPath}), adding child=${JSON.stringify(
|
||||
child
|
||||
)}`
|
||||
);
|
||||
// console.debug(
|
||||
// `looping result of _walkFolder(${id},${folderPath}), adding child=${JSON.stringify(
|
||||
// child
|
||||
// )}`
|
||||
// );
|
||||
children.push(child);
|
||||
}
|
||||
}
|
||||
@@ -322,16 +322,16 @@ export class FakeFsGoogleDrive extends FakeFs {
|
||||
parents = children;
|
||||
}
|
||||
|
||||
console.debug(`in the end of walk:`);
|
||||
console.debug(allFiles);
|
||||
console.debug(this.keyToGDEntity);
|
||||
// console.debug(`in the end of walk:`);
|
||||
// console.debug(allFiles);
|
||||
// console.debug(this.keyToGDEntity);
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
async _walkFolder(parentID: string, parentFolderPath: string) {
|
||||
console.debug(
|
||||
`input of single level: parentID=${parentID}, parentFolderPath=${parentFolderPath}`
|
||||
);
|
||||
// console.debug(
|
||||
// `input of single level: parentID=${parentID}, parentFolderPath=${parentFolderPath}`
|
||||
// );
|
||||
const filesOneLevel: GDEntity[] = [];
|
||||
let nextPageToken: string | undefined = undefined;
|
||||
if (parentID === undefined || parentID === "" || parentID === "root") {
|
||||
@@ -359,7 +359,7 @@ export class FakeFsGoogleDrive extends FakeFs {
|
||||
}
|
||||
|
||||
const k1 = await k.json();
|
||||
console.debug(k1);
|
||||
// console.debug(k1);
|
||||
for (const file of k1.files as File[]) {
|
||||
const entity = fromFileToGDEntity(file, parentID, parentFolderPath);
|
||||
this.keyToGDEntity[entity.keyRaw] = entity; // build cache
|
||||
|
||||
+13
-3
@@ -7,8 +7,14 @@
|
||||
"protocol_pro_connect_fail": "Something went wrong from response from Remotely Save official website. Maybe the network connection is not good. Maybe you rejected the auth?",
|
||||
"protocol_pro_connect_succ_revoke": "You've connected as user {{email}}. If you want to disconnect, click this button.",
|
||||
|
||||
"modal_googledriveauth_tutorial": "<p>Please firstly go to the address, then go on the auth flow. In the end, you will see a code, please paste that code here and submit.</p>",
|
||||
"modal_googledriveauth_copybutton": "Click to copy the auth url",
|
||||
"modal_googledriveauth_copynotice": "The auth url is copied to the clipboard!",
|
||||
"modal_googledrivce_maualinput": "The Code from the website",
|
||||
"modal_googledrivce_maualinput_desc": "Please input the code here from the end of auth flow, and press confirm.",
|
||||
"modal_googledrive_maualinput_notice": "We are trying to connect to Google and update the credentials...",
|
||||
"modal_googledrive_maualinput_succ_notice": "Great! The credentials are updated!",
|
||||
"modal_googledrive_maualinput_fail_notice": "Oops! Failed to update the credentials. Please try again later.",
|
||||
"modal_googledriverevokeauth_step1": "Step 1: Go to the following address, you can remove the connection there.",
|
||||
"modal_googledriverevokeauth_step2": "Step 2: Click the button below, to clean the locally-saved login credentials.",
|
||||
"modal_googledriverevokeauth_clean": "Clean Locally-Saved Login Credentials",
|
||||
@@ -30,10 +36,14 @@
|
||||
"modal_proauth_maualinput_notice": "Trying to connect, wait...",
|
||||
"modal_proauth_maualinput_conn_fail": "Failed to connect",
|
||||
|
||||
"settings_googledrive": "Google Drive (PRO)",
|
||||
"settings_chooseservice_googledrive": "Google Drive (PRO)",
|
||||
"settings_googledrive_disclaimer1": "Disclaimer: This app is NOT an official Google product.",
|
||||
"settings_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_chooseservice_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_googledrive_disclaimer1": "Disclaimer: This app is NOT an official Google product. The app just uses Google Drive's public api.",
|
||||
"settings_googledrive_disclaimer2": "Disclaimer: The information is stored locally. Other malicious/harmful/faulty plugins could read the info. If you see any unintentional access to your Google Drive, please immediately disconnect this app on https://myaccount.google.com/permissions .",
|
||||
"settings_googledrive_pro_desc": "<p><strong>!!It's a PRO feature of Remotely Save! You need a Remotely Save online account for this feature!!</strong>(<a href=\"#settings-pro\">scroll down</a> for more info about PRO account.)</p>",
|
||||
"settings_googledrive_notshowuphint": "Google Drive Settings Not Available",
|
||||
"settings_googledrive_notshowuphint_desc": "Google Drive settings are not available, because you haven't subscribed to the PRO feature in your Remotely Save account.",
|
||||
"settings_googledrive_notshowuphint_view_pro": "View PRO Settings",
|
||||
"settings_googledrive_folder": "We will create and sync inside the folder {{remoteBaseDir}} on your Google Drive. DO NOT create this folder by yourself manually.",
|
||||
"settings_googledrive_revoke": "Revoke Auth",
|
||||
"settings_googledrive_revoke_desc": "You've connected. If you want to disconnect, click this button.",
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
"protocol_pro_connect_fail": "Remotely Save 官网返回错误。可能是网络连接不稳定。也可能是您拒绝了授权?",
|
||||
"protocol_pro_connect_succ_revoke": "您已连接上账号 {{email}}。如果要取消连接,请点击此按钮。",
|
||||
|
||||
"modal_googledriveauth_tutorial": "<p>请访问此网址,然后会进入授权流程。最后,您会看到一个码,请复制粘贴到这里然后提交。</p>",
|
||||
"modal_googledriveauth_copybutton": "点击以复制网址",
|
||||
"modal_googledriveauth_copynotice": "网址已复制!",
|
||||
"modal_googledrivce_maualinput": "网站上的码",
|
||||
"modal_googledrivce_maualinput_desc": "请粘贴授权流程最后的那个码,然后点击确认。",
|
||||
"modal_googledrive_maualinput_notice": "正在尝试连接 Google 并更新授权信息......",
|
||||
"modal_googledrive_maualinput_succ_notice": "很好!授权信息已更新!",
|
||||
"modal_googledrive_maualinput_fail_notice": "更新授权信息失败。请稍后重试。",
|
||||
"modal_googledriverevokeauth_step1": "第 1 步:访问以下网址,可以删除连接。",
|
||||
"modal_googledriverevokeauth_step2": "第 2 步:点击以下按钮,从而清理本地的登录信息。",
|
||||
"modal_googledriverevokeauth_clean": "清理本地登录信息",
|
||||
"modal_googledriverevokeauth_clean_desc": "您需要点击此按钮。",
|
||||
"modal_googledriverevokeauth_clean_button": "清理",
|
||||
"modal_googledriverevokeauth_clean_notice": "已清理!",
|
||||
"modal_googledriverevokeauth_clean_fail": "清理授权时候发生了错误。",
|
||||
|
||||
"modal_prorevokeauth": "点击这里和按照步骤取消授权。",
|
||||
"modal_prorevokeauth_clean": "清理",
|
||||
"modal_prorevokeauth_clean_desc": "清理本地授权记录",
|
||||
@@ -20,6 +36,26 @@
|
||||
"modal_proauth_maualinput_notice": "正在连接,请稍候......",
|
||||
"modal_proauth_maualinput_conn_fail": "连接失败",
|
||||
|
||||
"settings_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_chooseservice_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_googledrive_disclaimer1": "声明:本插件不是 Google 的官方产品。只是用到了它的公开 API。",
|
||||
"settings_googledrive_disclaimer2": "声明:您所输入的信息存储于本地。其它有害的或者出错的插件,是有可能读取到这些信息的。如果您发现任何不符合预期的 Google Drive 访问,请立刻在以下网站操作断开连接: https://myaccount.google.com/permissions 。",
|
||||
"settings_googledrive_pro_desc": "<p><strong>!!这是 PRO(付费)功能! 您需要在线账号来使用此功能!!</strong>(<a href=\"#settings-pro\">向下滑</a>可以看到 PRO 账号的更多信息。)</p>",
|
||||
"settings_googledrive_notshowuphint": "Google Drive 设置不可用",
|
||||
"settings_googledrive_notshowuphint_desc": "Google Drive 设置不可用,因为您没有在 Remotely Save 账号里开启这个 PRO 功能。",
|
||||
"settings_googledrive_notshowuphint_view_pro": "查看 PRO 相关设置",
|
||||
"settings_googledrive_folder": "我们会在 Google Drive 创建此文件夹并同步内容进去: {{remoteBaseDir}} 。请不要手动在网站上创建。",
|
||||
"settings_googledrive_revoke": "撤回鉴权",
|
||||
"settings_googledrive_revoke_desc": "您现在已连接。如果想取消连接,请点击此按钮。",
|
||||
"settings_googledrive_revoke_button": "撤回鉴权",
|
||||
"settings_googledrive_auth": "鉴权",
|
||||
"settings_googledrive_auth_desc": "鉴权.",
|
||||
"settings_googledrive_auth_button": "鉴权",
|
||||
"settings_googledrive_connect_succ": "很好!我们可连接上 Google Drive!",
|
||||
"settings_googledrive_connect_fail": "我们未能连接上 Google Drive。",
|
||||
|
||||
"settings_export_googledrive_button": "导出 Google Drive 部分",
|
||||
|
||||
"settings_pro": "账号(PRO 付费功能)",
|
||||
"settings_pro_tutorial": "<p>使用 Remotely Save 的<stong>基本</strong>功能是<strong>免费的</strong>,而且<strong>不</strong>需要注册对应账号。</p><p>但是,您<strong>需要</strong>注册账号和对<strong>PRO</strong>功能<strong>付费</strong>使用,如智能处理冲突功能。</p><p>第一步:点击按钮从而注册和登录网站:<a href=\"https://remotelysave.com\">https://remotelysave.com</a>。注意:这和 Obsidian 官方账号无关,是不同的账号。</p><p>第二部:点击“连接”按钮,从而连接本设备和在线账号。",
|
||||
"settings_pro_features": "功能",
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
"protocol_pro_connect_fail": "Remotely Save 官網返回錯誤。可能是網路連線不穩定。也可能是您拒絕了授權?",
|
||||
"protocol_pro_connect_succ_revoke": "您已連線上賬號 {{email}}。如果要取消連線,請點選此按鈕。",
|
||||
|
||||
"modal_googledriveauth_tutorial": "<p>請訪問此網址,然後會進入授權流程。最後,您會看到一個碼,請複製貼上到這裡然後提交。</p>",
|
||||
"modal_googledriveauth_copybutton": "點選以複製網址",
|
||||
"modal_googledriveauth_copynotice": "網址已複製!",
|
||||
"modal_googledrivce_maualinput": "網站上的碼",
|
||||
"modal_googledrivce_maualinput_desc": "請貼上授權流程最後的那個碼,然後點選確認。",
|
||||
"modal_googledrive_maualinput_notice": "正在嘗試連線 Google 並更新授權資訊......",
|
||||
"modal_googledrive_maualinput_succ_notice": "很好!授權資訊已更新!",
|
||||
"modal_googledrive_maualinput_fail_notice": "更新授權資訊失敗。請稍後重試。",
|
||||
"modal_googledriverevokeauth_step1": "第 1 步:訪問以下網址,可以刪除連線。",
|
||||
"modal_googledriverevokeauth_step2": "第 2 步:點選以下按鈕,從而清理本地的登入資訊。",
|
||||
"modal_googledriverevokeauth_clean": "清理本地登入資訊",
|
||||
"modal_googledriverevokeauth_clean_desc": "您需要點選此按鈕。",
|
||||
"modal_googledriverevokeauth_clean_button": "清理",
|
||||
"modal_googledriverevokeauth_clean_notice": "已清理!",
|
||||
"modal_googledriverevokeauth_clean_fail": "清理授權時候發生了錯誤。",
|
||||
|
||||
"modal_prorevokeauth": "點選這裡和按照步驟取消授權。",
|
||||
"modal_prorevokeauth_clean": "清理",
|
||||
"modal_prorevokeauth_clean_desc": "清理本地授權記錄",
|
||||
@@ -20,6 +36,26 @@
|
||||
"modal_proauth_maualinput_notice": "正在連線,請稍候......",
|
||||
"modal_proauth_maualinput_conn_fail": "連線失敗",
|
||||
|
||||
"settings_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_chooseservice_googledrive": "Google Drive (PRO) (beta)",
|
||||
"settings_googledrive_disclaimer1": "宣告:本外掛不是 Google 的官方產品。只是用到了它的公開 API。",
|
||||
"settings_googledrive_disclaimer2": "宣告:您所輸入的資訊儲存於本地。其它有害的或者出錯的外掛,是有可能讀取到這些資訊的。如果您發現任何不符合預期的 Google Drive 訪問,請立刻在以下網站操作斷開連線: https://myaccount.google.com/permissions 。",
|
||||
"settings_googledrive_pro_desc": "<p><strong>!!這是 PRO(付費)功能! 您需要線上賬號來使用此功能!!</strong>(<a href=\"#settings-pro\">向下滑</a>可以看到 PRO 賬號的更多資訊。)</p>",
|
||||
"settings_googledrive_notshowuphint": "Google Drive 設定不可用",
|
||||
"settings_googledrive_notshowuphint_desc": "Google Drive 設定不可用,因為您沒有在 Remotely Save 賬號裡開啟這個 PRO 功能。",
|
||||
"settings_googledrive_notshowuphint_view_pro": "檢視 PRO 相關設定",
|
||||
"settings_googledrive_folder": "我們會在 Google Drive 建立此資料夾並同步內容進去: {{remoteBaseDir}} 。請不要手動在網站上建立。",
|
||||
"settings_googledrive_revoke": "撤回鑑權",
|
||||
"settings_googledrive_revoke_desc": "您現在已連線。如果想取消連線,請點選此按鈕。",
|
||||
"settings_googledrive_revoke_button": "撤回鑑權",
|
||||
"settings_googledrive_auth": "鑑權",
|
||||
"settings_googledrive_auth_desc": "鑑權.",
|
||||
"settings_googledrive_auth_button": "鑑權",
|
||||
"settings_googledrive_connect_succ": "很好!我們可連線上 Google Drive!",
|
||||
"settings_googledrive_connect_fail": "我們未能連線上 Google Drive。",
|
||||
|
||||
"settings_export_googledrive_button": "匯出 Google Drive 部分",
|
||||
|
||||
"settings_pro": "賬號(PRO 付費功能)",
|
||||
"settings_pro_tutorial": "<p>使用 Remotely Save 的<stong>基本</strong>功能是<strong>免費的</strong>,而且<strong>不</strong>需要註冊對應賬號。</p><p>但是,您<strong>需要</strong>註冊賬號和對<strong>PRO</strong>功能<strong>付費</strong>使用,如智慧處理衝突功能。</p><p>第一步:點選按鈕從而註冊和登入網站:<a href=\"https://remotelysave.com\">https://remotelysave.com</a>。注意:這和 Obsidian 官方賬號無關,是不同的賬號。</p><p>第二部:點選“連線”按鈕,從而連線本裝置和線上賬號。",
|
||||
"settings_pro_features": "功能",
|
||||
|
||||
@@ -3,8 +3,12 @@ import { type App, Modal, Notice, Setting } from "obsidian";
|
||||
import { getClient } from "../../src/fsGetter";
|
||||
import type { TransItemType } from "../../src/i18n";
|
||||
import type RemotelySavePlugin from "../../src/main";
|
||||
import { stringToFragment } from "../../src/misc";
|
||||
import { ChangeRemoteBaseDirModal } from "../../src/settings";
|
||||
import { DEFAULT_GOOGLEDRIVE_CONFIG } from "./fsGoogleDrive";
|
||||
import {
|
||||
DEFAULT_GOOGLEDRIVE_CONFIG,
|
||||
sendRefreshTokenReq,
|
||||
} from "./fsGoogleDrive";
|
||||
|
||||
class GoogleDriveAuthModal extends Modal {
|
||||
readonly plugin: RemotelySavePlugin;
|
||||
@@ -34,6 +38,9 @@ class GoogleDriveAuthModal extends Modal {
|
||||
|
||||
const authUrl = "https://remotelysave.com/auth/googledrive/start";
|
||||
const div2 = contentEl.createDiv();
|
||||
div2.createDiv({
|
||||
text: stringToFragment(t("modal_googledriveauth_tutorial")),
|
||||
});
|
||||
div2.createEl(
|
||||
"button",
|
||||
{
|
||||
@@ -51,6 +58,65 @@ class GoogleDriveAuthModal extends Modal {
|
||||
href: authUrl,
|
||||
text: authUrl,
|
||||
});
|
||||
|
||||
let refreshToken = "";
|
||||
new Setting(contentEl)
|
||||
.setName(t("modal_googledrivce_maualinput"))
|
||||
.setDesc(t("modal_googledrivce_maualinput_desc"))
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("")
|
||||
.setValue("")
|
||||
.onChange((val) => {
|
||||
refreshToken = val.trim();
|
||||
})
|
||||
)
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("submit"));
|
||||
button.onClick(async () => {
|
||||
new Notice(t("modal_googledrive_maualinput_notice"));
|
||||
|
||||
try {
|
||||
if (this.plugin.settings.googledrive === undefined) {
|
||||
this.plugin.settings.googledrive = cloneDeep(
|
||||
DEFAULT_GOOGLEDRIVE_CONFIG
|
||||
);
|
||||
}
|
||||
this.plugin.settings.googledrive.refreshToken = refreshToken;
|
||||
this.plugin.settings.googledrive.accessToken = "access";
|
||||
this.plugin.settings.googledrive.accessTokenExpiresAtTimeMs = 1;
|
||||
this.plugin.settings.googledrive.accessTokenExpiresInMs = 1;
|
||||
|
||||
// TODO: abstraction leaking now, how to fix?
|
||||
const k = await sendRefreshTokenReq(refreshToken);
|
||||
const ts = Date.now();
|
||||
this.plugin.settings.googledrive.accessToken = k.access_token;
|
||||
this.plugin.settings.googledrive.accessTokenExpiresInMs =
|
||||
k.expires_in * 1000;
|
||||
this.plugin.settings.googledrive.accessTokenExpiresAtTimeMs =
|
||||
ts + k.expires_in * 1000 - 60 * 2 * 1000;
|
||||
await this.plugin.saveSettings();
|
||||
|
||||
// try to remove data in clipboard
|
||||
await navigator.clipboard.writeText("");
|
||||
|
||||
new Notice(t("modal_googledrive_maualinput_succ_notice"));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
new Notice(t("modal_googledrive_maualinput_fail_notice"));
|
||||
} finally {
|
||||
this.authDiv.toggleClass(
|
||||
"googledrive-auth-button-hide",
|
||||
this.plugin.settings.googledrive.refreshToken !== ""
|
||||
);
|
||||
this.revokeAuthDiv.toggleClass(
|
||||
"googledrive-revoke-auth-button-hide",
|
||||
this.plugin.settings.googledrive.refreshToken === ""
|
||||
);
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onClose() {
|
||||
@@ -108,12 +174,12 @@ class GoogleDriveRevokeAuthModal extends Modal {
|
||||
|
||||
await this.plugin.saveSettings();
|
||||
this.authDiv.toggleClass(
|
||||
"onedrive-auth-button-hide",
|
||||
this.plugin.settings.onedrive.username !== ""
|
||||
"googledrive-auth-button-hide",
|
||||
this.plugin.settings.googledrive.refreshToken !== ""
|
||||
);
|
||||
this.revokeAuthDiv.toggleClass(
|
||||
"onedrive-revoke-auth-button-hide",
|
||||
this.plugin.settings.onedrive.username === ""
|
||||
"googledrive-revoke-auth-button-hide",
|
||||
this.plugin.settings.googledrive.refreshToken === ""
|
||||
);
|
||||
new Notice(t("modal_googledriverevokeauth_clean_notice"));
|
||||
this.close();
|
||||
@@ -167,7 +233,41 @@ export const generateGoogleDriveSettingsPart = (
|
||||
}),
|
||||
});
|
||||
|
||||
const googleDriveSelectAuthDiv = googleDriveDiv.createDiv();
|
||||
googleDriveLongDescDiv.createDiv({
|
||||
text: stringToFragment(t("settings_googledrive_pro_desc")),
|
||||
cls: "googledrive-disclaimer",
|
||||
});
|
||||
|
||||
const googleDriveNotShowUpHintSetting = new Setting(googleDriveDiv)
|
||||
.setName(t("settings_googledrive_notshowuphint"))
|
||||
.setDesc(t("settings_googledrive_notshowuphint_desc"))
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("settings_googledrive_notshowuphint_view_pro"));
|
||||
button.onClick(async () => {
|
||||
window.location.href = "#settings-pro";
|
||||
});
|
||||
});
|
||||
|
||||
const googleDriveAllowedToUsedDiv = googleDriveDiv.createDiv();
|
||||
// if pro enabled, show up; otherwise hide.
|
||||
const allowGoogleDrive =
|
||||
plugin.settings.pro?.enabledProFeatures.filter(
|
||||
(x) => x.featureName === "feature-google_drive"
|
||||
).length === 1;
|
||||
console.debug(`allow to show up google drive settings? ${allowGoogleDrive}`);
|
||||
if (allowGoogleDrive) {
|
||||
googleDriveAllowedToUsedDiv.removeClass("googledrive-allow-to-use-hide");
|
||||
googleDriveNotShowUpHintSetting.settingEl.addClass(
|
||||
"googledrive-allow-to-use-hide"
|
||||
);
|
||||
} else {
|
||||
googleDriveAllowedToUsedDiv.addClass("googledrive-allow-to-use-hide");
|
||||
googleDriveNotShowUpHintSetting.settingEl.removeClass(
|
||||
"googledrive-allow-to-use-hide"
|
||||
);
|
||||
}
|
||||
|
||||
const googleDriveSelectAuthDiv = googleDriveAllowedToUsedDiv.createDiv();
|
||||
const googleDriveAuthDiv = googleDriveSelectAuthDiv.createDiv({
|
||||
cls: "googledrive-auth-button-hide settings-auth-related",
|
||||
});
|
||||
@@ -224,7 +324,7 @@ export const generateGoogleDriveSettingsPart = (
|
||||
|
||||
let newgoogleDriveRemoteBaseDir =
|
||||
plugin.settings.googledrive.remoteBaseDir || "";
|
||||
new Setting(googleDriveDiv)
|
||||
new Setting(googleDriveAllowedToUsedDiv)
|
||||
.setName(t("settings_remotebasedir"))
|
||||
.setDesc(t("settings_remotebasedir_desc"))
|
||||
.addText((text) =>
|
||||
@@ -246,7 +346,7 @@ export const generateGoogleDriveSettingsPart = (
|
||||
).open();
|
||||
});
|
||||
});
|
||||
new Setting(googleDriveDiv)
|
||||
new Setting(googleDriveAllowedToUsedDiv)
|
||||
.setName(t("settings_checkonnectivity"))
|
||||
.setDesc(t("settings_checkonnectivity_desc"))
|
||||
.addButton(async (button) => {
|
||||
@@ -269,5 +369,9 @@ export const generateGoogleDriveSettingsPart = (
|
||||
});
|
||||
});
|
||||
|
||||
return googleDriveDiv;
|
||||
return {
|
||||
googleDriveDiv: googleDriveDiv,
|
||||
googleDriveAllowedToUsedDiv: googleDriveAllowedToUsedDiv,
|
||||
googleDriveNotShowUpHintSetting: googleDriveNotShowUpHintSetting,
|
||||
};
|
||||
};
|
||||
|
||||
+28
-1
@@ -150,6 +150,9 @@ export class ProAuthModal extends Modal {
|
||||
);
|
||||
this.plugin.oauth2Info.revokeDiv = undefined;
|
||||
|
||||
// try to remove data in clipboard
|
||||
await navigator.clipboard.writeText("");
|
||||
|
||||
this.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -244,7 +247,9 @@ export const generateProSettingsPart = (
|
||||
t: (x: TransItemType, vars?: any) => string,
|
||||
app: App,
|
||||
plugin: RemotelySavePlugin,
|
||||
saveUpdatedConfigFunc: () => Promise<any> | undefined
|
||||
saveUpdatedConfigFunc: () => Promise<any> | undefined,
|
||||
googleDriveAllowedToUsedDiv: HTMLDivElement,
|
||||
googleDriveNotShowUpHintSetting: Setting
|
||||
) => {
|
||||
proDiv
|
||||
.createEl("h2", { text: t("settings_pro") })
|
||||
@@ -290,6 +295,28 @@ export const generateProSettingsPart = (
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const allowGoogleDrive =
|
||||
plugin.settings.pro?.enabledProFeatures.filter(
|
||||
(x) => x.featureName === "feature-google_drive"
|
||||
).length === 1;
|
||||
console.debug(
|
||||
`allow to show up google drive settings? ${allowGoogleDrive}`
|
||||
);
|
||||
if (allowGoogleDrive) {
|
||||
googleDriveAllowedToUsedDiv.removeClass(
|
||||
"googledrive-allow-to-use-hide"
|
||||
);
|
||||
googleDriveNotShowUpHintSetting.settingEl.addClass(
|
||||
"googledrive-allow-to-use-hide"
|
||||
);
|
||||
} else {
|
||||
googleDriveAllowedToUsedDiv.addClass("googledrive-allow-to-use-hide");
|
||||
googleDriveNotShowUpHintSetting.settingEl.removeClass(
|
||||
"googledrive-allow-to-use-hide"
|
||||
);
|
||||
}
|
||||
|
||||
new Notice(t("settings_pro_features_refresh_succ"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user