From fddb2fb947e8b92e0b6ef41416a87bcbfface23f Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 7 Jan 2016 17:48:53 +0100 Subject: [PATCH] SONAR-7144 pin file in the workspace --- .../main/js/apps/code/components/Component.js | 122 ++++++++++-------- .../apps/code/components/ComponentDetach.js | 3 +- .../js/apps/code/components/ComponentPin.js | 45 +++++++ .../src/main/js/components/shared/pin-icon.js | 31 +++++ .../tests/apps/code/components-test.js | 82 ------------ .../resources/org/sonar/l10n/core.properties | 2 +- 6 files changed, 146 insertions(+), 139 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/code/components/ComponentPin.js create mode 100644 server/sonar-web/src/main/js/components/shared/pin-icon.js diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.js b/server/sonar-web/src/main/js/apps/code/components/Component.js index de9a7e1055f..205af9cef65 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.js +++ b/server/sonar-web/src/main/js/apps/code/components/Component.js @@ -22,63 +22,77 @@ import React from 'react'; import ComponentName from './ComponentName'; import ComponentMeasure from './ComponentMeasure'; import ComponentDetach from './ComponentDetach'; +import ComponentPin from './ComponentPin'; -const Component = ({ component, previous, coverageMetric, onBrowse }) => ( - - - - - - - - - - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- { + let componentAction = null; + + switch (component.qualifier) { + case 'FIL': + case 'UTS': + componentAction = ; + break; + default: + componentAction = ; + } + + return ( + + + + {componentAction} + + + + -
- - -); + previous={previous} + onBrowse={onBrowse}/> + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + ); +}; export default Component; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js b/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js index 37d6f62dc4e..b686188538a 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentDetach.js @@ -26,8 +26,7 @@ import { translate } from '../../../helpers/l10n'; const ComponentDetach = ({ component }) => ( ); diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js new file mode 100644 index 00000000000..80382734ffd --- /dev/null +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.js @@ -0,0 +1,45 @@ +/* + * SonarQube :: Web + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; + +import Workspace from '../../../components/workspace/main'; +import PinIcon from '../../../components/shared/pin-icon'; +import { translate } from '../../../helpers/l10n'; + + +const ComponentPin = ({ component }) => { + const handleClick = (e) => { + e.preventDefault(); + Workspace.openComponent({ uuid: component.uuid }); + }; + + return ( + + + + ); +}; + + +export default ComponentPin; diff --git a/server/sonar-web/src/main/js/components/shared/pin-icon.js b/server/sonar-web/src/main/js/components/shared/pin-icon.js new file mode 100644 index 00000000000..d6b26a886fc --- /dev/null +++ b/server/sonar-web/src/main/js/components/shared/pin-icon.js @@ -0,0 +1,31 @@ +/* + * SonarQube :: Web + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; + +const PinIcon = () => ( + + + +); + +export default PinIcon; + diff --git a/server/sonar-web/tests/apps/code/components-test.js b/server/sonar-web/tests/apps/code/components-test.js index 7729bf7b5ab..a31591cf24e 100644 --- a/server/sonar-web/tests/apps/code/components-test.js +++ b/server/sonar-web/tests/apps/code/components-test.js @@ -7,11 +7,9 @@ import TestUtils from 'react-addons-test-utils'; import Breadcrumb from '../../../src/main/js/apps/code/components/Breadcrumb'; import Breadcrumbs from '../../../src/main/js/apps/code/components/Breadcrumbs'; -import Component from '../../../src/main/js/apps/code/components/Component'; import ComponentDetach from '../../../src/main/js/apps/code/components/ComponentDetach'; import ComponentMeasure from '../../../src/main/js/apps/code/components/ComponentMeasure'; import ComponentName from '../../../src/main/js/apps/code/components/ComponentName'; -import Components from '../../../src/main/js/apps/code/components/Components'; import ComponentsEmpty from '../../../src/main/js/apps/code/components/ComponentsEmpty'; import Truncated from '../../../src/main/js/apps/code/components/Truncated'; @@ -87,50 +85,6 @@ describe('Code :: Components', () => { }); }); - describe('', () => { - let output; - - before(() => { - output = shallow( - ); - }); - - it('should render ', () => { - const findings = output.find(ComponentName); - expect(findings) - .to.have.length(1); - expect(findings.first().props()) - .to.deep.equal({ component: exampleComponent, previous: undefined, onBrowse: exampleOnBrowse }); - }); - - it('should render s', () => { - const findings = output.find(ComponentMeasure); - expect(findings) - .to.have.length(5); - expect(findings.at(0).props()) - .to.deep.equal({ component: exampleComponent, metricKey: 'ncloc', metricType: 'SHORT_INT' }); - expect(findings.at(1).props()) - .to.deep.equal({ component: exampleComponent, metricKey: 'sqale_index', metricType: 'SHORT_WORK_DUR' }); - expect(findings.at(2).props()) - .to.deep.equal({ component: exampleComponent, metricKey: 'violations', metricType: 'SHORT_INT' }); - expect(findings.at(3).props()) - .to.deep.equal({ component: exampleComponent, metricKey: 'coverage', metricType: 'PERCENT' }); - expect(findings.at(4).props()) - .to.deep.equal({ component: exampleComponent, metricKey: 'duplicated_lines_density', metricType: 'PERCENT' }); - }); - - it('should render ', () => { - const findings = output.find(ComponentDetach); - expect(findings) - .to.have.length(1); - expect(findings.first().props()) - .to.deep.equal({ component: exampleComponent }); - }); - }); - describe('', () => { it('should render link', () => { const output = shallow( @@ -139,8 +93,6 @@ describe('Code :: Components', () => { expect(output.type()) .to.equal('a'); - expect(output.prop('target')) - .to.equal('_blank'); expect(output.prop('href')) .to.equal(expectedUrl); }); @@ -228,40 +180,6 @@ describe('Code :: Components', () => { }); }); - describe('', () => { - let output; - - before(() => { - output = shallow( - ); - }); - - it('should render base component', () => { - const findings = output.findWhere(node => { - return node.type() === Component && node.prop('component') === exampleComponent; - }); - - expect(findings) - .to.have.length(1); - expect(findings.first().prop('onBrowse')) - .to.not.be.ok; - }); - - it('should render children component', () => { - const findings = output.findWhere(node => { - return node.type() === Component && node.prop('component') !== exampleComponent; - }); - - expect(findings) - .to.have.length(2); - expect(findings.at(0).prop('onBrowse')) - .to.equal(exampleOnBrowse) - }); - }); - describe('', () => { it('should render', () => { const output = shallow(); 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 8f4abb3efae..22198010256 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3170,4 +3170,4 @@ api_documentation.internal_tooltip=Use at your own risk; internal services are s # CODE # #------------------------------------------------------------------------------ -code.open_in_new_tab=Open in New Tab +code.open_component_page=Open Component's Page -- 2.39.5