feat(web): add lint (#875)

* feat: add lint

* feat: fix lint error

* chore: add ignore file

* chore: close indent
This commit is contained in:
キリサメ qianxi
2022-07-10 15:45:55 +08:00
committed by GitHub
parent 475b6da35a
commit 503d244166
121 changed files with 17023 additions and 16815 deletions

View File

@ -14,7 +14,7 @@
import React from "react";
import {Link} from "react-router-dom";
import {Button, Popconfirm, Switch, Table} from 'antd';
import {Button, Popconfirm, Switch, Table} from "antd";
import moment from "moment";
import * as Setting from "./Setting";
import * as OrganizationBackend from "./backend/OrganizationBackend";
@ -64,15 +64,15 @@ class OrganizationListPage extends BaseListPage {
{name: "Is forbidden", visible: true, viewRule: "Admin", modifyRule: "Admin"},
{name: "Is deleted", visible: true, viewRule: "Admin", modifyRule: "Admin"},
],
}
};
}
addOrganization() {
const newOrganization = this.newOrganization();
OrganizationBackend.addOrganization(newOrganization)
.then((res) => {
this.props.history.push({pathname: `/organizations/${newOrganization.name}`, mode: "add"});
}
this.props.history.push({pathname: `/organizations/${newOrganization.name}`, mode: "add"});
}
)
.catch(error => {
Setting.showMessage("error", `Organization failed to add: ${error}`);
@ -82,12 +82,12 @@ class OrganizationListPage extends BaseListPage {
deleteOrganization(i) {
OrganizationBackend.deleteOrganization(this.state.data[i])
.then((res) => {
Setting.showMessage("success", `Organization deleted successfully`);
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
});
}
Setting.showMessage("success", "Organization deleted successfully");
this.setState({
data: Setting.deleteRow(this.state.data, i),
pagination: {total: this.state.pagination.total - 1},
});
}
)
.catch(error => {
Setting.showMessage("error", `Organization failed to delete: ${error}`);
@ -98,25 +98,25 @@ class OrganizationListPage extends BaseListPage {
const columns = [
{
title: i18next.t("general:Name"),
dataIndex: 'name',
key: 'name',
width: '120px',
fixed: 'left',
dataIndex: "name",
key: "name",
width: "120px",
fixed: "left",
sorter: true,
...this.getColumnSearchProps('name'),
...this.getColumnSearchProps("name"),
render: (text, record, index) => {
return (
<Link to={`/organizations/${text}`}>
{text}
</Link>
)
);
}
},
{
title: i18next.t("general:Created time"),
dataIndex: 'createdTime',
key: 'createdTime',
width: '160px',
dataIndex: "createdTime",
key: "createdTime",
width: "160px",
sorter: true,
render: (text, record, index) => {
return Setting.getFormattedDate(text);
@ -124,106 +124,106 @@ class OrganizationListPage extends BaseListPage {
},
{
title: i18next.t("general:Display name"),
dataIndex: 'displayName',
key: 'displayName',
dataIndex: "displayName",
key: "displayName",
// width: '100px',
sorter: true,
...this.getColumnSearchProps('displayName'),
...this.getColumnSearchProps("displayName"),
},
{
title: i18next.t("organization:Favicon"),
dataIndex: 'favicon',
key: 'favicon',
width: '50px',
dataIndex: "favicon",
key: "favicon",
width: "50px",
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={text}>
<img src={text} alt={text} width={40} />
</a>
)
);
}
},
{
title: i18next.t("organization:Website URL"),
dataIndex: 'websiteUrl',
key: 'websiteUrl',
width: '300px',
dataIndex: "websiteUrl",
key: "websiteUrl",
width: "300px",
sorter: true,
...this.getColumnSearchProps('websiteUrl'),
...this.getColumnSearchProps("websiteUrl"),
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={text}>
{text}
</a>
)
);
}
},
{
title: i18next.t("general:Password type"),
dataIndex: 'passwordType',
key: 'passwordType',
width: '150px',
dataIndex: "passwordType",
key: "passwordType",
width: "150px",
sorter: true,
filterMultiple: false,
filters: [
{text: 'plain', value: 'plain'},
{text: 'salt', value: 'salt'},
{text: 'md5-salt', value: 'md5-salt'},
{text: "plain", value: "plain"},
{text: "salt", value: "salt"},
{text: "md5-salt", value: "md5-salt"},
],
},
{
title: i18next.t("general:Password salt"),
dataIndex: 'passwordSalt',
key: 'passwordSalt',
width: '150px',
dataIndex: "passwordSalt",
key: "passwordSalt",
width: "150px",
sorter: true,
...this.getColumnSearchProps('passwordSalt'),
...this.getColumnSearchProps("passwordSalt"),
},
{
title: i18next.t("organization:Default avatar"),
dataIndex: 'defaultAvatar',
key: 'defaultAvatar',
width: '120px',
dataIndex: "defaultAvatar",
key: "defaultAvatar",
width: "120px",
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={text}>
<img src={text} alt={text} width={40} />
</a>
)
<a target="_blank" rel="noreferrer" href={text}>
<img src={text} alt={text} width={40} />
</a>
);
}
},
{
title: i18next.t("organization:Soft deletion"),
dataIndex: 'enableSoftDeletion',
key: 'enableSoftDeletion',
width: '140px',
dataIndex: "enableSoftDeletion",
key: "enableSoftDeletion",
width: "140px",
sorter: true,
render: (text, record, index) => {
return (
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
)
);
}
},
{
title: i18next.t("general:Action"),
dataIndex: '',
key: 'op',
width: '240px',
dataIndex: "",
key: "op",
width: "240px",
fixed: (Setting.isMobile()) ? "false" : "right",
render: (text, record, index) => {
return (
<div>
<Button style={{marginTop: '10px', marginBottom: '10px', marginRight: '10px'}} type="primary" onClick={() => this.props.history.push(`/organizations/${record.name}/users`)}>{i18next.t("general:Users")}</Button>
<Button style={{marginTop: '10px', marginBottom: '10px', marginRight: '10px'}} onClick={() => this.props.history.push(`/organizations/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/organizations/${record.name}/users`)}>{i18next.t("general:Users")}</Button>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} onClick={() => this.props.history.push(`/organizations/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<Popconfirm
title={`Sure to delete organization: ${record.name} ?`}
onConfirm={() => this.deleteOrganization(index)}
disabled={record.name === "built-in"}
>
<Button style={{marginBottom: '10px'}} disabled={record.name === "built-in"} type="danger">{i18next.t("general:Delete")}</Button>
<Button style={{marginBottom: "10px"}} disabled={record.name === "built-in"} type="danger">{i18next.t("general:Delete")}</Button>
</Popconfirm>
</div>
)
);
}
},
];
@ -237,15 +237,15 @@ class OrganizationListPage extends BaseListPage {
return (
<div>
<Table scroll={{x: 'max-content'}} columns={columns} dataSource={organizations} rowKey="name" size="middle" bordered pagination={paginationProps}
title={() => (
<div>
{i18next.t("general:Organizations")}&nbsp;&nbsp;&nbsp;&nbsp;
<Button type="primary" size="small" onClick={this.addOrganization.bind(this)}>{i18next.t("general:Add")}</Button>
</div>
)}
loading={this.state.loading}
onChange={this.handleTableChange}
<Table scroll={{x: "max-content"}} columns={columns} dataSource={organizations} rowKey="name" size="middle" bordered pagination={paginationProps}
title={() => (
<div>
{i18next.t("general:Organizations")}&nbsp;&nbsp;&nbsp;&nbsp;
<Button type="primary" size="small" onClick={this.addOrganization.bind(this)}>{i18next.t("general:Add")}</Button>
</div>
)}
loading={this.state.loading}
onChange={this.handleTableChange}
/>
</div>
);
@ -258,7 +258,7 @@ class OrganizationListPage extends BaseListPage {
field = "passwordType";
value = params.passwordType;
}
this.setState({ loading: true });
this.setState({loading: true});
OrganizationBackend.getOrganizations("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => {
if (res.status === "ok") {