]> source.dussan.org Git - sonarqube.git/blob
25bab1a9d05444bee9da8e4001c560e008558d58
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2020 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
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.
10  *
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.
15  *
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.
19  */
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';
32
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;
40 }
41
42 export function ProjectInformationRenderer(props: ProjectInformationRendererProps) {
43   const { canConfigureNotifications, canUseBadges, component, measures = [] } = props;
44
45   const isApp = component.qualifier === ComponentQualifier.Application;
46
47   return (
48     <>
49       <div>
50         <h2 className="big-padded bordered-bottom">
51           {translate(isApp ? 'application' : 'project', 'info.title')}
52         </h2>
53       </div>
54
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}
65               />
66             )}
67           </div>
68
69           {component.description && <p>{component.description}</p>}
70
71           <MetaTags component={component} onComponentChange={props.onComponentChange} />
72         </div>
73
74         <div className="big-padded bordered-bottom it__project-loc-value">
75           <MetaSize component={component} measures={measures} />
76         </div>
77
78         {!isApp &&
79           (component.qualityGate ||
80             (component.qualityProfiles && component.qualityProfiles.length > 0)) && (
81             <>
82               <div className="big-padded bordered-bottom">
83                 {component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
84
85                 {component.qualityProfiles && component.qualityProfiles.length > 0 && (
86                   <MetaQualityProfiles
87                     headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
88                     profiles={component.qualityProfiles}
89                   />
90                 )}
91               </div>
92             </>
93           )}
94
95         {!isApp && <MetaLinks component={component} />}
96
97         <div className="big-padded bordered-bottom">
98           <MetaKey componentKey={component.key} qualifier={component.qualifier} />
99         </div>
100
101         {canUseBadges && (
102           <DrawerLink
103             label={translate('overview.badges.get_badge', component.qualifier)}
104             onPageChange={props.onPageChange}
105             to={ProjectInformationPages.badges}
106           />
107         )}
108         {canConfigureNotifications && (
109           <DrawerLink
110             label={translate('project.info.to_notifications')}
111             onPageChange={props.onPageChange}
112             to={ProjectInformationPages.notifications}
113           />
114         )}
115       </div>
116     </>
117   );
118 }
119
120 export default React.memo(ProjectInformationRenderer);