diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2021-08-25 11:54:11 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-08-27 20:03:16 +0000 |
commit | de15b5ae07c0e6f9bc6744f4d80f42147ffe9bcf (patch) | |
tree | 9a64503f1d4ccdddc9c74c03a52184ebf5e3ed90 /server/sonar-web/src/main/js/apps | |
parent | 79b13ac2a166eea535deceade405e8b99b098c64 (diff) | |
download | sonarqube-de15b5ae07c0e6f9bc6744f4d80f42147ffe9bcf.tar.gz sonarqube-de15b5ae07c0e6f9bc6744f4d80f42147ffe9bcf.zip |
SONAR-15175 Warn server id is not usable when running on embedded dtabase
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
4 files changed, 175 insertions, 66 deletions
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 ( <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); 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<Props> = {}) { 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" /> <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" diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap index 9792203714f..42c55f420c6 100644 --- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -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> `; |