From: Wouter Admiraal Date: Thu, 2 Feb 2023 10:33:05 +0000 (+0100) Subject: SONAR-18328 SONAR-18332 [1099493] [1101757] X-Git-Tag: 10.0.0.68432~263 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4420e38ff6ab4c38e31740f05f2858a2ed2c6f93;p=sonarqube.git SONAR-18328 SONAR-18332 [1099493] [1101757] * [1099493] Status message not automatically announced * [1101757] Visual list is not marked up as list --- diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts index 22a367dc1b4..46cda04a7f4 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts +++ b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts @@ -120,7 +120,7 @@ it('should behave correctly when using search', async () => { // Search with results that are deeper than the current level. await ui.searchForComponent('out'); - expect(ui.childComponent(/out\.tsx/).get()).toBeInTheDocument(); + expect(ui.searchResult(/out\.tsx/).get()).toBeInTheDocument(); // Search with no results. await ui.searchForComponent('nonexistent'); @@ -141,7 +141,7 @@ it('should behave correctly when using search', async () => { await act(async () => { await ui.arrowLeft(); }); - expect(await ui.childComponent(/folderA/).find()).toBeInTheDocument(); + expect(await ui.searchResult(/folderA/).find()).toBeInTheDocument(); }); it('should correcly handle long lists of components', async () => { @@ -370,6 +370,7 @@ function getPageObject(user: UserEvent) { const ui = { componentName: (name: string) => byText(name), childComponent: (name: string | RegExp) => byRole('cell', { name, exact: false }), + searchResult: (name: string | RegExp) => byRole('link', { name, exact: false }), componentIsEmptyTxt: (qualifier: ComponentQualifier) => byText(`code_viewer.no_source_code_displayed_due_to_empty_analysis.${qualifier}`), searchInput: byRole('searchbox'), diff --git a/server/sonar-web/src/main/js/apps/code/code.css b/server/sonar-web/src/main/js/apps/code/code.css index 4a74cd5c19b..8c9864aaf96 100644 --- a/server/sonar-web/src/main/js/apps/code/code.css +++ b/server/sonar-web/src/main/js/apps/code/code.css @@ -29,6 +29,18 @@ margin-top: -50px; } +.code-components .boxed-group.search-results li { + padding: var(--gridSize) calc(2 * var(--gridSize)); + border-width: 0 0 0 2px; + border-style: solid; + border-color: transparent; +} + +.code-components .boxed-group.search-results li.selected { + background-color: var(--info100); + border-left-color: var(--info500); +} + .code-components .table-wrapper { margin: 0 20px; } diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx index b7dbcdd5bc9..646599998aa 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx @@ -48,6 +48,7 @@ import { import Breadcrumbs from './Breadcrumbs'; import Components from './Components'; import Search from './Search'; +import SearchResults from './SearchResults'; import SourceViewerWrapper from './SourceViewerWrapper'; interface Props { @@ -72,7 +73,7 @@ interface State { newCodeSelected: boolean; } -export class CodeApp extends React.Component { +class CodeApp extends React.Component { mounted = false; state: State; @@ -266,10 +267,9 @@ export class CodeApp extends React.Component { const hasComponents = components.length > 0 || searchResults !== undefined; - const shouldShowBreadcrumbs = breadcrumbs.length > 1 && !showSearch; + const showBreadcrumbs = breadcrumbs.length > 1 && !showSearch; - const shouldShowComponentList = - sourceViewer === undefined && components.length > 0 && !showSearch; + const showComponentList = sourceViewer === undefined && components.length > 0 && !showSearch; const componentsClassName = classNames('boxed-group', 'spacer-top', { 'new-loading': loading, @@ -333,7 +333,7 @@ export class CodeApp extends React.Component { )} - {shouldShowBreadcrumbs && ( + {showBreadcrumbs && ( { /> )} - {shouldShowComponentList && ( - <> -
- -
- - - )} - - {showSearch && searchResults && ( -
+
+ {showComponentList && ( + )} + + {showSearch && ( + + )} + +
+ {searchResults?.length === 0 && translate('no_results')}
+
+ + {showComponentList && ( + )} {sourceViewer !== undefined && !showSearch && ( @@ -396,6 +398,7 @@ export class CodeApp extends React.Component { ); } } + const StyledAlert = styled(Alert)` display: inline-flex; margin-bottom: 15px; diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.tsx b/server/sonar-web/src/main/js/apps/code/components/Component.tsx index 7393e3f7556..d42aa9fb47b 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Component.tsx @@ -44,7 +44,7 @@ interface Props { showAnalysisDate?: boolean; } -export class Component extends React.PureComponent { +class Component extends React.PureComponent { render() { const { branchLike, diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index 0494af1de42..da5c4be7738 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx @@ -100,7 +100,7 @@ export default function ComponentName({ } return ( diff --git a/server/sonar-web/src/main/js/apps/code/components/Components.tsx b/server/sonar-web/src/main/js/apps/code/components/Components.tsx index 3e0c96d8a0e..159551a7e1e 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Components.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Components.tsx @@ -39,7 +39,7 @@ interface ComponentsProps { showAnalysisDate?: boolean; } -export function Components(props: ComponentsProps) { +function Components(props: ComponentsProps) { const { baseComponent, branchLike, diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx index 0a95d1baece..089de348926 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx @@ -28,7 +28,7 @@ import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; -import { ComponentQualifier } from '../../../types/component'; +import { ComponentQualifier, isView } from '../../../types/component'; import { ComponentMeasure } from '../../../types/types'; interface Props { @@ -47,7 +47,7 @@ interface State { loading: boolean; } -export class Search extends React.PureComponent { +class Search extends React.PureComponent { mounted = false; state: State = { query: '', @@ -99,11 +99,7 @@ export class Search extends React.PureComponent { }); } - const qualifiers = [ - ComponentQualifier.Portfolio, - ComponentQualifier.SubPortfolio, - ComponentQualifier.Application, - ].includes(component.qualifier as ComponentQualifier) + const qualifiers = isView(component.qualifier) ? [ComponentQualifier.SubPortfolio, ComponentQualifier.Project].join(',') : [ComponentQualifier.TestFile, ComponentQualifier.File].join(','); @@ -144,11 +140,11 @@ export class Search extends React.PureComponent { render() { const { component, newCodeSelected } = this.props; const { loading, query } = this.state; - const isPortfolio = ['VW', 'SVW', 'APP'].includes(component.qualifier); + const isViewLike = isView(component.qualifier); return (