]> source.dussan.org Git - sonarqube.git/blob
4bee5cdeac68e89431aa042b2482b5d1ad0fb0ad
[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         {(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}
66                 />
67               )}
68             </div>
69
70             {component.description && <p className="spacer-bottom">{component.description}</p>}
71
72             {!isApp && (
73               <MetaTags component={component} onComponentChange={props.onComponentChange} />
74             )}
75           </div>
76         )}
77
78         <div className="big-padded bordered-bottom it__project-loc-value">
79           <MetaSize component={component} measures={measures} />
80         </div>
81
82         {(component.qualityGate ||
83           (component.qualityProfiles && component.qualityProfiles.length > 0)) && (
84           <>
85             <div className="big-padded bordered-bottom">
86               {component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
87
88               {component.qualityProfiles && component.qualityProfiles.length > 0 && (
89                 <MetaQualityProfiles
90                   headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
91                   profiles={component.qualityProfiles}
92                 />
93               )}
94             </div>
95           </>
96         )}
97
98         {!isApp && <MetaLinks component={component} />}
99
100         <div className="big-padded bordered-bottom">
101           <MetaKey componentKey={component.key} qualifier={component.qualifier} />
102         </div>
103
104         {canUseBadges && (
105           <DrawerLink
106             label={translate('overview.badges.get_badge', component.qualifier)}
107             onPageChange={props.onPageChange}
108             to={ProjectInformationPages.badges}
109           />
110         )}
111         {canConfigureNotifications && (
112           <DrawerLink
113             label={translate('project.info.to_notifications')}
114             onPageChange={props.onPageChange}
115             to={ProjectInformationPages.notifications}
116           />
117         )}
118       </div>
119     </>
120   );
121 }
122
123 export default React.memo(ProjectInformationRenderer);