From de15b5ae07c0e6f9bc6744f4d80f42147ffe9bcf Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Wed, 25 Aug 2021 11:54:11 +0200 Subject: [PATCH] SONAR-15175 Warn server id is not usable when running on embedded dtabase --- .../license-manager.md | 3 + .../js/apps/system/components/PageHeader.tsx | 81 ++++++---- .../components/__tests__/PageHeader-test.tsx | 6 +- .../__tests__/__snapshots__/App-test.tsx.snap | 4 +- .../__snapshots__/PageHeader-test.tsx.snap | 150 ++++++++++++++---- .../resources/org/sonar/l10n/core.properties | 1 + 6 files changed, 179 insertions(+), 66 deletions(-) diff --git a/server/sonar-docs/src/pages/instance-administration/license-manager.md b/server/sonar-docs/src/pages/instance-administration/license-manager.md index c43e7584ed8..b862cc75399 100644 --- a/server/sonar-docs/src/pages/instance-administration/license-manager.md +++ b/server/sonar-docs/src/pages/instance-administration/license-manager.md @@ -8,6 +8,9 @@ _Starting in [Developer Edition](https://redirect.sonarsource.com/editions/devel You can use the License Manager to retrieve your server ID (required for obtaining a License Key) and configure your SonarSource-provided License key. +[[warning]] +|The server ID is specific to the current database system. Make sure to configure an external database for long-term use prior to requesting your license with this server ID. + ### Retrieving the server ID The server ID is always available on the License Manager page, as well as in the **System Info** section at **Administration > System**. diff --git a/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx index 4ad50569370..133d94d554e 100644 --- a/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx @@ -18,9 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { connect } from 'react-redux'; import { ClipboardButton } from '../../../components/controls/clipboard'; +import { Alert } from '../../../components/ui/Alert'; import { toShortNotSoISOString } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; +import { getAppState, Store } from '../../../store/rootReducer'; import PageActions from './PageActions'; export interface Props { @@ -28,13 +31,22 @@ export interface Props { loading: boolean; logLevel: string; onLogLevelChange: () => void; + productionDatabase: boolean; serverId?: string; showActions: boolean; version?: string; } -export default function PageHeader(props: Props) { - const { isCluster, loading, logLevel, serverId, showActions, version } = props; +export function PageHeader(props: Props) { + const { + isCluster, + loading, + logLevel, + serverId, + showActions, + version, + productionDatabase + } = props; return (

{translate('system_info.page')}

@@ -54,38 +66,51 @@ export default function PageHeader(props: Props) { )} {serverId && version && ( -
-
- - - - - - - - - - - -
- {translate('system.server_id')} - - {serverId} -
- {translate('system.version')} - {version}
-
- + {!productionDatabase && ( + + {translate('system.not_production_database_warning')} + + )} +
+
+ + + + + + + + + + + +
+ {translate('system.server_id')} + + {serverId} +
+ {translate('system.version')} + {version}
+
+ - {translate('system.copy_id_info')} - + {translate('system.copy_id_info')} + +
)}
); } + +const mapStateToProps = (store: Store) => ({ + productionDatabase: getAppState(store).productionDatabase +}); + +export default connect(mapStateToProps)(PageHeader); diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx index 32c07327d72..34e2ed927b2 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx @@ -19,7 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import PageHeader, { Props } from '../PageHeader'; +import { PageHeader, Props } from '../PageHeader'; jest.mock('../../../../helpers/dates', () => ({ toShortNotSoISOString: () => '2019-01-01' @@ -27,6 +27,9 @@ jest.mock('../../../../helpers/dates', () => ({ it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); + expect( + shallowRender({ productionDatabase: false, serverId: 'foo-bar', version: '7.7.0.1234' }) + ).toMatchSnapshot('on embedded database'); expect(shallowRender({ loading: true, showActions: false })).toMatchSnapshot(); expect(shallowRender({ serverId: 'foo-bar', version: '7.7.0.1234' })).toMatchSnapshot(); }); @@ -38,6 +41,7 @@ function shallowRender(props: Partial = {}) { loading={false} logLevel="INFO" onLogLevelChange={jest.fn()} + productionDatabase={true} showActions={true} {...props} /> diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap index 1e3f9399b54..c1191f63727 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap @@ -13,7 +13,7 @@ exports[`should render correctly: cluster sysinfo 1`] = ` title="system_info.page" /> - -
- - - - - - - - - - - -
- - system.server_id - - - - foo-bar - -
- - system.version - - - 7.7.0.1234 -
-
- + + + + + system.server_id + + + + + foo-bar + + + + + + + system.version + + + + 7.7.0.1234 + + + + +
+ + system.copy_id_info + + + + +`; + +exports[`should render correctly: on embedded database 1`] = ` +
+

+ system_info.page +

+ +
+ - system.copy_id_info - + system.not_production_database_warning + +
+
+ + + + + + + + + + + +
+ + system.server_id + + + + foo-bar + +
+ + system.version + + + 7.7.0.1234 +
+
+ + system.copy_id_info + +
`; 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 90bcc63c696..99e5a57b313 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2967,6 +2967,7 @@ system.restart_server=Restart Server system.instance_restarting={instance} restart is in progress. Ongoing {link} are completing. system.search_nodes_title=Search Nodes system.see_sonarqube_downloads=See All SonarQube Downloads +system.not_production_database_warning=This server ID is valid only for the embedded database, which should be considered disposable. Consider configuring an external database for long-term use prior to requesting your license. system.server_id=Server ID system.set_log_level=Set logs level system.show_intermediate_versions=Show intermediate versions -- 2.39.5