Ver código fonte

SONAR-6551 warn about deprecated rules on project overview (#1059)

tags/6.0-RC1
Stas Vilchik 8 anos atrás
pai
commit
fd2274207a

+ 92
- 25
server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.js Ver arquivo

@@ -18,30 +18,97 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
import { translate } from '../../../helpers/l10n';
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import { getQualityProfileUrl } from '../../../helpers/urls';
import { searchRules } from '../../../api/rules';
import { getRulesUrl } from '../../../helpers/urls';

const MetaQualityProfiles = ({ profiles }) => {
return (
<div>
<h4 className="overview-meta-header">
{translate('overview.quality_profiles')}
</h4>

<ul className="overview-meta-list">
{profiles.map(profile => (
<li key={profile.key}>
<span className="note spacer-right">
{'(' + profile.language + ')'}
</span>
<a href={getQualityProfileUrl(profile.key)}>
{profile.name}
</a>
</li>
))}
</ul>
</div>
);
};

export default MetaQualityProfiles;
export default class MetaQualityProfiles extends React.Component {
state = {
deprecatedByKey: {}
};

componentDidMount () {
this.mounted = true;
this.loadDeprecatedRules();
}

componentWillUnmount () {
this.mounted = false;
}

loadDeprecatedRules () {
const requests = this.props.profiles.map(profile => (
this.loadDeprecatedRulesForProfile(profile.key)
));
Promise.all(requests).then(responses => {
if (this.mounted) {
const deprecatedByKey = {};
responses.forEach((count, i) => {
const profileKey = this.props.profiles[i].key;
deprecatedByKey[profileKey] = count;
});
this.setState({ deprecatedByKey });
}
});
}

loadDeprecatedRulesForProfile (profileKey) {
const data = {
qprofile: profileKey,
activation: 'true',
statuses: 'DEPRECATED',
ps: 1
};
return searchRules(data).then(r => r.total);
}

renderDeprecated (profile) {
const count = this.state.deprecatedByKey[profile.key];
if (!count) {
return null;
}

const url = getRulesUrl({
qprofile: profile.key,
activation: 'true',
statuses: 'DEPRECATED'
});

return (
<a className="icon-alert-warn spacer-right"
href={url}
title={translateWithParameters('overview.deprecated_profile', count)}
data-toggle="tooltip"/>
);
}

render () {
const { profiles } = this.props;

return (
<TooltipsContainer>
<div>
<h4 className="overview-meta-header">
{translate('overview.quality_profiles')}
</h4>

<ul className="overview-meta-list">
{profiles.map(profile => (
<li key={profile.key}>
{this.renderDeprecated(profile)}
<span className="note spacer-right">
{'(' + profile.language + ')'}
</span>
<a href={getQualityProfileUrl(profile.key)}>
{profile.name}
</a>
</li>
))}
</ul>
</div>
</TooltipsContainer>
);
}
}

+ 5
- 0
server/sonar-web/src/main/js/apps/overview/styles.css Ver arquivo

@@ -260,6 +260,11 @@
white-space: nowrap;
}

.overview-meta-list i {
position: relative;
top: -1px;
}

/*
* Other
*/

+ 2
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties Ver arquivo

@@ -3009,6 +3009,8 @@ overview.domain.size=Size
overview.complexity_tooltip.function={0} functions have complexity around {1}
overview.complexity_tooltip.file={0} files have complexity around {1}

overview.deprecated_profile=This quality profile uses {0} deprecated rules and should be updated.


#------------------------------------------------------------------------------
#

Carregando…
Cancelar
Salvar