]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10262 Disable flagging a branch component as favorite
authorStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 28 Mar 2018 09:15:39 +0000 (11:15 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 29 Mar 2018 18:20:47 +0000 (20:20 +0200)
server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js
server/sonar-web/src/main/js/apps/component-measures/components/MeasureFavoriteContainer.js
server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx

index 5c5205077cbca90543a0229f05dbeadd7bf08912..f18f16b55e207de7ec45d9bee50dba24132beddb 100644 (file)
@@ -298,6 +298,7 @@ export default class MeasureContent extends React.PureComponent {
               {component.key !== rootComponent.key &&
                 isLoggedIn && (
                   <MeasureFavoriteContainer
+                    branchLike={branchLike}
                     component={component.key}
                     className="measure-favorite spacer-right"
                   />
index f1aac5309b1a4cca7d14573b68bd8cbc8601cea9..9eacba92a32496a8eda0962dad3279b0a62b2d29 100644 (file)
@@ -23,10 +23,12 @@ import { connect } from 'react-redux';
 import FavoriteContainer from '../../../components/controls/FavoriteContainer';
 import { getComponentForSourceViewer } from '../../../api/components';
 import { receiveFavorites } from '../../../store/favorites/duck';
+import { isMainBranch } from '../../../helpers/branches';
 
 /*:: type FavComponent = { key: string, canMarkAsFavorite: boolean, fav: boolean }; */
 
 /*:: type Props = {
+  branchLike?: { id?: string; name: string },
   className?: string,
   component: string,
   onReceiveComponent: (component: FavComponent) => void
@@ -65,7 +67,11 @@ class MeasureFavoriteContainer extends React.PureComponent {
 
   render() {
     const { component } = this.state;
-    if (component == null || !component.canMarkAsFavorite) {
+    if (
+      component == null ||
+      !component.canMarkAsFavorite ||
+      (this.props.branchLike && !isMainBranch(this.props.branchLike))
+    ) {
       return null;
     }
     return (
index 9255f0d7e51b316a3dfcde8ea095a71edb44538a..041856e2426659c510b0b5f030848cf893a112c6 100644 (file)
@@ -38,7 +38,7 @@ import {
 } from '../../helpers/urls';
 import { collapsedDirFromPath, fileFromPath } from '../../helpers/path';
 import { translate } from '../../helpers/l10n';
-import { getBranchLikeQuery } from '../../helpers/branches';
+import { getBranchLikeQuery, isMainBranch } from '../../helpers/branches';
 import { formatMeasure } from '../../helpers/measures';
 import { omitNil } from '../../helpers/request';
 
@@ -120,9 +120,10 @@ export default class SourceViewerHeader extends React.PureComponent<Props, State
             <div className="component-name-path">
               <QualifierIcon qualifier={q} /> <span>{collapsedDirFromPath(path)}</span>
               <span className="component-name-file">{fileFromPath(path)}</span>
-              {this.props.sourceViewerFile.canMarkAsFavorite && (
-                <FavoriteContainer className="component-name-favorite" componentKey={key} />
-              )}
+              {this.props.sourceViewerFile.canMarkAsFavorite &&
+                (!this.props.branchLike || isMainBranch(this.props.branchLike)) && (
+                  <FavoriteContainer className="component-name-favorite" componentKey={key} />
+                )}
             </div>
           </div>
         </div>