Fix organization page bug

This commit is contained in:
Yang Luo
2023-03-31 18:35:57 +08:00
parent 9c8ea027ef
commit 8d1ae4ea08
2 changed files with 18 additions and 5 deletions

View File

@@ -614,7 +614,7 @@ class UserEditPage extends React.Component {
); );
} }
submitUserEdit(willExist) { submitUserEdit(needExit) {
const user = Setting.deepCopy(this.state.user); const user = Setting.deepCopy(this.state.user);
UserBackend.updateUser(this.state.organizationName, this.state.userName, user) UserBackend.updateUser(this.state.organizationName, this.state.userName, user)
.then((res) => { .then((res) => {
@@ -626,13 +626,18 @@ class UserEditPage extends React.Component {
}); });
if (this.props.history !== undefined) { if (this.props.history !== undefined) {
if (willExist) { if (needExit) {
this.props.history.push("/users"); const userListUrl = sessionStorage.getItem("userListUrl");
if (userListUrl !== null) {
this.props.history.push(userListUrl);
} else {
this.props.history.push("/users");
}
} else { } else {
this.props.history.push(`/users/${this.state.user.owner}/${this.state.user.name}`); this.props.history.push(`/users/${this.state.user.owner}/${this.state.user.name}`);
} }
} else { } else {
if (willExist) { if (needExit) {
if (this.state.returnUrl) { if (this.state.returnUrl) {
window.location.href = this.state.returnUrl; window.location.href = this.state.returnUrl;
} }

View File

@@ -70,6 +70,7 @@ class UserListPage extends BaseListPage {
UserBackend.addUser(newUser) UserBackend.addUser(newUser)
.then((res) => { .then((res) => {
if (res.status === "ok") { if (res.status === "ok") {
sessionStorage.setItem("userListUrl", window.location.pathname);
this.props.history.push({pathname: `/users/${newUser.owner}/${newUser.name}`, mode: "add"}); this.props.history.push({pathname: `/users/${newUser.owner}/${newUser.name}`, mode: "add"});
Setting.showMessage("success", i18next.t("general:Successfully added")); Setting.showMessage("success", i18next.t("general:Successfully added"));
} else { } else {
@@ -341,7 +342,10 @@ class UserListPage extends BaseListPage {
const disabled = (record.owner === this.props.account.owner && record.name === this.props.account.name); const disabled = (record.owner === this.props.account.owner && record.name === this.props.account.name);
return ( return (
<div> <div>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/users/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button> <Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => {
sessionStorage.setItem("userListUrl", window.location.pathname);
this.props.history.push(`/users/${record.owner}/${record.name}`);
}}>{i18next.t("general:Edit")}</Button>
<PopconfirmModal <PopconfirmModal
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`} title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
onConfirm={() => this.deleteUser(index)} onConfirm={() => this.deleteUser(index)}
@@ -402,6 +406,8 @@ class UserListPage extends BaseListPage {
const users = res.data; const users = res.data;
if (users.length > 0) { if (users.length > 0) {
this.getOrganization(users[0].owner); this.getOrganization(users[0].owner);
} else {
this.getOrganization(this.state.organizationName);
} }
} else { } else {
if (Setting.isResponseDenied(res)) { if (Setting.isResponseDenied(res)) {
@@ -430,6 +436,8 @@ class UserListPage extends BaseListPage {
const users = res.data; const users = res.data;
if (users.length > 0) { if (users.length > 0) {
this.getOrganization(users[0].owner); this.getOrganization(users[0].owner);
} else {
this.getOrganization(this.state.organizationName);
} }
} else { } else {
if (Setting.isResponseDenied(res)) { if (Setting.isResponseDenied(res)) {