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 (
);
};
- renderDeactivateButton = (inherit: string) => {
+ renderDeactivateButton = (
+ inherit: string,
+ overlayTranslationKey = 'coding_rules.can_not_deactivate'
+ ) => {
return inherit === 'NONE' ? (
<ConfirmButton
confirmButtonText={translate('yes')}
)}
</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>
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()}
</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>
+`;
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: