aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-08-11 16:05:21 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-08-14 11:44:44 +0200
commitb061ff846dbab20e26e348b9e940de671d5296de (patch)
tree19394c6942128fab5249c4e19c87b1f40eb2cc1e
parentd74de53a7245cb970e7e62057dab72eccec6bdc2 (diff)
downloadsonarqube-b061ff846dbab20e26e348b9e940de671d5296de.tar.gz
sonarqube-b061ff846dbab20e26e348b9e940de671d5296de.zip
SONAR-9806 Add the quality gate metric back for Views and Subviews
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.js5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js5
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.js48
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/config/domains.js2
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js6
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js7
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/utils.js41
7 files changed, 76 insertions, 38 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.js b/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.js
index bcf1739c38c..38672597858 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.js
@@ -43,7 +43,10 @@ const mapStateToProps = (state, ownProps) => ({
});
const banQualityGate = (component: Component): Array<Measure> => {
- const bannedMetrics = ['alert_status'];
+ const bannedMetrics = [];
+ if (!['VW', 'SVW'].includes(component.qualifier)) {
+ bannedMetrics.push('alert_status');
+ }
if (component.qualifier === 'APP') {
bannedMetrics.push('releasability_rating', 'releasability_effort');
}
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
index 0a403474482..3b5552955bb 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
@@ -196,7 +196,7 @@ export default class MeasureContent extends React.PureComponent {
const component = this.state.components.find(
component => component.refKey === componentKey || component.key === componentKey
);
- if (component && component.qualifier === 'TRK') {
+ if (component && component.refKey != null) {
if (this.props.view === 'treemap') {
this.props.router.push(getProjectUrl(componentKey));
}
@@ -315,7 +315,8 @@ export default class MeasureContent extends React.PureComponent {
</div>
</div>
</div>
- {metric == null && <MetricNotFound className="layout-page-main-inner measure-details-content" />}
+ {metric == null &&
+ <MetricNotFound className="layout-page-main-inner measure-details-content" />}
{metric != null &&
measure != null &&
<div className="layout-page-main-inner measure-details-content">
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.js
index ec33171709a..e17f12a8589 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.js
@@ -23,7 +23,7 @@ import Select from 'react-select';
import ListIcon from '../../../components/icons-components/ListIcon';
import TreeIcon from '../../../components/icons-components/TreeIcon';
import TreemapIcon from '../../../components/icons-components/TreemapIcon';
-import { hasTreemap } from '../utils';
+import { hasList, hasTree, hasTreemap } from '../utils';
import { translate } from '../../../helpers/l10n';
import type { Metric } from '../../../store/metrics/actions';
@@ -40,27 +40,31 @@ export default class MeasureViewSelect extends React.PureComponent {
getOptions = () => {
const { metric } = this.props;
const options = [];
- options.push({
- value: 'list',
- label: (
- <div>
- <ListIcon className="little-spacer-right" />
- {translate('component_measures.tab.list')}
- </div>
- ),
- icon: <ListIcon />
- });
- options.push({
- value: 'tree',
- label: (
- <div>
- <TreeIcon className="little-spacer-right" />
- {translate('component_measures.tab.tree')}
- </div>
- ),
- icon: <TreeIcon />
- });
- if (hasTreemap(metric.type)) {
+ if (hasList(metric.key)) {
+ options.push({
+ value: 'list',
+ label: (
+ <div>
+ <ListIcon className="little-spacer-right" />
+ {translate('component_measures.tab.list')}
+ </div>
+ ),
+ icon: <ListIcon />
+ });
+ }
+ if (hasTree(metric.key)) {
+ options.push({
+ value: 'tree',
+ label: (
+ <div>
+ <TreeIcon className="little-spacer-right" />
+ {translate('component_measures.tab.tree')}
+ </div>
+ ),
+ icon: <TreeIcon />
+ });
+ }
+ if (hasTreemap(metric.key, metric.type)) {
options.push({
value: 'treemap',
label: (
diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/domains.js b/server/sonar-web/src/main/js/apps/component-measures/config/domains.js
index 9f10d6f7b28..274f09a5e86 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/config/domains.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/config/domains.js
@@ -116,7 +116,7 @@ export const domains = {
},
Releasability: {
- order: ['alert_status']
+ order: ['releasability_rating', 'releasability_effort', 'alert_status']
},
Issues: {
diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js
index 0efc611f94e..7bdea166fd9 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.js
@@ -27,7 +27,7 @@ import FacetItemsList from '../../../components/facet/FacetItemsList';
import FacetMeasureValue from './FacetMeasureValue';
import IssueTypeIcon from '../../../components/ui/IssueTypeIcon';
import Tooltip from '../../../components/controls/Tooltip';
-import { filterMeasures, hasBubbleChart, sortMeasures } from '../utils';
+import { filterMeasures, hasBubbleChart, hasFacetStat, sortMeasures } from '../utils';
import {
getLocalizedMetricDomain,
getLocalizedMetricName,
@@ -119,7 +119,9 @@ export default class DomainFacet extends React.PureComponent {
</Tooltip>
}
onClick={this.props.onChange}
- stat={<FacetMeasureValue measure={measure} />}
+ stat={
+ hasFacetStat(measure.metric.key) ? <FacetMeasureValue measure={measure} /> : null
+ }
value={measure.metric.key}
/>
)}
diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js
index f74f751656d..465439125af 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.js
@@ -21,7 +21,7 @@
import React from 'react';
import ProjectOverviewFacet from './ProjectOverviewFacet';
import DomainFacet from './DomainFacet';
-import { groupByDomains, KNOWN_DOMAINS, PROJECT_OVERVEW } from '../utils';
+import { getDefaultView, groupByDomains, KNOWN_DOMAINS, PROJECT_OVERVEW } from '../utils';
import type { MeasureEnhanced } from '../../../components/measure/types';
import type { Query } from '../types';
@@ -67,9 +67,10 @@ export default class Sidebar extends React.PureComponent {
}));
};
- resetSelection = () => ({ selected: null, view: 'list' });
+ resetSelection = (metric: string) => ({ selected: null, view: getDefaultView(metric) });
- changeMetric = (metric: string) => this.props.updateQuery({ metric, ...this.resetSelection() });
+ changeMetric = (metric: string) =>
+ this.props.updateQuery({ metric, ...this.resetSelection(metric) });
render() {
return (
diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.js b/server/sonar-web/src/main/js/apps/component-measures/utils.js
index a1cd1d3c2ac..0ae0a1dfa15 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/utils.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/utils.js
@@ -112,11 +112,25 @@ export const groupByDomains = memoize((measures: Array<MeasureEnhanced>): Array<
]);
});
-export const hasTreemap = (metricType: string): boolean =>
- ['PERCENT', 'RATING', 'LEVEL'].includes(metricType);
+export const getDefaultView = (metric: string): string => {
+ if (!hasList(metric)) {
+ return 'tree';
+ }
+ return DEFAULT_VIEW;
+};
+
+export const hasList = (metric: string): boolean =>
+ !['releasability_rating', 'releasability_effort'].includes(metric);
+
+export const hasTree = (metric: string): boolean => metric !== 'alert_status';
+
+export const hasTreemap = (metric: string, type: string): boolean =>
+ ['PERCENT', 'RATING', 'LEVEL'].includes(type) && hasTree(metric);
export const hasBubbleChart = (domainName: string): boolean => bubbles[domainName] != null;
+export const hasFacetStat = (metric: string): boolean => metric !== 'alert_status';
+
export const getBubbleMetrics = (domain: string, metrics: { [string]: Metric }) => {
const conf = bubbles[domain];
return {
@@ -129,11 +143,24 @@ export const getBubbleMetrics = (domain: string, metrics: { [string]: Metric })
export const isProjectOverview = (metric: string) => metric === PROJECT_OVERVEW;
-export const parseQuery = memoize((urlQuery: RawQuery): Query => ({
- metric: parseAsString(urlQuery['metric']) || DEFAULT_METRIC,
- selected: parseAsString(urlQuery['selected']),
- view: parseAsString(urlQuery['view']) || DEFAULT_VIEW
-}));
+const parseView = memoize((rawView?: string, metric: string) => {
+ const view = parseAsString(rawView) || DEFAULT_VIEW;
+ if (!hasTree(metric)) {
+ return 'list';
+ } else if (view === 'list' && !hasList(metric)) {
+ return 'tree';
+ }
+ return view;
+});
+
+export const parseQuery = memoize((urlQuery: RawQuery): Query => {
+ const metric = parseAsString(urlQuery['metric']) || DEFAULT_METRIC;
+ return {
+ metric,
+ selected: parseAsString(urlQuery['selected']),
+ view: parseView(urlQuery['view'], metric)
+ };
+});
export const serializeQuery = memoize((query: Query): RawQuery => {
return cleanQuery({