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 {(component.description || !isApp) && (
57 <div className="big-padded bordered-bottom">
58 <div className="display-flex-center">
59 <h3 className="spacer-right">{translate('project.info.description')}</h3>
60 {component.visibility && (
61 <PrivacyBadgeContainer
62 organization={undefined}
63 qualifier={component.qualifier}
64 tooltipProps={{ projectKey: component.key }}
65 visibility={component.visibility}
70 {component.description && <p className="spacer-bottom">{component.description}</p>}
73 <MetaTags component={component} onComponentChange={props.onComponentChange} />
78 <div className="big-padded bordered-bottom it__project-loc-value">
79 <MetaSize component={component} measures={measures} />
82 {(component.qualityGate ||
83 (component.qualityProfiles && component.qualityProfiles.length > 0)) && (
85 <div className="big-padded bordered-bottom">
86 {component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
88 {component.qualityProfiles && component.qualityProfiles.length > 0 && (
90 headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
91 profiles={component.qualityProfiles}
98 {!isApp && <MetaLinks component={component} />}
100 <div className="big-padded bordered-bottom">
101 <MetaKey componentKey={component.key} qualifier={component.qualifier} />
106 label={translate('overview.badges.get_badge', component.qualifier)}
107 onPageChange={props.onPageChange}
108 to={ProjectInformationPages.badges}
111 {canConfigureNotifications && (
113 label={translate('project.info.to_notifications')}
114 onPageChange={props.onPageChange}
115 to={ProjectInformationPages.notifications}
123 export default React.memo(ProjectInformationRenderer);