let bugs;
let vulnerabilities;
let codeSmells;
- let securityHotspots;
if (!loading && issueTypes) {
bugs = issueTypes['BUG'] && issueTypes['BUG'].count;
vulnerabilities = issueTypes['VULNERABILITY'] && issueTypes['VULNERABILITY'].count;
codeSmells = issueTypes['CODE_SMELL'] && issueTypes['CODE_SMELL'].count;
- securityHotspots = issueTypes['SECURITY_HOTSPOT'] && issueTypes['SECURITY_HOTSPOT'].count;
}
return (
bugs={bugs}
codeSmells={codeSmells}
loading={loading}
- securityHotspots={securityHotspots}
vulnerabilities={vulnerabilities}
/>
</div>
import { Link } from 'react-router';
import BugIcon from 'sonar-ui-common/components/icons/BugIcon';
import CodeSmellIcon from 'sonar-ui-common/components/icons/CodeSmellIcon';
-import SecurityHotspotIcon from 'sonar-ui-common/components/icons/SecurityHotspotIcon';
import VulnerabilityIcon from 'sonar-ui-common/components/icons/VulnerabilityIcon';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { formatMeasure } from 'sonar-ui-common/helpers/measures';
import { getIssuesUrl } from '../../../helpers/urls';
-interface Props {
+export interface EntryIssueTypesProps {
bugs?: number;
codeSmells?: number;
loading: boolean;
- securityHotspots?: number;
vulnerabilities?: number;
}
bugs,
codeSmells,
loading,
- securityHotspots,
vulnerabilities
-}: Props) {
+}: EntryIssueTypesProps) {
return (
<div className="about-page-projects">
{loading ? (
{translate('issue.type.CODE_SMELL.plural')}
</td>
</tr>
- <tr>
- <td className="about-page-issue-type-number">
- <Link
- className="about-page-issue-type-link"
- to={getIssuesUrl({
- resolved: 'false',
- types: 'SECURITY_HOTSPOT',
- s: 'CREATION_DATE'
- })}>
- {formatMeasure(securityHotspots, 'SHORT_INT')}
- </Link>
- </td>
- <td>
- <span className="little-spacer-right">
- <SecurityHotspotIcon />
- </span>
- {translate('issue.type.SECURITY_HOTSPOT.plural')}
- </td>
- </tr>
</tbody>
</table>
)}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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 { shallow } from 'enzyme';
+import * as React from 'react';
+import EntryIssueTypes, { EntryIssueTypesProps } from '../EntryIssueTypes';
+
+it('should render correctly', () => {
+ const wrapper = shallowRender();
+
+ expect(wrapper).toMatchSnapshot('loading');
+
+ wrapper.setProps({ loading: false });
+
+ expect(wrapper).toMatchSnapshot('loading');
+});
+
+function shallowRender(props: Partial<EntryIssueTypesProps> = {}) {
+ return shallow<EntryIssueTypesProps>(
+ <EntryIssueTypes loading={true} bugs={10} codeSmells={100} vulnerabilities={1000} {...props} />
+ );
+}
bugs={10}
codeSmells={5}
loading={false}
- securityHotspots={5}
vulnerabilities={0}
/>
</div>
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly: loading 1`] = `
+<div
+ className="about-page-projects"
+>
+ <i
+ className="spinner"
+ />
+</div>
+`;
+
+exports[`should render correctly: loading 2`] = `
+<div
+ className="about-page-projects"
+>
+ <table
+ className="about-page-issue-types"
+ >
+ <tbody>
+ <tr>
+ <td
+ className="about-page-issue-type-number"
+ >
+ <Link
+ className="about-page-issue-type-link"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/issues",
+ "query": Object {
+ "resolved": "false",
+ "s": "CREATION_DATE",
+ "types": "BUG",
+ },
+ }
+ }
+ >
+ 10
+ </Link>
+ </td>
+ <td>
+ <span
+ className="little-spacer-right"
+ >
+ <BugIcon />
+ </span>
+ issue.type.BUG.plural
+ </td>
+ </tr>
+ <tr>
+ <td
+ className="about-page-issue-type-number"
+ >
+ <Link
+ className="about-page-issue-type-link"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/issues",
+ "query": Object {
+ "resolved": "false",
+ "s": "CREATION_DATE",
+ "types": "VULNERABILITY",
+ },
+ }
+ }
+ >
+ 1short_number_suffix.k
+ </Link>
+ </td>
+ <td>
+ <span
+ className="little-spacer-right"
+ >
+ <VulnerabilityIcon />
+ </span>
+ issue.type.VULNERABILITY.plural
+ </td>
+ </tr>
+ <tr>
+ <td
+ className="about-page-issue-type-number"
+ >
+ <Link
+ className="about-page-issue-type-link"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/issues",
+ "query": Object {
+ "resolved": "false",
+ "s": "CREATION_DATE",
+ "types": "CODE_SMELL",
+ },
+ }
+ }
+ >
+ 100
+ </Link>
+ </td>
+ <td>
+ <span
+ className="little-spacer-right"
+ >
+ <CodeSmellIcon />
+ </span>
+ issue.type.CODE_SMELL.plural
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+`;