]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8800 remove usages of deprecated api 1740/head
authorStas Vilchik <vilchiks@gmail.com>
Tue, 14 Mar 2017 08:43:28 +0000 (09:43 +0100)
committerStas Vilchik <stas-vilchik@users.noreply.github.com>
Tue, 14 Mar 2017 09:39:38 +0000 (10:39 +0100)
server/sonar-web/src/main/js/api/components.js
server/sonar-web/src/main/js/apps/code/utils.js
server/sonar-web/src/main/js/apps/projects-admin/__tests__/projects-test.js
server/sonar-web/src/main/js/apps/projects-admin/create-view.js
server/sonar-web/src/main/js/apps/projects-admin/main.js
server/sonar-web/src/main/js/apps/projects-admin/projects.js

index c09192522e35efffece69edbad6cf8ce97be5bf9..456cb90e0e5cdbdc63e05661088f937289bca08f 100644 (file)
@@ -35,18 +35,23 @@ export function getGhosts (data?: Object) {
   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);
 }
@@ -80,9 +85,9 @@ export function getComponent (componentKey: string, metrics: Array<string> = [])
   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);
 }
 
@@ -92,10 +97,9 @@ export function getParents ({ id, key }: { id: string, key: string }) {
   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];
   });
index 2a3505d7bc825f861741f6a84302c500276f7f55..c6999204de878837404d28e9a6ce0240ad16c1e7 100644 (file)
@@ -166,7 +166,7 @@ function retrieveComponentBreadcrumbs (componentKey) {
     return Promise.resolve(existing);
   }
 
-  return getBreadcrumbs({ key: componentKey })
+  return getBreadcrumbs(componentKey)
       .then(skipRootDir)
       .then(breadcrumbs => {
         addComponentBreadcrumbs(componentKey, breadcrumbs);
index d69c7a54ee6f678d32ceac0649da664acf7ec659..4684de66847ee7816540d89bce4d82840881b603 100644 (file)
@@ -38,7 +38,7 @@ it('should render list of projects with one selected', () => {
     { 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);
index 07210b6e5d4e32903d3d8525b5af0d8a032a234d..fb44ac62486606fe5b605a72e7836bd38532d707 100644 (file)
@@ -43,7 +43,7 @@ export default ModalForm.extend({
     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;
index c683e7d0c285e0cac9d77f12461abb72794f3b65..d23dabeab8cbf3c3d55bf6a1e4e1bf439bd47d6e 100644 (file)
@@ -165,17 +165,17 @@ export default React.createClass({
   },
 
   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 });
   },
 
@@ -185,8 +185,8 @@ export default React.createClass({
 
   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 });
     }
index 6086c8ae2a99210ceb35e492be7d8f204f360172..7c2aaf752f8523c3b6f75cfeeaa0ba673e4ff361 100644 (file)
@@ -55,14 +55,14 @@ export default class Projects extends React.Component {
   }
 
   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)}