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
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 (
} 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';
<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>