From 1553847b42c26843c1503fdd8716fe3d9dbee726 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Fri, 22 Nov 2024 17:57:34 +0100 Subject: SONAR-23619 Change AI code assurance setting --- .../quality-gates/components/AIAssuredIcon.tsx | 35 ------------- .../apps/quality-gates/components/Conditions.tsx | 2 +- .../main/js/apps/quality-gates/components/List.tsx | 10 +++- .../js/components/icon-mappers/AIAssuredIcon.tsx | 61 ++++++++++++++++++++++ .../main/js/components/ui/icon/SheildCheckIcon.tsx | 47 +++++++++++++++++ .../main/js/components/ui/icon/SheildCrossIcon.tsx | 51 ++++++++++++++++++ .../src/main/js/components/ui/icon/ShieldIcon.tsx | 43 +++++++++++++++ .../design-system/components/icons/ShieldIcon.tsx | 44 ---------------- .../js/design-system/components/icons/index.ts | 1 - 9 files changed, 211 insertions(+), 83 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/quality-gates/components/AIAssuredIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/icon-mappers/AIAssuredIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/ui/icon/SheildCheckIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/ui/icon/SheildCrossIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/ui/icon/ShieldIcon.tsx delete mode 100644 server/sonar-web/src/main/js/design-system/components/icons/ShieldIcon.tsx (limited to 'server/sonar-web/src') diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/AIAssuredIcon.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/AIAssuredIcon.tsx deleted file mode 100644 index b4cf1d2a233..00000000000 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/AIAssuredIcon.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 { ShieldIcon } from '~design-system'; - -interface Props { - className?: string; - isDisabled?: boolean; -} - -export default function AIAssuredIcon({ isDisabled = false, className }: Readonly) { - return ( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx index 98801f60680..3cc78cc51ee 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx @@ -39,6 +39,7 @@ import { useAvailableFeatures } from '../../../app/components/available-features import { useMetrics } from '../../../app/components/metrics/withMetricsContext'; import DocumentationLink from '../../../components/common/DocumentationLink'; import { ModalProps } from '../../../components/controls/ModalButton'; +import AIAssuredIcon from '../../../components/icon-mappers/AIAssuredIcon'; import { DocLink } from '../../../helpers/doc-links'; import { useDocUrl } from '../../../helpers/docs'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; @@ -53,7 +54,6 @@ import { STANDARD_CONDITIONS_MAP, } from '../utils'; import AddConditionModal from './AddConditionModal'; -import AIAssuredIcon from './AIAssuredIcon'; import CaycCompliantBanner from './CaycCompliantBanner'; import CaycCondition from './CaycCondition'; import CaYCConditionsSimplificationGuide from './CaYCConditionsSimplificationGuide'; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx index bbf9a0f700d..023db95473c 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx @@ -22,12 +22,12 @@ import { IconRefresh, Spinner, Tooltip } from '@sonarsource/echoes-react'; import { useNavigate } from 'react-router-dom'; import { Badge, BareButton, SubnavigationGroup, SubnavigationItem } from '~design-system'; import { useAvailableFeatures } from '../../../app/components/available-features/withAvailableFeatures'; +import AIAssuredIcon, { AiIconColor } from '../../../components/icon-mappers/AIAssuredIcon'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; import { useStandardExperienceModeQuery } from '../../../queries/mode'; import { Feature } from '../../../types/features'; import { CaycStatus, QualityGate } from '../../../types/types'; -import AIAssuredIcon from './AIAssuredIcon'; import BuiltInQualityGateBadge from './BuiltInQualityGateBadge'; import QGRecommendedIcon from './QGRecommendedIcon'; @@ -111,7 +111,13 @@ export default function List({ qualityGates, currentQualityGate }: Readonly - + )} diff --git a/server/sonar-web/src/main/js/components/icon-mappers/AIAssuredIcon.tsx b/server/sonar-web/src/main/js/components/icon-mappers/AIAssuredIcon.tsx new file mode 100644 index 00000000000..1776e197ac6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icon-mappers/AIAssuredIcon.tsx @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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 { SheildCheckIcon } from '../ui/icon/SheildCheckIcon'; +import { SheildCrossIcon } from '../ui/icon/SheildCrossIcon'; +import { ShieldIcon } from '../ui/icon/ShieldIcon'; + +export enum AiIconColor { + Disable = '--echoes-color-icon-disabled', + Default = '--echoes-color-icon-default', + Accent = '--echoes-color-icon-accent', + Subdued = '--echoes-color-icon-subdued', +} + +export enum AiIconVariant { + Default, + Check, + Cross, +} + +interface Props { + className?: string; + color?: AiIconColor; + height?: number; + variant?: AiIconVariant; + width?: number; +} + +const VariantComp = { + [AiIconVariant.Check]: SheildCheckIcon, + [AiIconVariant.Default]: ShieldIcon, + [AiIconVariant.Cross]: SheildCrossIcon, +}; + +export default function AIAssuredIcon({ + color = AiIconColor.Accent, + variant = AiIconVariant.Default, + className, + width = 20, + height = 20, +}: Readonly) { + const Comp = VariantComp[variant]; + return ; +} diff --git a/server/sonar-web/src/main/js/components/ui/icon/SheildCheckIcon.tsx b/server/sonar-web/src/main/js/components/ui/icon/SheildCheckIcon.tsx new file mode 100644 index 00000000000..1ce14fa0670 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/icon/SheildCheckIcon.tsx @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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 { CustomIcon, IconProps } from '~design-system'; + +/* + * Temporary Icon. To remove when echoes gets the proper icon. + */ +export function SheildCheckIcon({ fill, ...iconProps }: Readonly) { + return ( + + + + + + + + ); +} diff --git a/server/sonar-web/src/main/js/components/ui/icon/SheildCrossIcon.tsx b/server/sonar-web/src/main/js/components/ui/icon/SheildCrossIcon.tsx new file mode 100644 index 00000000000..c33710de8f4 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/icon/SheildCrossIcon.tsx @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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 { CustomIcon, IconProps } from '~design-system'; + +/* + * Temporary Icon. To remove when echoes gets the proper icon. + */ +export function SheildCrossIcon({ fill, ...iconProps }: Readonly) { + return ( + + + + + + + + + ); +} diff --git a/server/sonar-web/src/main/js/components/ui/icon/ShieldIcon.tsx b/server/sonar-web/src/main/js/components/ui/icon/ShieldIcon.tsx new file mode 100644 index 00000000000..1e574830efa --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/icon/ShieldIcon.tsx @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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 { CustomIcon, IconProps } from '~design-system'; + +/* + * Temporary Icon. To remove when echoes gets the proper icon. + */ +export function ShieldIcon({ fill, ...iconProps }: Readonly) { + return ( + + + + + + + ); +} diff --git a/server/sonar-web/src/main/js/design-system/components/icons/ShieldIcon.tsx b/server/sonar-web/src/main/js/design-system/components/icons/ShieldIcon.tsx deleted file mode 100644 index 64727a87b61..00000000000 --- a/server/sonar-web/src/main/js/design-system/components/icons/ShieldIcon.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 { useTheme } from '@emotion/react'; -import { themeColor } from '../../helpers/theme'; -import { CustomIcon, IconProps } from './Icon'; - -export function ShieldIcon({ fill = 'currentColor', ...iconProps }: Readonly) { - const theme = useTheme(); - - return ( - - - - - - - ); -} diff --git a/server/sonar-web/src/main/js/design-system/components/icons/index.ts b/server/sonar-web/src/main/js/design-system/components/icons/index.ts index 7ae75fb0318..45d0a0c4ff9 100644 --- a/server/sonar-web/src/main/js/design-system/components/icons/index.ts +++ b/server/sonar-web/src/main/js/design-system/components/icons/index.ts @@ -77,7 +77,6 @@ export { SeverityCriticalIcon } from './SeverityCriticalIcon'; export { SeverityInfoIcon } from './SeverityInfoIcon'; export { SeverityMajorIcon } from './SeverityMajorIcon'; export { SeverityMinorIcon } from './SeverityMinorIcon'; -export { ShieldIcon } from './ShieldIcon'; export { SnoozeCircleIcon } from './SnoozeCircleIcon'; export { SoftwareImpactSeverityBlockerIcon } from './SoftwareImpactSeverityBlockerIcon'; export { SoftwareImpactSeverityHighIcon } from './SoftwareImpactSeverityHighIcon'; -- cgit v1.2.3