From: Grégoire Aubert Date: Fri, 20 Oct 2017 13:45:41 +0000 (+0200) Subject: Display last available version editions in read only when current edition is not... X-Git-Tag: 6.7-RC1~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=afdec5241d0bdeb88583f520c75d6f4de2d583d7;p=sonarqube.git Display last available version editions in read only when current edition is not found --- diff --git a/server/sonar-web/src/main/js/apps/marketplace/App.tsx b/server/sonar-web/src/main/js/apps/marketplace/App.tsx index c5012002c95..c57f3de78fd 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/App.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/App.tsx @@ -39,7 +39,14 @@ import { import { Edition, EditionStatus, getEditionsList, getEditionStatus } from '../../api/marketplace'; import { RawQuery } from '../../helpers/query'; import { translate } from '../../helpers/l10n'; -import { getEditionsForVersion, filterPlugins, parseQuery, Query, serializeQuery } from './utils'; +import { + getEditionsForLastVersion, + getEditionsForVersion, + filterPlugins, + parseQuery, + Query, + serializeQuery +} from './utils'; export interface Props { editionsUrl: string; @@ -51,6 +58,7 @@ export interface Props { interface State { editions?: Edition[]; + editionsReadOnly: boolean; editionStatus?: EditionStatus; loadingEditions: boolean; loadingPlugins: boolean; @@ -73,6 +81,7 @@ export default class App extends React.PureComponent { constructor(props: Props) { super(props); this.state = { + editionsReadOnly: false, loadingEditions: true, loadingPlugins: true, pending: { @@ -113,37 +122,26 @@ export default class App extends React.PureComponent { fetchAllPlugins = () => { this.setState({ loadingPlugins: true }); - Promise.all([getInstalledPluginsWithUpdates(), getAvailablePlugins()]).then( - ([installed, available]) => { - if (this.mounted) { - this.setState({ - loadingPlugins: false, - plugins: sortBy(uniqBy([...installed, ...available.plugins], 'key'), 'name') - }); - } - }, - () => { - if (this.mounted) { - this.setState({ loadingPlugins: false }); - } + Promise.all([ + getInstalledPluginsWithUpdates(), + getAvailablePlugins() + ]).then(([installed, available]) => { + if (this.mounted) { + this.setState({ + loadingPlugins: false, + plugins: sortBy(uniqBy([...installed, ...available.plugins], 'key'), 'name') + }); } - ); + }, this.stopLoadingPlugins); }; fetchUpdatesOnly = () => { this.setState({ loadingPlugins: true }); - getPluginUpdates().then( - plugins => { - if (this.mounted) { - this.setState({ loadingPlugins: false, plugins }); - } - }, - () => { - if (this.mounted) { - this.setState({ loadingPlugins: false }); - } + getPluginUpdates().then(plugins => { + if (this.mounted) { + this.setState({ loadingPlugins: false, plugins }); } - ); + }, this.stopLoadingPlugins); }; fetchPendingPlugins = () => @@ -171,10 +169,16 @@ export default class App extends React.PureComponent { getEditionsList(this.props.editionsUrl).then( editionsPerVersion => { if (this.mounted) { - this.setState({ + const newState = { editions: getEditionsForVersion(editionsPerVersion, this.props.sonarqubeVersion), + editionsReadOnly: false, loadingEditions: false - }); + }; + if (!newState.editions) { + newState.editions = getEditionsForLastVersion(editionsPerVersion); + newState.editionsReadOnly = true; + } + this.setState(newState); } }, () => { @@ -204,6 +208,12 @@ export default class App extends React.PureComponent { this.context.router.push({ pathname: this.props.location.pathname, query }); }; + stopLoadingPlugins = () => { + if (this.mounted) { + this.setState({ loadingPlugins: false }); + } + }; + render() { const { standaloneMode } = this.props; const { editions, editionStatus, loadingPlugins, plugins, pending } = this.state; @@ -222,7 +232,7 @@ export default class App extends React.PureComponent { updateEditionStatus={this.updateEditionStatus} /> )} - {!standaloneMode && ( + {standaloneMode && ( )} @@ -232,7 +242,7 @@ export default class App extends React.PureComponent { loading={this.state.loadingEditions} editionStatus={editionStatus} editionsUrl={this.props.editionsUrl} - readOnly={!standaloneMode} + readOnly={!standaloneMode || this.state.editionsReadOnly} sonarqubeVersion={this.props.sonarqubeVersion} updateCenterActive={this.props.updateCenterActive} updateEditionStatus={this.updateEditionStatus} diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx index 4bc679d4d2a..79498c13948 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginsList.tsx @@ -74,6 +74,7 @@ export default class PluginsList extends React.PureComponent { /> ); } + return null; }; render() { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx index d637c7116ae..27130a159a4 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx @@ -48,7 +48,7 @@ export default class EditionBox extends React.PureComponent { if (isInstalled) { return ( - + {translate('marketplace.installed')} ); @@ -59,6 +59,8 @@ export default class EditionBox extends React.PureComponent { render() { const { edition, editionStatus, readOnly } = this.props; const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; + const uninstallInProgress = + editionStatus && editionStatus.installationStatus === 'UNINSTALL_IN_PROGRESS'; const installInProgress = editionStatus && ['AUTOMATIC_IN_PROGRESS', 'AUTOMATIC_READY'].includes(editionStatus.installationStatus); @@ -74,20 +76,20 @@ export default class EditionBox extends React.PureComponent { {translate('marketplace.learn_more')} {!readOnly && - !isInstalled && ( - - )} - {!readOnly && - isInstalled && ( - - )} + (isInstalled ? ( + + ) : ( + + ))} ); diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx index 2430200ac27..f21e8a30588 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionsStatusNotif.tsx @@ -49,8 +49,67 @@ export default class EditionsStatusNotif extends React.PureComponent + + {edition ? ( + translateWithParameters( + 'marketplace.status_x.' + editionStatus.installationStatus, + edition.name + ) + ) : ( + translate('marketplace.status', editionStatus.installationStatus) + )} + + {!readOnly && ( + + )} + {!readOnly && this.state.openRestart && } + + ); + } + + renderManualMsg(edition?: Edition) { + const { editionStatus } = this.props; + return ( +
+ {edition ? ( + translateWithParameters( + 'marketplace.status_x.' + editionStatus.installationStatus, + edition.name + ) + ) : ( + translate('marketplace.status', editionStatus.installationStatus) + )} +

+ {edition && ( + + {translate('marketplace.download_package')} + + )} + + {translate('marketplace.how_to_install')} + +

+ + {translate('marketplace.how_to_install')} + +
+ ); + } + + renderStatusAlert() { + const { editionStatus } = this.props; const { installationStatus, nextEditionKey } = editionStatus; const nextEdition = this.props.editions && this.props.editions.find(edition => edition.key === nextEditionKey); @@ -65,59 +124,9 @@ export default class EditionsStatusNotif extends React.PureComponent - - {nextEdition ? ( - translateWithParameters( - 'marketplace.status_x.' + installationStatus, - nextEdition.name - ) - ) : ( - translate('marketplace.status', installationStatus) - )} - - {!readOnly && ( - - )} - {!readOnly && - this.state.openRestart && } - - ); + return this.renderRestartMsg(nextEdition); case 'MANUAL_IN_PROGRESS': - return ( -
- {nextEdition ? ( - translateWithParameters( - 'marketplace.status_x.' + installationStatus, - nextEdition.name - ) - ) : ( - translate('marketplace.status', installationStatus) - )} -

- {nextEdition && ( - - {translate('marketplace.download_package')} - - )} - - {translate('marketplace.how_to_install')} - -

- - {translate('marketplace.how_to_install')} - -
- ); + return this.renderManualMsg(nextEdition); } return null; } @@ -127,12 +136,9 @@ export default class EditionsStatusNotif extends React.PureComponent {installError && ( -
+
{installError} - +
diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx index 10def5d07bd..58b58f371a7 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx @@ -130,11 +130,11 @@ export default class LicenseEditionSet extends React.PureComponent