mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Disable publish button for releases with a published app
This commit is contained in:
parent
c4927c3508
commit
0df8c8d91c
@ -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,
|
||||
|
||||
@ -702,7 +702,14 @@ class AppDetailsDrawer extends React.Component {
|
||||
title="Click to view full details"
|
||||
placement="topRight"
|
||||
>
|
||||
<Link to={'apps/releases/' + release.uuid}>
|
||||
<Link
|
||||
to={{
|
||||
pathname: `apps/releases/${release.uuid}`,
|
||||
state: {
|
||||
fullAppDetails: app.applicationReleases,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Card className="release-card">
|
||||
<Meta
|
||||
avatar={
|
||||
@ -773,7 +780,12 @@ class AppDetailsDrawer extends React.Component {
|
||||
<Text>Add new release for the application</Text>
|
||||
</div>
|
||||
<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">
|
||||
Add
|
||||
|
||||
@ -27,6 +27,7 @@ import {
|
||||
Steps,
|
||||
Alert,
|
||||
Tabs,
|
||||
Tooltip,
|
||||
} from 'antd';
|
||||
import axios from 'axios';
|
||||
import ReactQuill from 'react-quill';
|
||||
@ -198,6 +199,35 @@ class LifeCycle extends React.Component {
|
||||
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 = (proceedingStates, lifecycleState) => {
|
||||
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'
|
||||
) {
|
||||
isPublished = true;
|
||||
return isPublished;
|
||||
}
|
||||
}
|
||||
isPublished = false;
|
||||
return isPublished;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
currentStatus,
|
||||
@ -207,6 +237,7 @@ class LifeCycle extends React.Component {
|
||||
lifeCycleStates,
|
||||
} = this.state;
|
||||
const { lifecycle } = this.props;
|
||||
const text = <span>Already an app is in publish state</span>;
|
||||
let proceedingStates = [];
|
||||
if (
|
||||
lifecycle !== null &&
|
||||
@ -247,17 +278,33 @@ class LifeCycle extends React.Component {
|
||||
<p>{step.text}</p>
|
||||
{proceedingStates.map(lifecycleState => {
|
||||
return (
|
||||
<Button
|
||||
size={'small'}
|
||||
style={{ marginRight: 3 }}
|
||||
onClick={() =>
|
||||
this.showReasonModal(lifecycleState)
|
||||
// eslint-disable-next-line react/jsx-key
|
||||
<Tooltip
|
||||
title={
|
||||
this.checkReleaseLifeCycleStatus(
|
||||
proceedingStates,
|
||||
lifecycleState,
|
||||
) === true
|
||||
? text
|
||||
: ''
|
||||
}
|
||||
key={lifecycleState}
|
||||
type={'primary'}
|
||||
>
|
||||
{lifecycleState}
|
||||
</Button>
|
||||
<Button
|
||||
size={'small'}
|
||||
style={{ marginRight: 3 }}
|
||||
disabled={this.checkReleaseLifeCycleStatus(
|
||||
proceedingStates,
|
||||
lifecycleState,
|
||||
)}
|
||||
onClick={() =>
|
||||
this.showReasonModal(lifecycleState)
|
||||
}
|
||||
key={lifecycleState}
|
||||
type={'primary'}
|
||||
>
|
||||
{lifecycleState}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@ -232,6 +232,7 @@ class Release extends React.Component {
|
||||
this.changeCurrentLifecycleStatus
|
||||
}
|
||||
lifecycle={lifecycle}
|
||||
appReleases={this.props.location.state}
|
||||
/>
|
||||
)}
|
||||
</Skeleton>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user