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",
userRole: "admin",
authed: true,
extInfo: {
usedSpace: "256",
},
quota: {
spaceLimit: "7",
uploadSpeedLimit: 3,

View file

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

View file

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

View file

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

View file

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

View file

@ -796,7 +796,7 @@ export class FilesPanel extends React.Component<Props, State, {}> {
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,
});
const spaceLimit = FileSize(

View file

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

View file

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