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 qualifier={component.qualifier}
62 visibility={component.visibility}
67 {component.description && <p>{component.description}</p>}
69 <MetaTags component={component} onComponentChange={props.onComponentChange} />
72 <div className="big-padded bordered-bottom it__project-loc-value">
73 <MetaSize component={component} measures={measures} />
77 (component.qualityGate ||
78 (component.qualityProfiles && component.qualityProfiles.length > 0)) && (
80 <div className="big-padded bordered-bottom">
81 {component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
83 {component.qualityProfiles && component.qualityProfiles.length > 0 && (
85 headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
86 profiles={component.qualityProfiles}
93 {!isApp && <MetaLinks component={component} />}
95 <div className="big-padded bordered-bottom">
96 <MetaKey componentKey={component.key} qualifier={component.qualifier} />
101 label={translate('overview.badges.get_badge', component.qualifier)}
102 onPageChange={props.onPageChange}
103 to={ProjectInformationPages.badges}
106 {canConfigureNotifications && (
108 label={translate('project.info.to_notifications')}
109 onPageChange={props.onPageChange}
110 to={ProjectInformationPages.notifications}
118 export default React.memo(ProjectInformationRenderer);