return getJSON(url, data);
}
-export function deleteComponents (data?: Object) {
+export function deleteComponents (data: { projects: string, organization?: string }) {
const url = '/api/projects/bulk_delete';
return post(url, data);
}
-export function deleteProject (key: string) {
+export function deleteProject (project: string) {
const url = '/api/projects/delete';
- const data = { key };
+ const data = { project };
return post(url, data);
}
-export function createProject (data?: Object) {
+export function createProject (data: {
+ branch?: string,
+ name: string,
+ project: string,
+ organization?: string
+}) {
const url = '/api/projects/create';
return postJSON(url, data);
}
return getJSON(url, data).then(r => r.component);
}
-export function getTree (baseComponentKey: string, options?: Object = {}) {
+export function getTree (component: string, options?: Object = {}) {
const url = '/api/components/tree';
- const data = Object.assign({}, options, { baseComponentKey });
+ const data = { ...options, component };
return getJSON(url, data);
}
return getJSON(url, data).then(r => r.ancestors);
}
-export function getBreadcrumbs ({ id, key }: { id: string, key: string }) {
+export function getBreadcrumbs (component: string) {
const url = '/api/components/show';
- const data = id ? { id } : { key };
- return getJSON(url, data).then(r => {
+ return getJSON(url, { component }).then(r => {
const reversedAncestors = [...r.ancestors].reverse();
return [...reversedAncestors, r.component];
});
return Promise.resolve(existing);
}
- return getBreadcrumbs({ key: componentKey })
+ return getBreadcrumbs(componentKey)
.then(skipRootDir)
.then(breadcrumbs => {
addComponentBreadcrumbs(componentKey, breadcrumbs);
{ id: '1', key: 'a', name: 'A', qualifier: 'TRK' },
{ id: '2', key: 'b', name: 'B', qualifier: 'TRK' }
];
- const selection = ['1'];
+ const selection = ['a'];
const result = shallow(<Projects projects={projects} selection={selection} refresh={jest.fn()}/>);
expect(result.find('tr').length).toBe(2);
const data = {
name: this.$('#create-project-name').val(),
branch: this.$('#create-project-branch').val(),
- key: this.$('#create-project-key').val()
+ project: this.$('#create-project-key').val()
};
if (this.options.organization) {
data.organization = this.options.organization.key;
},
onProjectSelected (project) {
- const newSelection = uniq([].concat(this.state.selection, project.id));
+ const newSelection = uniq([].concat(this.state.selection, project.key));
this.setState({ selection: newSelection });
},
onProjectDeselected (project) {
- const newSelection = without(this.state.selection, project.id);
+ const newSelection = without(this.state.selection, project.key);
this.setState({ selection: newSelection });
},
onAllSelected () {
- const newSelection = this.state.projects.map(project => project.id);
+ const newSelection = this.state.projects.map(project => project.key);
this.setState({ selection: newSelection });
},
deleteProjects () {
this.setState({ ready: false });
- const ids = this.state.selection.join(',');
- const data = { ids };
+ const projects = this.state.selection.join(',');
+ const data = { projects };
if (this.props.organization) {
Object.assign(data, { organization: this.props.organization.key });
}
}
isProjectSelected (project) {
- return this.props.selection.indexOf(project.id) !== -1;
+ return this.props.selection.indexOf(project.key) !== -1;
}
renderProject (project) {
const permissionsUrl = getComponentPermissionsUrl(project.key);
return (
- <tr key={project.id}>
+ <tr key={project.key}>
<td className="thin">
<Checkbox
checked={this.isProjectSelected(project)}