From 52b86027c2dcba6dcb773e24e12286177958b59a Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Tue, 26 Jul 2022 14:02:08 +0200 Subject: [PATCH] SONAR-16537 Change issue file header style --- .../ComponentSourceSnippetGroupViewer.tsx | 4 +- .../CrossComponentSourceViewer.tsx | 52 +++++++++++-------- .../IssueSourceViewerHeader.css} | 4 +- .../IssueSourceViewerHeader.tsx} | 28 +++++----- .../SnippetViewer.css | 2 +- .../IssueSourceViewerHeader-test.tsx} | 10 ++-- ...nentSourceSnippetGroupViewer-test.tsx.snap | 2 +- .../IssueSourceViewerHeader-test.tsx.snap} | 0 .../src/main/js/apps/issues/styles.css | 4 -- .../components/SourceViewer/SourceViewer.tsx | 10 ++-- .../__tests__/SourceViewer-it.tsx | 1 - .../resources/org/sonar/l10n/core.properties | 1 + 12 files changed, 58 insertions(+), 60 deletions(-) rename server/sonar-web/src/main/js/{components/SourceViewer/SourceViewerHeaderSlim.css => apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.css} (93%) rename server/sonar-web/src/main/js/{components/SourceViewer/SourceViewerHeaderSlim.tsx => apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx} (80%) rename server/sonar-web/src/main/js/{components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx => apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx} (83%) rename server/sonar-web/src/main/js/{components/SourceViewer/__tests__/__snapshots__/SourceViewerHeaderSlim-test.tsx.snap => apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/IssueSourceViewerHeader-test.tsx.snap} (100%) diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx index 00a82856a42..08a9d12d6aa 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx @@ -23,7 +23,6 @@ import Issue from '../../../components/issue/Issue'; import SecondaryIssue from '../../../components/issue/SecondaryIssue'; import getCoverageStatus from '../../../components/SourceViewer/helpers/getCoverageStatus'; import { locationsByLine } from '../../../components/SourceViewer/helpers/indexing'; -import SourceViewerHeaderSlim from '../../../components/SourceViewer/SourceViewerHeaderSlim'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; @@ -40,6 +39,7 @@ import { SourceLine, SourceViewerFile } from '../../../types/types'; +import IssueSourceViewerHeader from './IssueSourceViewerHeader'; import SnippetViewer from './SnippetViewer'; import { createSnippets, @@ -422,7 +422,7 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone return (
- + + + )}
); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.css similarity index 93% rename from server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css rename to server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.css index 813f73a0555..4f70cddf426 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.css +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.css @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ .source-viewer-header-slim { - padding: 4px 10px 4px; - border-bottom: 1px solid var(--gray80); + padding: 4px 10px; + border: 1px solid var(--gray80); background-color: var(--barBackgroundColor); align-items: center; min-height: 25px; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx similarity index 80% rename from server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx rename to server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx index b6a6ac4774f..69b4465cbe1 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/IssueSourceViewerHeader.tsx @@ -20,19 +20,19 @@ import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router-dom'; -import { ButtonIcon } from '../../components/controls/buttons'; -import { ClipboardIconButton } from '../../components/controls/clipboard'; -import ExpandSnippetIcon from '../../components/icons/ExpandSnippetIcon'; -import QualifierIcon from '../../components/icons/QualifierIcon'; -import DeferredSpinner from '../../components/ui/DeferredSpinner'; -import { getBranchLikeQuery } from '../../helpers/branch-like'; -import { translate } from '../../helpers/l10n'; -import { collapsedDirFromPath, fileFromPath } from '../../helpers/path'; -import { getBranchLikeUrl, getComponentIssuesUrl, getPathUrlAsString } from '../../helpers/urls'; -import { BranchLike } from '../../types/branch-like'; -import { ComponentQualifier } from '../../types/component'; -import { SourceViewerFile } from '../../types/types'; -import './SourceViewerHeaderSlim.css'; +import { ButtonIcon } from '../../../components/controls/buttons'; +import { ClipboardIconButton } from '../../../components/controls/clipboard'; +import ExpandSnippetIcon from '../../../components/icons/ExpandSnippetIcon'; +import QualifierIcon from '../../../components/icons/QualifierIcon'; +import DeferredSpinner from '../../../components/ui/DeferredSpinner'; +import { getBranchLikeQuery } from '../../../helpers/branch-like'; +import { translate } from '../../../helpers/l10n'; +import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path'; +import { getBranchLikeUrl, getComponentIssuesUrl, getPathUrlAsString } from '../../../helpers/urls'; +import { BranchLike } from '../../../types/branch-like'; +import { ComponentQualifier } from '../../../types/component'; +import { SourceViewerFile } from '../../../types/types'; +import './IssueSourceViewerHeader.css'; export interface Props { branchLike: BranchLike | undefined; @@ -44,7 +44,7 @@ export interface Props { sourceViewerFile: SourceViewerFile; } -export default function SourceViewerHeaderSlim(props: Props) { +export default function IssueSourceViewerHeader(props: Props) { const { branchLike, expandable, diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.css b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.css index 3f49652df25..b3b151ce897 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.css +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.css @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ .snippet { - margin: var(--gridSize); + margin: var(--gridSize) 0; border: 1px solid var(--gray80); overflow-x: auto; overflow-y: hidden; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx similarity index 83% rename from server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx rename to server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx index e9b49afdd41..06655111a37 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeaderSlim-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/IssueSourceViewerHeader-test.tsx @@ -19,10 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import { mockMainBranch } from '../../../helpers/mocks/branch-like'; -import { mockSourceViewerFile } from '../../../helpers/mocks/sources'; -import { ComponentQualifier } from '../../../types/component'; -import SourceViewerHeaderSlim, { Props } from '../SourceViewerHeaderSlim'; +import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; +import { mockSourceViewerFile } from '../../../../helpers/mocks/sources'; +import { ComponentQualifier } from '../../../../types/component'; +import IssueSourceViewerHeader, { Props } from '../IssueSourceViewerHeader'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); @@ -39,7 +39,7 @@ it('should render correctly', () => { function shallowRender(props: Partial = {}) { return shallow( - - { ); } - renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: SourceViewerFile) { - return this.props.slimHeader ? ( - - ) : ( + renderHeader(sourceViewerFile: SourceViewerFile) { + return ( {({ openComponent }) => ( { return (
(this.node = node)}> - {this.renderHeader(this.props.branchLike, component)} + {this.renderHeader(component)} {sourceRemoved && ( {translate('code_viewer.no_source_code_displayed_due_to_source_removed')} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx index e8a35ab3ad9..0039a2b5d3d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx @@ -397,7 +397,6 @@ function getSourceViewerUi(override?: Partial) { onLoaded={jest.fn()} onLocationSelect={jest.fn()} scroll={jest.fn()} - slimHeader={true} {...override} /> ); diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 34094e1bfa8..0b0167d6bd3 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -826,6 +826,7 @@ issue.comment.posted_on=Comment posted on issue.comment.edit=Edit comment issue.comment.delete=Delete comment issue.comment.delete_confirm_message=Do you want to delete this comment? +issue.get_permalink=Get Permalink issue.manual_vulnerability=Manual issue.manual_vulnerability.description=This Vulnerability was created from a Security Hotspot and has its own issue workflow. issue.rule_details=Rule Details -- 2.39.5