Browse Source

SONAR-15175 Warn server id is not usable when running on embedded dtabase

tags/9.1.0.47736
Mathieu Suen 2 years ago
parent
commit
de15b5ae07

+ 3
- 0
server/sonar-docs/src/pages/instance-administration/license-manager.md View File

@@ -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**.


+ 53
- 28
server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx View File

@@ -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 (
<header className="page-header">
<h1 className="page-title">{translate('system_info.page')}</h1>
@@ -54,38 +66,51 @@ export default function PageHeader(props: Props) {
</div>
)}
{serverId && version && (
<div className="system-info-copy-paste-id-info boxed-group display-flex-center">
<div className="flex-1">
<table className="width-100">
<tbody>
<tr>
<th>
<strong>{translate('system.server_id')}</strong>
</th>
<td>
<code>{serverId}</code>
</td>
</tr>
<tr>
<th>
<strong>{translate('system.version')}</strong>
</th>
<td>{version}</td>
</tr>
</tbody>
</table>
</div>
<ClipboardButton
className="flex-0"
copyValue={`SonarQube ID information
<div className="system-info-copy-paste-id-info boxed-group ">
{!productionDatabase && (
<Alert className="width-100" variant="warning">
{translate('system.not_production_database_warning')}
</Alert>
)}
<div className="display-flex-center">
<div className="flex-1">
<table className="width-100">
<tbody>
<tr>
<th>
<strong>{translate('system.server_id')}</strong>
</th>
<td>
<code>{serverId}</code>
</td>
</tr>
<tr>
<th>
<strong>{translate('system.version')}</strong>
</th>
<td>{version}</td>
</tr>
</tbody>
</table>
</div>
<ClipboardButton
className="flex-0"
copyValue={`SonarQube ID information
Server ID: ${serverId}
Version: ${version}
Date: ${toShortNotSoISOString(Date.now())}
`}>
{translate('system.copy_id_info')}
</ClipboardButton>
{translate('system.copy_id_info')}
</ClipboardButton>
</div>
</div>
)}
</header>
);
}

const mapStateToProps = (store: Store) => ({
productionDatabase: getAppState(store).productionDatabase
});

export default connect(mapStateToProps)(PageHeader);

+ 5
- 1
server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx View File

@@ -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<Props> = {}) {
loading={false}
logLevel="INFO"
onLogLevelChange={jest.fn()}
productionDatabase={true}
showActions={true}
{...props}
/>

+ 2
- 2
server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/App-test.tsx.snap View File

@@ -13,7 +13,7 @@ exports[`should render correctly: cluster sysinfo 1`] = `
title="system_info.page"
/>
<SystemUpgradeNotif />
<PageHeader
<Connect(PageHeader)
isCluster={true}
loading={false}
logLevel="DEBUG"
@@ -215,7 +215,7 @@ exports[`should render correctly: stand-alone sysinfo 1`] = `
title="system_info.page"
/>
<SystemUpgradeNotif />
<PageHeader
<Connect(PageHeader)
isCluster={false}
loading={false}
logLevel="DEBUG"

+ 115
- 35
server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap View File

@@ -56,50 +56,130 @@ exports[`should render correctly 3`] = `
serverId="foo-bar"
/>
<div
className="system-info-copy-paste-id-info boxed-group display-flex-center"
className="system-info-copy-paste-id-info boxed-group "
>
<div
className="flex-1"
className="display-flex-center"
>
<table
className="width-100"
<div
className="flex-1"
>
<tbody>
<tr>
<th>
<strong>
system.server_id
</strong>
</th>
<td>
<code>
foo-bar
</code>
</td>
</tr>
<tr>
<th>
<strong>
system.version
</strong>
</th>
<td>
7.7.0.1234
</td>
</tr>
</tbody>
</table>
</div>
<ClipboardButton
className="flex-0"
copyValue="SonarQube ID information
<table
className="width-100"
>
<tbody>
<tr>
<th>
<strong>
system.server_id
</strong>
</th>
<td>
<code>
foo-bar
</code>
</td>
</tr>
<tr>
<th>
<strong>
system.version
</strong>
</th>
<td>
7.7.0.1234
</td>
</tr>
</tbody>
</table>
</div>
<ClipboardButton
className="flex-0"
copyValue="SonarQube ID information
Server ID: foo-bar
Version: 7.7.0.1234
Date: 2019-01-01
"
>
system.copy_id_info
</ClipboardButton>
</div>
</div>
</header>
`;

exports[`should render correctly: on embedded database 1`] = `
<header
className="page-header"
>
<h1
className="page-title"
>
system_info.page
</h1>
<PageActions
canDownloadLogs={false}
canRestart={false}
cluster={true}
logLevel="INFO"
onLogLevelChange={[MockFunction]}
serverId="foo-bar"
/>
<div
className="system-info-copy-paste-id-info boxed-group "
>
<Alert
className="width-100"
variant="warning"
>
system.copy_id_info
</ClipboardButton>
system.not_production_database_warning
</Alert>
<div
className="display-flex-center"
>
<div
className="flex-1"
>
<table
className="width-100"
>
<tbody>
<tr>
<th>
<strong>
system.server_id
</strong>
</th>
<td>
<code>
foo-bar
</code>
</td>
</tr>
<tr>
<th>
<strong>
system.version
</strong>
</th>
<td>
7.7.0.1234
</td>
</tr>
</tbody>
</table>
</div>
<ClipboardButton
className="flex-0"
copyValue="SonarQube ID information
Server ID: foo-bar
Version: 7.7.0.1234
Date: 2019-01-01
"
>
system.copy_id_info
</ClipboardButton>
</div>
</div>
</header>
`;

+ 1
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -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

Loading…
Cancel
Save