aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx
diff options
context:
space:
mode:
authorstanislavh <stanislav.honcharov@sonarsource.com>2023-10-05 10:04:28 +0200
committersonartech <sonartech@sonarsource.com>2023-10-10 20:02:44 +0000
commit047d3846d5e415786323625cd5101a9d54b04725 (patch)
tree714c5c79cd6baf2279b83e549ba590ef6a2081f0 /server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx
parenta898251506b3b27006fa1cfca7c93042ebd857c0 (diff)
downloadsonarqube-047d3846d5e415786323625cd5101a9d54b04725.tar.gz
sonarqube-047d3846d5e415786323625cd5101a9d54b04725.zip
SONAR-20547 Show new taxonomy in profile compare page
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx79
1 files changed, 79 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx
new file mode 100644
index 00000000000..8ff41c5fa1e
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultDeactivation.tsx
@@ -0,0 +1,79 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { DangerButtonSecondary } from 'design-system';
+import { noop } from 'lodash';
+import * as React from 'react';
+import { useIntl } from 'react-intl';
+import { Profile, deactivateRule } from '../../../api/quality-profiles';
+import ConfirmButton from '../../../components/controls/ConfirmButton';
+import Tooltip from '../../../components/controls/Tooltip';
+
+interface Props {
+ onDone: () => Promise<void>;
+ profile: Profile;
+ ruleKey: string;
+ canDeactivateInheritedRules: boolean;
+}
+
+export default function ComparisonResultDeactivation(props: React.PropsWithChildren<Props>) {
+ const { profile, ruleKey, canDeactivateInheritedRules } = props;
+ const intl = useIntl();
+
+ const handleDeactivate = () => {
+ const data = {
+ key: profile.key,
+ rule: ruleKey,
+ };
+ deactivateRule(data).then(props.onDone, noop);
+ };
+
+ return (
+ <ConfirmButton
+ confirmButtonText={intl.formatMessage({ id: 'yes' })}
+ modalBody={intl.formatMessage({ id: 'coding_rules.deactivate.confirm' })}
+ modalHeader={intl.formatMessage({ id: 'coding_rules.deactivate' })}
+ onConfirm={handleDeactivate}
+ >
+ {({ onClick }) => (
+ <Tooltip
+ overlay={
+ canDeactivateInheritedRules
+ ? intl.formatMessage(
+ { id: 'quality_profiles.comparison.deactivate_rule' },
+ { profile: profile.name },
+ )
+ : intl.formatMessage({ id: 'coding_rules.can_not_deactivate' })
+ }
+ >
+ <DangerButtonSecondary
+ disabled={!canDeactivateInheritedRules}
+ onClick={onClick}
+ aria-label={intl.formatMessage(
+ { id: 'quality_profiles.comparison.deactivate_rule' },
+ { profile: profile.name },
+ )}
+ >
+ {intl.formatMessage({ id: 'coding_rules.deactivate' })}
+ </DangerButtonSecondary>
+ </Tooltip>
+ )}
+ </ConfirmButton>
+ );
+}