From a8511f967b832c51b5002767f48cdac6e9e5cc1a Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Tue, 13 Aug 2019 09:27:56 -0400 Subject: [PATCH] build details url once --- .../JobTemplateEdit/JobTemplateEdit.jsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.jsx b/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.jsx index 6dcad602f4..ebd450171d 100644 --- a/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.jsx +++ b/awx/ui_next/src/screens/Template/JobTemplateEdit/JobTemplateEdit.jsx @@ -17,6 +17,11 @@ class JobTemplateEdit extends Component { error: '', }; + const { + template: { id, type }, + } = props; + this.detailsUrl = `/templates/${type}/${id}/details`; + this.handleCancel = this.handleCancel.bind(this); this.handleSubmit = this.handleSubmit.bind(this); this.submitLabels = this.submitLabels.bind(this); @@ -31,7 +36,7 @@ class JobTemplateEdit extends Component { try { await JobTemplatesAPI.update(id, { ...values }); await Promise.all([this.submitLabels(newLabels, removedLabels)]); - history.push(`/templates/${type}/${id}/details`); + history.push(this.detailsUrl); } catch (error) { this.setState({ error }); } @@ -60,11 +65,8 @@ class JobTemplateEdit extends Component { } handleCancel() { - const { - template: { id, type }, - history, - } = this.props; - history.push(`/templates/${type}/${id}/details`); + const { history } = this.props; + history.push(this.detailsUrl); } render() { @@ -73,10 +75,7 @@ class JobTemplateEdit extends Component { const canEdit = template.summary_fields.user_capabilities.edit; if (!canEdit) { - const { - template: { id, type }, - } = this.props; - return ; + return ; } return (