From fdaf8bd7efa5f86b9da7c4758b818a0dc650e9d7 Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Thu, 12 Nov 2020 06:05:00 +0530 Subject: [PATCH] Update changes for lifecycle check method --- .../Release/components/LifeCycle/index.js | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/LifeCycle/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/LifeCycle/index.js index fc815d61f05..5660802b5ac 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/LifeCycle/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/LifeCycle/index.js @@ -77,6 +77,7 @@ class LifeCycle extends React.Component { current: 0, lifecycleSteps: [], lifeCycleStates: [], + isPublished: false, }; } @@ -91,6 +92,10 @@ class LifeCycle extends React.Component { lifecycleSteps, }); this.getLifeCycleHistory(); + + this.setState({ + isPublished: this.checkReleaseLifeCycleStatus(), + }); } componentDidUpdate(prevProps, prevState, snapshot) { @@ -204,26 +209,18 @@ class LifeCycle extends React.Component { state or not and assigned a boolean value to disable the publish button if an app release is already published */ - checkReleaseLifeCycleStatus = (proceedingStates, lifecycleState) => { + checkReleaseLifeCycleStatus = () => { if (typeof this.props.appReleases !== 'undefined') { - const currentAppUUID = this.props.uuid; let appReleases = this.props.appReleases.fullAppDetails; - let appRelease; - let isPublished; for (let i = 0; i < appReleases.length; i++) { - appRelease = appReleases[i]; if ( - currentAppUUID !== appRelease.uuid && - appRelease.currentStatus === 'PUBLISHED' && - proceedingStates.includes('PUBLISHED') && - lifecycleState === 'PUBLISHED' + this.props.uuid !== appReleases[i].uuid && + appReleases[i].currentStatus === 'PUBLISHED' ) { - isPublished = true; - return isPublished; + return true; } } - isPublished = false; - return isPublished; + return false; } return false; }; @@ -278,13 +275,11 @@ class LifeCycle extends React.Component {

{step.text}

{proceedingStates.map(lifecycleState => { return ( - // eslint-disable-next-line react/jsx-key this.showReasonModal(lifecycleState) }