diff options
author | Damien Urruty <damien.urruty@sonarsource.com> | 2024-11-08 18:35:05 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-19 20:02:54 +0000 |
commit | 12d6a58bf18b8996a52be8c30af3fc03c31a0a57 (patch) | |
tree | 1010bd8f9b9cc590141ea8e4d09679201b2f39ae | |
parent | 045816274ba0f5a3ae1984ce06356caac8ff29df (diff) | |
download | sonarqube-12d6a58bf18b8996a52be8c30af3fc03c31a0a57.tar.gz sonarqube-12d6a58bf18b8996a52be8c30af3fc03c31a0a57.zip |
CODEFIX-189 Simplify accepting the terms and conditions
The T&C are automatically accepted when enabling the feature
-rw-r--r-- | server/sonar-web/src/main/js/apps/settings/components/CodeFixAdmin.tsx | 80 | ||||
-rw-r--r-- | sonar-core/src/main/resources/org/sonar/l10n/core.properties | 2 |
2 files changed, 34 insertions, 48 deletions
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<Props>) { 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<Props>) { const handleCancel = () => { setEnableCodeFix(isCodeFixEnabled); - setAcceptedTerms(false); }; if (!hasFeature(Feature.FixSuggestions)) { @@ -124,46 +119,37 @@ function CodeFixAdmin({ hasFeature }: Readonly<Props>) { label={translate('property.codefix.admin.checkbox.label')} checked={Boolean(enableCodeFix)} onCheck={() => setEnableCodeFix(!enableCodeFix)} + helpText={ + <FormattedMessage + id="property.codefix.admin.terms" + defaultMessage={translate('property.codefix.admin.acceptTerm.label')} + values={{ + terms: ( + <Link shouldOpenInNewTab to={getAiCodeFixTermsOfServiceUrl()}> + {translate('property.codefix.admin.acceptTerm.terms')} + </Link> + ), + }} + /> + } /> - {isValueChanged && ( - <div> - <BasicSeparator className="sw-mt-6" /> - {enableCodeFix && ( - <Checkbox - className="sw-mt-6" - label={ - <FormattedMessage - id="property.codefix.admin.terms" - defaultMessage={translate('property.codefix.admin.acceptTerm.label')} - values={{ - terms: ( - <LinkStandalone to={getAiCodeFixTermsOfServiceUrl()}> - {translate('property.codefix.admin.acceptTerm.terms')} - </LinkStandalone> - ), - }} - /> - } - checked={acceptedTerms} - onCheck={() => setAcceptedTerms(!acceptedTerms)} - /> - )} - <div className="sw-mt-6"> - <Button - variety={ButtonVariety.Primary} - isDisabled={!acceptedTerms && enableCodeFix} - onClick={() => { - handleSave(); - }} - > - {translate('save')} - </Button> - <Button className="sw-ml-3" variety={ButtonVariety.Default} onClick={handleCancel}> - {translate('cancel')} - </Button> - </div> + <div> + <BasicSeparator className="sw-mt-6" /> + <div className="sw-mt-6"> + <Button + variety={ButtonVariety.Primary} + isDisabled={!isValueChanged} + onClick={() => { + handleSave(); + }} + > + {translate('save')} + </Button> + <Button className="sw-ml-3" variety={ButtonVariety.Default} onClick={handleCancel}> + {translate('cancel')} + </Button> </div> - )} + </div> </div> <div className="sw-flex-col sw-w-abs-600 sw-p-6"> <HighlightedSection className="sw-items-start"> 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. |