Fixed hiding of branch drop down when there are no branches

This commit is contained in:
Philipp Czora
2018-09-18 15:07:30 +02:00
parent 75767bde69
commit 732a84bb7c
3 changed files with 22 additions and 19 deletions

View File

@@ -10,18 +10,20 @@ class ChangesetTable extends React.Component<Props> {
render() {
const {changesets} = this.props;
return <table className="table is-hoverable is-fullwidth is-striped is-bordered">
<thead>
<tr>
<th>Changesets</th>
</tr>
</thead>
<tbody>
{changesets.map((changeset, index) => {
return <ChangesetRow key={index} changeset={changeset}/>;
})}
</tbody>
</table>
return <div>
<table className="table is-hoverable is-fullwidth is-striped is-bordered">
<thead>
<tr>
<th>Changesets</th>
</tr>
</thead>
<tbody>
{changesets.map((changeset, index) => {
return <ChangesetRow key={index} changeset={changeset}/>;
})}
</tbody>
</table>
</div>
}
}

View File

@@ -30,18 +30,19 @@ class Changesets extends React.Component<State, Props> {
componentDidMount() {
const {namespace, name} = this.props.repository;
const branchName = this.props.match.params.branch;
const {fetchChangesetsByNamespaceNameAndBranch, fetchChangesetsByNamespaceAndName, fetchBranchesByNamespaceAndName} = this.props;
if (branchName) {
this.props.fetchChangesetsByNamespaceNameAndBranch(namespace, name, branchName);
fetchChangesetsByNamespaceNameAndBranch(namespace, name, branchName);
} else {
this.props.fetchChangesetsByNamespaceAndName(namespace, name);
fetchChangesetsByNamespaceAndName(namespace, name);
}
this.props.fetchBranchesByNamespaceAndName(namespace, name);
fetchBranchesByNamespaceAndName(namespace, name);
}
render() {
const {changesets, loading, error} = this.props;
if (loading || !changesets) {
return <Loading/>
return <Loading />
}
return <div>
<ErrorNotification error={error}/>
@@ -54,9 +55,9 @@ class Changesets extends React.Component<State, Props> {
const branch = this.props.match.params.branch;
const {changesets, branchNames} = this.props;
if (branchNames) {
if (branchNames && branchNames.length > 0) {
return <div>
<DropDown options={branchNames} preselectedOption={branch}
<label className="label">Branch: </label><DropDown options={branchNames} preselectedOption={branch}
optionSelected={branch => this.branchChanged(branch)}/>
<ChangesetTable changesets={changesets}/>
</div>;

View File

@@ -95,7 +95,7 @@ export function getBranchesForNamespaceAndNameFromState(namespace: string, name:
export function getBranchNames(namespace: string, name: string, state: Object) {
const key = namespace + "/" + name;
if (!state.branches[key]) {
if (!state.branches[key] || !state.branches[key].byNames) {
return null;
}
return Object.keys(state.branches[key].byNames);