From fc415711a8d3a3ac3cfd69ba439d2f6c84a350c5 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Thu, 20 Jun 2019 13:32:11 +0200 Subject: [PATCH] SONAR-12106 Add link to overall issues of a file in new slim header --- .../SourceViewer/SourceViewerHeaderSlim.css | 4 -- .../SourceViewer/SourceViewerHeaderSlim.tsx | 36 +++++++++++++-- .../SourceViewerHeaderSlim-test.tsx.snap | 44 ++++++++++++++++++- .../resources/org/sonar/l10n/core.properties | 1 + 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css index eaaa3d7deb9..97317e012ff 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css @@ -24,7 +24,3 @@ align-items: center; min-height: 25px; } - -.source-viewer-header-slim-actions { - margin-left: calc(3 * var(--gridSize)); -} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx index cfc2c65ba7f..9342c53651b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx @@ -18,14 +18,17 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Link } from 'react-router'; +import * as classNames from 'classnames'; import DeferredSpinner from '../common/DeferredSpinner'; import Favorite from '../controls/Favorite'; import ExpandSnippetIcon from '../icons-components/ExpandSnippetIcon'; import QualifierIcon from '../icons-components/QualifierIcon'; import { ButtonIcon } from '../ui/buttons'; -import { getPathUrlAsString, getBranchLikeUrl } from '../../helpers/urls'; +import { translate } from '../../helpers/l10n'; +import { getPathUrlAsString, getBranchLikeUrl, getComponentIssuesUrl } from '../../helpers/urls'; import { collapsedDirFromPath, fileFromPath } from '../../helpers/path'; -import { isMainBranch } from '../../helpers/branches'; +import { isMainBranch, getBranchLikeQuery } from '../../helpers/branches'; import './SourceViewerHeaderSlim.css'; export interface Props { @@ -43,7 +46,16 @@ export default function SourceViewerHeaderSlim({ onExpand, sourceViewerFile }: Props) { - const { key, path, project, projectName, q, subProject, subProjectName } = sourceViewerFile; + const { + key, + measures, + path, + project, + projectName, + q, + subProject, + subProjectName + } = sourceViewerFile; return (
@@ -78,9 +90,25 @@ export default function SourceViewerHeaderSlim({ )}
+ {measures.issues !== undefined && ( +
+ + {translate('source_viewer.view_all_issues')} + +
+ )} + {expandable && ( -
+
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap index 20f543700bf..c237d08a24c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap @@ -38,12 +38,32 @@ exports[`should render correctly 1`] = `
+
+ + source_viewer.view_all_issues + +
+
+ + source_viewer.view_all_issues + +