From: Damien Urruty Date: Fri, 8 Nov 2024 17:35:05 +0000 (+0100) Subject: CODEFIX-189 Simplify accepting the terms and conditions X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=12d6a58bf18b8996a52be8c30af3fc03c31a0a57;p=sonarqube.git CODEFIX-189 Simplify accepting the terms and conditions The T&C are automatically accepted when enabling the feature --- diff --git a/server/sonar-web/src/main/js/apps/settings/components/CodeFixAdmin.tsx b/server/sonar-web/src/main/js/apps/settings/components/CodeFixAdmin.tsx index e111ed87715..486aeebeeb5 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/CodeFixAdmin.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/CodeFixAdmin.tsx @@ -26,9 +26,9 @@ import { Heading, IconCheckCircle, IconError, - LinkStandalone, + Link, Spinner, - Text, + Text } from '@sonarsource/echoes-react'; import { MutationStatus } from '@tanstack/react-query'; import { AxiosError } from 'axios'; @@ -37,16 +37,13 @@ import { FormattedMessage } from 'react-intl'; import { BasicSeparator, HighlightedSection, themeColor, UnorderedList } from '~design-system'; import { SuggestionServiceStatusCheckResponse } from '../../../api/fix-suggestions'; import withAvailableFeatures, { - WithAvailableFeaturesProps, + WithAvailableFeaturesProps } from '../../../app/components/available-features/withAvailableFeatures'; import DocumentationLink from '../../../components/common/DocumentationLink'; import { DocLink } from '../../../helpers/doc-links'; import { translate } from '../../../helpers/l10n'; import { getAiCodeFixTermsOfServiceUrl } from '../../../helpers/urls'; -import { - useCheckServiceMutation, - useRemoveCodeSuggestionsCache, -} from '../../../queries/fix-suggestions'; +import { useCheckServiceMutation, useRemoveCodeSuggestionsCache } from '../../../queries/fix-suggestions'; import { useGetValueQuery, useSaveSimpleValueMutation } from '../../../queries/settings'; import { Feature } from '../../../types/features'; import { SettingsKey } from '../../../types/settings'; @@ -68,7 +65,6 @@ function CodeFixAdmin({ hasFeature }: Readonly) { const isCodeFixEnabled = codeFixSetting?.value === 'true'; const [enableCodeFix, setEnableCodeFix] = React.useState(isCodeFixEnabled); - const [acceptedTerms, setAcceptedTerms] = React.useState(false); const { mutate: checkService, isIdle, @@ -94,7 +90,6 @@ function CodeFixAdmin({ hasFeature }: Readonly) { const handleCancel = () => { setEnableCodeFix(isCodeFixEnabled); - setAcceptedTerms(false); }; if (!hasFeature(Feature.FixSuggestions)) { @@ -124,46 +119,37 @@ function CodeFixAdmin({ hasFeature }: Readonly) { label={translate('property.codefix.admin.checkbox.label')} checked={Boolean(enableCodeFix)} onCheck={() => setEnableCodeFix(!enableCodeFix)} + helpText={ + + {translate('property.codefix.admin.acceptTerm.terms')} + + ), + }} + /> + } /> - {isValueChanged && ( -
- - {enableCodeFix && ( - - {translate('property.codefix.admin.acceptTerm.terms')} - - ), - }} - /> - } - checked={acceptedTerms} - onCheck={() => setAcceptedTerms(!acceptedTerms)} - /> - )} -
- - -
+
+ +
+ +
- )} +
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 77db33e8c0d..fbe809bd8df 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1925,7 +1925,7 @@ property.category.housekeeping.auditLogs=Audit Logs property.codefix.admin.title=Enable AI-generated fix suggestions property.codefix.admin.description=Activate this option to enable any user in your organization to generate an AI-suggested code fix for an issue using the Sonar AI CodeFix service. property.codefix.admin.checkbox.label=Enable AI CodeFix -property.codefix.admin.acceptTerm.label=I have read and I accept the {terms} +property.codefix.admin.acceptTerm.label=By activating this option, you agree to the {terms} property.codefix.admin.acceptTerm.terms=AI CodeFix Terms property.codefix.admin.promoted_section.title=Free - early access feature property.codefix.admin.promoted_section.content1=This no cost trial is offered to you at Sonar’s discretion. Sonar can decide to stop this trial anytime.