chore(ui): remove unused code

This commit is contained in:
hexxa 2021-08-22 21:51:33 +08:00 committed by Hexxa
parent ee056aa193
commit 19a635a4b5
3 changed files with 3 additions and 118 deletions

View file

@ -125,8 +125,6 @@ export class UserForm extends React.Component<
});
};
// setRole = () => {};
render() {
return (
<div

View file

@ -2,8 +2,6 @@ import * as React from "react";
import { Set, Map } from "immutable";
import { updater } from "./state_updater";
// import { IUsersClient, User, ListUsersResp, ListRolesResp } from "../client";
// import { UsersClient } from "../client/users";
import { ICoreState } from "./core_state";
import { PaneSettings } from "./pane_settings";
import { AdminPane, Props as AdminPaneProps } from "./pane_admin";
@ -18,116 +16,6 @@ export interface Props {
update?: (updater: (prevState: ICoreState) => ICoreState) => void;
}
// export class Updater {
// static props: Props;
// private static client: IUsersClient;
// static init = (props: Props) => (Updater.props = { ...props });
// static setClient = (client: IUsersClient): void => {
// Updater.client = client;
// };
// static displayPane = (paneName: string) => {
// if (paneName === "") {
// // hide all panes
// Updater.props.displaying = "";
// } else {
// const pane = Updater.props.paneNames.get(paneName);
// if (pane != null) {
// Updater.props.displaying = paneName;
// } else {
// alert(`dialgos: pane (${paneName}) not found`);
// }
// }
// };
// static self = async (): Promise<boolean> => {
// const resp = await Updater.client.self();
// if (resp.status === 200) {
// Updater.props.userRole = resp.data.role;
// return true;
// }
// return false;
// };
// static addUser = async (user: User): Promise<boolean> => {
// const resp = await Updater.client.addUser(user.name, user.pwd, user.role);
// // TODO: should return uid instead
// return resp.status === 200;
// };
// static delUser = async (userID: string): Promise<boolean> => {
// const resp = await Updater.client.delUser(userID);
// return resp.status === 200;
// };
// static setRole = async (userID: string, role: string): Promise<boolean> => {
// const resp = await Updater.client.delUser(userID);
// return resp.status === 200;
// };
// static forceSetPwd = async (
// userID: string,
// pwd: string
// ): Promise<boolean> => {
// const resp = await Updater.client.forceSetPwd(userID, pwd);
// return resp.status === 200;
// };
// static listUsers = async (): Promise<boolean> => {
// const resp = await Updater.client.listUsers();
// if (resp.status !== 200) {
// return false;
// }
// const lsRes = resp.data as ListUsersResp;
// let users = Map<User>({});
// lsRes.users.forEach((user: User) => {
// users = users.set(user.name, user);
// });
// Updater.props.admin.users = users;
// return true;
// };
// static addRole = async (role: string): Promise<boolean> => {
// const resp = await Updater.client.addRole(role);
// // TODO: should return uid instead
// return resp.status === 200;
// };
// static delRole = async (role: string): Promise<boolean> => {
// const resp = await Updater.client.delRole(role);
// return resp.status === 200;
// };
// static listRoles = async (): Promise<boolean> => {
// const resp = await Updater.client.listRoles();
// if (resp.status !== 200) {
// return false;
// }
// const lsRes = resp.data as ListRolesResp;
// let roles = Set<string>();
// Object.keys(lsRes.roles).forEach((role: string) => {
// roles = roles.add(role);
// });
// Updater.props.admin.roles = roles;
// return true;
// };
// static updateState = (prevState: ICoreState): ICoreState => {
// return {
// ...prevState,
// panel: {
// ...prevState.panel,
// panes: { ...prevState.panel.panes, ...Updater.props },
// },
// };
// };
// }
export interface State {}
export class Panes extends React.Component<Props, State, {}> {
constructor(p: Props) {
@ -189,6 +77,7 @@ export class Panes extends React.Component<Props, State, {}> {
<div className="container">
<div className="flex-list-container padding-l">
<h3 className="flex-list-item-l txt-cap">{displaying}</h3>
<div className="flex-list-item-r">
<button
onClick={this.closePane}
@ -202,8 +91,6 @@ export class Panes extends React.Component<Props, State, {}> {
{panes}
</div>
{/* <div className="hr white0-bg margin-b-m margin-l-m margin-r-m"></div> */}
{/* <div className="padding-l"></div> */}
</div>
);
}

View file

@ -15,10 +15,10 @@ export class StateMgr extends React.Component<Props, State, {}> {
constructor(p: Props) {
super(p);
this.state = newState();
this.initUpdaters(this.state);
this.initUpdater(this.state);
}
initUpdaters = (state: ICoreState) => {
initUpdater = (state: ICoreState) => {
updater().init(state);
updater().setClients(new UsersClient(""), new FilesClient(""));