fix(fe/login): add extInfo to login props

This commit is contained in:
hexxa 2022-01-19 16:18:31 +08:00 committed by Hexxa
parent e39d3b88e0
commit 81d375eafe
8 changed files with 30 additions and 16 deletions

View file

@ -72,7 +72,9 @@ describe("Login", () => {
userName: "mockUser", userName: "mockUser",
userRole: "admin", userRole: "admin",
authed: true, authed: true,
extInfo: {
usedSpace: "256", usedSpace: "256",
},
quota: { quota: {
spaceLimit: "7", spaceLimit: "7",
uploadSpeedLimit: 3, uploadSpeedLimit: 3,

View file

@ -1,5 +1,4 @@
import { List, Set, Map } from "immutable"; import { List, Set, Map } from "immutable";
import { mock, instance } from "ts-mockito";
import { initMockWorker } from "../../test/helpers"; import { initMockWorker } from "../../test/helpers";
import { StateMgr } from "../state_mgr"; import { StateMgr } from "../state_mgr";
@ -72,7 +71,9 @@ describe("State Manager", () => {
userID: "0", userID: "0",
userName: "mockUser", userName: "mockUser",
userRole: "admin", userRole: "admin",
extInfo: {
usedSpace: "256", usedSpace: "256",
},
quota: { quota: {
spaceLimit: "7", spaceLimit: "7",
uploadSpeedLimit: 3, uploadSpeedLimit: 3,
@ -189,7 +190,9 @@ describe("State Manager", () => {
userName: mockSelfResp.data.name, userName: mockSelfResp.data.name,
userRole: mockSelfResp.data.role, userRole: mockSelfResp.data.role,
quota: mockSelfResp.data.quota, quota: mockSelfResp.data.quota,
extInfo: {
usedSpace: mockSelfResp.data.usedSpace, usedSpace: mockSelfResp.data.usedSpace,
},
authed: false, authed: false,
captchaID: "mockCaptchaID", captchaID: "mockCaptchaID",
preferences: { preferences: {

View file

@ -101,7 +101,9 @@ describe("TopBar", () => {
userID: visitorID, userID: visitorID,
userName: "visitor", userName: "visitor",
userRole: roleVisitor, userRole: roleVisitor,
extInfo: {
usedSpace: "0", usedSpace: "0",
},
quota: { quota: {
spaceLimit: "0", spaceLimit: "0",
uploadSpeedLimit: 0, uploadSpeedLimit: 0,

View file

@ -74,7 +74,9 @@ export function initState(): ICoreState {
userID: "", userID: "",
userName: "", userName: "",
userRole: "", userRole: "",
extInfo: {
usedSpace: "0", usedSpace: "0",
},
quota: { quota: {
spaceLimit: "0", spaceLimit: "0",
uploadSpeedLimit: 0, uploadSpeedLimit: 0,

View file

@ -8,14 +8,17 @@ import { alertMsg } from "../common/env";
import { Quota, Preferences } from "../client"; import { Quota, Preferences } from "../client";
import { getErrMsg } from "../common/utils"; import { getErrMsg } from "../common/utils";
export interface ExtInfo {
usedSpace: string;
}
export interface LoginProps { export interface LoginProps {
authed: boolean;
captchaID: string;
userID: string; userID: string;
userName: string; userName: string;
userRole: string; userRole: string;
usedSpace: string; extInfo: ExtInfo;
quota: Quota; quota: Quota;
authed: boolean;
captchaID: string;
preferences: Preferences; preferences: Preferences;
} }

View file

@ -796,7 +796,7 @@ export class FilesPanel extends React.Component<Props, State, {}> {
this.prepareTable(this.props.filesInfo.items, showOp) this.prepareTable(this.props.filesInfo.items, showOp)
); );
const usedSpace = FileSize(parseInt(this.props.login.usedSpace, 10), { const usedSpace = FileSize(parseInt(this.props.login.extInfo.usedSpace, 10), {
round: 0, round: 0,
}); });
const spaceLimit = FileSize( const spaceLimit = FileSize(

View file

@ -458,7 +458,9 @@ export class Updater {
return ""; return "";
}; };
getParamMap = async (params: URLSearchParams): Promise<Map<string, string>> => { getParamMap = async (
params: URLSearchParams
): Promise<Map<string, string>> => {
let paramMap = Map<string, string>(); let paramMap = Map<string, string>();
paramMap = paramMap.set("sh", ""); paramMap = paramMap.set("sh", "");
paramMap = paramMap.set("dir", ""); paramMap = paramMap.set("dir", "");
@ -466,7 +468,7 @@ export class Updater {
let shareID = params.get("sh"); let shareID = params.get("sh");
if (shareID != null && shareID !== "") { if (shareID != null && shareID !== "") {
paramMap = paramMap.set("sh", shareID); paramMap = paramMap.set("sh", shareID);
const resp = await this.filesClient.getSharingDir(shareID) const resp = await this.filesClient.getSharingDir(shareID);
if (resp.status === 200) { if (resp.status === 200) {
paramMap = paramMap.set("dir", resp.data.sharingDir); paramMap = paramMap.set("dir", resp.data.sharingDir);
} }
@ -478,7 +480,7 @@ export class Updater {
}; };
initCwd = async (params: URLSearchParams): Promise<string> => { initCwd = async (params: URLSearchParams): Promise<string> => {
const paramMap = await this.getParamMap(params) const paramMap = await this.getParamMap(params);
const dir = paramMap.get("dir", ""); const dir = paramMap.get("dir", "");
if (dir != null && dir !== "") { if (dir != null && dir !== "") {
@ -551,7 +553,7 @@ export class Updater {
this.props.login.userID = visitorID; this.props.login.userID = visitorID;
this.props.login.userName = "visitor"; this.props.login.userName = "visitor";
this.props.login.userRole = roleVisitor; this.props.login.userRole = roleVisitor;
this.props.login.usedSpace = "0"; this.props.login.extInfo.usedSpace = "0";
this.props.login.quota = { this.props.login.quota = {
uploadSpeedLimit: 0, uploadSpeedLimit: 0,
downloadSpeedLimit: 0, downloadSpeedLimit: 0,
@ -579,7 +581,7 @@ export class Updater {
this.props.login.userID = resp.data.id; this.props.login.userID = resp.data.id;
this.props.login.userName = resp.data.name; this.props.login.userName = resp.data.name;
this.props.login.userRole = resp.data.role; this.props.login.userRole = resp.data.role;
this.props.login.usedSpace = resp.data.usedSpace; this.props.login.extInfo.usedSpace = resp.data.usedSpace;
this.props.login.quota = resp.data.quota; this.props.login.quota = resp.data.quota;
this.props.login.preferences = resp.data.preferences; this.props.login.preferences = resp.data.preferences;
return ""; return "";

View file

@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import { List } from "immutable"; import { List } from "immutable";
import { alertMsg, confirmMsg } from "../common/env";
import { alertMsg, confirmMsg } from "../common/env";
import { ICoreState, MsgProps, UIProps } from "./core_state"; import { ICoreState, MsgProps, UIProps } from "./core_state";
import { LoginProps } from "./pane_login"; import { LoginProps } from "./pane_login";
import { updater } from "./state_updater"; import { updater } from "./state_updater";