Merge branch 'issue-works' into 'master'

Fix new app publishing feature if there is an app release already published for the same application

Closes product-iots#678

See merge request entgra/carbon-device-mgt!686
revert-70ac1926
Dharmakeerthi Lasantha 4 years ago
commit 92e23ca03a

@ -127,7 +127,10 @@ class AddNewReleaseFormComponent extends React.Component {
description: 'New release was added successfully', description: 'New release was added successfully',
}); });
const uuid = res.data.data.uuid; 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 { } else {
this.setState({ this.setState({
loading: false, loading: false,

@ -702,7 +702,14 @@ class AppDetailsDrawer extends React.Component {
title="Click to view full details" title="Click to view full details"
placement="topRight" placement="topRight"
> >
<Link to={'apps/releases/' + release.uuid}> <Link
to={{
pathname: `apps/releases/${release.uuid}`,
state: {
fullAppDetails: app.applicationReleases,
},
}}
>
<Card className="release-card"> <Card className="release-card">
<Meta <Meta
avatar={ avatar={
@ -773,7 +780,12 @@ class AppDetailsDrawer extends React.Component {
<Text>Add new release for the application</Text> <Text>Add new release for the application</Text>
</div> </div>
<Link <Link
to={`/publisher/apps/${app.deviceType}/${app.id}/add-release`} to={{
pathname: `/publisher/apps/${app.deviceType}/${app.id}/add-release`,
state: {
fullAppDetails: app.applicationReleases,
},
}}
> >
<Button htmlType="button" type="primary" size="small"> <Button htmlType="button" type="primary" size="small">
Add Add

@ -27,6 +27,7 @@ import {
Steps, Steps,
Alert, Alert,
Tabs, Tabs,
Tooltip,
} from 'antd'; } from 'antd';
import axios from 'axios'; import axios from 'axios';
import ReactQuill from 'react-quill'; import ReactQuill from 'react-quill';
@ -76,6 +77,7 @@ class LifeCycle extends React.Component {
current: 0, current: 0,
lifecycleSteps: [], lifecycleSteps: [],
lifeCycleStates: [], lifeCycleStates: [],
isPublished: false,
}; };
} }
@ -85,9 +87,11 @@ class LifeCycle extends React.Component {
const lifecycleSteps = Object.keys(lifeCycleConfig).map(config => { const lifecycleSteps = Object.keys(lifeCycleConfig).map(config => {
return lifeCycleConfig[config]; return lifeCycleConfig[config];
}); });
let isPublished = this.checkReleaseLifeCycleStatus();
this.setState({ this.setState({
current: lifeCycleConfig[this.props.currentStatus].step, current: lifeCycleConfig[this.props.currentStatus].step,
lifecycleSteps, lifecycleSteps,
isPublished,
}); });
this.getLifeCycleHistory(); this.getLifeCycleHistory();
} }
@ -198,6 +202,27 @@ class LifeCycle extends React.Component {
this.setState({ current }); this.setState({ current });
}; };
/*
Function to check if the same app releases are in published
state or not and assigned a boolean value to disable
the publish button if an app release is already published
*/
checkReleaseLifeCycleStatus = () => {
if (typeof this.props.appReleases !== 'undefined') {
let appReleases = this.props.appReleases.fullAppDetails;
for (let i = 0; i < appReleases.length; i++) {
if (
this.props.uuid !== appReleases[i].uuid &&
appReleases[i].currentStatus === 'PUBLISHED'
) {
return true;
}
}
return false;
}
return false;
};
render() { render() {
const { const {
currentStatus, currentStatus,
@ -207,6 +232,7 @@ class LifeCycle extends React.Component {
lifeCycleStates, lifeCycleStates,
} = this.state; } = this.state;
const { lifecycle } = this.props; const { lifecycle } = this.props;
const text = <span>Already an app is in publish state</span>;
let proceedingStates = []; let proceedingStates = [];
if ( if (
lifecycle !== null && lifecycle !== null &&
@ -247,9 +273,22 @@ class LifeCycle extends React.Component {
<p>{step.text}</p> <p>{step.text}</p>
{proceedingStates.map(lifecycleState => { {proceedingStates.map(lifecycleState => {
return ( return (
<Tooltip
key={lifecycleState}
title={
lifecycleState === 'PUBLISHED' &&
this.state.isPublished
? text
: ''
}
>
<Button <Button
size={'small'} size={'small'}
style={{ marginRight: 3 }} style={{ marginRight: 3 }}
disabled={
lifecycleState === 'PUBLISHED' &&
this.state.isPublished
}
onClick={() => onClick={() =>
this.showReasonModal(lifecycleState) this.showReasonModal(lifecycleState)
} }
@ -258,6 +297,7 @@ class LifeCycle extends React.Component {
> >
{lifecycleState} {lifecycleState}
</Button> </Button>
</Tooltip>
); );
})} })}
</div> </div>

@ -232,6 +232,7 @@ class Release extends React.Component {
this.changeCurrentLifecycleStatus this.changeCurrentLifecycleStatus
} }
lifecycle={lifecycle} lifecycle={lifecycle}
appReleases={this.props.location.state}
/> />
)} )}
</Skeleton> </Skeleton>

Loading…
Cancel
Save