]> source.dussan.org Git - sonarqube.git/commitdiff
replace deprecated componentKey in web api calls
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 6 Dec 2018 10:01:55 +0000 (11:01 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 11 Dec 2018 19:20:58 +0000 (20:20 +0100)
12 files changed:
server/sonar-web/src/main/js/api/ce.ts
server/sonar-web/src/main/js/api/components.ts
server/sonar-web/src/main/js/api/measures.ts
server/sonar-web/src/main/js/api/nav.ts
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx
server/sonar-web/src/main/js/apps/code/utils.ts
server/sonar-web/src/main/js/apps/portfolio/components/App.tsx
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx
server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx
server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx

index a159628a65f2b371e76920a71b092059c6c20c07..7f372e961ee1dcddeca9eb627057c8bb06e8d7ce 100644 (file)
@@ -64,9 +64,9 @@ export function cancelAllTasks(): Promise<any> {
 }
 
 export function getTasksForComponent(
-  componentKey: string
+  component: string
 ): Promise<{ queue: T.Task[]; current: T.Task }> {
-  return getJSON('/api/ce/component', { componentKey }).catch(throwGlobalError);
+  return getJSON('/api/ce/component', { component }).catch(throwGlobalError);
 }
 
 export function getTypes(): Promise<string[]> {
index c2706de28efaa29edf17b9bb8e930a0be0175349..6b9ab42382169f7a80381e4f5eb4dc03cf2c5cf4 100644 (file)
@@ -89,7 +89,7 @@ export function setProjectTags(data: { project: string; tags: string }): Promise
 
 export function getComponentTree(
   strategy: string,
-  componentKey: string,
+  component: string,
   metrics: string[] = [],
   additional: RequestData = {}
 ): Promise<{
@@ -98,32 +98,28 @@ export function getComponentTree(
   paging: T.Paging;
 }> {
   const url = '/api/measures/component_tree';
-  const data = Object.assign({}, additional, {
-    baseComponentKey: componentKey,
-    metricKeys: metrics.join(','),
-    strategy
-  });
+  const data = { ...additional, component, metricKeys: metrics.join(','), strategy };
   return getJSON(url, data).catch(throwGlobalError);
 }
 
 export function getChildren(
-  componentKey: string,
+  component: string,
   metrics: string[] = [],
   additional: RequestData = {}
 ) {
-  return getComponentTree('children', componentKey, metrics, additional);
+  return getComponentTree('children', component, metrics, additional);
 }
 
 export function getComponentLeaves(
-  componentKey: string,
+  component: string,
   metrics: string[] = [],
   additional: RequestData = {}
 ) {
-  return getComponentTree('leaves', componentKey, metrics, additional);
+  return getComponentTree('leaves', component, metrics, additional);
 }
 
 export function getComponent(
-  data: { componentKey: string; metricKeys: string } & T.BranchParameters
+  data: { component: string; metricKeys: string } & T.BranchParameters
 ): Promise<any> {
   return getJSON('/api/measures/component', data).then(r => r.component, throwGlobalError);
 }
index 58d537385dbcf81c663593df2f7e2a74c89c791b..e932f497ae9eae91c200035ab2f50f8de225457a 100644 (file)
@@ -21,17 +21,17 @@ import { getJSON, RequestData, postJSON, post } from '../helpers/request';
 import throwGlobalError from '../app/utils/throwGlobalError';
 
 export function getMeasures(
-  data: { componentKey: string; metricKeys: string } & T.BranchParameters
+  data: { component: string; metricKeys: string } & T.BranchParameters
 ): Promise<T.Measure[]> {
   return getJSON('/api/measures/component', data).then(r => r.component.measures, throwGlobalError);
 }
 
 export function getMeasuresAndMeta(
-  componentKey: string,
+  component: string,
   metrics: string[],
   additional: RequestData = {}
 ): Promise<{ component: T.ComponentMeasure; metrics?: T.Metric[]; periods?: T.Period[] }> {
-  const data = { ...additional, componentKey, metricKeys: metrics.join(',') };
+  const data = { ...additional, component, metricKeys: metrics.join(',') };
   return getJSON('/api/measures/component', data);
 }
 
index 66da48b10ab03adbe7d3fdf9ad00b375b74868d6..d5785a41906eea3aea677220c9db43ca6ea53121 100644 (file)
@@ -25,7 +25,7 @@ export function getGlobalNavigation(): Promise<T.AppState> {
 }
 
 export function getComponentNavigation(
-  data: { componentKey: string } & T.BranchParameters
+  data: { component: string } & T.BranchParameters
 ): Promise<any> {
   return getJSON('/api/navigation/component', data).catch(throwGlobalError);
 }
index 1d458306d2b0e01c7dde076218847a3c092b17cd..0bc2bfa614e372095771d5e963208d2a69bfadfd 100644 (file)
@@ -116,7 +116,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
     };
 
     Promise.all([
-      getComponentNavigation({ componentKey: key, branch, pullRequest }),
+      getComponentNavigation({ component: key, branch, pullRequest }),
       getComponentData({ component: key, branch, pullRequest })
     ])
       .then(([nav, data]) => {
@@ -193,7 +193,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
     const project = component.breadcrumbs.find(({ qualifier }) => qualifier === 'TRK');
     if (project && (isShortLivingBranch(branchLike) || isPullRequest(branchLike))) {
       return getMeasures({
-        componentKey: project.key,
+        component: project.key,
         metricKeys: 'new_coverage,new_duplicated_lines_density',
         ...getBranchLikeQuery(branchLike)
       }).then(measures => {
index f78e8ea0189c096e7db5f7e3403cf325f458f31b..b661f086095c34cf2fa85b557119eff32290b7de 100644 (file)
@@ -109,7 +109,7 @@ it("loads branches for module's project", async () => {
   expect(getBranches).toBeCalledWith('projectKey');
   expect(getPullRequests).toBeCalledWith('projectKey');
   expect(getComponentData).toBeCalledWith({ component: 'moduleKey', branch: undefined });
-  expect(getComponentNavigation).toBeCalledWith({ componentKey: 'moduleKey', branch: undefined });
+  expect(getComponentNavigation).toBeCalledWith({ component: 'moduleKey', branch: undefined });
 });
 
 it("doesn't load branches portfolio", async () => {
@@ -123,10 +123,7 @@ it("doesn't load branches portfolio", async () => {
   expect(getBranches).not.toBeCalled();
   expect(getPullRequests).not.toBeCalled();
   expect(getComponentData).toBeCalledWith({ component: 'portfolioKey', branch: undefined });
-  expect(getComponentNavigation).toBeCalledWith({
-    componentKey: 'portfolioKey',
-    branch: undefined
-  });
+  expect(getComponentNavigation).toBeCalledWith({ component: 'portfolioKey', branch: undefined });
   wrapper.update();
   expect(wrapper.find(Inner).exists()).toBeTruthy();
 });
@@ -176,7 +173,7 @@ it('updates the branch measures', async () => {
 
   await new Promise(setImmediate);
   expect(getMeasures).toBeCalledWith({
-    componentKey: 'foo',
+    component: 'foo',
     metricKeys: 'new_coverage,new_duplicated_lines_density',
     branch: 'feature'
   });
index 8017304aa58328ee773f0214a14b442bdf424bef..e090986643f2c96f5f42217daab3c89b5492a156 100644 (file)
@@ -82,7 +82,7 @@ export class GlobalNavPlus extends React.PureComponent<Props & WithRouterProps,
   };
 
   handleCreatePortfolio = ({ key, qualifier }: { key: string; qualifier: string }) => {
-    return getComponentNavigation({ componentKey: key }).then(data => {
+    return getComponentNavigation({ component: key }).then(data => {
       if (
         data.configuration &&
         data.configuration.extensions &&
index 6f50aec5213974803ef230f8dee2c0294343e058..28bc03e063b441729c083663fb42cf6d842825a9 100644 (file)
@@ -168,7 +168,7 @@ function retrieveComponentBase(componentKey: string, qualifier: string, branchLi
   const metrics = getCodeMetrics(qualifier, branchLike);
 
   return getComponent({
-    componentKey,
+    component: componentKey,
     metricKeys: metrics.join(),
     ...getBranchLikeQuery(branchLike)
   }).then(component => {
index dd6bc722b411b60e552159262834ae5c54380c27..3a27c2335d6cd0e2db46ac13409e0d9ab5c9b0a6 100644 (file)
@@ -81,7 +81,7 @@ export class App extends React.PureComponent<Props, State> {
   fetchData() {
     this.setState({ loading: true });
     Promise.all([
-      getMeasures({ componentKey: this.props.component.key, metricKeys: PORTFOLIO_METRICS.join() }),
+      getMeasures({ component: this.props.component.key, metricKeys: PORTFOLIO_METRICS.join() }),
       getChildren(this.props.component.key, SUB_COMPONENTS_METRICS, { ps: 20, s: 'qualifier' })
     ]).then(
       ([measures, subComponents]) => {
index 1a66a9537990152414271c2a124314ee3185b072..4a564bbb016ec0deca69d2a4423cc02646768406 100644 (file)
@@ -78,7 +78,7 @@ it('fetches measures and children components', () => {
   getChildren.mockClear();
   mount(<App component={component} fetchMetrics={jest.fn()} metrics={{}} />);
   expect(getMeasures).toBeCalledWith({
-    componentKey: 'foo',
+    component: 'foo',
     metricKeys:
       'projects,ncloc,ncloc_language_distribution,releasability_rating,releasability_effort,sqale_rating,maintainability_rating_effort,reliability_rating,reliability_rating_effort,security_rating,security_rating_effort,last_change_on_releasability_rating,last_change_on_maintainability_rating,last_change_on_security_rating,last_change_on_reliability_rating'
   });
index 5932a17e570f6bd3b81f958705a85737f12f9918..fcdba4382761d5b8379a4c2b6a67e5dcb3f4dc94 100644 (file)
@@ -56,7 +56,7 @@ export default class ProjectRowActions extends React.PureComponent<Props, State>
     // call `getComponentNavigation` to check if user has the "Administer" permission
     // call `getComponentShow` to check if user has the "Browse" permission
     Promise.all([
-      getComponentNavigation({ componentKey: this.props.project.key }),
+      getComponentNavigation({ component: this.props.project.key }),
       getComponentShow({ component: this.props.project.key })
     ]).then(
       ([navResponse]) => {
index 3a56a2174711579148dc1f19454b4386bb5206f6..fd62f1fc72462ebd9d2e37f334a8d709a19ac712 100644 (file)
@@ -96,7 +96,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> {
 
       // eslint-disable-next-line promise/no-nesting
       return getMeasures({
-        componentKey: this.props.sourceViewerFile.key,
+        component: this.props.sourceViewerFile.key,
         metricKeys: metricKeys.join(),
         ...getBranchLikeQuery(this.props.branchLike)
       }).then(measures => {