From fd88c0ae2735b35e7ecd407105bbd0026bf6596e Mon Sep 17 00:00:00 2001 From: 7PH Date: Thu, 11 May 2023 17:10:31 +0200 Subject: [PATCH] SONAR-19236 Implement sidebar file-specific hotspot list --- .../components/HotspotSimpleList.tsx | 137 ++++++++++-------- 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSimpleList.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSimpleList.tsx index 781edfdba8d..ac5aa7c2dcc 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSimpleList.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSimpleList.tsx @@ -17,13 +17,15 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { withTheme } from '@emotion/react'; +import styled from '@emotion/styled'; +import { Badge, SubnavigationAccordion, themeColor } from 'design-system'; import * as React from 'react'; +import { FormattedMessage } from 'react-intl'; import ListFooter from '../../../components/controls/ListFooter'; import Tooltip from '../../../components/controls/Tooltip'; import QualifierIcon from '../../../components/icons/QualifierIcon'; -import SecurityHotspotIcon from '../../../components/icons/SecurityHotspotIcon'; -import { translateWithParameters } from '../../../helpers/l10n'; -import { addSideBarClass, removeSideBarClass } from '../../../helpers/pages'; +import { translate } from '../../../helpers/l10n'; import { fileFromPath } from '../../../helpers/path'; import { ComponentQualifier } from '../../../types/component'; import { SecurityStandard, Standards } from '../../../types/security'; @@ -49,45 +51,43 @@ export interface HotspotSimpleListProps { standards: Standards; } -export default class HotspotSimpleList extends React.Component { - componentDidMount() { - addSideBarClass(); - } +export default function HotspotSimpleList(props: HotspotSimpleListProps) { + const { + filterByCategory, + filterByCWE, + filterByFile, + hotspots, + hotspotsTotal, + loadingMore, + selectedHotspot, + standards, + onLocationClick, + selectedHotspotLocation, + } = props; - componentWillUnmount() { - removeSideBarClass(); - } + const categoryLabel = + filterByCategory && + SECURITY_STANDARD_RENDERER[filterByCategory.standard](standards, filterByCategory.category); - render() { - const { - filterByCategory, - filterByCWE, - filterByFile, - hotspots, - hotspotsTotal, - loadingMore, - selectedHotspot, - selectedHotspotLocation, - standards, - } = this.props; + const cweLabel = + filterByCWE && SECURITY_STANDARD_RENDERER[SecurityStandard.CWE](standards, filterByCWE); - const categoryLabel = - filterByCategory && - SECURITY_STANDARD_RENDERER[filterByCategory.standard](standards, filterByCategory.category); - - const cweLabel = - filterByCWE && SECURITY_STANDARD_RENDERER[SecurityStandard.CWE](standards, filterByCWE); - - return ( -
-

- - {translateWithParameters('hotspots.list_title', hotspotsTotal)} -

-
-
-
- + return ( + + + {hotspotsTotal}, + }} + /> + +
+ +
{filterByFile ? ( @@ -105,30 +105,39 @@ export default class HotspotSimpleList extends React.Component )} - -
-
    - {hotspots.map((h) => ( -
  • - -
  • - ))} -
-
-
- +
+ {hotspots.length} + + } + id="hotspot-category" + expanded={true} + > + {hotspots.map((hotspot) => ( + + ))} +
- ); - } + + + ); } + +const SubNavigationContainer = styled.div` + width: calc(100% - 1.5rem); +`; + +const StyledContainer = withTheme(styled.div` + background-color: ${themeColor('subnavigation')}; +`); -- 2.39.5