From d4877e8bb9625d71700a523c7b70ff4e9d735cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Thu, 27 Jul 2017 17:13:03 +0100 Subject: [PATCH] fix(cp-frontend): handle non existing service in scale --- .../src/containers/service/scale.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/cp-frontend/src/containers/service/scale.js b/packages/cp-frontend/src/containers/service/scale.js index e4732db6..af89951b 100644 --- a/packages/cp-frontend/src/containers/service/scale.js +++ b/packages/cp-frontend/src/containers/service/scale.js @@ -31,6 +31,20 @@ class ServiceScale extends Component { } }; + const handleCloseClick = evt => { + const closeUrl = match.url.split('/').slice(0, -2).join('/'); + history.replace(closeUrl); + }; + + const handleSubmitClick = values => { + scale(service.id, values.replicas).then(handleCloseClick); + }; + + if (!service) { + setTimeout(handleCloseClick, 33); + return null; + } + const ServiceScaleForm = reduxForm({ form: 'scale-service', destroyOnUnmount: true, @@ -41,15 +55,6 @@ class ServiceScale extends Component { } })(ServiceScaleComponent); - const handleCloseClick = evt => { - const closeUrl = match.url.split('/').slice(0, -2).join('/'); - history.replace(closeUrl); - }; - - const handleSubmitClick = values => { - scale(service.id, values.replicas).then(handleCloseClick); - }; - return (