aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMathieu Suen <mathieu.suen@sonarsource.com>2020-04-30 15:23:04 +0200
committersonartech <sonartech@sonarsource.com>2020-05-25 20:05:21 +0000
commit3d4a3d278a957142a3d10f216b9a430b89f40607 (patch)
tree850aee4559fa0a2af51844cf0e771fc5029dfee5 /server
parentac532a55b9c7ee51b8ad3516103b453f030392d6 (diff)
downloadsonarqube-3d4a3d278a957142a3d10f216b9a430b89f40607.tar.gz
sonarqube-3d4a3d278a957142a3d10f216b9a430b89f40607.zip
SONAR-132221 Fix qualitygate API type.
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts16
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/Form-test.tsx18
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/DetailsHeader-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Condition-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Conditions-test.tsx.snap20
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/CopyQualityGateForm-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Details-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsContent-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsHeader-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/List-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts2
-rw-r--r--server/sonar-web/src/main/js/types/types.d.ts2
14 files changed, 46 insertions, 48 deletions
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 9e9255e02ec..c81bc29a120 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -46,14 +46,14 @@ export function createQualityGate(data: {
}
export function deleteQualityGate(data: {
- id: number;
+ id: string;
organization?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/destroy', data).catch(throwGlobalError);
}
export function renameQualityGate(data: {
- id: number;
+ id: string;
name: string;
organization?: string;
}): Promise<void | Response> {
@@ -61,7 +61,7 @@ export function renameQualityGate(data: {
}
export function copyQualityGate(data: {
- id: number;
+ id: string;
name: string;
organization?: string;
}): Promise<T.QualityGate> {
@@ -69,7 +69,7 @@ export function copyQualityGate(data: {
}
export function setQualityGateAsDefault(data: {
- id: number;
+ id: string;
organization?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/set_as_default', data).catch(throwGlobalError);
@@ -77,7 +77,7 @@ export function setQualityGateAsDefault(data: {
export function createCondition(
data: {
- gateId: number;
+ gateId: string;
organization?: string;
} & T.Omit<T.Condition, 'id'>
): Promise<T.Condition> {
@@ -109,7 +109,7 @@ export function getGateForProject(data: {
}
export function searchProjects(data: {
- gateId: number;
+ gateId: string;
organization?: string;
page?: number;
pageSize?: number;
@@ -123,7 +123,7 @@ export function searchProjects(data: {
}
export function associateGateWithProject(data: {
- gateId: number;
+ gateId: string;
organization?: string;
projectKey: string;
}): Promise<void | Response> {
@@ -131,7 +131,7 @@ export function associateGateWithProject(data: {
}
export function dissociateGateWithProject(data: {
- gateId: number;
+ gateId: string;
organization?: string;
projectKey: string;
}): Promise<void | Response> {
diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx
index fa6f38802eb..904280fd446 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx
@@ -91,7 +91,7 @@ export default class App extends React.PureComponent<Props> {
);
}
- handleChangeGate = (oldId?: number, newId?: number) => {
+ handleChangeGate = (oldId?: string, newId?: string) => {
const { allGates } = this.state;
if ((!oldId && !newId) || !allGates) {
return Promise.resolve();
diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx
index 3237229c642..bdd3eb375c2 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx
@@ -24,7 +24,7 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
interface Props {
allGates: T.QualityGate[];
gate?: T.QualityGate;
- onChange: (oldGate?: number, newGate?: number) => Promise<void>;
+ onChange: (oldGate?: string, newGate?: string) => Promise<void>;
}
interface State {
@@ -60,14 +60,12 @@ export default class Form extends React.PureComponent<Props, State> {
const isSet = gate == null && option.value != null;
const isUnset = gate != null && option.value == null;
- const isChanged = gate != null && gate.id !== Number(option.value);
+ const isChanged = gate != null && gate.id !== option.value;
const hasChanged = isSet || isUnset || isChanged;
if (hasChanged) {
this.setState({ loading: true });
- this.props
- .onChange(gate && gate.id, Number(option.value))
- .then(this.stopLoading, this.stopLoading);
+ this.props.onChange(gate && gate.id, option.value).then(this.stopLoading, this.stopLoading);
}
};
diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/Form-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/Form-test.tsx
index 1a6bffc4e78..b69f987d2e9 100644
--- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/Form-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/Form-test.tsx
@@ -22,25 +22,25 @@ import * as React from 'react';
import Form from '../Form';
it('renders', () => {
- const foo = randomGate(1);
- const allGates = [foo, randomGate(2)];
+ const foo = randomGate('1');
+ const allGates = [foo, randomGate('2')];
expect(shallow(<Form allGates={allGates} gate={foo} onChange={jest.fn()} />)).toMatchSnapshot();
});
it('changes quality gate', () => {
- const allGates = [randomGate(1), randomGate(2)];
+ const allGates = [randomGate('1'), randomGate('2')];
const onChange = jest.fn(() => Promise.resolve());
const wrapper = shallow(<Form allGates={allGates} onChange={onChange} />);
- wrapper.find('Select').prop<Function>('onChange')({ value: 2 });
- expect(onChange).lastCalledWith(undefined, 2);
+ wrapper.find('Select').prop<Function>('onChange')({ value: '2' });
+ expect(onChange).lastCalledWith(undefined, '2');
- wrapper.setProps({ gate: randomGate(1) });
- wrapper.find('Select').prop<Function>('onChange')({ value: 2 });
- expect(onChange).lastCalledWith(1, 2);
+ wrapper.setProps({ gate: randomGate('1') });
+ wrapper.find('Select').prop<Function>('onChange')({ value: '2' });
+ expect(onChange).lastCalledWith('1', '2');
});
-function randomGate(id: number) {
+function randomGate(id: string) {
return {
id,
name: `name-${id}`
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 c3d927b6efb..4ff383a6eb7 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
@@ -54,11 +54,11 @@ it('should allow the QG to be set as the default', async () => {
const refreshItem = jest.fn();
const refreshList = jest.fn();
- const qualityGate = mockQualityGate({ id: 1, actions: { setAsDefault: true } });
+ const qualityGate = mockQualityGate({ id: 'one', actions: { setAsDefault: true } });
const wrapper = shallowRender({ onSetDefault, qualityGate, refreshItem, refreshList });
click(wrapper.find('Button#quality-gate-toggle-default'));
- expect(setQualityGateAsDefault).toBeCalledWith({ id: 1 });
+ expect(setQualityGateAsDefault).toBeCalledWith({ id: 'one' });
expect(onSetDefault).toBeCalled();
await waitAndUpdate(wrapper);
expect(refreshItem).toBeCalled();
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Condition-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Condition-test.tsx.snap
index 427e1faef9e..50f735e44ee 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Condition-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Condition-test.tsx.snap
@@ -194,7 +194,7 @@ exports[`should render the update modal correctly 1`] = `
onClose={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Conditions-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Conditions-test.tsx.snap
index 1c75a3af287..14bf9466228 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Conditions-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Conditions-test.tsx.snap
@@ -78,7 +78,7 @@ exports[`should render correctly 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -107,7 +107,7 @@ exports[`should render correctly 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -220,7 +220,7 @@ exports[`should render correctly with an updated condition 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -249,7 +249,7 @@ exports[`should render correctly with an updated condition 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -339,7 +339,7 @@ exports[`should render correctly with new code conditions 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -368,7 +368,7 @@ exports[`should render correctly with new code conditions 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -440,7 +440,7 @@ exports[`should render correctly with new code conditions 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -469,7 +469,7 @@ exports[`should render correctly with new code conditions 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -578,7 +578,7 @@ exports[`should render the add conditions button and modal 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -607,7 +607,7 @@ exports[`should render the add conditions button and modal 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/CopyQualityGateForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/CopyQualityGateForm-test.tsx.snap
index dae3160544a..e961412c207 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/CopyQualityGateForm-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/CopyQualityGateForm-test.tsx.snap
@@ -6,7 +6,7 @@ exports[`should render correctly 1`] = `
onCopy={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Details-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Details-test.tsx.snap
index bdcfec6b95d..ba5a76662eb 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Details-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/Details-test.tsx.snap
@@ -17,7 +17,7 @@ exports[`should render correctly: loaded 1`] = `
onSetDefault={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -32,7 +32,7 @@ exports[`should render correctly: loaded 1`] = `
onSaveCondition={[Function]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsContent-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsContent-test.tsx.snap
index 8aa1b677220..c98a62ada70 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsContent-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsContent-test.tsx.snap
@@ -12,7 +12,7 @@ exports[`should render correctly: is default 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -49,7 +49,7 @@ exports[`should render correctly: is not default 1`] = `
onSaveCondition={[MockFunction]}
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
@@ -73,7 +73,7 @@ exports[`should render correctly: is not default 1`] = `
key="1"
qualityGate={
Object {
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsHeader-test.tsx.snap
index 8e593a3fd98..9326e5cf1d1 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsHeader-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/DetailsHeader-test.tsx.snap
@@ -47,7 +47,7 @@ exports[`should render correctly: admin actions 1`] = `
"rename": true,
"setAsDefault": true,
},
- "id": 1,
+ "id": "1",
"name": "qualitygate",
}
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/List-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/List-test.tsx.snap
index ab4398468dd..9fad96d9809 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/List-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/__snapshots__/List-test.tsx.snap
@@ -7,7 +7,7 @@ exports[`should render correctly 1`] = `
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
@@ -26,7 +26,7 @@ exports[`should render correctly 1`] = `
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
@@ -48,7 +48,7 @@ exports[`should render correctly 1`] = `
<Link
activeClassName="active"
className="list-group-item display-flex-center"
- data-id={1}
+ data-id="1"
key="1"
onlyActiveOnIndex={false}
style={Object {}}
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
index 1da53327e55..057a069e47f 100644
--- a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
+++ b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts
@@ -29,7 +29,7 @@ import { mockMeasureEnhanced, mockMetric } from '../testMocks';
export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.QualityGate {
return {
- id: 1,
+ id: '1',
name: 'qualitygate',
...overrides
};
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 3559864277f..0ae48e4efbe 100644
--- a/server/sonar-web/src/main/js/types/types.d.ts
+++ b/server/sonar-web/src/main/js/types/types.d.ts
@@ -654,7 +654,7 @@ declare namespace T {
setAsDefault?: boolean;
};
conditions?: Condition[];
- id: number;
+ id: string;
isBuiltIn?: boolean;
isDefault?: boolean;
name: string;