1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* SonarQube
* Copyright (C) 2009-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import classNames from 'classnames';
import { BasicSeparator, SubTitle } from 'design-system';
import React, { PropsWithChildren, useEffect, useState } from 'react';
import { getProjectLinks } from '../../../api/projectLinks';
import { translate } from '../../../helpers/l10n';
import { ComponentQualifier, Visibility } from '../../../types/component';
import { Component, Measure, ProjectLink } from '../../../types/types';
import MetaDescription from './components/MetaDescription';
import MetaKey from './components/MetaKey';
import MetaLinks from './components/MetaLinks';
import MetaQualityGate from './components/MetaQualityGate';
import MetaQualityProfiles from './components/MetaQualityProfiles';
import MetaSize from './components/MetaSize';
import MetaTags from './components/MetaTags';
import MetaVisibility from './components/MetaVisibility';
export interface AboutProjectProps {
component: Component;
measures?: Measure[];
onComponentChange: (changes: {}) => void;
}
export default function AboutProject(props: AboutProjectProps) {
const { component, measures = [] } = props;
const isApp = component.qualifier === ComponentQualifier.Application;
const [links, setLinks] = useState<ProjectLink[] | undefined>(undefined);
useEffect(() => {
if (!isApp) {
getProjectLinks(component.key).then(
(links) => setLinks(links),
() => {},
);
}
}, [component.key, isApp]);
return (
<>
<div>
<SubTitle>{translate(isApp ? 'application' : 'project', 'about.title')}</SubTitle>
</div>
{!isApp &&
(component.qualityGate ||
(component.qualityProfiles && component.qualityProfiles.length > 0)) && (
<ProjectInformationSection className="sw-pt-0">
{component.qualityGate && <MetaQualityGate qualityGate={component.qualityGate} />}
{component.qualityProfiles && component.qualityProfiles.length > 0 && (
<MetaQualityProfiles
headerClassName={component.qualityGate ? 'big-spacer-top' : undefined}
profiles={component.qualityProfiles}
/>
)}
</ProjectInformationSection>
)}
<ProjectInformationSection>
<MetaKey componentKey={component.key} qualifier={component.qualifier} />
</ProjectInformationSection>
<ProjectInformationSection>
<MetaVisibility
qualifier={component.qualifier}
visibility={component.visibility ?? Visibility.Public}
/>
</ProjectInformationSection>
<ProjectInformationSection>
<MetaDescription description={component.description} isApp={isApp} />
</ProjectInformationSection>
<ProjectInformationSection>
<MetaTags component={component} onComponentChange={props.onComponentChange} />
</ProjectInformationSection>
<ProjectInformationSection last={isApp || !links?.length}>
<MetaSize component={component} measures={measures} />
</ProjectInformationSection>
{!isApp && links && links.length > 0 && (
<ProjectInformationSection last>
<MetaLinks links={links} />
</ProjectInformationSection>
)}
</>
);
}
interface ProjectInformationSectionProps {
last?: boolean;
className?: string;
}
function ProjectInformationSection(props: PropsWithChildren<ProjectInformationSectionProps>) {
const { children, className, last = false } = props;
return (
<>
<div className={classNames('sw-py-4', className)}>{children}</div>
{!last && <BasicSeparator />}
</>
);
}
|