aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/system
diff options
context:
space:
mode:
authorphilippe-perrin-sonarsource <philippe.perrin@sonarsource.com>2022-01-27 11:06:59 +0100
committersonartech <sonartech@sonarsource.com>2022-01-27 20:03:05 +0000
commitdca8354af94e9feb46ea2312857e000aaa232372 (patch)
tree336b645749ab1fb1b1abdac19a69c70257e98b68 /server/sonar-web/src/main/js/apps/system
parent85f744be340d8f404978341186dd77cc05584f31 (diff)
downloadsonarqube-dca8354af94e9feb46ea2312857e000aaa232372.tar.gz
sonarqube-dca8354af94e9feb46ea2312857e000aaa232372.zip
SONAR-15945 Get rid of T namespace in sonar-web
Diffstat (limited to 'server/sonar-web/src/main/js/apps/system')
-rw-r--r--server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts7
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/App.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/system/utils.ts75
10 files changed, 66 insertions, 48 deletions
diff --git a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
index 3194894a6ab..accdb5de9b5 100644
--- a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts
@@ -19,6 +19,7 @@
*/
import { mockClusterSysInfo, mockStandaloneSysInfo } from '../../../helpers/testMocks';
+import { SysInfoBase, SysInfoStandalone } from '../../../types/types';
import * as u from '../utils';
describe('parseQuery', () => {
@@ -68,7 +69,7 @@ describe('getSystemLogsLevel', () => {
})
)
).toBe('INFO');
- expect(u.getSystemLogsLevel({} as T.SysInfoStandalone)).toBe('INFO');
+ expect(u.getSystemLogsLevel({} as SysInfoStandalone)).toBe('INFO');
});
});
@@ -169,13 +170,13 @@ describe('getNodeName', () => {
describe('getHealthCauses', () => {
it('should return the correct information', () => {
- expect(u.getHealthCauses({ 'Health Causes': ['Foo'] } as T.SysInfoBase)).toEqual(['Foo']);
+ expect(u.getHealthCauses({ 'Health Causes': ['Foo'] } as SysInfoBase)).toEqual(['Foo']);
});
});
describe('getHealth', () => {
it('should return the correct information', () => {
- expect(u.getHealth({ Health: 'GREEN' } as T.SysInfoBase)).toEqual('GREEN');
+ expect(u.getHealth({ Health: 'GREEN' } as SysInfoBase)).toEqual('GREEN');
});
});
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 7e5cdc02608..45532818e90 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
@@ -24,6 +24,7 @@ import { getSystemInfo } from '../../../api/system';
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
import UpdateNotification from '../../../app/components/update-notification/UpdateNotification';
import { translate } from '../../../helpers/l10n';
+import { SysInfoCluster, SysInfoStandalone } from '../../../types/types';
import '../styles.css';
import {
getClusterVersion,
@@ -43,7 +44,7 @@ type Props = WithRouterProps;
interface State {
loading: boolean;
- sysInfoData?: T.SysInfoCluster | T.SysInfoStandalone;
+ sysInfoData?: SysInfoCluster | SysInfoStandalone;
}
export class App extends React.PureComponent<Props, State> {
diff --git a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx
index 28b52667d18..b1bdf0109a1 100644
--- a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx
@@ -20,6 +20,7 @@
import { sortBy } from 'lodash';
import * as React from 'react';
import { translate } from '../../../helpers/l10n';
+import { SysInfoAppNode, SysInfoCluster, SysInfoSearchNode } from '../../../types/types';
import {
getAppNodes,
getClusterMainCardSection,
@@ -33,7 +34,7 @@ import HealthCard from './info-items/HealthCard';
interface Props {
expandedCards: string[];
- sysInfoData: T.SysInfoCluster;
+ sysInfoData: SysInfoCluster;
toggleCard: (toggledCard: string) => void;
}
@@ -53,7 +54,7 @@ export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard
<li className="note system-info-health-title">
{translate('system.application_nodes_title')}
</li>
- {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: T.SysInfoAppNode) => (
+ {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: SysInfoAppNode) => (
<HealthCard
health={getHealth(node)}
healthCauses={getHealthCauses(node)}
@@ -65,7 +66,7 @@ export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard
/>
))}
<li className="note system-info-health-title">{translate('system.search_nodes_title')}</li>
- {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: T.SysInfoSearchNode) => (
+ {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: SysInfoSearchNode) => (
<HealthCard
key={getNodeName(node)}
name={getNodeName(node)}
diff --git a/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx
index 650d10fcde1..b39595cb16f 100644
--- a/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx
@@ -19,6 +19,7 @@
*/
import { map } from 'lodash';
import * as React from 'react';
+import { SysInfoStandalone } from '../../../types/types';
import {
getHealth,
getHealthCauses,
@@ -30,7 +31,7 @@ import HealthCard from './info-items/HealthCard';
interface Props {
expandedCards: string[];
- sysInfoData: T.SysInfoStandalone;
+ sysInfoData: SysInfoStandalone;
toggleCard: (toggledCard: string) => void;
}
diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx
index 5c403aadf4f..175143c3f32 100644
--- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx
@@ -22,18 +22,19 @@ import * as React from 'react';
import BoxedGroupAccordion from '../../../../components/controls/BoxedGroupAccordion';
import { Alert } from '../../../../components/ui/Alert';
import { translate } from '../../../../helpers/l10n';
+import { HealthType, SysInfoValueObject } from '../../../../types/types';
import { getLogsLevel, groupSections, LOGS_LEVELS } from '../../utils';
import HealthItem from './HealthItem';
import Section from './Section';
interface Props {
biggerHealth?: boolean;
- health?: T.HealthType;
+ health?: HealthType;
healthCauses?: string[];
onClick: (toggledCard: string) => void;
open: boolean;
name: string;
- sysInfoData: T.SysInfoValueObject;
+ sysInfoData: SysInfoValueObject;
}
export default function HealthCard({
diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx
index f6022748fb5..56442b15ee8 100644
--- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx
@@ -20,10 +20,11 @@
import classNames from 'classnames';
import * as React from 'react';
import { Alert } from '../../../../components/ui/Alert';
+import { HealthType } from '../../../../types/types';
interface Props {
className?: string;
- health: T.HealthType;
+ health: HealthType;
healthCause: string;
}
diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx
index 3c9fa6acebd..70b0209aa80 100644
--- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx
@@ -22,13 +22,14 @@ import * as React from 'react';
import StatusIndicator from '../../../../components/common/StatusIndicator';
import Tooltip from '../../../../components/controls/Tooltip';
import { translateWithParameters } from '../../../../helpers/l10n';
+import { HealthType } from '../../../../types/types';
import HealthCauseItem from './HealthCauseItem';
interface Props {
biggerHealth?: boolean;
name?: string;
className?: string;
- health: T.HealthType;
+ health: HealthType;
healthCauses?: string[];
}
diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx
index 34087dcf973..85a9a0c1895 100644
--- a/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx
@@ -19,11 +19,12 @@
*/
import { map } from 'lodash';
import * as React from 'react';
+import { SysInfoValueObject } from '../../../../types/types';
import SysInfoItem from './SysInfoItem';
interface Props {
name?: string;
- items: T.SysInfoValueObject;
+ items: SysInfoValueObject;
}
export default function Section({ name, items }: Props) {
diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx
index 4cd91ec7c53..aa299cc81da 100644
--- a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx
+++ b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx
@@ -20,17 +20,18 @@
import { map } from 'lodash';
import * as React from 'react';
import { translate } from '../../../../helpers/l10n';
+import { HealthType, SysInfoValue } from '../../../../types/types';
import { HEALTH_FIELD, STATE_FIELD } from '../../utils';
import HealthItem from './HealthItem';
export interface Props {
name: string;
- value: T.SysInfoValue;
+ value: SysInfoValue;
}
export default function SysInfoItem({ name, value }: Props) {
if (name === HEALTH_FIELD || name === STATE_FIELD) {
- return <HealthItem className="no-margin" health={value as T.HealthType} />;
+ return <HealthItem className="no-margin" health={value as HealthType} />;
}
if (value instanceof Array) {
return <code>{JSON.stringify(value)}</code>;
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 a9857503449..93978f0d9af 100644
--- a/server/sonar-web/src/main/js/apps/system/utils.ts
+++ b/server/sonar-web/src/main/js/apps/system/utils.ts
@@ -20,6 +20,17 @@
import { each, memoize, omit, omitBy, pickBy, sortBy } from 'lodash';
import { formatMeasure } from '../../helpers/measures';
import { cleanQuery, parseAsArray, parseAsString, serializeStringArray } from '../../helpers/query';
+import {
+ RawQuery,
+ SysInfoAppNode,
+ SysInfoBase,
+ SysInfoCluster,
+ SysInfoLogging,
+ SysInfoSearchNode,
+ SysInfoSection,
+ SysInfoStandalone,
+ SysInfoValueObject
+} from '../../types/types';
export interface Query {
expandedCards: string[];
@@ -51,7 +62,7 @@ export const VERSION_FIELD = 'Version';
export const WEB_LOGGING_FIELD = 'Web Logging';
export const WEB_PREFIX = 'Web';
-export function ignoreInfoFields(sysInfoObject: T.SysInfoValueObject) {
+export function ignoreInfoFields(sysInfoObject: SysInfoValueObject) {
return omit(sysInfoObject, [
ALMS_FIELD,
BUNDLED_FIELD,
@@ -65,15 +76,15 @@ export function ignoreInfoFields(sysInfoObject: T.SysInfoValueObject) {
]);
}
-export function getHealth(sysInfoObject: T.SysInfoBase) {
+export function getHealth(sysInfoObject: SysInfoBase) {
return sysInfoObject[HEALTH_FIELD];
}
-export function getHealthCauses(sysInfoObject: T.SysInfoBase) {
+export function getHealthCauses(sysInfoObject: SysInfoBase) {
return sysInfoObject[HEALTH_CAUSES_FIELD];
}
-export function getLogsLevel(sysInfoObject?: T.SysInfoValueObject): string {
+export function getLogsLevel(sysInfoObject?: SysInfoValueObject): string {
if (sysInfoObject !== undefined) {
if (isLogInfoBlock(sysInfoObject)) {
return sysInfoObject[LOGS_LEVEL_FIELD];
@@ -90,46 +101,44 @@ export function getLogsLevel(sysInfoObject?: T.SysInfoValueObject): string {
return DEFAULT_LOG_LEVEL;
}
-export function getAppNodes(sysInfoData: T.SysInfoCluster): T.SysInfoAppNode[] {
+export function getAppNodes(sysInfoData: SysInfoCluster): SysInfoAppNode[] {
return sysInfoData[APP_NODES_FIELD];
}
-export function getSearchNodes(sysInfoData: T.SysInfoCluster): T.SysInfoSearchNode[] {
+export function getSearchNodes(sysInfoData: SysInfoCluster): SysInfoSearchNode[] {
return sysInfoData[SEARCH_NODES_FIELD];
}
export function isCluster(
- sysInfoData: T.SysInfoCluster | T.SysInfoStandalone
-): sysInfoData is T.SysInfoCluster {
+ sysInfoData: SysInfoCluster | SysInfoStandalone
+): sysInfoData is SysInfoCluster {
return sysInfoData[SYSTEM_FIELD] && sysInfoData[SYSTEM_FIELD][HA_FIELD] === true;
}
-export function isLogInfoBlock(
- sysInfoObject: T.SysInfoValueObject
-): sysInfoObject is T.SysInfoLogging {
+export function isLogInfoBlock(sysInfoObject: SysInfoValueObject): sysInfoObject is SysInfoLogging {
return sysInfoObject[LOGS_LEVEL_FIELD] !== undefined;
}
export function hasLoggingInfo(
- sysInfoObject: T.SysInfoValueObject
-): sysInfoObject is T.SysInfoStandalone | T.SysInfoAppNode {
+ sysInfoObject: SysInfoValueObject
+): sysInfoObject is SysInfoStandalone | SysInfoAppNode {
return Boolean(sysInfoObject[WEB_LOGGING_FIELD] || sysInfoObject[CE_LOGGING_FIELD]);
}
-export function getServerId(sysInfoData: T.SysInfoCluster | T.SysInfoStandalone): string {
+export function getServerId(sysInfoData: SysInfoCluster | SysInfoStandalone): string {
return sysInfoData && sysInfoData[SYSTEM_FIELD][SERVER_ID_FIELD];
}
-export function getVersion(sysInfoData: T.SysInfoStandalone): string | undefined {
+export function getVersion(sysInfoData: SysInfoStandalone): string | undefined {
return sysInfoData && sysInfoData[SYSTEM_FIELD][VERSION_FIELD];
}
-export function getClusterVersion(sysInfoData: T.SysInfoCluster): string | undefined {
+export function getClusterVersion(sysInfoData: SysInfoCluster): string | undefined {
const appNodes = getAppNodes(sysInfoData);
return appNodes.length > 0 ? appNodes[0][SYSTEM_FIELD][VERSION_FIELD] : undefined;
}
-export function getSystemLogsLevel(sysInfoData: T.SysInfoCluster | T.SysInfoStandalone): string {
+export function getSystemLogsLevel(sysInfoData: SysInfoCluster | SysInfoStandalone): string {
if (isCluster(sysInfoData)) {
const logLevels = sortBy(getAppNodes(sysInfoData).map(getLogsLevel), logLevel =>
LOGS_LEVELS.indexOf(logLevel)
@@ -140,20 +149,20 @@ export function getSystemLogsLevel(sysInfoData: T.SysInfoCluster | T.SysInfoStan
}
}
-export function getNodeName(nodeInfo: T.SysInfoAppNode | T.SysInfoSearchNode): string {
+export function getNodeName(nodeInfo: SysInfoAppNode | SysInfoSearchNode): string {
return nodeInfo[NAME_FIELD];
}
-function getSystemData(sysInfoData: T.SysInfoBase): T.SysInfoValueObject {
- const statData: T.SysInfoValueObject = {};
- const statistics = sysInfoData[STATS_FIELD] as T.SysInfoValueObject; // TODO
+function getSystemData(sysInfoData: SysInfoBase): SysInfoValueObject {
+ const statData: SysInfoValueObject = {};
+ const statistics = sysInfoData[STATS_FIELD] as SysInfoValueObject; // TODO
if (statistics) {
statData['Lines of Code'] = formatMeasure(statistics[NCLOC_FIELD] as number, 'INT');
}
return { ...sysInfoData[SYSTEM_FIELD], ...statData };
}
-export function getClusterMainCardSection(sysInfoData: T.SysInfoCluster): T.SysInfoValueObject {
+export function getClusterMainCardSection(sysInfoData: SysInfoCluster): SysInfoValueObject {
return {
...getSystemData(sysInfoData),
...omit(sysInfoData, [
@@ -167,7 +176,7 @@ export function getClusterMainCardSection(sysInfoData: T.SysInfoCluster): T.SysI
};
}
-export function getStandaloneMainSections(sysInfoData: T.SysInfoBase): T.SysInfoValueObject {
+export function getStandaloneMainSections(sysInfoData: SysInfoBase): SysInfoValueObject {
return {
...getSystemData(sysInfoData),
...(omitBy(
@@ -178,19 +187,19 @@ export function getStandaloneMainSections(sysInfoData: T.SysInfoBase): T.SysInfo
key.startsWith(CE_FIELD_PREFIX) ||
key.startsWith(SEARCH_PREFIX) ||
key.startsWith(WEB_PREFIX)
- ) as T.SysInfoValueObject)
+ ) as SysInfoValueObject)
};
}
-export function getStandaloneSecondarySections(sysInfoData: T.SysInfoBase): T.SysInfoSection {
+export function getStandaloneSecondarySections(sysInfoData: SysInfoBase): SysInfoSection {
return {
- Web: pickBy(sysInfoData, (_, key) => key.startsWith(WEB_PREFIX)) as T.SysInfoValueObject,
+ Web: pickBy(sysInfoData, (_, key) => key.startsWith(WEB_PREFIX)) as SysInfoValueObject,
'Compute Engine': pickBy(sysInfoData, (_, key) =>
key.startsWith(CE_FIELD_PREFIX)
- ) as T.SysInfoValueObject,
+ ) as SysInfoValueObject,
'Search Engine': pickBy(sysInfoData, (_, key) =>
key.startsWith(SEARCH_PREFIX)
- ) as T.SysInfoValueObject
+ ) as SysInfoValueObject
};
}
@@ -203,9 +212,9 @@ export function getFileNameSuffix(suffix?: string) {
);
}
-export function groupSections(sysInfoData: T.SysInfoValueObject) {
- const mainSection: T.SysInfoValueObject = {};
- const sections: T.SysInfoSection = {};
+export function groupSections(sysInfoData: SysInfoValueObject) {
+ const mainSection: SysInfoValueObject = {};
+ const sections: SysInfoSection = {};
each(sysInfoData, (item, key) => {
if (typeof item !== 'object' || item instanceof Array) {
mainSection[key] = item;
@@ -217,13 +226,13 @@ export function groupSections(sysInfoData: T.SysInfoValueObject) {
}
export const parseQuery = memoize(
- (urlQuery: T.RawQuery): Query => ({
+ (urlQuery: RawQuery): Query => ({
expandedCards: parseAsArray(urlQuery.expand, parseAsString)
})
);
export const serializeQuery = memoize(
- (query: Query): T.RawQuery =>
+ (query: Query): RawQuery =>
cleanQuery({
expand: serializeStringArray(query.expandedCards)
})