@@ -136,7 +136,11 @@ export default class RuleListItem extends React.PureComponent<Props> { | |||
if (selectedProfile.isBuiltIn && canCopy) { | |||
return ( | |||
<td className="coding-rule-table-meta-cell coding-rule-activation-actions"> | |||
{this.renderDeactivateButton('', 'coding_rules.need_extend_or_copy')} | |||
<Tooltip overlay={translate('coding_rules.need_extend_or_copy')}> | |||
<Button className="coding-rules-detail-quality-profile-deactivate button-red disabled"> | |||
{translate('coding_rules', activation ? 'deactivate' : 'activate')} | |||
</Button> | |||
</Tooltip> | |||
</td> | |||
); | |||
} | |||
@@ -146,48 +150,47 @@ export default class RuleListItem extends React.PureComponent<Props> { | |||
return null; | |||
} | |||
if (activation) { | |||
return ( | |||
<td className="coding-rule-table-meta-cell coding-rule-activation-actions"> | |||
{activation.inherit === 'NONE' ? ( | |||
<ConfirmButton | |||
confirmButtonText={translate('yes')} | |||
modalBody={translate('coding_rules.deactivate.confirm')} | |||
modalHeader={translate('coding_rules.deactivate')} | |||
onConfirm={this.handleDeactivate}> | |||
{({ onClick }) => ( | |||
<Button | |||
className="coding-rules-detail-quality-profile-deactivate button-red" | |||
onClick={onClick}> | |||
{translate('coding_rules.deactivate')} | |||
</Button> | |||
)} | |||
</ConfirmButton> | |||
) : ( | |||
<Tooltip overlay={translate('coding_rules.can_not_deactivate')}> | |||
<Button className="coding-rules-detail-quality-profile-deactivate button-red disabled"> | |||
{translate('coding_rules.deactivate')} | |||
</Button> | |||
</Tooltip> | |||
)} | |||
</td> | |||
); | |||
} | |||
return ( | |||
<td className="coding-rule-table-meta-cell coding-rule-activation-actions"> | |||
{activation | |||
? this.renderDeactivateButton(activation.inherit) | |||
: !rule.isTemplate && ( | |||
<ActivationButton | |||
buttonText={translate('coding_rules.activate')} | |||
className="coding-rules-detail-quality-profile-activate" | |||
modalHeader={translate('coding_rules.activate_in_quality_profile')} | |||
onDone={this.handleActivate} | |||
profiles={[selectedProfile]} | |||
rule={rule} | |||
/> | |||
)} | |||
</td> | |||
); | |||
}; | |||
renderDeactivateButton = ( | |||
inherit: string, | |||
overlayTranslationKey = 'coding_rules.can_not_deactivate' | |||
) => { | |||
return inherit === 'NONE' ? ( | |||
<ConfirmButton | |||
confirmButtonText={translate('yes')} | |||
modalBody={translate('coding_rules.deactivate.confirm')} | |||
modalHeader={translate('coding_rules.deactivate')} | |||
onConfirm={this.handleDeactivate}> | |||
{({ onClick }) => ( | |||
<Button | |||
className="coding-rules-detail-quality-profile-deactivate button-red" | |||
onClick={onClick}> | |||
{translate('coding_rules.deactivate')} | |||
</Button> | |||
{!rule.isTemplate && ( | |||
<ActivationButton | |||
buttonText={translate('coding_rules.activate')} | |||
className="coding-rules-detail-quality-profile-activate" | |||
modalHeader={translate('coding_rules.activate_in_quality_profile')} | |||
onDone={this.handleActivate} | |||
profiles={[selectedProfile]} | |||
rule={rule} | |||
/> | |||
)} | |||
</ConfirmButton> | |||
) : ( | |||
<Tooltip overlay={translate(overlayTranslationKey)}> | |||
<Button className="coding-rules-detail-quality-profile-deactivate button-red disabled"> | |||
{translate('coding_rules.deactivate')} | |||
</Button> | |||
</Tooltip> | |||
</td> | |||
); | |||
}; | |||
@@ -71,18 +71,6 @@ it('handle deactivation', async () => { | |||
expect(onDeactivate).toBeCalledWith(profile.key, rule.key); | |||
}); | |||
describe('#renderDeactivateButton', () => { | |||
it('should render correctly', () => { | |||
const wrapper = shallowRender(); | |||
const instance = wrapper.instance(); | |||
expect(instance.renderDeactivateButton('NONE')).toMatchSnapshot(); | |||
expect( | |||
instance.renderDeactivateButton('', 'coding_rules.need_extend_or_copy') | |||
).toMatchSnapshot(); | |||
}); | |||
}); | |||
describe('renderActions', () => { | |||
it('should be null when there is no selected profile', () => { | |||
const wrapper = shallowRender({ | |||
@@ -120,7 +108,9 @@ describe('renderActions', () => { | |||
}) | |||
}); | |||
expect(wrapper.instance().renderActions()).toMatchSnapshot(); | |||
expect(wrapper.instance().renderActions()).toMatchSnapshot('activate'); | |||
wrapper.setProps({ activation: { inherit: 'INHERITED', severity: 'CRITICAL' } }); | |||
expect(wrapper.instance().renderActions()).toMatchSnapshot('deactivate'); | |||
}); | |||
it('should render the deactivate button', () => { |
@@ -1,29 +1,22 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`#renderDeactivateButton should render correctly 1`] = ` | |||
<ConfirmButton | |||
confirmButtonText="yes" | |||
modalBody="coding_rules.deactivate.confirm" | |||
modalHeader="coding_rules.deactivate" | |||
onConfirm={[Function]} | |||
> | |||
[Function] | |||
</ConfirmButton> | |||
`; | |||
exports[`#renderDeactivateButton should render correctly 2`] = ` | |||
<Tooltip | |||
overlay="coding_rules.need_extend_or_copy" | |||
exports[`renderActions should disable the button when I am on a built-in profile: activate 1`] = ` | |||
<td | |||
className="coding-rule-table-meta-cell coding-rule-activation-actions" | |||
> | |||
<Button | |||
className="coding-rules-detail-quality-profile-deactivate button-red disabled" | |||
<Tooltip | |||
overlay="coding_rules.need_extend_or_copy" | |||
> | |||
coding_rules.deactivate | |||
</Button> | |||
</Tooltip> | |||
<Button | |||
className="coding-rules-detail-quality-profile-deactivate button-red disabled" | |||
> | |||
coding_rules.activate | |||
</Button> | |||
</Tooltip> | |||
</td> | |||
`; | |||
exports[`renderActions should disable the button when I am on a built-in profile 1`] = ` | |||
exports[`renderActions should disable the button when I am on a built-in profile: deactivate 1`] = ` | |||
<td | |||
className="coding-rule-table-meta-cell coding-rule-activation-actions" | |||
> |
@@ -1647,7 +1647,7 @@ coding_rules.bulk_change=Bulk Change | |||
coding_rules.bulk_change.success={2} rule(s) changed in profile {0} - {1} | |||
coding_rules.bulk_change.warning={2} rule(s) changed, {3} rule(s) ignored in profile {0} - {1} | |||
coding_rules.can_not_bulk_change=Bulk change is only available when you have a custom Quality Profile to target. You can create a customizable Quality Profile based on a built-in one by Copying or Extending it in the Quality Profiles list. | |||
coding_rules.can_not_deactivate=This rule is inherited and can not be deactivated. | |||
coding_rules.can_not_deactivate=This rule is inherited and cannot be deactivated. | |||
coding_rules.change_details=Change Details of Quality Profile | |||
coding_rules.create=Create | |||
coding_rules.create_custom_rule=Create Custom Rule | |||
@@ -1668,7 +1668,7 @@ coding_rules.inherits="{0}" inherits from "{1}" | |||
coding_rules.issues=Issues | |||
coding_rules.issues.only_main_branches=Only issues from the main project branches are included. | |||
coding_rules.most_violating_projects=Most Violating Projects | |||
coding_rules.need_extend_or_copy=Rules in built-in Quality Profiles can't be deactivated. You can create a customizable Quality Profile based on a built-in one by Copying or Extending it in the Quality Profiles list. | |||
coding_rules.need_extend_or_copy=Rules in built-in Quality Profiles can't be changed. You can create a customizable Quality Profile based on a built-in one by Copying or Extending it in the Quality Profiles list. | |||
coding_rules.no_results=No Coding Rules | |||
coding_rules.no_tags=No tags | |||
coding_rules.original=Original: |