Update changes for lifecycle check method

4.x.x
Farheen99 4 years ago
parent 0df8c8d91c
commit fdaf8bd7ef

@ -77,6 +77,7 @@ class LifeCycle extends React.Component {
current: 0, current: 0,
lifecycleSteps: [], lifecycleSteps: [],
lifeCycleStates: [], lifeCycleStates: [],
isPublished: false,
}; };
} }
@ -91,6 +92,10 @@ class LifeCycle extends React.Component {
lifecycleSteps, lifecycleSteps,
}); });
this.getLifeCycleHistory(); this.getLifeCycleHistory();
this.setState({
isPublished: this.checkReleaseLifeCycleStatus(),
});
} }
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate(prevProps, prevState, snapshot) {
@ -204,26 +209,18 @@ class LifeCycle extends React.Component {
state or not and assigned a boolean value to disable state or not and assigned a boolean value to disable
the publish button if an app release is already published the publish button if an app release is already published
*/ */
checkReleaseLifeCycleStatus = (proceedingStates, lifecycleState) => { checkReleaseLifeCycleStatus = () => {
if (typeof this.props.appReleases !== 'undefined') { if (typeof this.props.appReleases !== 'undefined') {
const currentAppUUID = this.props.uuid;
let appReleases = this.props.appReleases.fullAppDetails; let appReleases = this.props.appReleases.fullAppDetails;
let appRelease;
let isPublished;
for (let i = 0; i < appReleases.length; i++) { for (let i = 0; i < appReleases.length; i++) {
appRelease = appReleases[i];
if ( if (
currentAppUUID !== appRelease.uuid && this.props.uuid !== appReleases[i].uuid &&
appRelease.currentStatus === 'PUBLISHED' && appReleases[i].currentStatus === 'PUBLISHED'
proceedingStates.includes('PUBLISHED') &&
lifecycleState === 'PUBLISHED'
) { ) {
isPublished = true; return true;
return isPublished;
} }
} }
isPublished = false; return false;
return isPublished;
} }
return false; return false;
}; };
@ -278,13 +275,11 @@ class LifeCycle extends React.Component {
<p>{step.text}</p> <p>{step.text}</p>
{proceedingStates.map(lifecycleState => { {proceedingStates.map(lifecycleState => {
return ( return (
// eslint-disable-next-line react/jsx-key
<Tooltip <Tooltip
key={lifecycleState}
title={ title={
this.checkReleaseLifeCycleStatus( lifecycleState === 'PUBLISHED' &&
proceedingStates, this.state.isPublished
lifecycleState,
) === true
? text ? text
: '' : ''
} }
@ -292,10 +287,10 @@ class LifeCycle extends React.Component {
<Button <Button
size={'small'} size={'small'}
style={{ marginRight: 3 }} style={{ marginRight: 3 }}
disabled={this.checkReleaseLifeCycleStatus( disabled={
proceedingStates, lifecycleState === 'PUBLISHED' &&
lifecycleState, this.state.isPublished
)} }
onClick={() => onClick={() =>
this.showReasonModal(lifecycleState) this.showReasonModal(lifecycleState)
} }

Loading…
Cancel
Save