diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-06-29 15:44:13 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-07-04 16:29:36 +0200 |
commit | e843bd39520a3c97948b9920ae9db6c525cada95 (patch) | |
tree | 8c2dee8c762d70948a36a748cbb87b56c2bee937 /server/sonar-web/src/main/js | |
parent | 06ee234f17c62f3296deb212e9b1ab20d812db42 (diff) | |
download | sonarqube-e843bd39520a3c97948b9920ae9db6c525cada95.tar.gz sonarqube-e843bd39520a3c97948b9920ae9db6c525cada95.zip |
SONAR-9483 Add link to the rules and highlight compared quality profiles
Diffstat (limited to 'server/sonar-web/src/main/js')
3 files changed, 44 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js index 5b1ce432a7a..09a232e530e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js @@ -33,6 +33,29 @@ export default BaseFacet.extend({ }; }, + onRender() { + this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled')); + this.$el.attr('data-property', this.model.get('property')); + const that = this; + const property = this.model.get('property'); + const value = this.options.app.state.get('query')[property]; + if (typeof value === 'string') { + value.split(',').forEach(s => { + const facet = that.$('.js-facet').filter(`[data-value="${s}"]`); + if (facet.length > 0) { + facet.addClass('active'); + } + }); + } + const compareToProfile = this.options.app.state.get('query').compareToProfile; + if (typeof compareToProfile === 'string') { + const facet = that.$('.js-facet').filter(`[data-value="${compareToProfile}"]`); + if (facet.length > 0) { + facet.addClass('active compare'); + } + } + }, + getValues() { const that = this; const languagesQuery = this.options.app.state.get('query').languages; @@ -64,12 +87,23 @@ export default BaseFacet.extend({ setActivation(e) { e.stopPropagation(); - this.options.app.state.updateFilter({ activation: 'true' }); + const compareProfile = this.options.app.state.get('query').compareToProfile; + const profile = $(e.currentTarget).parents('.js-facet').data('value'); + if (compareProfile == null || compareProfile !== profile) { + this.options.app.state.updateFilter({ activation: 'true' }); + } }, unsetActivation(e) { e.stopPropagation(); - this.options.app.state.updateFilter({ activation: 'false', active_severities: null }); + const compareProfile = this.options.app.state.get('query').compareToProfile; + const profile = $(e.currentTarget).parents('.js-facet').data('value'); + if (compareProfile == null || compareProfile !== profile) { + this.options.app.state.updateFilter({ + activation: 'false', + active_severities: null + }); + } }, getToggled() { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js index 97427ee1d34..edf0ab821b4 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRulesSonarWayComparison.js @@ -21,6 +21,7 @@ import React from 'react'; import { Link } from 'react-router'; import Tooltip from '../../../components/controls/Tooltip'; +import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; type Props = { @@ -31,6 +32,11 @@ type Props = { }; export default function ProfileRulesSonarWayComparison(props: Props) { + const url = getRulesUrl( + { qprofile: props.profile, activation: false, compareToProfile: props.sonarway }, + props.organization + ); + return ( <div className="quality-profile-rules-sonarway-missing clearfix"> <span className="pull-left"> @@ -39,7 +45,7 @@ export default function ProfileRulesSonarWayComparison(props: Props) { <i className="icon-help spacer-left" /> </Tooltip> </span> - <Link className="pull-right"> + <Link className="pull-right" to={url}> {props.sonarWayMissingRules} </Link> </div> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRulesSonarWayComparison-test.js.snap b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRulesSonarWayComparison-test.js.snap index 6864b28e71b..9d9c67072bf 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRulesSonarWayComparison-test.js.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/ProfileRulesSonarWayComparison-test.js.snap @@ -21,6 +21,7 @@ exports[`should render correctly 1`] = ` className="pull-right" onlyActiveOnIndex={false} style={Object {}} + to="/organizations/foo/rules#qprofile=bar|activation=false|compareToProfile=baz" > 158 </Link> |