/* * 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 { ActionCell, ButtonPrimary, ContentCell, HelperHintIcon, InteractiveIcon, LargeCenteredLayout, Link, PageContentFontWrapper, PencilIcon, Spinner, Table, TableRow, TableRowInteractive, Title, } from 'design-system'; import { groupBy, orderBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip'; import { Profile } from '../../api/quality-profiles'; import A11ySkipTarget from '../../components/a11y/A11ySkipTarget'; import Suggestions from '../../components/embed-docs-modal/Suggestions'; import { translate } from '../../helpers/l10n'; import { getRulesUrl } from '../../helpers/urls'; import { Component } from '../../types/types'; import BuiltInQualityProfileBadge from '../quality-profiles/components/BuiltInQualityProfileBadge'; import AddLanguageModal from './components/AddLanguageModal'; import SetQualityProfileModal from './components/SetQualityProfileModal'; import { ProjectProfile } from './types'; export interface ProjectQualityProfilesAppRendererProps { allProfiles?: Profile[]; component: Component; loading: boolean; onAddLanguage: (key: string) => Promise; onCloseModal: () => void; onOpenAddLanguageModal: () => void; onOpenSetProfileModal: (projectProfile: ProjectProfile) => void; onSetProfile: (newKey: string | undefined, oldKey: string) => Promise; projectProfiles?: ProjectProfile[]; showAddLanguageModal?: boolean; showProjectProfileInModal?: ProjectProfile; } export default function ProjectQualityProfilesAppRenderer( props: Readonly, ) { const { allProfiles, component, loading, showProjectProfileInModal, projectProfiles, showAddLanguageModal, } = props; const profilesByLanguage = groupBy(allProfiles, 'language'); const orderedProfiles = orderBy(projectProfiles, (p) => p.profile.languageName); const COLUMN_WIDTHS_WITH_PURGE_SETTING = ['auto', 'auto', 'auto', '5%']; const header = ( {translate('language')} {translate('project_quality_profile.current')} {translate('coding_rules.filters.activation.active_rules')} {translate('actions')} ); return (
{translate('project_quality_profiles.page')}

{translate('project_quality_profiles.page.description')}

{!loading && orderedProfiles.length > 0 && ( {orderedProfiles.map((projectProfile) => { const { profile, selected } = projectProfile; return ( {profile.languageName} {!selected && profile.isDefault ? ( {translate('project_quality_profile.instance_default')} ) : ( <> {profile.name} {profile.isBuiltIn && ( )} )} {profile.activeRuleCount} { props.onOpenSetProfileModal(projectProfile); }} size="small" stopPropagation={false} /> ); })}
)}
{translate('project_quality_profile.add_language.description')}
{translate('project_quality_profile.add_language.action')}
{showProjectProfileInModal && ( )} {showAddLanguageModal && projectProfiles && ( p.profile.language)} /> )}
); }