}
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[]> {
export function getComponentTree(
strategy: string,
- componentKey: string,
+ component: string,
metrics: string[] = [],
additional: RequestData = {}
): Promise<{
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);
}
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);
}
}
export function getComponentNavigation(
- data: { componentKey: string } & T.BranchParameters
+ data: { component: string } & T.BranchParameters
): Promise<any> {
return getJSON('/api/navigation/component', data).catch(throwGlobalError);
}
};
Promise.all([
- getComponentNavigation({ componentKey: key, branch, pullRequest }),
+ getComponentNavigation({ component: key, branch, pullRequest }),
getComponentData({ component: key, branch, pullRequest })
])
.then(([nav, data]) => {
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 => {
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 () => {
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();
});
await new Promise(setImmediate);
expect(getMeasures).toBeCalledWith({
- componentKey: 'foo',
+ component: 'foo',
metricKeys: 'new_coverage,new_duplicated_lines_density',
branch: 'feature'
});
};
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 &&
const metrics = getCodeMetrics(qualifier, branchLike);
return getComponent({
- componentKey,
+ component: componentKey,
metricKeys: metrics.join(),
...getBranchLikeQuery(branchLike)
}).then(component => {
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]) => {
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'
});
// 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]) => {
// 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 => {