Browse Source

replace deprecated componentKey in web api calls

tags/7.5
Stas Vilchik 5 years ago
parent
commit
0a3fef5c6b

+ 2
- 2
server/sonar-web/src/main/js/api/ce.ts View 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[]> {

+ 7
- 11
server/sonar-web/src/main/js/api/components.ts View 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);
}

+ 3
- 3
server/sonar-web/src/main/js/api/measures.ts View 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);
}


+ 1
- 1
server/sonar-web/src/main/js/api/nav.ts View 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);
}

+ 2
- 2
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx View 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 => {

+ 3
- 6
server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx View 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'
});

+ 1
- 1
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx View 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 &&

+ 1
- 1
server/sonar-web/src/main/js/apps/code/utils.ts View 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 => {

+ 1
- 1
server/sonar-web/src/main/js/apps/portfolio/components/App.tsx View 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]) => {

+ 1
- 1
server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx View 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'
});

+ 1
- 1
server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx View 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]) => {

+ 1
- 1
server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx View 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 => {

Loading…
Cancel
Save