From a8e976cb9ef832197897c7d466ba6ab67c7e6625 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Wed, 30 May 2018 11:58:36 +0200 Subject: [PATCH] SONAR-10811 Update editions boxes for marketing needs --- .../src/images/sonarsource-icon.png | Bin 0 -> 625 bytes .../src/tooltips/editions/community.md | 3 - .../src/tooltips/editions/datacenter.md | 4 +- .../src/tooltips/editions/developer.md | 8 ++- .../src/tooltips/editions/enterprise.md | 8 ++- .../src/main/js/apps/marketplace/App.tsx | 7 +- .../main/js/apps/marketplace/EditionBoxes.tsx | 13 +++- .../src/main/js/apps/marketplace/Header.tsx | 17 ++++- .../__tests__/EditionBoxes-test.tsx | 32 +++++++-- .../marketplace/__tests__/Header-test.tsx | 27 ++++++++ .../__snapshots__/EditionBoxes-test.tsx.snap | 63 +++++++++++++----- .../__snapshots__/Header-test.tsx.snap | 47 +++++++++++++ .../marketplace/components/EditionBox.tsx | 26 +++----- .../components/__tests__/EditionBox-test.tsx | 19 +++--- .../__snapshots__/EditionBox-test.tsx.snap | 42 ++---------- .../src/main/js/apps/marketplace/style.css | 6 +- .../src/main/js/apps/marketplace/utils.ts | 2 +- .../resources/org/sonar/l10n/core.properties | 10 ++- 18 files changed, 230 insertions(+), 104 deletions(-) create mode 100644 server/sonar-docs/src/images/sonarsource-icon.png delete mode 100644 server/sonar-docs/src/tooltips/editions/community.md create mode 100644 server/sonar-web/src/main/js/apps/marketplace/__tests__/Header-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Header-test.tsx.snap diff --git a/server/sonar-docs/src/images/sonarsource-icon.png b/server/sonar-docs/src/images/sonarsource-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..430eb1f3688dbbdab379f07eef88d31d881d0e4e GIT binary patch literal 625 zcmV-%0*?KOP)P000>X1^@s6#OZ}&0006wNklNu+~LF(iZU`N+@g~bX*X^rNVi6F3%YzTRq| z!3P+`A&kVD@05^w@B==MHGgyuWOkI0R^t_H!<$%%PjGk!tPdygGv10dPdCt6ydP`+ z>b{U!!0z^%_Tv#8h&6xOa!+C$x6vPK{;Pzvp(*N(HD8(+WCrYU9L9V2LdQ{4P4%g! z_VrlvKP99=4B_Qi^PTy)3&fgl#F~e&6@5C6S{rMg#sF61SgZXUH}N*}v+!)#H+Tt; z;l~nEPpo;Wf!-(~z0*qf;oyQG4Ris$I*$ChgtRKwJgH;vk*4rhytrUU1O0)1Y{HRt z_9f2X!?yo>QIOW;Ja%Dc38}vwAHen!(z?5Ki-I)JXZRLJOGqml_ { }; render() { - const { currentEdition, standaloneMode, pendingPlugins } = this.props; + const { currentEdition = 'community', standaloneMode, pendingPlugins } = this.props; const { loadingPlugins, plugins } = this.state; const query = parseQuery(this.props.location.query); const filteredPlugins = query.search ? filterPlugins(plugins, query.search) : plugins; @@ -128,8 +128,11 @@ export default class App extends React.PureComponent {
-
+
+
+

{translate('marketplace.page.open_source_plugins')}

