* 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 {
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>
</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);
*/
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'
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();
});
loading={false}
logLevel="INFO"
onLogLevelChange={jest.fn()}
+ productionDatabase={true}
showActions={true}
{...props}
/>
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>
`;