From 76914764de8ac8599890ea257a30c2507e0479e4 Mon Sep 17 00:00:00 2001 From: Damien Urruty Date: Tue, 19 Nov 2024 16:22:37 +0100 Subject: [PATCH] CODEFIX-204 Display the enablement on the Project Information page --- .../__tests__/ProjectInformationApp-it.tsx | 18 ++++++++++++++++++ .../projectInformation/about/AboutProject.tsx | 9 +++++++++ server/sonar-web/src/main/js/types/types.ts | 1 + .../resources/org/sonar/l10n/core.properties | 2 ++ 4 files changed, 30 insertions(+) diff --git a/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx b/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx index 0d7ba65ab3a..833f0a76838 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/__tests__/ProjectInformationApp-it.tsx @@ -164,6 +164,24 @@ it('should not display ai code assurence', async () => { expect(screen.queryByText('project.info.ai_code_assurance.title')).not.toBeInTheDocument(); }); +it('should display ai code fix section if enabled', async () => { + renderProjectInformationApp({ + isAiCodeFixEnabled: true, + }); + expect(await ui.projectPageTitle.find()).toBeInTheDocument(); + expect(screen.getByText('project.info.ai_code_fix.title')).toBeInTheDocument(); + expect(screen.getByText('project.info.ai_code_fix.message')).toBeInTheDocument(); +}); + +it('should not display ai code fix section if disabled', async () => { + renderProjectInformationApp({ + isAiCodeFixEnabled: false, + }); + expect(await ui.projectPageTitle.find()).toBeInTheDocument(); + expect(screen.queryByText('project.info.ai_code_fix.title')).not.toBeInTheDocument(); + expect(screen.queryByText('project.info.ai_code_fix.message')).not.toBeInTheDocument(); +}); + it('should not show field that is not configured', async () => { renderProjectInformationApp({ qualityGate: undefined, diff --git a/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx b/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx index cef354b5931..27dd155c0fb 100644 --- a/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx +++ b/server/sonar-web/src/main/js/apps/projectInformation/about/AboutProject.tsx @@ -95,6 +95,15 @@ export default function AboutProject(props: AboutProjectProps) { )} + {component.isAiCodeFixEnabled === true && ( + + {translate('project.info.ai_code_fix.title')} + + + + + )} + diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts index 7192a7e8389..f0af608905f 100644 --- a/server/sonar-web/src/main/js/types/types.ts +++ b/server/sonar-web/src/main/js/types/types.ts @@ -78,6 +78,7 @@ export interface Component extends ComponentBase { canBrowseAllChildProjects?: boolean; configuration?: ComponentConfiguration; extensions?: Extension[]; + isAiCodeFixEnabled?: boolean; needIssueSync?: boolean; } 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 e19834083c2..94f23f8c2c5 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2284,6 +2284,8 @@ overview.project_key.tooltip.TRK=Your project key is a unique identifier for you overview.project_key.tooltip.APP=Your application key is a unique identifier for your application. project.info.ai_code_assurance.title=AI Code Assurance project.info.quality_gate.ai_code_assurance.description=This project contains AI-generated code. It must use Sonar way Quality Gate to benefit from Sonar’s AI Code Assurance. +project.info.ai_code_fix.title=AI CodeFix +project.info.ai_code_fix.message=AI CodeFix is enabled for this project. #------------------------------------------------------------------------------ -- 2.39.5