3 * Copyright (C) 2009-2020 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import * as React from 'react';
21 import { translate } from 'sonar-ui-common/helpers/l10n';
22 import PrivacyBadgeContainer from '../../../../../components/common/PrivacyBadgeContainer';
23 import { ComponentQualifier } from '../../../../../types/component';
24 import DrawerLink from './DrawerLink';
25 import MetaKey from './meta/MetaKey';
26 import MetaLinks from './meta/MetaLinks';
27 import MetaQualityGate from './meta/MetaQualityGate';
28 import MetaQualityProfiles from './meta/MetaQualityProfiles';
29 import MetaSize from './meta/MetaSize';
30 import MetaTags from './meta/MetaTags';
31 import { ProjectInformationPages } from './ProjectInformationPages';
33 export interface ProjectInformationRendererProps {
34 canConfigureNotifications: boolean;
35 canUseBadges: boolean;
36 component: T.Component;
37 measures?: T.Measure[];
38 onComponentChange: (changes: {}) => void;
39 onPageChange: (page: ProjectInformationPages) => void;
42 export function ProjectInformationRenderer(props: ProjectInformationRendererProps) {
43 const { canConfigureNotifications, canUseBadges, component, measures = [] } = props;
45 const isApp = component.qualifier === ComponentQualifier.Application;
50 <h2 className="big-padded bordered-bottom">
51 {translate(isApp ? 'application' : 'project', 'info.title')}
55 <div className="overflow-y-auto">
56 <div className="big-padded bordered-bottom">
57 <div className="display-flex-center">
58 <h3 className="spacer-right">{translate('project.info.description')}</h3>
59 {component.visibility && (
60 <PrivacyBadgeContainer
61 organization={undefined}
62 qualifier={component.qualifier}
63 tooltipProps={{ projectKey: component.key }}
64 visibility={component.visibility}
69 {component.description && <p>{component.description}</p>}
71 <MetaTags component={component} onComponentChange={props.onComponentChange} />
74 <div className="big-padded bordered-bottom it__project-loc-value">
75 <MetaSize component={component} measures={measures} />
79 (component.qualityGate ||
80 (component.qualityProfiles && component.qualityProfiles.length > 0)) && (
82 <div className="big-padded bordered-bottom">
83 {component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
85 {component.qualityProfiles && component.qualityProfiles.length > 0 && (
87 headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
88 profiles={component.qualityProfiles}
95 {!isApp && <MetaLinks component={component} />}
97 <div className="big-padded bordered-bottom">
98 <MetaKey componentKey={component.key} qualifier={component.qualifier} />
103 label={translate('overview.badges.get_badge', component.qualifier)}
104 onPageChange={props.onPageChange}
105 to={ProjectInformationPages.badges}
108 {canConfigureNotifications && (
110 label={translate('project.info.to_notifications')}
111 onPageChange={props.onPageChange}
112 to={ProjectInformationPages.notifications}
120 export default React.memo(ProjectInformationRenderer);