@@ -131,7 +131,11 @@ export default class RuleListItem extends React.PureComponent<Props> { | |||
const canEdit = selectedProfile.actions && selectedProfile.actions.edit; | |||
if (!canEdit || selectedProfile.isBuiltIn) { | |||
return null; | |||
return ( | |||
<td className="coding-rule-table-meta-cell coding-rule-activation-actions"> | |||
{this.renderDeactivateButton('', 'coding_rules.need_extend_or_copy')} | |||
</td> | |||
); | |||
} | |||
return ( | |||
@@ -153,7 +157,10 @@ export default class RuleListItem extends React.PureComponent<Props> { | |||
); | |||
}; | |||
renderDeactivateButton = (inherit: string) => { | |||
renderDeactivateButton = ( | |||
inherit: string, | |||
overlayTranslationKey = 'coding_rules.can_not_deactivate' | |||
) => { | |||
return inherit === 'NONE' ? ( | |||
<ConfirmButton | |||
confirmButtonText={translate('yes')} | |||
@@ -169,7 +176,7 @@ export default class RuleListItem extends React.PureComponent<Props> { | |||
)} | |||
</ConfirmButton> | |||
) : ( | |||
<Tooltip overlay={translate('coding_rules.can_not_deactivate')}> | |||
<Tooltip overlay={translate(overlayTranslationKey)}> | |||
<Button className="coding-rules-detail-quality-profile-deactivate button-red disabled"> | |||
{translate('coding_rules.deactivate')} | |||
</Button> |
@@ -33,8 +33,16 @@ it('should open rule', () => { | |||
expect(onOpen).toBeCalledWith('javascript:S1067'); | |||
}); | |||
it('should render deactivate button', () => { | |||
const wrapper = shallowRender(); | |||
const instance = wrapper.instance(); | |||
expect(instance.renderDeactivateButton('NONE')).toMatchSnapshot(); | |||
expect(instance.renderDeactivateButton('', 'coding_rules.need_extend_or_copy')).toMatchSnapshot(); | |||
}); | |||
function shallowRender(props?: Partial<RuleListItem['props']>) { | |||
return shallow( | |||
return shallow<RuleListItem>( | |||
<RuleListItem | |||
onActivate={jest.fn()} | |||
onDeactivate={jest.fn()} |
@@ -96,3 +96,26 @@ exports[`should render 1`] = ` | |||
</table> | |||
</div> | |||
`; | |||
exports[`should render deactivate button 1`] = ` | |||
<ConfirmButton | |||
confirmButtonText="yes" | |||
modalBody="coding_rules.deactivate.confirm" | |||
modalHeader="coding_rules.deactivate" | |||
onConfirm={[Function]} | |||
> | |||
[Function] | |||
</ConfirmButton> | |||
`; | |||
exports[`should render deactivate button 2`] = ` | |||
<Tooltip | |||
overlay="coding_rules.need_extend_or_copy" | |||
> | |||
<Button | |||
className="coding-rules-detail-quality-profile-deactivate button-red disabled" | |||
> | |||
coding_rules.deactivate | |||
</Button> | |||
</Tooltip> | |||
`; |
@@ -1321,6 +1321,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.no_results=No Coding Rules | |||
coding_rules.no_tags=No tags | |||
coding_rules.original=Original: |