From: Stas Vilchik Date: Thu, 6 Dec 2018 10:01:55 +0000 (+0100) Subject: replace deprecated componentKey in web api calls X-Git-Tag: 7.5~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a3fef5c6baba580a558b996bd23b435dfc9e4aa;p=sonarqube.git replace deprecated componentKey in web api calls --- diff --git a/server/sonar-web/src/main/js/api/ce.ts b/server/sonar-web/src/main/js/api/ce.ts index a159628a65f..7f372e961ee 100644 --- a/server/sonar-web/src/main/js/api/ce.ts +++ b/server/sonar-web/src/main/js/api/ce.ts @@ -64,9 +64,9 @@ export function cancelAllTasks(): Promise { } 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 { diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index c2706de28ef..6b9ab423821 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -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 { return getJSON('/api/measures/component', data).then(r => r.component, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts index 58d537385db..e932f497ae9 100644 --- a/server/sonar-web/src/main/js/api/measures.ts +++ b/server/sonar-web/src/main/js/api/measures.ts @@ -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 { 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); } diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts index 66da48b10ab..d5785a41906 100644 --- a/server/sonar-web/src/main/js/api/nav.ts +++ b/server/sonar-web/src/main/js/api/nav.ts @@ -25,7 +25,7 @@ export function getGlobalNavigation(): Promise { } export function getComponentNavigation( - data: { componentKey: string } & T.BranchParameters + data: { component: string } & T.BranchParameters ): Promise { return getJSON('/api/navigation/component', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index 1d458306d2b..0bc2bfa614e 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -116,7 +116,7 @@ export class ComponentContainer extends React.PureComponent { }; 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 { 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 => { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index f78e8ea0189..b661f086095 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -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' }); diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx index 8017304aa58..e090986643f 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx @@ -82,7 +82,7 @@ export class GlobalNavPlus extends React.PureComponent { - return getComponentNavigation({ componentKey: key }).then(data => { + return getComponentNavigation({ component: key }).then(data => { if ( data.configuration && data.configuration.extensions && diff --git a/server/sonar-web/src/main/js/apps/code/utils.ts b/server/sonar-web/src/main/js/apps/code/utils.ts index 6f50aec5213..28bc03e063b 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -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 => { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx index dd6bc722b41..3a27c2335d6 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx @@ -81,7 +81,7 @@ export class App extends React.PureComponent { 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]) => { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx index 1a66a953799..4a564bbb016 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx @@ -78,7 +78,7 @@ it('fetches measures and children components', () => { getChildren.mockClear(); mount(); 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' }); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx index 5932a17e570..fcdba438276 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx @@ -56,7 +56,7 @@ export default class ProjectRowActions extends React.PureComponent // 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]) => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx index 3a56a217471..fd62f1fc724 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx @@ -96,7 +96,7 @@ export default class MeasuresOverlay extends React.PureComponent { // 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 => {