aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-15 08:56:18 +0100
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-15 11:40:43 +0100
commitec5f54c943df55d53fa6fae8632fcaede060ae19 (patch)
tree074682bcee788d3a1009595751fa94a98b120980 /server/sonar-web/src/main/js/apps
parent27e0b0190229a78b0d57907b3b49e2ea381826ab (diff)
downloadsonarqube-ec5f54c943df55d53fa6fae8632fcaede060ae19.tar.gz
sonarqube-ec5f54c943df55d53fa6fae8632fcaede060ae19.zip
SONAR-10120 Add server id and date in the system info json name
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/App.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/PageActions.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx49
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/StandaloneSysInfos-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/StandaloneSysInfos-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/apps/system/utils.ts13
10 files changed, 54 insertions, 42 deletions
diff --git a/server/sonar-web/src/main/js/apps/system/components/App.tsx b/server/sonar-web/src/main/js/apps/system/components/App.tsx
index 4ca3983b019..7c3c01adf5c 100644
--- a/server/sonar-web/src/main/js/apps/system/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/App.tsx
@@ -26,7 +26,14 @@ import StandaloneSysInfos from './StandaloneSysInfos';
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';
@@ -124,11 +131,12 @@ export default class App extends React.PureComponent<Props, State> {
<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>
diff --git a/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx
index 1499dfde562..dfda4b9e904 100644
--- a/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx
@@ -20,6 +20,7 @@
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';
@@ -30,6 +31,7 @@ interface Props {
cluster: boolean;
logLevel: string;
onLogLevelChange: () => void;
+ serverId?: string;
}
interface State {
@@ -139,7 +141,7 @@ export default class PageActions extends React.PureComponent<Props, 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>
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 3828cc2cd72..653a3841154 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
@@ -25,8 +25,9 @@ interface Props {
isCluster: boolean;
loading: boolean;
logLevel: string;
- showActions: boolean;
onLogLevelChange: () => void;
+ serverId?: string;
+ showActions: boolean;
}
export default function PageHeader(props: Props) {
@@ -39,6 +40,7 @@ export default function PageHeader(props: Props) {
canRestart={!props.isCluster}
cluster={props.isCluster}
logLevel={props.logLevel}
+ serverId={props.serverId}
onLogLevelChange={props.onLogLevelChange}
/>
)}
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx
index 643e09c5a28..ad20d28f61f 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx
@@ -45,7 +45,8 @@ const sysInfoData: ClusterSysInfo = {
],
System: {
'High Availability': true,
- 'Logs Level': 'INFO'
+ 'Logs Level': 'INFO',
+ 'Server ID': 'MyServerId'
}
};
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx
index 1aa058f3238..5bf79f1de3d 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx
@@ -22,58 +22,41 @@ import { shallow } from 'enzyme';
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);
-});
+}
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/StandaloneSysInfos-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/StandaloneSysInfos-test.tsx
index f3a45b2883f..121a57d0941 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/StandaloneSysInfos-test.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/StandaloneSysInfos-test.tsx
@@ -30,7 +30,8 @@ const sysInfoData: SysInfo = {
Search: { 'Number of Nodes': 1 },
System: {
'High Availability': true,
- 'Logs Level': 'DEBUG'
+ 'Logs Level': 'DEBUG',
+ 'Server ID': 'MyServerId'
}
};
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap
index 4cee8e00890..ca216f72e04 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap
@@ -17,6 +17,7 @@ exports[`should support more than two nodes 1`] = `
Object {
"High Availability": true,
"Logs Level": "INFO",
+ "Server ID": "MyServerId",
}
}
/>
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap
index 3556043a83b..dd7d6f39b36 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap
@@ -80,7 +80,7 @@ exports[`should render correctly 1`] = `
</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]}
@@ -122,7 +122,7 @@ exports[`should render without restart and log download 1`] = `
</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]}
diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/StandaloneSysInfos-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/StandaloneSysInfos-test.tsx.snap
index 13877f72b86..e5832de513c 100644
--- a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/StandaloneSysInfos-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/StandaloneSysInfos-test.tsx.snap
@@ -17,6 +17,7 @@ exports[`should render correctly 1`] = `
Object {
"High Availability": true,
"Logs Level": "DEBUG",
+ "Server ID": "MyServerId",
}
}
/>
diff --git a/server/sonar-web/src/main/js/apps/system/utils.ts b/server/sonar-web/src/main/js/apps/system/utils.ts
index 503084200e4..e24f796cd60 100644
--- a/server/sonar-web/src/main/js/apps/system/utils.ts
+++ b/server/sonar-web/src/main/js/apps/system/utils.ts
@@ -98,6 +98,10 @@ export function isCluster(sysInfoData?: SysInfo): boolean {
);
}
+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) {
@@ -166,6 +170,15 @@ export function getStandaloneSecondarySections(sysInfoData: SysInfo): SysInfoSec
};
}
+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 = {};