feat: reuse component Users

Signed-off-by: wasabi <690898835@qq.com>
This commit is contained in:
wasabi 2021-06-19 11:38:24 +08:00
parent 910ea04384
commit 50a9ca2b4c
3 changed files with 18 additions and 6 deletions

View File

@ -377,6 +377,7 @@ class App extends Component {
<Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/>
<Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/>
<Route exact path="/organizations/:organizationName" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationEditPage account={this.state.account} {...props} />)}/>
<Route exact path="/organizations/:organizationName/users" render={(props) => this.renderLoginIfNotLoggedIn(<UserListPage account={this.state.account} {...props} />)}/>
<Route exact path="/users" render={(props) => this.renderLoginIfNotLoggedIn(<UserListPage account={this.state.account} {...props} />)}/>
<Route exact path="/users/:organizationName/:userName" render={(props) => <UserEditPage account={this.state.account} {...props} />}/>
<Route exact path="/providers" render={(props) => this.renderLoginIfNotLoggedIn(<ProviderListPage account={this.state.account} {...props} />)}/>

View File

@ -168,6 +168,7 @@ class OrganizationListPage extends React.Component {
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'}} type="primary" onClick={() => this.props.history.push(`/organizations/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<Popconfirm
title={`Sure to delete organization: ${record.name} ?`}

View File

@ -26,6 +26,7 @@ class UserListPage extends React.Component {
this.state = {
classes: props,
users: null,
organizationName: props.match.params.organizationName,
};
}
@ -34,12 +35,21 @@ class UserListPage extends React.Component {
}
getUsers() {
UserBackend.getGlobalUsers()
.then((res) => {
this.setState({
users: res,
});
});
if (this.state.organizationName === undefined) {
UserBackend.getGlobalUsers()
.then((res) => {
this.setState({
users: res,
});
});
} else {
UserBackend.getUsers(this.state.organizationName)
.then((res) => {
this.setState({
users: res,
});
});
}
}
newUser() {