@@ -20,9 +20,8 @@ | |||
import React from 'react'; | |||
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; | |||
import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
import { getQualityProfileUrl } from '../../../helpers/urls'; | |||
import { getQualityProfileUrl, getRulesUrl } from '../../../helpers/urls'; | |||
import { searchRules } from '../../../api/rules'; | |||
import { getRulesUrl } from '../../../helpers/urls'; | |||
export default class MetaQualityProfiles extends React.Component { | |||
state = { | |||
@@ -64,6 +63,11 @@ export default class MetaQualityProfiles extends React.Component { | |||
return searchRules(data).then(r => r.total); | |||
} | |||
getDeprecatedRulesCount (profile) { | |||
const count = this.state.deprecatedByKey[profile.key]; | |||
return count || 0; | |||
} | |||
renderDeprecated (profile) { | |||
const count = this.state.deprecatedByKey[profile.key]; | |||
if (!count) { | |||
@@ -84,9 +88,50 @@ export default class MetaQualityProfiles extends React.Component { | |||
); | |||
} | |||
renderProfile (profile) { | |||
const inner = ( | |||
<div> | |||
<span className="note spacer-right"> | |||
{'(' + profile.language + ')'} | |||
</span> | |||
<a href={getQualityProfileUrl(profile.key)}> | |||
{profile.name} | |||
</a> | |||
</div> | |||
); | |||
const count = this.getDeprecatedRulesCount(profile); | |||
if (count > 0) { | |||
const tooltip = | |||
translateWithParameters('overview.deprecated_profile', count); | |||
return ( | |||
<li key={profile.key} | |||
className="overview-deprecated-rules" | |||
title={tooltip} | |||
data-toggle="tooltip"> | |||
{inner} | |||
</li> | |||
); | |||
} | |||
return ( | |||
<li key={profile.key}> | |||
{inner} | |||
</li> | |||
); | |||
} | |||
render () { | |||
const { profiles } = this.props; | |||
const deprecatedStyles = { | |||
padding: '3px 6px', | |||
border: '1px solid #ebccd1', | |||
borderRadius: '3px', | |||
backgroundColor: '#f2dede' | |||
}; | |||
return ( | |||
<TooltipsContainer> | |||
<div> | |||
@@ -95,17 +140,7 @@ export default class MetaQualityProfiles extends React.Component { | |||
</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> | |||
))} | |||
{profiles.map(profile => this.renderProfile(profile))} | |||
</ul> | |||
</div> | |||
</TooltipsContainer> |
@@ -283,6 +283,14 @@ | |||
background-color: transparent !important; | |||
} | |||
.overview-deprecated-rules { | |||
margin: 4px -6px 4px; | |||
padding: 3px 6px; | |||
border: 1px solid #ebccd1; | |||
border-radius: 3px; | |||
background-color: #f2dede; | |||
} | |||
/* | |||
* Animations | |||
*/ |
@@ -21,7 +21,6 @@ import React from 'react'; | |||
import keyBy from 'lodash/keyBy'; | |||
import ProfileRulesRow from './ProfileRulesRow'; | |||
import { ProfileType } from '../propTypes'; | |||
import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; | |||
import { searchRules, takeFacet } from '../../../api/rules'; | |||
import { translate, translateWithParameters } from '../../../helpers/l10n'; | |||
import { formatMeasure } from '../../../helpers/measures'; |
@@ -37,10 +37,6 @@ export default class EvolutionDeprecated extends React.Component { | |||
return null; | |||
} | |||
const totalRules = profilesWithDeprecations | |||
.map(p => p.activeDeprecatedRuleCount) | |||
.reduce((p, c) => p + c, 0); | |||
const sortedProfiles = | |||
sortBy(profilesWithDeprecations, p => -p.activeDeprecatedRuleCount); | |||
@@ -52,8 +48,7 @@ export default class EvolutionDeprecated extends React.Component { | |||
</div> | |||
<div className="spacer-bottom"> | |||
{translateWithParameters( | |||
'quality_profiles.x_deprecated_rules_are_still_activated', | |||
totalRules, | |||
'quality_profiles.deprecated_rules_are_still_activated', | |||
profilesWithDeprecations.length | |||
)} | |||
</div> |
@@ -23,10 +23,11 @@ import sortBy from 'lodash/sortBy'; | |||
import { searchRules } from '../../../api/rules'; | |||
import { translateWithParameters, translate } from '../../../helpers/l10n'; | |||
import { getRulesUrl } from '../../../helpers/urls'; | |||
import { formatMeasure } from '../../../helpers/measures'; | |||
const RULES_LIMIT = 3; | |||
const RULES_LIMIT = 10; | |||
const PERIOD_START_MOMENT = moment().subtract(1, 'month'); | |||
const PERIOD_START_MOMENT = moment().subtract(1, 'year'); | |||
function parseRules (r) { | |||
const { rules, actives } = r; | |||
@@ -82,13 +83,6 @@ export default class EvolutionRules extends React.Component { | |||
<strong className="pull-left"> | |||
{translate('quality_profiles.latest_new_rules')} | |||
</strong> | |||
{this.state.latestRulesTotal > RULES_LIMIT && ( | |||
<a className="pull-right small text-muted" | |||
href={newRulesUrl}> | |||
{translate('see_all')} | |||
</a> | |||
)} | |||
</div> | |||
<ul> | |||
{this.state.latestRules.map(rule => ( | |||
@@ -117,6 +111,16 @@ export default class EvolutionRules extends React.Component { | |||
</li> | |||
))} | |||
</ul> | |||
{this.state.latestRulesTotal > RULES_LIMIT && ( | |||
<div className="spacer-top"> | |||
<a className="small" | |||
href={newRulesUrl}> | |||
{translate('see_all')} | |||
{' '} | |||
{formatMeasure(this.state.latestRulesTotal, 'SHORT_INT')} | |||
</a> | |||
</div> | |||
)} | |||
</div> | |||
); | |||
} |
@@ -77,8 +77,7 @@ | |||
.quality-profile-rules-deprecated { | |||
padding: 15px 20px; | |||
border-top: 1px solid #e6e6e6; | |||
background-color: #fcf8e3; | |||
background-color: #f2dede; | |||
} | |||
.quality-profile-exporters { |
@@ -1755,7 +1755,7 @@ quality_profiles.deleted_profile=The profile {0} doesn't exist anymore | |||
quality_profiles.projects_for_default=Every project not specifically associated with a quality profile will be associated to this one by default. | |||
quality_profiles.projects_for_default.edit=You must not select specific projects for the default quality profile. | |||
quality_profiles.inherits=Inherits "{0}" | |||
quality_profile.x_rules={0} rules | |||
quality_profile.x_rules={0} rule(s) | |||
quality_profile.x_active_rules={0} active rules | |||
quality_profiles.x_overridden_rules={0} overridden rules | |||
quality_profiles.change_parent=Change Parent | |||
@@ -1785,7 +1785,7 @@ quality_profiles.latest_new_rules=Latest New Rules | |||
quality_profiles.latest_new_rules.activated={0}, activated on {1} profile(s) | |||
quality_profiles.latest_new_rules.not_activated={0}, not yet activated | |||
quality_profiles.deprecated_rules=Deprecated Rules | |||
quality_profiles.x_deprecated_rules_are_still_activated={0} deprecated rule(s) are still activated on {1} quality profile(s): | |||
quality_profiles.deprecated_rules_are_still_activated=Deprecated rules are still activated on {0} quality profile(s): | |||
quality_profiles.stagnant_profiles=Stagnant Profiles | |||
quality_profiles.not_updated_more_than_year=The following profiles haven't been updated for more than 1 year: | |||
quality_profiles.exporters=Exporters |