]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12106 Add link to overall issues of a file in new slim header
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Thu, 20 Jun 2019 11:32:11 +0000 (13:32 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 28 Jun 2019 06:45:44 +0000 (08:45 +0200)
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx
server/sonar-web/src/main/js/components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index eaaa3d7deb9f70088147ac0c146626dbeeb84e51..97317e012ffa114d2d8cc8097f93426084e1a256 100644 (file)
@@ -24,7 +24,3 @@
   align-items: center;
   min-height: 25px;
 }
-
-.source-viewer-header-slim-actions {
-  margin-left: calc(3 * var(--gridSize));
-}
index cfc2c65ba7f34402452daaf475d0956a9632669f..9342c53651baa38adead60e090dec0c3b457e17a 100644 (file)
  * 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 (
     <div className="source-viewer-header-slim display-flex-row display-flex-space-between">
@@ -78,9 +90,25 @@ export default function SourceViewerHeaderSlim({
         )}
       </div>
 
+      {measures.issues !== undefined && (
+        <div
+          className={classNames('flex-0 big-spacer-left', {
+            'little-spacer-right': !expandable || loading
+          })}>
+          <Link
+            to={getComponentIssuesUrl(project, {
+              ...getBranchLikeQuery(branchLike),
+              fileUuids: sourceViewerFile.uuid,
+              resolved: 'false'
+            })}>
+            {translate('source_viewer.view_all_issues')}
+          </Link>
+        </div>
+      )}
+
       {expandable && (
         <DeferredSpinner className="little-spacer-right" loading={loading}>
-          <div className="source-viewer-header-slim-actions flex-0">
+          <div className="flex-0 big-spacer-left">
             <ButtonIcon className="js-actions" onClick={onExpand}>
               <ExpandSnippetIcon />
             </ButtonIcon>
index 20f543700bf9da95eb0cd791af38e2d257511250..c237d08a24cb9f226b4afae3385cf779e5a0796d 100644 (file)
@@ -38,12 +38,32 @@ exports[`should render correctly 1`] = `
       </span>
     </div>
   </div>
+  <div
+    className="flex-0 big-spacer-left"
+  >
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/project/issues",
+          "query": Object {
+            "fileUuids": "foo-bar",
+            "id": "my-project",
+            "resolved": "false",
+          },
+        }
+      }
+    >
+      source_viewer.view_all_issues
+    </Link>
+  </div>
   <DeferredSpinner
     className="little-spacer-right"
     timeout={100}
   >
     <div
-      className="source-viewer-header-slim-actions flex-0"
+      className="flex-0 big-spacer-left"
     >
       <ButtonIcon
         className="js-actions"
@@ -101,12 +121,32 @@ exports[`should render correctly for subproject 1`] = `
       </span>
     </div>
   </div>
+  <div
+    className="flex-0 big-spacer-left"
+  >
+    <Link
+      onlyActiveOnIndex={false}
+      style={Object {}}
+      to={
+        Object {
+          "pathname": "/project/issues",
+          "query": Object {
+            "fileUuids": "foo-bar",
+            "id": "my-project",
+            "resolved": "false",
+          },
+        }
+      }
+    >
+      source_viewer.view_all_issues
+    </Link>
+  </div>
   <DeferredSpinner
     className="little-spacer-right"
     timeout={100}
   >
     <div
-      className="source-viewer-header-slim-actions flex-0"
+      className="flex-0 big-spacer-left"
     >
       <ButtonIcon
         className="js-actions"
index 0e1ef8fc0fd2cc306d52ced570e926e881026a2c..824d1d98b9b6ee0d18ca54be9f7bd6d2bec25e2e 100644 (file)
@@ -2221,6 +2221,7 @@ component_viewer.show_details=Show Measures
 component_viewer.show_all_measures=Show all measures
 component_viewer.no_component=The component has been removed or never existed.
 
+source_viewer.view_all_issues=See all issues in this file
 source_viewer.covered=Covered by the following tests
 source_viewer.not_covered=Not covered by tests
 source_viewer.conditions=conditions