+
{ render() { const { currentEdition } = this.props; const { serverId, ncloc } = this.state; + const currentEditionIdx = EDITIONS.findIndex(edition => edition.key === currentEdition); + const visibleEditions = EDITIONS.slice(currentEditionIdx + 1); + + if (visibleEditions.length <= 0) { + return null; + } + return (
- {EDITIONS.map(edition => ( + {visibleEditions.map(edition => ( +

{translate('marketplace.page')}

-

{translate('marketplace.page.description')}

+

+ {translate('marketplace.page.you_are_running', currentEdition)} +

+

+ {currentEdition === 'datacenter' + ? translate('marketplace.page.description_best_edition') + : translate('marketplace.page.description')} +

); } diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx index dd49bb10079..9c35ee382d6 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/EditionBoxes-test.tsx @@ -23,19 +23,41 @@ import EditionBoxes from '../EditionBoxes'; jest.mock('../utils', () => ({ EDITIONS: [ - { key: 'comunity', homeUrl: 'more_url' }, - { key: 'developer', downloadUrl: 'download_url', homeUrl: 'more_url' } + { key: 'community', name: 'Community Edition', homeUrl: 'more_url' }, + { + key: 'developer', + name: 'Developer Edition', + homeUrl: 'more_url' + }, + { + key: 'enterprise', + name: 'Enterprise Edition', + homeUrl: 'more_url' + }, + { + key: 'datacenter', + name: 'Data Center Edition', + homeUrl: 'more_url' + } ] })); -it('should display the edition boxes correctly', () => { +it('should display the available edition boxes correctly', () => { expect(getWrapper()).toMatchSnapshot(); }); -it('should display the developer edition as installed', () => { +it('should display the enterprise and datacenter edition boxes', () => { expect(getWrapper({ currentEdition: 'developer' })).toMatchSnapshot(); }); +it('should display the datacenter edition box only', () => { + expect(getWrapper({ currentEdition: 'enterprise' })).toMatchSnapshot(); +}); + +it('should not display any edition box', () => { + expect(getWrapper({ currentEdition: 'datacenter' }).type()).toBeNull(); +}); + function getWrapper(props = {}) { - return shallow(); + return shallow(); } diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/Header-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/__tests__/Header-test.tsx new file mode 100644 index 00000000000..3e0a609c781 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/Header-test.tsx @@ -0,0 +1,27 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { shallow } from 'enzyme'; +import Header from '../Header'; + +it('should render with installed editions', () => { + expect(shallow(
)).toMatchSnapshot(); + expect(shallow(
)).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap index 687a2cde364..d8abf481899 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/EditionBoxes-test.tsx.snap @@ -1,57 +1,88 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should display the developer edition as installed 1`] = ` +exports[`should display the available edition boxes correctly 1`] = `
+
`; -exports[`should display the edition boxes correctly 1`] = ` +exports[`should display the datacenter edition box only 1`] = `
+
+`; + +exports[`should display the enterprise and datacenter edition boxes 1`] = ` +
+
`; diff --git a/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Header-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Header-test.tsx.snap new file mode 100644 index 00000000000..4b6c283ca46 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/__tests__/__snapshots__/Header-test.tsx.snap @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render with installed editions 1`] = ` +
+

+ marketplace.page +

+

+ marketplace.page.you_are_running.community +

+

+ marketplace.page.description +

+
+`; + +exports[`should render with installed editions 2`] = ` +
+

+ marketplace.page +

+

+ marketplace.page.you_are_running.datacenter +

+

+ marketplace.page.description_best_edition +

+
+`; 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 968aa566020..55309126c7e 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 @@ -18,10 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import CheckIcon from '../../../components/icons-components/CheckIcon'; -import { translate } from '../../../helpers/l10n'; -import DocInclude from '../../../components/docs/DocInclude'; import { Edition, getEditionUrl } from '../utils'; +import DocInclude from '../../../components/docs/DocInclude'; +import { translate } from '../../../helpers/l10n'; interface Props { currentEdition: string; @@ -30,23 +29,16 @@ interface Props { serverId?: string; } -export default function EditionBox({ currentEdition, edition, ncloc, serverId }: Props) { - const isInstalled = currentEdition === edition.key; - const url = getEditionUrl(edition, { ncloc, serverId, sourceEdition: currentEdition }); +export default function EditionBox({ edition, ncloc, serverId, currentEdition }: Props) { return (
- {isInstalled && ( - - - {translate('marketplace.installed')} - - )} -
- -
+
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 4142b022e58..f4398076daf 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 @@ -29,13 +29,14 @@ const DEFAULT_EDITION = { }; it('should display the edition', () => { - expect(getWrapper({ ncloc: 1000, serverId: 'serverId' })).toMatchSnapshot(); + expect( + shallow( + + ) + ).toMatchSnapshot(); }); - -it('should show insalled badge', () => { - expect(getWrapper({ currentEdition: 'foo' })).toMatchSnapshot(); -}); - -function getWrapper(props = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap index 39c71155bc6..69af9d6c1db 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap @@ -4,50 +4,18 @@ exports[`should display the edition 1`] = ` -`; - -exports[`should show insalled badge 1`] = ` -
- - - marketplace.installed - -
- -
-
diff --git a/server/sonar-web/src/main/js/apps/marketplace/style.css b/server/sonar-web/src/main/js/apps/marketplace/style.css index 0e2ef2a2831..5016e1db61b 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/style.css +++ b/server/sonar-web/src/main/js/apps/marketplace/style.css @@ -20,7 +20,6 @@ .marketplace-editions { display: flex; flex-direction: row; - justify-content: space-between; margin-left: -8px; margin-right: -8px; } @@ -33,6 +32,11 @@ justify-content: space-between; margin-left: 8px; margin-right: 8px; + max-width: 50%; +} + +.marketplace-edition .markdown img { + width: 16px; } .marketplace-edition .markdown h3 { diff --git a/server/sonar-web/src/main/js/apps/marketplace/utils.ts b/server/sonar-web/src/main/js/apps/marketplace/utils.ts index 0c93eb22f17..29ea02d891f 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/utils.ts +++ b/server/sonar-web/src/main/js/apps/marketplace/utils.ts @@ -66,7 +66,7 @@ export const EDITIONS: Edition[] = [ export function getEditionUrl( edition: Edition, - data: { serverId?: string; ncloc?: number; sourceEdition: string } + data: { serverId?: string; ncloc?: number; sourceEdition?: string } ) { let url = edition.homeUrl; const query = stringify(omitNil(data)); diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 546935e89ba..f35e01ce87c 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -190,6 +190,7 @@ visibility=Visibility with=With worst=Worst yes=Yes +no=No @@ -2132,7 +2133,13 @@ workspace.no_rule=The rule has been removed or never existed. # #------------------------------------------------------------------------------ marketplace.page=Marketplace -marketplace.page.description=Discover and install new features +marketplace.page.description=Discover more features with the SonarSource Editions: +marketplace.page.description_best_edition=This Edition gives you access to all features of the SonarQube-SonarLint ecosystem, including all SonarSource code analyzers ! +marketplace.page.you_are_running.community=You are currently running a Community Edition. +marketplace.page.you_are_running.developer=You are currently running a Developer Edition. +marketplace.page.you_are_running.enterprise=You are currently running an Enterprise Edition. +marketplace.page.you_are_running.datacenter=You are currently running a Data Center Edition. +marketplace.page.open_source_plugins=Community plugins marketplace.instance_needs_to_be_restarted_to={instance} needs to be restarted in order to marketplace.install_x_plugins=install {nb} plugins marketplace.update_x_plugins=update {nb} plugins @@ -2154,6 +2161,7 @@ marketplace.checking_license=Checking your license... marketplace._installed=installed marketplace.available_under_commercial_license=Available under our commercial editions marketplace.learn_more=Learn more +marketplace.ask_for_information=Ask for more information marketplace.homepage=Homepage marketplace.issue_tracker=Issue Tracker marketplace.licensed_under_x=Licensed under {license} -- 2.39.5