const items = branches.map((branch, index) => {
const isOrphan = isShortLivingBranch(branch) && branch.isOrphan;
- const previous = index > 0 ? branches[index - 1] : null;
+ const previous = index > 0 ? branches[index - 1] : undefined;
const isPreviousOrphan = isShortLivingBranch(previous) ? previous.isOrphan : false;
const showDivider = isLongLivingBranch(branch) || (isOrphan && !isPreviousOrphan);
const showOrphanHeader = isOrphan && !isPreviousOrphan;
}
renderDashboardLink() {
- if (this.props.branch && isShortLivingBranch(this.props.branch)) {
+ if (isShortLivingBranch(this.props.branch)) {
return null;
}
to={{
pathname,
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
}}
to={{
pathname: '/code',
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
}}
}
renderActivityLink() {
- if (this.props.branch && isShortLivingBranch(this.props.branch)) {
+ if (isShortLivingBranch(this.props.branch)) {
return null;
}
to={{
pathname: '/project/activity',
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
}}
to={{
pathname: '/project/issues',
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key,
resolved: 'false'
}
}
renderComponentMeasuresLink() {
- if (this.props.branch && isShortLivingBranch(this.props.branch)) {
+ if (isShortLivingBranch(this.props.branch)) {
return null;
}
to={{
pathname: '/component_measures',
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
}}
const isSettingsActive = SETTINGS_URLS.some(url => window.location.href.indexOf(url) !== -1);
- if (branch && isLongLivingBranch(branch)) {
+ if (isLongLivingBranch(branch)) {
return (
<li>
<Link
to={{
pathname: '/project/settings',
query: {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
}}
}
export function ComponentNavMeta({ branch, component, currentUser }: Props) {
- const shortBranch = branch && isShortLivingBranch(branch);
+ const shortBranch = isShortLivingBranch(branch);
const mainBranch = !branch || branch.isMain;
return (
this.setState({ loading: true });
const isPortfolio = ['VW', 'SVW'].includes(component.qualifier);
- retrieveComponentChildren(component.key, isPortfolio, branch && getBranchName(branch))
+ retrieveComponentChildren(component.key, isPortfolio, getBranchName(branch))
.then(() => {
addComponent(component);
if (this.mounted) {
this.setState({ loading: true });
const isPortfolio = ['VW', 'SVW'].includes(this.props.component.qualifier);
- retrieveComponent(
- componentKey,
- isPortfolio,
- this.props.branch && getBranchName(this.props.branch)
- )
+ retrieveComponent(componentKey, isPortfolio, getBranchName(this.props.branch))
.then(r => {
if (this.mounted) {
if (['FIL', 'UTS'].includes(r.component.qualifier)) {
return;
}
const isPortfolio = ['VW', 'SVW'].includes(this.props.component.qualifier);
- loadMoreChildren(
- baseComponent.key,
- page + 1,
- isPortfolio,
- this.props.branch && getBranchName(this.props.branch)
- )
+ loadMoreChildren(baseComponent.key, page + 1, isPortfolio, getBranchName(this.props.branch))
.then(r => {
if (this.mounted) {
this.setState({
total,
sourceViewer
} = this.state;
- const branchName = branch && getBranchName(branch);
+ const branchName = getBranchName(branch);
const shouldShowBreadcrumbs = breadcrumbs.length > 1;
const filteredKeys = metricsKey.filter(
key => !metrics[key].hidden && !['DATA', 'DISTRIB'].includes(metrics[key].type)
);
- fetchMeasures(component.key, filteredKeys, branch && getBranchName(branch)).then(
+ fetchMeasures(component.key, filteredKeys, getBranchName(branch)).then(
({ measures, leakPeriod }) => {
if (this.mounted) {
this.setState({
pathname: this.props.location.pathname,
query: {
...query,
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
});
{metric != null && (
<MeasureContentContainer
- branch={branch && getBranchName(branch)}
+ branch={getBranchName(branch)}
className="layout-page-main"
currentUser={this.props.currentUser}
rootComponent={component}
{metric == null &&
hasBubbleChart(query.metric) && (
<MeasureOverviewContainer
- branch={branch && getBranchName(branch)}
+ branch={getBranchName(branch)}
className="layout-page-main"
rootComponent={component}
currentUser={this.props.currentUser}
pathname: this.props.location.pathname,
query: {
...serializeQuery(this.state.query),
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component && this.props.component.key,
myIssues: this.state.myIssues ? 'true' : undefined,
open: issue
pathname: this.props.location.pathname,
query: {
...serializeQuery(this.state.query),
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component && this.props.component.key,
myIssues: this.state.myIssues ? 'true' : undefined,
open: undefined
: undefined;
const parameters = {
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
componentKeys: component && component.key,
s: 'FILE_LINE',
...serializeQuery(query),
pathname: this.props.location.pathname,
query: {
...serializeQuery({ ...this.state.query, ...changes }),
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component && this.props.component.key,
myIssues: this.state.myIssues ? 'true' : undefined
}
pathname: this.props.location.pathname,
query: {
...serializeQuery({ ...this.state.query, assigned: true, assignees: [] }),
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component && this.props.component.key,
myIssues: myIssues ? 'true' : undefined
}
pathname: this.props.location.pathname,
query: {
...DEFAULT_QUERY,
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component && this.props.component.key,
myIssues: this.state.myIssues ? 'true' : undefined
}
<div>
{paging.total > 0 && (
<IssuesList
- branch={this.props.branch && getBranchName(branch)}
+ branch={getBranchName(branch)}
checked={this.state.checked}
component={component}
issues={issues}
{openIssue != null ? (
<div className="pull-left width-60">
<ComponentBreadcrumbs
- branch={this.props.branch && getBranchName(this.props.branch)}
+ branch={getBranchName(this.props.branch)}
component={component}
issue={openIssue}
organization={this.props.organization}
<div>
{openIssue ? (
<IssuesSourceViewer
- branch={this.props.branch && getBranchName(this.props.branch)}
+ branch={getBranchName(this.props.branch)}
component={component}
openIssue={openIssue}
loadIssues={this.fetchIssuesForComponent}
pathname: this.props.location.pathname,
query: {
...serializeUrlQuery(newQuery),
- branch: this.props.branch && getBranchName(this.props.branch)
+ branch: getBranchName(this.props.branch)
}
});
} else {
project,
p,
ps,
- branch: this.props.branch && getBranchName(this.props.branch)
+ branch: getBranchName(this.props.branch)
};
return api
.getProjectActivity({ ...additional, ...parameters })
return Promise.resolve([]);
}
return getAllTimeMachineData(this.props.component.key, metrics, {
- branch: this.props.branch && getBranchName(this.props.branch)
+ branch: getBranchName(this.props.branch)
}).then(
({ measures }) =>
measures.map(measure => ({
pathname: this.props.location.pathname,
query: {
...query,
- branch: this.props.branch && getBranchName(this.props.branch),
+ branch: getBranchName(this.props.branch),
id: this.props.component.key
}
});
import { sortBy } from 'lodash';
import { Branch, BranchType, ShortLivingBranch, LongLivingBranch } from '../app/types';
-export function isShortLivingBranch(branch: Branch | null): branch is ShortLivingBranch {
- return branch != null && !branch.isMain && branch.type === BranchType.SHORT;
+export function isShortLivingBranch(branch?: Branch): branch is ShortLivingBranch {
+ return branch !== undefined && !branch.isMain && branch.type === BranchType.SHORT;
}
-export function isLongLivingBranch(branch: Branch | null): branch is LongLivingBranch {
- return branch != null && !branch.isMain && branch.type === BranchType.LONG;
+export function isLongLivingBranch(branch?: Branch): branch is LongLivingBranch {
+ return branch !== undefined && !branch.isMain && branch.type === BranchType.LONG;
}
-export function getBranchName(branch: Branch): string | undefined {
- return branch.isMain ? undefined : branch.name;
+export function getBranchName(branch?: Branch): string | undefined {
+ return !branch || branch.isMain ? undefined : branch.name;
}
export function sortBranchesAsTree(branches: Branch[]): Branch[] {