From 0df8c8d91cb07085559eafafa61864f1319d03ba Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Tue, 10 Nov 2020 21:13:57 +0530 Subject: [PATCH 1/3] Disable publish button for releases with a published app --- .../components/AddNewReleaseForm/index.js | 5 +- .../ApssTable/AppDetailsDrawer/index.js | 16 ++++- .../Release/components/LifeCycle/index.js | 65 ++++++++++++++++--- .../Home/scenes/Apps/scenes/Release/index.js | 1 + 4 files changed, 75 insertions(+), 12 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/AddNewRelease/components/AddNewReleaseForm/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/AddNewRelease/components/AddNewReleaseForm/index.js index 0ae2d7ae595..6162c4fac0b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/AddNewRelease/components/AddNewReleaseForm/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/AddNewRelease/components/AddNewReleaseForm/index.js @@ -127,7 +127,10 @@ class AddNewReleaseFormComponent extends React.Component { description: 'New release was added successfully', }); const uuid = res.data.data.uuid; - this.props.history.push('/publisher/apps/releases/' + uuid); + this.props.history.push({ + pathname: '/publisher/apps/releases/' + uuid, + state: { fullAppDetails: this.props.location.state.fullAppDetails }, + }); } else { this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/components/ApssTable/AppDetailsDrawer/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/components/ApssTable/AppDetailsDrawer/index.js index 3698c5d840d..1a80bc120a3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/components/ApssTable/AppDetailsDrawer/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/components/ApssTable/AppDetailsDrawer/index.js @@ -702,7 +702,14 @@ class AppDetailsDrawer extends React.Component { title="Click to view full details" placement="topRight" > - + Add new release for the application + + ); })} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js index 7fb6cdb70e1..91f05673b2a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js @@ -232,6 +232,7 @@ class Release extends React.Component { this.changeCurrentLifecycleStatus } lifecycle={lifecycle} + appReleases={this.props.location.state} /> )} From fdaf8bd7efa5f86b9da7c4758b818a0dc650e9d7 Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Thu, 12 Nov 2020 06:05:00 +0530 Subject: [PATCH 2/3] 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) } From 01e5e301738a3bf53f780bad8774f6b2bf8512df Mon Sep 17 00:00:00 2001 From: Farheen99 Date: Thu, 12 Nov 2020 10:01:58 +0530 Subject: [PATCH 3/3] Remove added setState method in componentDidMount --- .../Apps/scenes/Release/components/LifeCycle/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 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 5660802b5ac..03c7801ac36 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 @@ -87,15 +87,13 @@ class LifeCycle extends React.Component { const lifecycleSteps = Object.keys(lifeCycleConfig).map(config => { return lifeCycleConfig[config]; }); + let isPublished = this.checkReleaseLifeCycleStatus(); this.setState({ current: lifeCycleConfig[this.props.currentStatus].step, lifecycleSteps, + isPublished, }); this.getLifeCycleHistory(); - - this.setState({ - isPublished: this.checkReleaseLifeCycleStatus(), - }); } componentDidUpdate(prevProps, prevState, snapshot) {