diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-19 16:00:36 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-23 08:01:13 -0700 |
commit | 33a0c7138e444e5eba8272a48206c6bb05297793 (patch) | |
tree | 977e8c1e3bca3f4f2e4aead5b65bbbb16379d72d /server/sonar-web/src/main/js/apps/marketplace/components | |
parent | f03c5e9858dd86ecd78e6278aa6f95d146ada270 (diff) | |
download | sonarqube-33a0c7138e444e5eba8272a48206c6bb05297793.tar.gz sonarqube-33a0c7138e444e5eba8272a48206c6bb05297793.zip |
Update marketplace editions json format
Diffstat (limited to 'server/sonar-web/src/main/js/apps/marketplace/components')
8 files changed, 62 insertions, 47 deletions
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 8ca571c0bfc..70920158b75 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 @@ -32,35 +32,44 @@ interface Props { export default class EditionBox extends React.PureComponent<Props> { handleInstall = () => this.props.onInstall(this.props.edition); + renderBadge(isInstalled?: boolean, installInProgress?: boolean) { + const { edition, editionStatus } = this.props; + const installReady = editionStatus && editionStatus.installationStatus === 'AUTOMATIC_READY'; + const isInstalling = + installInProgress && editionStatus && editionStatus.nextEditionKey === edition.key; + if (isInstalling) { + return ( + <span className="marketplace-edition-badge badge badge-normal-size"> + {installReady ? translate('marketplace.pending') : translate('marketplace.installing')} + </span> + ); + } + if (isInstalled) { + return ( + <span className="marketplace-edition-badge badge badge-normal-size"> + <CheckIcon size={14} className="little-spacer-right text-text-top" /> + {translate('marketplace.installed')} + </span> + ); + } + return null; + } + render() { const { edition, editionStatus } = this.props; + const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; const installInProgress = editionStatus && ['AUTOMATIC_IN_PROGRESS', 'AUTOMATIC_READY'].includes(editionStatus.installationStatus); - const installReady = editionStatus && editionStatus.installationStatus === 'AUTOMATIC_READY'; - const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; - const isInstalling = - installInProgress && editionStatus && editionStatus.nextEditionKey === edition.key; return ( <div className="boxed-group boxed-group-inner marketplace-edition"> - {isInstalled && - !isInstalling && ( - <span className="marketplace-edition-badge badge badge-normal-size"> - <CheckIcon size={14} className="little-spacer-right text-text-top" /> - {translate('marketplace.installed')} - </span> - )} - {isInstalling && ( - <span className="marketplace-edition-badge badge badge-normal-size"> - {installReady ? translate('marketplace.pending') : translate('marketplace.installing')} - </span> - )} + {this.renderBadge(isInstalled, installInProgress)} <div> <h3 className="spacer-bottom">{edition.name}</h3> - <p>{edition.desc}</p> + <p>{edition.textDescription}</p> </div> <div className="marketplace-edition-action spacer-top"> - <a href={edition.more_link} target="_blank"> + <a href={edition.homeUrl} target="_blank"> {translate('marketplace.learn_more')} </a> {!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 672a0b7a28b..7679e29a591 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 @@ -21,7 +21,7 @@ import * as React from 'react'; import RestartForm from '../../../components/common/RestartForm'; import CloseIcon from '../../../components/icons-components/CloseIcon'; import { dismissErrorMessage, Edition, EditionStatus } from '../../../api/marketplace'; -import { translate } from '../../../helpers/l10n'; +import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { editions?: Edition[]; @@ -67,7 +67,10 @@ export default class EditionsStatusNotif extends React.PureComponent<Props, Stat <div className="alert alert-success"> <span> {nextEdition ? ( - translate('marketplace.status_x.' + installationStatus, nextEdition.name) + translateWithParameters( + 'marketplace.status_x.' + installationStatus, + nextEdition.name + ) ) : ( translate('marketplace.status', installationStatus) )} @@ -82,7 +85,10 @@ export default class EditionsStatusNotif extends React.PureComponent<Props, Stat return ( <div className="alert alert-danger"> {nextEdition ? ( - translate('marketplace.status_x.' + installationStatus, nextEdition.name) + translateWithParameters( + 'marketplace.status_x.' + installationStatus, + nextEdition.name + ) ) : ( translate('marketplace.status', installationStatus) )} @@ -91,7 +97,7 @@ export default class EditionsStatusNotif extends React.PureComponent<Props, Stat <a className="button spacer-right" download={`sonarqube-${nextEdition.name}.zip`} - href={nextEdition.download_link} + href={nextEdition.downloadUrl} target="_blank"> {translate('marketplace.download_package')} </a> 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 496c5fe988d..10def5d07bd 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 @@ -90,7 +90,7 @@ export default class LicenseEditionSet extends React.PureComponent<Props, State> }; getLicenseFormUrl = (edition: Edition) => { - let url = edition.request_license_link; + let url = edition.requestUrl; if (this.state.formData) { const query = stringify(omitNil(this.state.formData)); if (query) { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx index 0eb4f92f95d..ceaf61a7aa5 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx @@ -31,10 +31,10 @@ const DEFAULT_STATUS: EditionStatus = { const DEFAULT_EDITION: Edition = { key: 'foo', name: 'Foo', - desc: 'Foo desc', - download_link: 'download_url', - more_link: 'more_url', - request_license_link: 'license_url' + textDescription: 'Foo desc', + downloadUrl: 'download_url', + homeUrl: 'more_url', + requestUrl: 'license_url' }; it('should display the edition', () => { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionForm-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionForm-test.tsx index 2beffa70f82..bb6e8d213ee 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionForm-test.tsx @@ -33,10 +33,10 @@ const applyLicense = require('../../../../api/marketplace').applyLicense as jest const DEFAULT_EDITION = { key: 'foo', name: 'Foo', - desc: 'Foo desc', - download_link: 'download_url', - more_link: 'more_url', - request_license_link: 'license_url' + textDescription: 'Foo desc', + downloadUrl: 'download_url', + homeUrl: 'more_url', + requestUrl: 'license_url' }; beforeEach(() => { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionSet-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionSet-test.tsx index 4e682893968..0992ebb36bd 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionSet-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/LicenseEditionSet-test.tsx @@ -41,10 +41,10 @@ const getLicensePreview = require('../../../../api/marketplace').getLicensePrevi const DEFAULT_EDITION = { key: 'foo', name: 'Foo', - desc: 'Foo desc', - download_link: 'download_url', - more_link: 'more_url', - request_license_link: 'license_url' + textDescription: 'Foo desc', + downloadUrl: 'download_url', + homeUrl: 'more_url', + requestUrl: 'license_url' }; beforeEach(() => { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/UninstallEditionForm-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/UninstallEditionForm-test.tsx index 037c2d33cd2..3f52d0cce13 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/UninstallEditionForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/UninstallEditionForm-test.tsx @@ -31,10 +31,10 @@ const uninstallEdition = require('../../../../api/marketplace').uninstallEdition const DEFAULT_EDITION = { key: 'foo', name: 'Foo', - desc: 'Foo desc', - download_link: 'download_url', - more_link: 'more_url', - request_license_link: 'license_url' + textDescription: 'Foo desc', + downloadUrl: 'download_url', + homeUrl: 'more_url', + requestUrl: 'license_url' }; beforeEach(() => { diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionForm-test.tsx.snap index e3951bfeaff..382c562bb02 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/LicenseEditionForm-test.tsx.snap @@ -55,23 +55,23 @@ exports[`should display correctly 1`] = ` className="modal-body" edition={ Object { - "desc": "Foo desc", - "download_link": "download_url", + "downloadUrl": "download_url", + "homeUrl": "more_url", "key": "foo", - "more_link": "more_url", "name": "Foo", - "request_license_link": "license_url", + "requestUrl": "license_url", + "textDescription": "Foo desc", } } editions={ Array [ Object { - "desc": "Foo desc", - "download_link": "download_url", + "downloadUrl": "download_url", + "homeUrl": "more_url", "key": "foo", - "more_link": "more_url", "name": "Foo", - "request_license_link": "license_url", + "requestUrl": "license_url", + "textDescription": "Foo desc", }, ] } |