From 600c1e6a9ec2eb8a7ed9d25aeb8eef4a67309473 Mon Sep 17 00:00:00 2001 From: hexxa Date: Wed, 25 Aug 2021 18:47:23 +0800 Subject: [PATCH] fix(ui): replace alert with alertMsg --- src/client/web/src/components/browser.tsx | 4 ++-- src/client/web/src/components/pane_login.tsx | 5 +++-- src/client/web/src/components/pane_settings.tsx | 11 ++++++----- src/client/web/src/components/state_mgr.tsx | 3 ++- src/client/web/src/components/state_updater.ts | 9 +++++---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/client/web/src/components/browser.tsx b/src/client/web/src/components/browser.tsx index aba5309..e4301a7 100644 --- a/src/client/web/src/components/browser.tsx +++ b/src/client/web/src/components/browser.tsx @@ -240,7 +240,7 @@ export class Browser extends React.Component { .addSharing() .then((ok) => { if (!ok) { - alert("failed to enable sharing"); + alertMsg("failed to enable sharing"); } else { updater().setSharing(true); return this.listSharings(); @@ -256,7 +256,7 @@ export class Browser extends React.Component { .deleteSharing(dirPath) .then((ok) => { if (!ok) { - alert("failed to disable sharing"); + alertMsg("failed to disable sharing"); } else { updater().setSharing(false); return this.listSharings(); diff --git a/src/client/web/src/components/pane_login.tsx b/src/client/web/src/components/pane_login.tsx index 72d1695..52bec36 100644 --- a/src/client/web/src/components/pane_login.tsx +++ b/src/client/web/src/components/pane_login.tsx @@ -3,6 +3,7 @@ import { List } from "immutable"; import { ICoreState } from "./core_state"; import { updater } from "./state_updater"; +import { alertMsg } from "../common/env"; export interface Props { userRole: string; @@ -67,7 +68,7 @@ export class AuthPane extends React.Component { ]); } else { this.setState({ user: "", pwd: "", captchaInput: "" }); - alert("Failed to login."); + alertMsg("Failed to login."); return updater().getCaptchaID(); } @@ -84,7 +85,7 @@ export class AuthPane extends React.Component { if (ok) { this.update(updater().updateLogin); } else { - alert("Failed to logout."); + alertMsg("Failed to logout."); } }); }; diff --git a/src/client/web/src/components/pane_settings.tsx b/src/client/web/src/components/pane_settings.tsx index d4ac9da..19f7718 100644 --- a/src/client/web/src/components/pane_settings.tsx +++ b/src/client/web/src/components/pane_settings.tsx @@ -3,6 +3,7 @@ import * as React from "react"; import { ICoreState } from "./core_state"; import { AuthPane, Props as LoginProps } from "./pane_login"; import { updater } from "./state_updater"; +import { alertMsg } from "../common/env"; export interface Props { login: LoginProps; @@ -39,19 +40,19 @@ export class PaneSettings extends React.Component { setPwd = () => { if (this.state.newPwd1 !== this.state.newPwd2) { - alert("new passwords are not same"); + alertMsg("new passwords are not same"); } else if (this.state.newPwd1 == "") { - alert("new passwords can not be empty"); + alertMsg("new passwords can not be empty"); } else if (this.state.oldPwd == this.state.newPwd1) { - alert("old and new passwords are same"); + alertMsg("old and new passwords are same"); } else { updater() .setPwd(this.state.oldPwd, this.state.newPwd1) .then((ok: boolean) => { if (ok) { - alert("Password is updated"); + alertMsg("Password is updated"); } else { - alert("Failed to update password"); + alertMsg("Failed to update password"); } this.setState({ oldPwd: "", diff --git a/src/client/web/src/components/state_mgr.tsx b/src/client/web/src/components/state_mgr.tsx index 054f0a7..b165e7a 100644 --- a/src/client/web/src/components/state_mgr.tsx +++ b/src/client/web/src/components/state_mgr.tsx @@ -7,6 +7,7 @@ import { RootFrame } from "./root_frame"; import { FilesClient } from "../client/files"; import { UsersClient } from "../client/users"; import { IUsersClient, IFilesClient } from "../client"; +import { alertMsg } from "../common/env"; export interface Props {} export interface State extends ICoreState {} @@ -55,7 +56,7 @@ export class StateMgr extends React.Component { }) .then((ok: boolean) => { if (!ok) { - alert("failed to get captcha id"); + alertMsg("failed to get captcha id"); } else { this.update(updater().updateLogin); } diff --git a/src/client/web/src/components/state_updater.ts b/src/client/web/src/components/state_updater.ts index 796aa66..a04b4b2 100644 --- a/src/client/web/src/components/state_updater.ts +++ b/src/client/web/src/components/state_updater.ts @@ -16,6 +16,7 @@ import { FilesClient } from "../client/files"; import { UsersClient } from "../client/users"; import { UploadEntry } from "../worker/interface"; import { Up } from "../worker/upload_mgr"; +import { alertMsg } from "../common/env"; export class Updater { props: ICoreState; @@ -112,7 +113,7 @@ export class Updater { mkDir = async (dirPath: string): Promise => { const resp = await this.filesClient.mkdir(dirPath); if (resp.status !== 200) { - alert(`failed to make dir ${dirPath}`); + alertMsg(`failed to make dir ${dirPath}`); } }; @@ -134,7 +135,7 @@ export class Updater { const failedFiles = await Promise.all(delRequests); failedFiles.forEach((failedFile) => { if (failedFile !== "") { - alert(`failed to delete ${failedFile}`); + alertMsg(`failed to delete ${failedFile}`); } }); return this.setItems(dirParts); @@ -178,7 +179,7 @@ export class Updater { const failedFiles = await Promise.all(moveRequests); failedFiles.forEach((failedItem) => { if (failedItem !== "") { - alert(`failed to move ${failedItem}`); + alertMsg(`failed to move ${failedItem}`); } }); @@ -194,7 +195,7 @@ export class Updater { if (pane != null) { this.props.panes.displaying = paneName; } else { - alert(`dialgos: pane (${paneName}) not found`); + alertMsg(`dialgos: pane (${paneName}) not found`); } } };