System: {
'High Availability': boolean;
'Logs Level': string;
+ 'Server ID': string;
};
}
import SystemUpgradeNotif from './system-upgrade/SystemUpgradeNotif';
import { translate } from '../../../helpers/l10n';
import { ClusterSysInfo, getSystemInfo, SysInfo } from '../../../api/system';
-import { getSystemLogsLevel, isCluster, parseQuery, Query, serializeQuery } from '../utils';
+import {
+ getServerId,
+ getSystemLogsLevel,
+ isCluster,
+ parseQuery,
+ Query,
+ serializeQuery
+} from '../utils';
import { RawQuery } from '../../../helpers/query';
import '../styles.css';
<Helmet title={translate('system_info.page')} />
<SystemUpgradeNotif />
<PageHeader
- loading={loading}
isCluster={isCluster(sysInfoData)}
+ loading={loading}
logLevel={getSystemLogsLevel(sysInfoData)}
- showActions={sysInfoData !== undefined}
onLogLevelChange={this.fetchSysInfo}
+ serverId={getServerId(sysInfoData)}
+ showActions={sysInfoData !== undefined}
/>
{this.renderSysInfo()}
</div>
import * as React from 'react';
import ChangeLogLevelForm from './ChangeLogLevelForm';
import RestartForm from '../../../components/common/RestartForm';
+import { getFileNameSuffix } from '../utils';
import { EditButton } from '../../../components/ui/buttons';
import { getBaseUrl } from '../../../helpers/urls';
import { translate } from '../../../helpers/l10n';
cluster: boolean;
logLevel: string;
onLogLevelChange: () => void;
+ serverId?: string;
}
interface State {
id="download-link"
className="button spacer-left"
onClick={this.removeElementFocus}
- download="sonarqube_system_info.json"
+ download={`sonarqube-support-info-${getFileNameSuffix(this.props.serverId)}.json`}
target="_blank">
{translate('system.download_system_info')}
</a>
isCluster: boolean;
loading: boolean;
logLevel: string;
- showActions: boolean;
onLogLevelChange: () => void;
+ serverId?: string;
+ showActions: boolean;
}
export default function PageHeader(props: Props) {
canRestart={!props.isCluster}
cluster={props.isCluster}
logLevel={props.logLevel}
+ serverId={props.serverId}
onLogLevelChange={props.onLogLevelChange}
/>
)}
],
System: {
'High Availability': true,
- 'Logs Level': 'INFO'
+ 'Logs Level': 'INFO',
+ 'Server ID': 'MyServerId'
}
};
import PageActions from '../PageActions';
import { click } from '../../../../helpers/testUtils';
+jest.mock('../../utils', () => ({
+ getFileNameSuffix: (suffix?: string) => `filesuffix(${suffix || ''})`
+}));
+
it('should render correctly', () => {
- expect(
- shallow(
- <PageActions
- canDownloadLogs={true}
- canRestart={true}
- cluster={false}
- logLevel="INFO"
- onLogLevelChange={() => {}}
- />
- )
- ).toMatchSnapshot();
+ expect(getWrapper({ serverId: 'MyServerId' })).toMatchSnapshot();
});
it('should render without restart and log download', () => {
expect(
- shallow(
- <PageActions
- canDownloadLogs={false}
- canRestart={false}
- cluster={true}
- logLevel="INFO"
- onLogLevelChange={() => {}}
- />
- )
+ getWrapper({ canDownloadLogs: false, canRestart: false, cluster: true })
).toMatchSnapshot();
});
it('should open restart modal', () => {
- const wrapper = shallow(
- <PageActions
- canDownloadLogs={true}
- canRestart={true}
- cluster={false}
- logLevel="INFO"
- onLogLevelChange={() => {}}
- />
- );
+ const wrapper = getWrapper();
click(wrapper.find('#restart-server-button'));
expect(wrapper.find('RestartForm')).toHaveLength(1);
});
it('should open change log level modal', () => {
- const wrapper = shallow(
+ const wrapper = getWrapper();
+ click(wrapper.find('#edit-logs-level-button'));
+ expect(wrapper.find('ChangeLogLevelForm')).toHaveLength(1);
+});
+
+function getWrapper(props = {}) {
+ return shallow(
<PageActions
canDownloadLogs={true}
canRestart={true}
cluster={false}
logLevel="INFO"
onLogLevelChange={() => {}}
+ {...props}
/>
);
- click(wrapper.find('#edit-logs-level-button'));
- expect(wrapper.find('ChangeLogLevelForm')).toHaveLength(1);
-});
+}
Search: { 'Number of Nodes': 1 },
System: {
'High Availability': true,
- 'Logs Level': 'DEBUG'
+ 'Logs Level': 'DEBUG',
+ 'Server ID': 'MyServerId'
}
};
Object {
"High Availability": true,
"Logs Level": "INFO",
+ "Server ID": "MyServerId",
}
}
/>
</div>
<a
className="button spacer-left"
- download="sonarqube_system_info.json"
+ download="sonarqube-support-info-filesuffix(MyServerId).json"
href="/api/system/info"
id="download-link"
onClick={[Function]}
</span>
<a
className="button spacer-left"
- download="sonarqube_system_info.json"
+ download="sonarqube-support-info-filesuffix().json"
href="/api/system/info"
id="download-link"
onClick={[Function]}
Object {
"High Availability": true,
"Logs Level": "DEBUG",
+ "Server ID": "MyServerId",
}
}
/>
);
}
+export function getServerId(sysInfoData?: SysInfo): string | undefined {
+ return sysInfoData && sysInfoData['System']['Server ID'];
+}
+
export function getSystemLogsLevel(sysInfoData?: SysInfo): string {
const defaultLevel = LOGS_LEVELS[0];
if (!sysInfoData) {
};
}
+export function getFileNameSuffix(suffix?: string) {
+ const now = new Date();
+ return (
+ `${suffix ? suffix + '-' : ''}` +
+ `${now.getFullYear()}-${now.getMonth() + 1}-` +
+ `${now.getDate()}-${now.getHours()}-${now.getMinutes()}`
+ );
+}
+
export function groupSections(sysInfoData: SysValueObject) {
const mainSection: SysValueObject = {};
const sections: SysInfoSection = {};