diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-12-09 10:05:57 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-12-09 14:28:10 +0100 |
commit | d4679b41fd1e399ab456b92f22d4ba32ad82259f (patch) | |
tree | 9ac424a19fda5e6201473fc5056d163e128e4aa1 | |
parent | 977242ca23b3ac74ef6fdb08d6e65a1a54b65159 (diff) | |
download | sonarqube-d4679b41fd1e399ab456b92f22d4ba32ad82259f.tar.gz sonarqube-d4679b41fd1e399ab456b92f22d4ba32ad82259f.zip |
do not use "canBeFavorite" from api/navigation/component
9 files changed, 14 insertions, 13 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java index c19c8367b3e..c7e3c2b1704 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java @@ -141,7 +141,6 @@ public class ComponentNavigationAction implements NavigationWsAction { .prop("name", component.name()) .prop("description", component.description()) .prop("isComparable", componentTypeHasProperty(component, PROPERTY_COMPARABLE)) - .prop("canBeFavorite", userSession.isLoggedIn()) .prop("isFavorite", isFavourite(session, component)); if (analysis != null) { diff --git a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json index 1778572c92a..85f2548c560 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/example-component.json @@ -4,7 +4,6 @@ "name": "Sonarqube", "description": "Open source platform for continuous inspection of code quality", "isComparable": true, - "canBeFavorite": true, "isFavorite": true, "version": "6.3", "snapshotDate": "2016-12-06T11:44:00+0200", diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_bread_crumbs_on_several_levels.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_bread_crumbs_on_several_levels.json index c0b1fa23a6e..5fb54d79106 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_bread_crumbs_on_several_levels.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_bread_crumbs_on_several_levels.json @@ -3,7 +3,6 @@ "uuid": "cdef", "name": "Source.xoo", "isComparable": false, - "canBeFavorite": false, "isFavorite": false, "breadcrumbs": [ { diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json index 4b7bd4cea94..e8fa6e98863 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_anonymous_no_snapshot.json @@ -4,7 +4,6 @@ "name": "Polop", "description": "test project", "isComparable": false, - "canBeFavorite": false, "isFavorite": false, "breadcrumbs": [ { diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json index 2b77dd2789a..d4563ff3cb0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_when_snapshot.json @@ -4,7 +4,6 @@ "name": "Polop", "description": "test project", "isComparable": false, - "canBeFavorite": false, "isFavorite": false, "snapshotDate": "2015-04-22T11:44:00+0200", "version": "3.14", diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json index d8304d006dd..e80f7efce3f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentNavigationActionTest/return_component_info_with_favourite.json @@ -4,7 +4,6 @@ "name": "Polop", "description": "test project", "isComparable": false, - "canBeFavorite": true, "isFavorite": true, "breadcrumbs": [ { diff --git a/server/sonar-web/src/main/js/app/components/ProjectContainer.js b/server/sonar-web/src/main/js/app/components/ProjectContainer.js index 44d64f0cd9e..41eaec1e7db 100644 --- a/server/sonar-web/src/main/js/app/components/ProjectContainer.js +++ b/server/sonar-web/src/main/js/app/components/ProjectContainer.js @@ -40,8 +40,8 @@ class ProjectContainer extends React.Component { } render () { - // check `canBeFavorite` to be sure that /api/navigation/component has been already called - if (!this.props.project || this.props.project.canBeFavorite == null) { + // check `breadcrumbs` to be sure that /api/navigation/component has been already called + if (!this.props.project || this.props.project.breadcrumbs == null) { return null; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js index 5e3057b65ff..689f4fc760f 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js @@ -69,8 +69,7 @@ export default React.createClass({ <div className="container"> <ComponentNavFavorite component={this.props.component.key} - favorite={this.props.component.isFavorite} - canBeFavorite={this.props.component.canBeFavorite}/> + favorite={this.props.component.isFavorite}/> <ComponentNavBreadcrumbs breadcrumbs={this.props.component.breadcrumbs}/> diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js index 9e9cb8bfe1d..e5ac6b7cbe6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavFavorite.js @@ -18,15 +18,17 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import React from 'react'; +import { connect } from 'react-redux'; import Favorite from '../../../../components/controls/Favorite'; +import { getCurrentUser } from '../../../store/rootReducer'; -export default class ComponentNavFavorite extends React.Component { +class ComponentNavFavorite extends React.Component { static propTypes = { - canBeFavorite: React.PropTypes.bool.isRequired + currentUser: React.PropTypes.object.isRequired }; render () { - if (!this.props.canBeFavorite) { + if (!this.props.currentUser.isLoggedIn) { return null; } @@ -39,3 +41,9 @@ export default class ComponentNavFavorite extends React.Component { ); } } + +const mapStateToProps = state => ({ + currentUser: getCurrentUser(state) +}); + +export default connect(mapStateToProps)(ComponentNavFavorite); |