From 7ea9a6c19724d218a5237a6bfbde1a74865cf2a0 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Wed, 13 Feb 2019 10:42:19 +0100 Subject: [PATCH] SONAR-11724 Remove Leak Period logic from code navigator --- .../src/main/js/app/styles/init/tables.css | 14 ----- .../js/apps/code/components/Component.tsx | 6 +- .../js/apps/code/components/Components.tsx | 16 ++---- .../apps/code/components/ComponentsEmpty.tsx | 5 +- .../apps/code/components/ComponentsHeader.tsx | 8 +-- .../__tests__/ComponentsHeader-test.tsx | 56 ++++++------------- .../__snapshots__/Components-test.tsx.snap | 16 ------ .../ComponentsHeader-test.tsx.snap | 39 +------------ 8 files changed, 29 insertions(+), 131 deletions(-) diff --git a/server/sonar-web/src/main/js/app/styles/init/tables.css b/server/sonar-web/src/main/js/app/styles/init/tables.css index 2767bfbe9f5..a4c1d368464 100644 --- a/server/sonar-web/src/main/js/app/styles/init/tables.css +++ b/server/sonar-web/src/main/js/app/styles/init/tables.css @@ -225,12 +225,6 @@ table.data > tbody > tr > td.text-middle { line-height: 15px; } -.data tr > th.leak, -.data tr > td.leak { - background-color: var(--leakColor) !important; - line-height: 15px; -} - .data tr.highlight { background-color: var(--lightBlue); } @@ -299,14 +293,6 @@ table.data.zebra.zebra-inversed > tbody > tr:nth-child(odd) { background-color: #f5f5f5; } -table.data.zebra:not(.zebra-inversed) - > tbody - > tr:not(.blank):nth-child(even) - > td:not(.blank).leak, -table.data.zebra.zebra-inversed > tbody > tr:not(.blank):nth-child(odd) > td:not(.blank).leak { - background-color: var(--leakColorHover) !important; -} - table#project-history tr > td { vertical-align: top; } 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 d5262dabeb9..6391a622928 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 @@ -29,7 +29,6 @@ interface Props { branchLike?: T.BranchLike; canBrowse?: boolean; component: T.ComponentMeasure; - isLeak: boolean; metrics: T.Metric[]; previous?: T.ComponentMeasure; rootComponent: T.ComponentMeasure; @@ -42,7 +41,6 @@ export class Component extends React.PureComponent { branchLike, canBrowse = false, component, - isLeak, metrics, previous, rootComponent, @@ -80,13 +78,13 @@ export class Component extends React.PureComponent { {metrics.map(metric => ( - +
))} - + ); } 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 506a3d4fe83..7fd2c4f50c3 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 @@ -18,12 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import * as classNames from 'classnames'; import Component from './Component'; import ComponentsEmpty from './ComponentsEmpty'; import ComponentsHeader from './ComponentsHeader'; import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation'; -import { getCodeMetrics, showLeakMeasure } from '../utils'; +import { getCodeMetrics } from '../utils'; import { isDefined } from '../../../helpers/types'; interface Props { @@ -40,13 +39,11 @@ export class Components extends React.PureComponent { const { baseComponent, branchLike, components, rootComponent, selected } = this.props; const metricKeys = getCodeMetrics(rootComponent.qualifier, branchLike); const metrics = metricKeys.map(metric => this.props.metrics[metric]).filter(isDefined); - const isLeak = Boolean(baseComponent && showLeakMeasure(branchLike)); return ( {baseComponent && ( @@ -56,17 +53,13 @@ export class Components extends React.PureComponent { - + )} @@ -77,7 +70,6 @@ export class Components extends React.PureComponent { branchLike={branchLike} canBrowse={true} component={component} - isLeak={isLeak} key={component.key} metrics={metrics} previous={index > 0 ? list[index - 1] : undefined} @@ -86,12 +78,12 @@ export class Components extends React.PureComponent { /> )) ) : ( - + )}
  - {' '} -  {' '} -  
