aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/api/application.ts9
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts29
-rw-r--r--server/sonar-web/src/main/js/apps/overview/__tests__/utils-test.ts8
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Details-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsContent-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/List-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/RenameQualityGateForm-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/helpers/__tests__/qualityGates-test.ts37
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/application.ts31
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts145
-rw-r--r--server/sonar-web/src/main/js/helpers/qualityGates.ts26
-rw-r--r--server/sonar-web/src/main/js/helpers/testMocks.ts41
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/branches-test.ts5
-rw-r--r--server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx6
-rw-r--r--server/sonar-web/src/main/js/store/branches.ts5
-rw-r--r--server/sonar-web/src/main/js/types/application.ts24
-rw-r--r--server/sonar-web/src/main/js/types/quality-gates.ts79
-rw-r--r--server/sonar-web/src/main/js/types/types.d.ts29
20 files changed, 364 insertions, 125 deletions
diff --git a/server/sonar-web/src/main/js/api/application.ts b/server/sonar-web/src/main/js/api/application.ts
index 73de323927b..470e0798cd4 100644
--- a/server/sonar-web/src/main/js/api/application.ts
+++ b/server/sonar-web/src/main/js/api/application.ts
@@ -19,17 +19,12 @@
*/
import { getJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-
-export interface ApplicationLeak {
- date: string;
- project: string;
- projectName: string;
-}
+import { ApplicationPeriod } from '../types/application';
export function getApplicationLeak(
application: string,
branch?: string
-): Promise<Array<ApplicationLeak>> {
+): Promise<ApplicationPeriod[]> {
return getJSON('/api/applications/show_leak', { application, branch }).then(
r => r.leaks,
throwGlobalError
diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts
index a43ccdc0250..2af81857bfa 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -20,6 +20,7 @@
import { getJSON, post, postJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
import { BranchParameters } from '../types/branch-like';
+import { QualityGateApplicationStatus, QualityGateProjectStatus } from '../types/quality-gates';
export function fetchQualityGates(data: {
organization?: string;
@@ -139,35 +140,11 @@ export function dissociateGateWithProject(data: {
return post('/api/qualitygates/deselect', data).catch(throwGlobalError);
}
-export interface ConditionAnalysis {
- comparator: string;
- errorThreshold?: string;
- metric: string;
- periodIndex?: number;
- onLeak?: boolean;
- status: string;
- value: string;
- warningThreshold?: string;
-}
-
-export interface ApplicationProject {
- key: string;
- name: string;
- status: string;
- conditions: ConditionAnalysis[];
-}
-
-export interface ApplicationQualityGate {
- metrics: T.Metric[];
- projects: ApplicationProject[];
- status: string;
-}
-
export function getApplicationQualityGate(data: {
application: string;
branch?: string;
organization?: string;
-}): Promise<ApplicationQualityGate> {
+}): Promise<QualityGateApplicationStatus> {
return getJSON('/api/qualitygates/application_status', data).catch(throwGlobalError);
}
@@ -176,7 +153,7 @@ export function getQualityGateProjectStatus(
projectKey?: string;
projectId?: string;
} & BranchParameters
-): Promise<T.QualityGateProjectStatus> {
+): Promise<QualityGateProjectStatus> {
return getJSON('/api/qualitygates/project_status', data)
.then(r => r.projectStatus)
.catch(throwGlobalError);
diff --git a/server/sonar-web/src/main/js/apps/overview/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/overview/__tests__/utils-test.ts
index 5cf88d6dda6..fced030fc86 100644
--- a/server/sonar-web/src/main/js/apps/overview/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/apps/overview/__tests__/utils-test.ts
@@ -17,11 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import {
- mockMeasureEnhanced,
- mockMetric,
- mockQualityGateStatusCondition
-} from '../../../helpers/testMocks';
+import { mockQualityGateStatusCondition } from '../../../helpers/mocks/quality-gates';
+import { mockMeasureEnhanced, mockMetric } from '../../../helpers/testMocks';
+import { MetricKey } from '../../../types/metrics';
import { getThreshold } from '../utils';
// eslint-disable-next-line no-console
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Details-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Details-test.tsx
index d76b2b1475a..27835834681 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Details-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Details-test.tsx
@@ -21,12 +21,13 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { fetchQualityGate } from '../../../../api/quality-gates';
-import { mockCondition, mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
+import { mockCondition } from '../../../../helpers/testMocks';
import { addCondition, deleteCondition, replaceCondition } from '../../utils';
import { Details } from '../Details';
jest.mock('../../../../api/quality-gates', () => {
- const { mockQualityGate } = jest.requireActual('../../../../helpers/testMocks');
+ const { mockQualityGate } = jest.requireActual('../../../../helpers/mocks/quality-gates');
return {
fetchQualityGate: jest.fn().mockResolvedValue(mockQualityGate())
};
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsContent-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsContent-test.tsx
index 0235cffcd0a..6f21e9f6fb9 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsContent-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsContent-test.tsx
@@ -19,7 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
import { DetailsContent, DetailsContentProps } from '../DetailsContent';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx
index 5707ad41b51..c3d927b6efb 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx
@@ -21,7 +21,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import { click, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { setQualityGateAsDefault } from '../../../../api/quality-gates';
-import { mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
import DetailsHeader from '../DetailsHeader';
jest.mock('../../../../api/quality-gates', () => ({
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/List-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/List-test.tsx
index 685ddd9da1a..ae327226a47 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/List-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/List-test.tsx
@@ -19,7 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
import List from '../List';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx
index 99d12c3d3dc..39135e168fe 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx
@@ -26,7 +26,7 @@ import {
dissociateGateWithProject,
searchProjects
} from '../../../../api/quality-gates';
-import { mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
import Projects from '../Projects';
const qualityGate = mockQualityGate();
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/RenameQualityGateForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/RenameQualityGateForm-test.tsx
index a497f84a3e0..40eb1a513bf 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/RenameQualityGateForm-test.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/RenameQualityGateForm-test.tsx
@@ -19,7 +19,7 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { mockQualityGate } from '../../../../helpers/testMocks';
+import { mockQualityGate } from '../../../../helpers/mocks/quality-gates';
import RenameQualityGateForm from '../RenameQualityGateForm';
it('should render correctly', () => {
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/qualityGates-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/qualityGates-test.ts
index a7269d65869..0017092aa53 100644
--- a/server/sonar-web/src/main/js/helpers/__tests__/qualityGates-test.ts
+++ b/server/sonar-web/src/main/js/helpers/__tests__/qualityGates-test.ts
@@ -17,8 +17,14 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { extractStatusConditionsFromProjectStatus } from '../qualityGates';
-import { mockQualityGateProjectStatus } from '../testMocks';
+import {
+ mockQualityGateApplicationStatus,
+ mockQualityGateProjectStatus
+} from '../mocks/quality-gates';
+import {
+ extractStatusConditionsFromApplicationStatusChildProject,
+ extractStatusConditionsFromProjectStatus
+} from '../qualityGates';
describe('extractStatusConditionsFromProjectStatus', () => {
it('should correclty extract the conditions for the project status', () => {
@@ -34,3 +40,30 @@ describe('extractStatusConditionsFromProjectStatus', () => {
]);
});
});
+
+describe('extractStatusConditionsFromApplicationStatusChildProject', () => {
+ it('should correclty extract the conditions for the application child project status', () => {
+ expect(
+ extractStatusConditionsFromApplicationStatusChildProject(
+ mockQualityGateApplicationStatus().projects[0]
+ )
+ ).toEqual([
+ {
+ actual: '10',
+ error: '1.0',
+ level: 'ERROR',
+ metric: 'coverage',
+ op: 'GT',
+ period: undefined
+ },
+ {
+ actual: '5',
+ error: '1.0',
+ level: 'ERROR',
+ metric: 'new_bugs',
+ op: 'GT',
+ period: 1
+ }
+ ]);
+ });
+});
diff --git a/server/sonar-web/src/main/js/helpers/mocks/application.ts b/server/sonar-web/src/main/js/helpers/mocks/application.ts
new file mode 100644
index 00000000000..8f81272cea9
--- /dev/null
+++ b/server/sonar-web/src/main/js/helpers/mocks/application.ts
@@ -0,0 +1,31 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { ApplicationPeriod } from '../../types/application';
+
+export function mockApplicationPeriod(
+ overrides: Partial<ApplicationPeriod> = {}
+): ApplicationPeriod {
+ return {
+ date: '2017-10-01',
+ project: 'foo',
+ projectName: 'Foo',
+ ...overrides
+ };
+}
diff --git a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
new file mode 100644
index 00000000000..1da53327e55
--- /dev/null
+++ b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
@@ -0,0 +1,145 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+/* eslint-disable sonarjs/no-duplicate-string */
+import {
+ QualityGateApplicationStatus,
+ QualityGateProjectStatus,
+ QualityGateStatus,
+ QualityGateStatusCondition,
+ QualityGateStatusConditionEnhanced
+} from '../../types/quality-gates';
+import { mockMeasureEnhanced, mockMetric } from '../testMocks';
+
+export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.QualityGate {
+ return {
+ id: 1,
+ name: 'qualitygate',
+ ...overrides
+ };
+}
+
+export function mockQualityGateStatus(
+ overrides: Partial<QualityGateStatus> = {}
+): QualityGateStatus {
+ return {
+ ignoredConditions: false,
+ failedConditions: [mockQualityGateStatusConditionEnhanced()],
+ key: 'foo',
+ name: 'Foo',
+ status: 'ERROR',
+ ...overrides
+ };
+}
+
+export function mockQualityGateStatusCondition(
+ overrides: Partial<QualityGateStatusCondition> = {}
+): QualityGateStatusCondition {
+ return {
+ actual: '10',
+ error: '0',
+ level: 'ERROR',
+ metric: 'foo',
+ op: 'GT',
+ ...overrides
+ };
+}
+
+export function mockQualityGateStatusConditionEnhanced(
+ overrides: Partial<QualityGateStatusConditionEnhanced> = {}
+): QualityGateStatusConditionEnhanced {
+ return {
+ actual: '10',
+ error: '0',
+ level: 'ERROR',
+ metric: 'foo',
+ op: 'GT',
+ measure: mockMeasureEnhanced({ ...(overrides.measure || {}) }),
+ ...overrides
+ };
+}
+
+export function mockQualityGateProjectStatus(
+ overrides: Partial<QualityGateProjectStatus> = {}
+): QualityGateProjectStatus {
+ return {
+ conditions: [
+ {
+ actualValue: '0',
+ comparator: 'GT',
+ errorThreshold: '1.0',
+ metricKey: 'new_bugs',
+ periodIndex: 1,
+ status: 'OK'
+ }
+ ],
+ ignoredConditions: false,
+ status: 'OK',
+ ...overrides
+ };
+}
+
+export function mockQualityGateApplicationStatus(
+ overrides: Partial<QualityGateApplicationStatus> = {}
+): QualityGateApplicationStatus {
+ return {
+ metrics: [mockMetric(), mockMetric({ name: 'new_bugs', key: 'new_bugs', type: 'INT' })],
+ projects: [
+ {
+ key: 'foo',
+ name: 'Foo',
+ conditions: [
+ {
+ comparator: 'GT',
+ errorThreshold: '1.0',
+ metric: 'coverage',
+ status: 'ERROR',
+ value: '10'
+ },
+ {
+ comparator: 'GT',
+ errorThreshold: '1.0',
+ metric: 'new_bugs',
+ periodIndex: 1,
+ status: 'ERROR',
+ value: '5'
+ }
+ ],
+ status: 'ERROR'
+ },
+ {
+ key: 'bar',
+ name: 'Bar',
+ conditions: [
+ {
+ comparator: 'GT',
+ errorThreshold: '5.0',
+ metric: 'new_bugs',
+ periodIndex: 1,
+ status: 'ERROR',
+ value: '15'
+ }
+ ],
+ status: 'ERROR'
+ }
+ ],
+ status: 'ERROR',
+ ...overrides
+ };
+}
diff --git a/server/sonar-web/src/main/js/helpers/qualityGates.ts b/server/sonar-web/src/main/js/helpers/qualityGates.ts
index 6be70a2e417..8724ebc72bb 100644
--- a/server/sonar-web/src/main/js/helpers/qualityGates.ts
+++ b/server/sonar-web/src/main/js/helpers/qualityGates.ts
@@ -17,9 +17,15 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import {
+ QualityGateApplicationStatusChildProject,
+ QualityGateProjectStatus,
+ QualityGateStatusCondition
+} from '../types/quality-gates';
+
export function extractStatusConditionsFromProjectStatus(
- projectStatus: T.QualityGateProjectStatus
-): T.QualityGateStatusCondition[] {
+ projectStatus: QualityGateProjectStatus
+): QualityGateStatusCondition[] {
const { conditions } = projectStatus;
return conditions
? conditions.map(c => ({
@@ -32,3 +38,19 @@ export function extractStatusConditionsFromProjectStatus(
}))
: [];
}
+
+export function extractStatusConditionsFromApplicationStatusChildProject(
+ projectStatus: QualityGateApplicationStatusChildProject
+): QualityGateStatusCondition[] {
+ const { conditions } = projectStatus;
+ return conditions
+ ? conditions.map(c => ({
+ actual: c.value,
+ error: c.errorThreshold,
+ level: c.status,
+ metric: c.metric,
+ op: c.comparator,
+ period: c.periodIndex
+ }))
+ : [];
+}
diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts
index 356092537ec..9b43cec23f3 100644
--- a/server/sonar-web/src/main/js/helpers/testMocks.ts
+++ b/server/sonar-web/src/main/js/helpers/testMocks.ts
@@ -325,19 +325,6 @@ export function mockCondition(overrides: Partial<T.Condition> = {}): T.Condition
};
}
-export function mockQualityGateStatusCondition(
- overrides: Partial<T.QualityGateStatusCondition> = {}
-): T.QualityGateStatusCondition {
- return {
- actual: '10',
- error: '0',
- level: 'ERROR',
- metric: 'foo',
- op: 'GT',
- ...overrides
- };
-}
-
export function mockSnippetsByComponent(
component = 'main.js',
lines: number[] = [16]
@@ -543,14 +530,6 @@ export function mockPeriod(overrides: Partial<T.Period> = {}): T.Period {
};
}
-export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.QualityGate {
- return {
- id: 1,
- name: 'qualitygate',
- ...overrides
- };
-}
-
export function mockQualityProfile(overrides: Partial<Profile> = {}): Profile {
return {
activeDeprecatedRuleCount: 2,
@@ -605,26 +584,6 @@ export function mockQualityProfileExporter(override?: Partial<Exporter>): Export
};
}
-export function mockQualityGateProjectStatus(
- overrides: Partial<T.QualityGateProjectStatus> = {}
-): T.QualityGateProjectStatus {
- return {
- conditions: [
- {
- actualValue: '0',
- comparator: 'GT',
- errorThreshold: '1.0',
- metricKey: 'new_bugs',
- periodIndex: 1,
- status: 'OK'
- }
- ],
- ignoredConditions: false,
- status: 'OK',
- ...overrides
- };
-}
-
export function mockRouter(overrides: { push?: Function; replace?: Function } = {}) {
return {
createHref: jest.fn(),
diff --git a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
index e74645fafaa..dd2ffe3c8d7 100644
--- a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
+++ b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts
@@ -19,15 +19,16 @@
*/
import { getBranchLikeKey } from '../../helpers/branch-like';
import { mockBranch, mockPullRequest } from '../../helpers/mocks/branch-like';
-import { mockQualityGateStatusCondition } from '../../helpers/testMocks';
+import { mockQualityGateStatusCondition } from '../../helpers/mocks/quality-gates';
import { BranchLike } from '../../types/branch-like';
+import { QualityGateStatusCondition } from '../../types/quality-gates';
import reducer, {
getBranchStatusByBranchLike,
registerBranchStatusAction,
State
} from '../branches';
-type TestArgs = [BranchLike, string, T.Status, T.QualityGateStatusCondition[], boolean?];
+type TestArgs = [BranchLike, string, T.Status, QualityGateStatusCondition[], boolean?];
const FAILING_CONDITION = mockQualityGateStatusCondition();
const COMPONENT = 'foo';
diff --git a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
index 4c4add7250c..50fae18e874 100644
--- a/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
+++ b/server/sonar-web/src/main/js/store/__tests__/rootActions-test.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { mockBranch } from '../../helpers/mocks/branch-like';
-import { mockQualityGateStatusCondition } from '../../helpers/testMocks';
+import { mockQualityGateStatusCondition } from '../../helpers/mocks/quality-gates';
import { registerBranchStatusAction } from '../branches';
import { fetchBranchStatus, registerBranchStatus } from '../rootActions';
@@ -28,7 +28,9 @@ jest.mock('../branches', () => ({
}));
jest.mock('../../api/quality-gates', () => {
- const { mockQualityGateProjectStatus } = require.requireActual('../../helpers/testMocks');
+ const { mockQualityGateProjectStatus } = require.requireActual(
+ '../../helpers/mocks/quality-gates'
+ );
return {
getQualityGateProjectStatus: jest.fn().mockResolvedValue(
mockQualityGateProjectStatus({
diff --git a/server/sonar-web/src/main/js/store/branches.ts b/server/sonar-web/src/main/js/store/branches.ts
index 67928e2f86d..f05a531af98 100644
--- a/server/sonar-web/src/main/js/store/branches.ts
+++ b/server/sonar-web/src/main/js/store/branches.ts
@@ -19,10 +19,11 @@
*/
import { getBranchLikeKey } from '../helpers/branch-like';
import { BranchLike } from '../types/branch-like';
+import { QualityGateStatusCondition } from '../types/quality-gates';
import { ActionType } from './utils/actions';
export interface BranchStatusData {
- conditions?: T.QualityGateStatusCondition[];
+ conditions?: QualityGateStatusCondition[];
ignoredConditions?: boolean;
status?: T.Status;
}
@@ -41,7 +42,7 @@ export function registerBranchStatusAction(
branchLike: BranchLike,
component: string,
status: T.Status,
- conditions?: T.QualityGateStatusCondition[],
+ conditions?: QualityGateStatusCondition[],
ignoredConditions?: boolean
) {
return {
diff --git a/server/sonar-web/src/main/js/types/application.ts b/server/sonar-web/src/main/js/types/application.ts
new file mode 100644
index 00000000000..255c88ec7e6
--- /dev/null
+++ b/server/sonar-web/src/main/js/types/application.ts
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+export interface ApplicationPeriod {
+ date: string;
+ project: string;
+ projectName: string;
+}
diff --git a/server/sonar-web/src/main/js/types/quality-gates.ts b/server/sonar-web/src/main/js/types/quality-gates.ts
new file mode 100644
index 00000000000..e3dbe2130c3
--- /dev/null
+++ b/server/sonar-web/src/main/js/types/quality-gates.ts
@@ -0,0 +1,79 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+export interface QualityGateProjectStatus {
+ conditions?: QualityGateProjectStatusCondition[];
+ ignoredConditions: boolean;
+ status: T.Status;
+}
+
+export interface QualityGateProjectStatusCondition {
+ actualValue: string;
+ comparator: string;
+ errorThreshold: string;
+ metricKey: string;
+ periodIndex: number;
+ status: T.Status;
+}
+
+export interface QualityGateApplicationStatus {
+ metrics: T.Metric[];
+ projects: QualityGateApplicationStatusChildProject[];
+ status: T.Status;
+}
+
+export interface QualityGateApplicationStatusCondition {
+ comparator: string;
+ errorThreshold?: string;
+ metric: string;
+ periodIndex?: number;
+ onLeak?: boolean;
+ status: string;
+ value: string;
+ warningThreshold?: string;
+}
+
+export interface QualityGateApplicationStatusChildProject {
+ conditions: QualityGateApplicationStatusCondition[];
+ key: string;
+ name: string;
+ status: T.Status;
+}
+
+export interface QualityGateStatus {
+ failedConditions: QualityGateStatusConditionEnhanced[];
+ ignoredConditions?: boolean;
+ key: string;
+ name: string;
+ status: T.Status;
+}
+
+export interface QualityGateStatusCondition {
+ actual?: string;
+ error?: string;
+ level: string;
+ metric: string;
+ op: string;
+ period?: number;
+ warning?: string;
+}
+
+export interface QualityGateStatusConditionEnhanced extends QualityGateStatusCondition {
+ measure: T.MeasureEnhanced;
+}
diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts
index c951f28def9..365b9e59c18 100644
--- a/server/sonar-web/src/main/js/types/types.d.ts
+++ b/server/sonar-web/src/main/js/types/types.d.ts
@@ -657,35 +657,6 @@ declare namespace T {
name: string;
}
- export interface QualityGateProjectStatusCondition {
- status: Status;
- metricKey: string;
- comparator: string;
- periodIndex: number;
- errorThreshold: string;
- actualValue: string;
- }
-
- export interface QualityGateProjectStatus {
- conditions?: QualityGateProjectStatusCondition[];
- ignoredConditions: boolean;
- status: Status;
- }
-
- export interface QualityGateStatusCondition {
- actual?: string;
- error?: string;
- level: string;
- metric: string;
- op: string;
- period?: number;
- warning?: string;
- }
-
- export interface QualityGateStatusConditionEnhanced extends QualityGateStatusCondition {
- measure: T.MeasureEnhanced;
- }
-
export interface Rule {
isTemplate?: boolean;
key: string;