From 24963a443c4459d03baab2b583e3690250d056aa Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 9 Aug 2019 10:23:50 +0200 Subject: [PATCH] Improve Edition handling --- server/sonar-web/src/main/js/api/system.ts | 3 +- .../main/js/app/components/GlobalFooter.tsx | 7 +- .../app/components/GlobalFooterContainer.tsx | 5 +- .../main/js/app/components/StartupModal.tsx | 5 +- .../__tests__/GlobalFooter-test.tsx | 2 +- .../__tests__/StartupModal-test.tsx | 2 +- server/sonar-web/src/main/js/app/types.d.ts | 12 +-- .../src/main/js/apps/marketplace/App.tsx | 3 +- .../main/js/apps/marketplace/AppContainer.tsx | 5 +- .../main/js/apps/marketplace/EditionBoxes.tsx | 8 +- .../src/main/js/apps/marketplace/Header.tsx | 3 +- .../__tests__/EditionBoxes-test.tsx | 2 +- .../marketplace/__tests__/Header-test.tsx | 2 +- .../__snapshots__/EditionBoxes-test.tsx.snap | 12 +-- .../marketplace/components/EditionBox.tsx | 5 +- .../components/__tests__/EditionBox-test.tsx | 12 +-- .../__snapshots__/EditionBox-test.tsx.snap | 2 +- .../src/main/js/apps/marketplace/utils.ts | 57 ------------- .../js/apps/system/__tests__/utils-test.ts | 9 ++- .../src/main/js/apps/system/utils.ts | 11 +-- .../sonar-web/src/main/js/helpers/editions.ts | 80 +++++++++++++++++++ .../sonar-web/src/main/js/types/editions.ts | 34 ++++++++ server/sonar-web/src/main/js/types/system.ts | 32 ++++++++ 23 files changed, 198 insertions(+), 115 deletions(-) create mode 100644 server/sonar-web/src/main/js/helpers/editions.ts create mode 100644 server/sonar-web/src/main/js/types/editions.ts create mode 100644 server/sonar-web/src/main/js/types/system.ts diff --git a/server/sonar-web/src/main/js/api/system.ts b/server/sonar-web/src/main/js/api/system.ts index 57e3210f165..3936416d805 100644 --- a/server/sonar-web/src/main/js/api/system.ts +++ b/server/sonar-web/src/main/js/api/system.ts @@ -19,6 +19,7 @@ */ import { getJSON, post, postJSON, requestTryAndRepeatUntil } from 'sonar-ui-common/helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; +import { SystemUpgrade } from '../types/system'; export function setLogLevel(level: string): Promise { return post('/api/system/change_log_level', { level }).catch(throwGlobalError); @@ -33,7 +34,7 @@ export function getSystemStatus(): Promise<{ id: string; version: string; status } export function getSystemUpgrades(): Promise<{ - upgrades: T.SystemUpgrade[]; + upgrades: SystemUpgrade[]; updateCenterRefresh: string; }> { return getJSON('/api/system/upgrades'); diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx index 49b5609512a..5ffecb7d0ce 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx @@ -21,16 +21,17 @@ import * as React from 'react'; import { Link } from 'react-router'; import { Alert } from 'sonar-ui-common/components/ui/Alert'; import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; -import { EDITIONS } from '../../apps/marketplace/utils'; import InstanceMessage from '../../components/common/InstanceMessage'; +import { getEdition } from '../../helpers/editions'; import { isSonarCloud } from '../../helpers/system'; +import { EditionKey } from '../../types/editions'; import GlobalFooterBranding from './GlobalFooterBranding'; import GlobalFooterSonarCloud from './GlobalFooterSonarCloud'; interface Props { hideLoggedInInfo?: boolean; productionDatabase: boolean; - sonarqubeEdition?: T.EditionKey; + sonarqubeEdition?: EditionKey; sonarqubeVersion?: string; } @@ -44,7 +45,7 @@ export default function GlobalFooter({ return ; } - const currentEdition = EDITIONS.find(edition => edition.key === sonarqubeEdition); + const currentEdition = sonarqubeEdition && getEdition(sonarqubeEdition); return (