From 284f05fc0b5ae45aad6b8613c8df9f7b397c4907 Mon Sep 17 00:00:00 2001 From: David Cho-Lerat Date: Thu, 31 Aug 2023 10:56:43 +0200 Subject: [PATCH] SONAR-20057 Security hostpot header remains visible --- .../components/HotspotHeader.tsx | 25 +++++++++++++++---- .../components/HotspotSnippetContainer.tsx | 4 +-- .../HotspotSnippetContainerRenderer.tsx | 14 +++-------- .../components/HotspotSnippetHeader.tsx | 10 +++++--- .../components/HotspotViewerTabs.tsx | 1 + 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx index 3752781483a..56e20a3c899 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotHeader.tsx @@ -17,6 +17,7 @@ * 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 { @@ -47,6 +48,7 @@ import { SecurityStandard, Standards } from '../../../types/security'; import { Hotspot, HotspotStatusOption } from '../../../types/security-hotspots'; import { Component } from '../../../types/types'; import HotspotHeaderRightSection from './HotspotHeaderRightSection'; +import HotspotSnippetHeader from './HotspotSnippetHeader'; import Status from './status/Status'; import StatusReviewButton from './status/StatusReviewButton'; @@ -54,6 +56,7 @@ export interface HotspotHeaderProps { hotspot: Hotspot; component: Component; branchLike?: BranchLike; + isCodeTab?: boolean; standards?: Standards; onUpdateHotspot: (statusUpdate?: boolean, statusOption?: HotspotStatusOption) => Promise; tabs: React.ReactNode; @@ -67,7 +70,8 @@ interface StyledHeaderProps { } export function HotspotHeader(props: HotspotHeaderProps) { - const { hotspot, component, branchLike, standards, tabs, isCompressed, isScrolled } = props; + const { branchLike, component, hotspot, isCodeTab, isCompressed, isScrolled, standards, tabs } = + props; const { message, messageFormattings, rule, key } = hotspot; const refrechBranchStatus = useRefreshBranchStatus(); @@ -86,10 +90,17 @@ export function HotspotHeader(props: HotspotHeaderProps) { }; const content = isCompressed ? ( -
- {tabs} - -
+ +
+ {tabs} + + +
+ + {isCodeTab && ( + + )} +
) : ( <>
@@ -124,6 +135,10 @@ export function HotspotHeader(props: HotspotHeaderProps) {
{tabs} + + {isCodeTab && ( + + )} ); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx index 285bdd7c94a..95a5aee9e10 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx @@ -197,7 +197,7 @@ export default class HotspotSnippetContainer extends React.Component undefined; @@ -111,16 +107,14 @@ export default function HotspotSnippetContainerRenderer( props: HotspotSnippetContainerRendererProps ) { const { - branchLike, highlightedSymbols, hotspot, loading, locations: primaryLocations, - sourceLines, - sourceViewerFile, secondaryLocations, - component, selectedHotspotLocation, + sourceLines, + sourceViewerFile, } = props; const scrollableRef = React.useRef(null); @@ -153,8 +147,6 @@ export default function HotspotSnippetContainerRenderer( )} - - {!loading && sourceLines.length > 0 && ( diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetHeader.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetHeader.tsx index ddf494953fc..453c2d7ac61 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetHeader.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetHeader.tsx @@ -17,6 +17,7 @@ * 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 { ClipboardIconButton, HoverLink, Note, themeBorder, themeColor } from 'design-system'; @@ -50,8 +51,11 @@ function HotspotSnippetHeader(props: HotspotSnippetHeaderProps) { const displayProjectName = component.qualifier === ComponentQualifier.Application; return ( - - + + {displayProjectName && ( @@ -82,7 +86,7 @@ function HotspotSnippetHeader(props: HotspotSnippetHeaderProps) { const StyledHeader = withTheme(styled.div` background-color: ${themeColor('codeLine')}; - border-bottom: ${themeBorder('default', 'codeLineBorder')}; + border: ${themeBorder('default', 'codeLineBorder')}; `); export default withCurrentUserContext(HotspotSnippetHeader); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerTabs.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerTabs.tsx index 2401739e699..1394845f085 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerTabs.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerTabs.tsx @@ -186,6 +186,7 @@ export default function HotspotViewerTabs(props: Props) { branchLike={branchLike} component={component} hotspot={hotspot} + isCodeTab={currentTab.value === TabKeys.Code} isCompressed={isCompressed} isScrolled={isScrolled} onUpdateHotspot={props.onUpdateHotspot} -- 2.39.5