From bd3b85c1990216123622756da8469707344a8917 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Tue, 23 Feb 2021 11:25:46 +0100 Subject: [PATCH] SONAR-11751 SONAR-11748 Use semantically correct elements on Projects page --- .../src/main/js/app/styles/init/misc.css | 9 + .../apps/projects/components/AllProjects.tsx | 16 +- .../projects/components/FavoriteFilter.tsx | 4 +- .../apps/projects/components/PageHeader.tsx | 4 +- .../apps/projects/components/PageSidebar.tsx | 2 +- .../__snapshots__/AllProjects-test.tsx.snap | 352 ++++++++++-------- .../FavoriteFilter-test.tsx.snap | 4 +- .../__snapshots__/PageHeader-test.tsx.snap | 12 +- .../__snapshots__/PageSidebar-test.tsx.snap | 24 +- .../components/project-card/ProjectCard.tsx | 4 +- .../__snapshots__/ProjectCard-test.tsx.snap | 42 +-- .../js/apps/projects/filters/FilterHeader.tsx | 2 +- .../__snapshots__/FilterHeader-test.tsx.snap | 12 +- .../visualizations/Visualizations.tsx | 4 +- .../Visualizations-test.tsx.snap | 8 +- .../main/js/components/search-navigator.css | 6 + .../resources/org/sonar/l10n/core.properties | 1 + 17 files changed, 287 insertions(+), 219 deletions(-) diff --git a/server/sonar-web/src/main/js/app/styles/init/misc.css b/server/sonar-web/src/main/js/app/styles/init/misc.css index 920e5ddfc26..6e6ba4d39c8 100644 --- a/server/sonar-web/src/main/js/app/styles/init/misc.css +++ b/server/sonar-web/src/main/js/app/styles/init/misc.css @@ -39,6 +39,15 @@ th.hide-overflow { visibility: hidden !important; } +.a11y-hidden { + position: absolute; + left: -10000px; + top: auto; + width: 1px; + height: 1px; + overflow: hidden; +} + .invisible { visibility: hidden; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 9e61241f479..185be554b6d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -224,7 +224,10 @@ export class AllProjects extends React.PureComponent { renderSide = () => ( {({ top }) => ( -
+
{ />
-
+ )}
); @@ -317,13 +320,18 @@ export class AllProjects extends React.PureComponent { +

{translate('projects.page')}

+ {this.renderSide()}
- {this.renderHeader()} - {this.renderMain()} +
+

{translate('list_of_projects')}

+ {this.renderHeader()} + {this.renderMain()} +
); diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx index d4ed964fefe..20969b7bb67 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx @@ -47,7 +47,7 @@ export default class FavoriteFilter extends React.PureComponent { const pathnameForAll = '/projects'; return ( -
+
{ {translate('all')}
-
+ ); } } diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx index d0fb81c5b52..c954611367a 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx @@ -52,7 +52,7 @@ export default function PageHeader(props: Props) { const sortingDisabled = view === 'visualizations' && !limitReached; return ( -
+
@@ -97,6 +97,6 @@ export default function PageHeader(props: Props) {
-
+ ); } diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx index 0ffaf0986cb..9097005dbf9 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx @@ -75,7 +75,7 @@ export default function PageSidebar(props: PageSidebarProps) {
{isFiltered && } -

{translate('filters')}

+

{translate('filters')}

{!isLeakView && ( diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap index a4497f47c20..0d57d3d1949 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/AllProjects-test.tsx.snap @@ -40,6 +40,11 @@ exports[`renders 1`] = ` encodeSpecialCharacters={true} title="projects.page" /> +

+ projects.page +

@@ -52,129 +57,138 @@ exports[`renders 1`] = ` anchor="projects_main" />
+

+ list_of_projects +

- + + selectedSort="name" + total={0} + view="overall" + visualization="risk" + /> +
- -
- + - + /> + +
@@ -193,6 +207,11 @@ exports[`renders 2`] = ` encodeSpecialCharacters={true} title="projects.page" /> +

+ projects.page +

@@ -205,68 +224,77 @@ exports[`renders 2`] = ` anchor="projects_main" />
+

+ list_of_projects +

- + + selectedSort="name" + total={0} + view="visualizations" + visualization="risk" + /> +
- -
- +
+ +
diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/FavoriteFilter-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/FavoriteFilter-test.tsx.snap index 4793b31af19..55d42cf6c82 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/FavoriteFilter-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/FavoriteFilter-test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`renders for logged in user 1`] = ` -
-
+ `; diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.tsx.snap index 7f5915cf34f..31ec1cb22bf 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should render correctly 1`] = ` -
-
+ `; exports[`should render correctly while loading 1`] = ` -
-
+ `; exports[`should render disabled sorting options for visualizations 1`] = ` -
-
+ `; exports[`should render switch the default sorting option for anonymous users 1`] = ` diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageSidebar-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageSidebar-test.tsx.snap index 748cc246cbb..5e4876ebeda 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageSidebar-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageSidebar-test.tsx.snap @@ -12,9 +12,11 @@ exports[`should render \`leak\` view correctly 1`] = `
-

+

filters -

+
-

+

filters -

+ -

+

filters -

+ -

+

filters -

+ )} -

+

{needIssueSync ? name : {name}} -

+ {analysisDate && ( <> diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/__snapshots__/ProjectCard-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/__snapshots__/ProjectCard-test.tsx.snap index c57e8c54439..a326b9ecfcd 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/__snapshots__/ProjectCard-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/__snapshots__/ProjectCard-test.tsx.snap @@ -32,8 +32,8 @@ exports[`should display applications 1`] = ` /> -

Foo -

+ @@ -140,8 +140,8 @@ exports[`should display applications: with project count 1`] = ` /> -

Foo -

+ @@ -229,8 +229,8 @@ exports[`should display configure analysis button for logged in user: default 1`
-

Foo -

+
-

Foo -

+ @@ -453,8 +453,8 @@ exports[`should display not analyzed yet 1`] = `
-

Foo -

+
-

Foo -

+ diff --git a/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.tsx b/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.tsx index 8183777ec9e..61e512f8e43 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/FilterHeader.tsx @@ -27,7 +27,7 @@ interface Props { export default function FilterHeader(props: Props) { return (
- {props.name} +

{props.name}

{props.children}
); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/FilterHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/FilterHeader-test.tsx.snap index b1f4611eae9..95be013ebaa 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/FilterHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/FilterHeader-test.tsx.snap @@ -4,7 +4,11 @@ exports[`renders 1`] = `
- foo +

+ foo +

`; @@ -12,7 +16,11 @@ exports[`renders with children 1`] = `
- foo +

+ foo +

`; diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx index 4a1314a3546..b4b259882cb 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx @@ -78,9 +78,9 @@ export default class Visualizations extends React.PureComponent { return (
-
+
{projects != null && this.renderVisualization(projects)} -
+ {this.renderFooter()}
); diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/__snapshots__/Visualizations-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/__snapshots__/Visualizations-test.tsx.snap index 831d01106d2..a74c4bec92d 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/__snapshots__/Visualizations-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/__snapshots__/Visualizations-test.tsx.snap @@ -4,14 +4,14 @@ exports[`renders 1`] = `
-
-
+
`; @@ -19,14 +19,14 @@ exports[`renders when limit is reached 1`] = `
-
-
+