aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorPhilippe Perrin <philippe.perrin@sonarsource.com>2020-03-25 14:35:12 +0100
committersonartech <sonartech@sonarsource.com>2020-04-14 20:04:05 +0000
commitdf3c515c32549db6be2ded722a6c217d25fa1122 (patch)
tree2a7d3fa97498e8b81de73533fcd942d84fa1f5c9 /server
parentd8081f847f92247a64166572605876e67e9a34ed (diff)
downloadsonarqube-df3c515c32549db6be2ded722a6c217d25fa1122.tar.gz
sonarqube-df3c515c32549db6be2ded722a6c217d25fa1122.zip
SONAR-13220 Use project's key instead of project's id with Quality Gate WS
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts8
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx24
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/Projects-test.tsx4
3 files changed, 17 insertions, 19 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 2af81857bfa..9e9255e02ec 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -117,7 +117,7 @@ export function searchProjects(data: {
selected?: string;
}): Promise<{
paging: T.Paging;
- results: Array<{ id: string; key: string; name: string; selected: boolean }>;
+ results: Array<{ key: string; name: string; selected: boolean }>;
}> {
return getJSON('/api/qualitygates/search', data).catch(throwGlobalError);
}
@@ -125,8 +125,7 @@ export function searchProjects(data: {
export function associateGateWithProject(data: {
gateId: number;
organization?: string;
- projectKey?: string;
- projectId?: string;
+ projectKey: string;
}): Promise<void | Response> {
return post('/api/qualitygates/select', data).catch(throwGlobalError);
}
@@ -134,8 +133,7 @@ export function associateGateWithProject(data: {
export function dissociateGateWithProject(data: {
gateId: number;
organization?: string;
- projectKey?: string;
- projectId?: string;
+ projectKey: string;
}): Promise<void | Response> {
return post('/api/qualitygates/deselect', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx
index 7cd7ee42da0..a7eadc3eaa4 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx
+++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx
@@ -39,7 +39,7 @@ interface Props {
interface State {
needToReload: boolean;
lastSearchParams?: SelectListSearchParams;
- projects: Array<{ id: string; key: string; name: string; selected: boolean }>;
+ projects: Array<{ key: string; name: string; selected: boolean }>;
projectsTotalCount?: number;
selectedProjects: string[];
}
@@ -81,7 +81,7 @@ export default class Projects extends React.PureComponent<Props, State> {
const projects = more ? [...prevState.projects, ...data.results] : data.results;
const newSelectedProjects = data.results
.filter(project => project.selected)
- .map(project => project.id);
+ .map(project => project.key);
const selectedProjects = more
? [...prevState.selectedProjects, ...newSelectedProjects]
: newSelectedProjects;
@@ -97,40 +97,40 @@ export default class Projects extends React.PureComponent<Props, State> {
}
});
- handleSelect = (id: string) =>
+ handleSelect = (key: string) =>
associateGateWithProject({
gateId: this.props.qualityGate.id,
organization: this.props.organization,
- projectId: id
+ projectKey: key
}).then(() => {
if (this.mounted) {
this.setState(prevState => ({
needToReload: true,
- selectedProjects: [...prevState.selectedProjects, id]
+ selectedProjects: [...prevState.selectedProjects, key]
}));
}
});
- handleUnselect = (id: string) =>
+ handleUnselect = (key: string) =>
dissociateGateWithProject({
gateId: this.props.qualityGate.id,
organization: this.props.organization,
- projectId: id
+ projectKey: key
}).then(() => {
if (this.mounted) {
this.setState(prevState => ({
needToReload: true,
- selectedProjects: without(prevState.selectedProjects, id)
+ selectedProjects: without(prevState.selectedProjects, key)
}));
}
});
- renderElement = (id: string): React.ReactNode => {
- const project = find(this.state.projects, { id });
+ renderElement = (key: string): React.ReactNode => {
+ const project = find(this.state.projects, { key });
return (
<div className="select-list-list-item">
{project === undefined ? (
- id
+ key
) : (
<>
{project.name}
@@ -145,7 +145,7 @@ export default class Projects extends React.PureComponent<Props, State> {
render() {
return (
<SelectList
- elements={this.state.projects.map(project => project.id)}
+ elements={this.state.projects.map(project => project.key)}
elementsTotalCount={this.state.projectsTotalCount}
labelAll={translate('quality_gates.projects.all')}
labelSelected={translate('quality_gates.projects.with')}
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 39135e168fe..15e36a03b11 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
@@ -90,7 +90,7 @@ it('should handle selection properly', async () => {
expect(associateGateWithProject).toHaveBeenCalledWith(
expect.objectContaining({
- projectId: 'toto'
+ projectKey: 'toto'
})
);
expect(wrapper.state().needToReload).toBe(true);
@@ -103,7 +103,7 @@ it('should handle deselection properly', async () => {
expect(dissociateGateWithProject).toHaveBeenCalledWith(
expect.objectContaining({
- projectId: 'tata'
+ projectKey: 'tata'
})
);
expect(wrapper.state().needToReload).toBe(true);