- +
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsEmpty.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsEmpty.tsx index ab2dc4c4182..3c3e4fab144 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsEmpty.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsEmpty.tsx @@ -18,17 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import * as classNames from 'classnames'; import { translate } from '../../../helpers/l10n'; -export default function ComponentsEmpty({ isLeak }: { isLeak: boolean }) { +export default function ComponentsEmpty() { return ( {translate('no_results')} - + ); } diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx index 35d2f801e06..81de436c90f 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx @@ -23,7 +23,6 @@ import { translate } from '../../../helpers/l10n'; interface Props { baseComponent?: T.ComponentMeasure; - isLeak: boolean; metrics: string[]; rootComponent: T.ComponentMeasure; } @@ -35,7 +34,7 @@ const SHORT_NAME_METRICS = [ 'new_duplicated_lines_density' ]; -export default function ComponentsHeader({ baseComponent, isLeak, metrics, rootComponent }: Props) { +export default function ComponentsHeader({ baseComponent, metrics, rootComponent }: Props) { const isPortfolio = ['VW', 'SVW'].includes(rootComponent.qualifier); let columns: string[] = []; if (isPortfolio) { @@ -61,14 +60,13 @@ export default function ComponentsHeader({ baseComponent, isLeak, metrics, rootC columns.map((column, index) => ( 0, - leak: isLeak + 'code-components-cell': index > 0 })} key={column}> {column} ))} - + ); diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentsHeader-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentsHeader-test.tsx index 24e7e40e074..1b8fd7e98de 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentsHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/ComponentsHeader-test.tsx @@ -20,52 +20,28 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentsHeader from '../ComponentsHeader'; - -const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' }; -const PORTFOLIO = { key: 'bar', name: 'Bar', qualifier: 'VW' }; -const METRICS = ['foo', 'bar']; +import { mockComponent } from '../../../../helpers/testMocks'; it('renders correctly for projects', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); -}); - -it('renders correctly for leak', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot(); }); it('renders correctly for portfolios', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); + const portfolio = mockComponent({ qualifier: 'VW' }); + expect(shallowRender({ baseComponent: portfolio, rootComponent: portfolio })).toMatchSnapshot(); }); it('renders correctly for a search', () => { - expect( - shallow() - ).toMatchSnapshot(); + expect(shallowRender({ baseComponent: undefined })).toMatchSnapshot(); }); + +function shallowRender(props = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap index 9f8963ef37d..6d8d7177b40 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/Components-test.tsx.snap @@ -12,7 +12,6 @@ exports[`renders correctly 1`] = ` "qualifier": "TRK", } } - isLeak={false} metrics={ Array [ "ncloc", @@ -40,7 +39,6 @@ exports[`renders correctly 1`] = ` "qualifier": "TRK", } } - isLeak={false} key="foo" metrics={ Array [ @@ -69,12 +67,9 @@ exports[`renders correctly 1`] = `   -   - @@ -88,7 +83,6 @@ exports[`renders correctly 1`] = ` "qualifier": "TRK", } } - isLeak={false} key="foo" metrics={ Array [ @@ -115,7 +109,6 @@ exports[`renders correctly 1`] = ` colSpan={3} /> @@ -137,7 +130,6 @@ exports[`renders correctly for a search 1`] = ` "qualifier": "TRK", } } - isLeak={false} key="foo" metrics={ Array [ @@ -164,7 +156,6 @@ exports[`renders correctly for a search 1`] = ` colSpan={3} /> @@ -184,7 +175,6 @@ exports[`renders correctly for leak 1`] = ` "qualifier": "TRK", } } - isLeak={true} metrics={ Array [ "new_lines", @@ -220,7 +210,6 @@ exports[`renders correctly for leak 1`] = ` "qualifier": "TRK", } } - isLeak={true} key="foo" metrics={Array []} rootComponent={ @@ -240,12 +229,9 @@ exports[`renders correctly for leak 1`] = `   -   - @@ -267,7 +253,6 @@ exports[`renders correctly for leak 1`] = ` "qualifier": "TRK", } } - isLeak={true} key="foo" metrics={Array []} rootComponent={ @@ -285,7 +270,6 @@ exports[`renders correctly for leak 1`] = ` colSpan={3} /> diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentsHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentsHeader-test.tsx.snap index a37d9e497f5..69c4c1f0371 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentsHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/__snapshots__/ComponentsHeader-test.tsx.snap @@ -10,38 +10,7 @@ exports[`renders correctly for a search 1`] = ` colSpan={2} /> - - - -`; - -exports[`renders correctly for leak 1`] = ` - - - - - metric.foo.name - - - metric.bar.name - - `; @@ -86,9 +55,7 @@ exports[`renders correctly for portfolios 1`] = ` > metric.ncloc.name - + `; @@ -115,9 +82,7 @@ exports[`renders correctly for projects 1`] = ` > metric.bar.name - + `; -- 2.39.5