mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-17 04:03:23 +08:00
feat: add cancel buttons on the edit page (#509)
* feat: add cancel buttons on the edit page Signed-off-by: Yixiang Zhao <seriouszyx@foxmail.com> * fix: remove warning and primary type of cancel buttons Signed-off-by: Yixiang Zhao <seriouszyx@foxmail.com>
This commit is contained in:
@ -25,6 +25,7 @@ class TokenEditPage extends React.Component {
|
||||
classes: props,
|
||||
tokenName: props.match.params.tokenName,
|
||||
token: null,
|
||||
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,9 +63,10 @@ class TokenEditPage extends React.Component {
|
||||
return (
|
||||
<Card size="small" title={
|
||||
<div>
|
||||
{i18next.t("token:Edit Token")}
|
||||
{this.state.mode === "add" ? i18next.t("token:New Token") : i18next.t("token:Edit Token")}
|
||||
<Button onClick={() => this.submitTokenEdit(false)}>{i18next.t("general:Save")}</Button>
|
||||
<Button style={{marginLeft: '20px'}} type="primary" onClick={() => this.submitTokenEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
||||
{this.state.mode === "add" ? <Button style={{marginLeft: '20px'}} onClick={() => this.deleteToken()}>{i18next.t("general:Cancel")}</Button> : null}
|
||||
</div>
|
||||
} style={(Setting.isMobile())? {margin: '5px'}:{}} type="inner">
|
||||
<Row style={{marginTop: '10px'}} >
|
||||
@ -186,6 +188,16 @@ class TokenEditPage extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
deleteToken() {
|
||||
TokenBackend.deleteToken(this.state.token)
|
||||
.then(() => {
|
||||
this.props.history.push(`/tokens`);
|
||||
})
|
||||
.catch(error => {
|
||||
Setting.showMessage("error", `Token failed to delete: ${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
@ -195,6 +207,7 @@ class TokenEditPage extends React.Component {
|
||||
<div style={{marginTop: '20px', marginLeft: '40px'}}>
|
||||
<Button size="large" onClick={() => this.submitTokenEdit(false)}>{i18next.t("general:Save")}</Button>
|
||||
<Button style={{marginLeft: '20px'}} type="primary" size="large" onClick={() => this.submitTokenEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
||||
{this.state.mode === "add" ? <Button style={{marginLeft: '20px'}} size="large" onClick={() => this.deleteToken()}>{i18next.t("general:Cancel")}</Button> : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user