mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 10:57:35 -02:30
build details url once
This commit is contained in:
@@ -17,6 +17,11 @@ class JobTemplateEdit extends Component {
|
|||||||
error: '',
|
error: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const {
|
||||||
|
template: { id, type },
|
||||||
|
} = props;
|
||||||
|
this.detailsUrl = `/templates/${type}/${id}/details`;
|
||||||
|
|
||||||
this.handleCancel = this.handleCancel.bind(this);
|
this.handleCancel = this.handleCancel.bind(this);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.submitLabels = this.submitLabels.bind(this);
|
this.submitLabels = this.submitLabels.bind(this);
|
||||||
@@ -31,7 +36,7 @@ class JobTemplateEdit extends Component {
|
|||||||
try {
|
try {
|
||||||
await JobTemplatesAPI.update(id, { ...values });
|
await JobTemplatesAPI.update(id, { ...values });
|
||||||
await Promise.all([this.submitLabels(newLabels, removedLabels)]);
|
await Promise.all([this.submitLabels(newLabels, removedLabels)]);
|
||||||
history.push(`/templates/${type}/${id}/details`);
|
history.push(this.detailsUrl);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setState({ error });
|
this.setState({ error });
|
||||||
}
|
}
|
||||||
@@ -60,11 +65,8 @@ class JobTemplateEdit extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleCancel() {
|
handleCancel() {
|
||||||
const {
|
const { history } = this.props;
|
||||||
template: { id, type },
|
history.push(this.detailsUrl);
|
||||||
history,
|
|
||||||
} = this.props;
|
|
||||||
history.push(`/templates/${type}/${id}/details`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -73,10 +75,7 @@ class JobTemplateEdit extends Component {
|
|||||||
const canEdit = template.summary_fields.user_capabilities.edit;
|
const canEdit = template.summary_fields.user_capabilities.edit;
|
||||||
|
|
||||||
if (!canEdit) {
|
if (!canEdit) {
|
||||||
const {
|
return <Redirect to={this.detailsUrl} />;
|
||||||
template: { id, type },
|
|
||||||
} = this.props;
|
|
||||||
return <Redirect to={`/templates/${type}/${id}/details`} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user