fix: add returnUrl for user edit page (#1152)

* feat: add redirect param

Signed-off-by: magicwind <2814461814@qq.com>

* Update UserEditPage.js

Signed-off-by: magicwind <2814461814@qq.com>
Co-authored-by: Gucheng <85475922+nomeguy@users.noreply.github.com>
This commit is contained in:
leoshine 2022-09-23 12:01:21 +08:00 committed by GitHub
parent 79f2af405a
commit 1490044295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,11 @@ class UserEditPage extends React.Component {
}); });
} }
getReturnUrl() {
const searchParams = new URLSearchParams(this.props.location.search);
return searchParams.get("returnUrl");
}
parseUserField(key, value) { parseUserField(key, value) {
// if ([].includes(key)) { // if ([].includes(key)) {
// value = Setting.myParseInt(value); // value = Setting.myParseInt(value);
@ -616,6 +621,13 @@ class UserEditPage extends React.Component {
} 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 {
if (willExist) {
const returnUrl = this.getReturnUrl();
if (returnUrl) {
window.location.href = returnUrl;
}
}
} }
} else { } else {
Setting.showMessage("error", res.msg); Setting.showMessage("error", res.msg);