diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-04-06 14:59:52 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-04-07 13:45:44 +0200 |
commit | 3049d9176376e1907980a692c318c9d0299b8bd8 (patch) | |
tree | ccb6d137191c018fee3af6302503b3844339e427 /server/sonar-web/src/main/js/apps/component-measures | |
parent | 006b48f55c912b1d058e4c20cdf73c5e8625dc07 (diff) | |
download | sonarqube-3049d9176376e1907980a692c318c9d0299b8bd8.tar.gz sonarqube-3049d9176376e1907980a692c318c9d0299b8bd8.zip |
SONAR-7402 add ability to drilldown with developer selected
Diffstat (limited to 'server/sonar-web/src/main/js/apps/component-measures')
4 files changed, 38 insertions, 20 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js index e5e5a3cbb17..856c79cbe56 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ComponentCell.js @@ -55,7 +55,7 @@ const ComponentCell = ({ component, isSelected, onClick }) => { return ( <td style={{ maxWidth: 0 }}> <div style={{ maxWidth: '100%', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}> - {component.refId == null ? ( + {(component.refId == null || component.qualifier === 'DEV_PRJ') ? ( <a id={'component-measures-component-link-' + component.key} className={linkClassName} diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js index c0fcc23de7d..87dd4c9e085 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js @@ -26,8 +26,17 @@ import Spinner from '../../components/Spinner'; import SourceViewer from '../../../code/components/SourceViewer'; export default class ListView extends React.Component { + static contextTypes = { + router: React.PropTypes.object.isRequired + }; + componentDidMount () { - this.handleChangeBaseComponent(this.props.component); + const { component, metric } = this.props; + if (component.qualifier === 'DEV') { + const { router } = this.context; + router.replace({ pathname: `metric/${metric.key}/tree`, query: { id: component.key } }); + } + this.handleChangeBaseComponent(component); } componentDidUpdate (nextProps) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js index fe2946c15b8..f41d19f8411 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/MeasureDrilldown.js @@ -38,14 +38,16 @@ export default class MeasureDrilldown extends React.Component { return ( <div className="measure-details-drilldown"> <ul className="measure-details-drilldown-mode"> - <li> - <Link - activeClassName="active" - to={{ pathname: `metric/${metric.key}/list`, query: { id: component.key } }}> - <IconList/> - {translate('component_measures.tab.list')} - </Link> - </li> + {component.qualifier !== 'DEV' && ( + <li> + <Link + activeClassName="active" + to={{ pathname: `metric/${metric.key}/list`, query: { id: component.key } }}> + <IconList/> + {translate('component_measures.tab.list')} + </Link> + </li> + )} <li> <Link diff --git a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js index cd1382c271a..782ddfd7ebc 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js +++ b/server/sonar-web/src/main/js/apps/component-measures/store/treeViewActions.js @@ -65,7 +65,7 @@ function getComplementary (metric) { return [metric, ...comp]; } -function makeRequest (baseComponent, metric, options, periodIndex = 1) { +function makeRequest (rootComponent, baseComponent, metric, options, periodIndex = 1) { const asc = metric.direction === 1; const ps = 100; const finalOptions = { asc, ps }; @@ -83,14 +83,21 @@ function makeRequest (baseComponent, metric, options, periodIndex = 1) { }); } + if (rootComponent.qualifier === 'DEV' && baseComponent.qualifier !== 'DEV') { + Object.assign(options, { developerId: rootComponent.id }); + } + Object.assign(finalOptions, options); - return getComponentTree('children', baseComponent.key, getComplementary(metric.key), finalOptions); + + const finalKey = baseComponent.refKey || baseComponent.key; + + return getComponentTree('children', finalKey, getComplementary(metric.key), finalOptions); } -function fetchComponents (baseComponent, metric, pageIndex = 1, periodIndex = 1) { +function fetchComponents (rootComponent, baseComponent, metric, pageIndex = 1, periodIndex = 1) { const options = { p: pageIndex }; - return makeRequest(baseComponent, metric, options, periodIndex).then(r => { + return makeRequest(rootComponent, baseComponent, metric, options, periodIndex).then(r => { const nextComponents = filterOutEmptyMeasures(enhanceWithMeasure(r.components, metric.key, periodIndex)); return { @@ -108,10 +115,10 @@ function fetchComponents (baseComponent, metric, pageIndex = 1, periodIndex = 1) */ function fetchList (baseComponent) { return (dispatch, getState) => { - const { metric, periodIndex } = getState().tree; + const { metric, periodIndex, rootComponent } = getState().tree; dispatch(startFetching()); - return fetchComponents(baseComponent, metric, 1, periodIndex).then(r => { + return fetchComponents(rootComponent, baseComponent, metric, 1, periodIndex).then(r => { dispatch(updateStore({ ...r, baseComponent, @@ -148,9 +155,9 @@ export function start (rootComponent, metric, periodIndex = 1) { */ export function drilldown (component) { return (dispatch, getState) => { - const { metric, breadcrumbs, periodIndex } = getState().tree; + const { metric, rootComponent, breadcrumbs, periodIndex } = getState().tree; dispatch(startFetching()); - return fetchComponents(component, metric, 1, periodIndex).then(r => { + return fetchComponents(rootComponent, component, metric, 1, periodIndex).then(r => { dispatch(updateStore({ ...r, breadcrumbs: [...breadcrumbs, component], @@ -167,10 +174,10 @@ export function drilldown (component) { */ export function useBreadcrumbs (component) { return (dispatch, getState) => { - const { metric, breadcrumbs, periodIndex } = getState().tree; + const { metric, rootComponent, breadcrumbs, periodIndex } = getState().tree; const index = breadcrumbs.indexOf(component); dispatch(startFetching()); - return fetchComponents(component, metric, 1, periodIndex).then(r => { + return fetchComponents(rootComponent, component, metric, 1, periodIndex).then(r => { dispatch(updateStore({ ...r, breadcrumbs: breadcrumbs.slice(0, index + 1), |