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);
}
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);
}
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);
}
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[];
}
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;
}
});
- 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}
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')}