mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Show BranchChooser div only when there are branches to choose from
This commit is contained in:
@@ -18,7 +18,8 @@ type Props = {
|
||||
callback: (?Branch) => void,
|
||||
branches: Branch[],
|
||||
selectedBranchName: string,
|
||||
loading: boolean
|
||||
loading: boolean,
|
||||
label: string
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -39,17 +40,20 @@ class BranchChooser extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { branches, loading } = this.props;
|
||||
const { branches, loading, label } = this.props;
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
if (branches && branches.length > 0) {
|
||||
return (
|
||||
<DropDown
|
||||
options={branches.map(b => b.name)}
|
||||
preselectedOption={this.state.selectedBranchName}
|
||||
optionSelected={branch => this.branchChanged(branch)}
|
||||
/>
|
||||
<div className={"box"}>
|
||||
<label className="label">{label}</label>
|
||||
<DropDown
|
||||
options={branches.map(b => b.name)}
|
||||
preselectedOption={this.state.selectedBranchName}
|
||||
optionSelected={branch => this.branchChanged(branch)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,16 +144,12 @@ class Changesets extends React.PureComponent<Props, State> {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={"box"}>
|
||||
<label className="label">
|
||||
{t("changesets.branchselector-label")}
|
||||
</label>
|
||||
<BranchChooser
|
||||
repository={repository}
|
||||
selectedBranchName={branch}
|
||||
callback={branch => this.branchChanged(branch)}
|
||||
/>
|
||||
</div>
|
||||
<BranchChooser
|
||||
repository={repository}
|
||||
selectedBranchName={branch}
|
||||
label={t("changesets.branchselector-label")}
|
||||
callback={branch => this.branchChanged(branch)}
|
||||
/>
|
||||
<ChangesetList repository={repository} changesets={changesets} />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -132,14 +132,14 @@ export function getBranch(
|
||||
state: Object,
|
||||
repository: Repository,
|
||||
name: string
|
||||
): ?Branch {
|
||||
): Branch {
|
||||
const key = createKey(repository);
|
||||
if (state.branches[key]) {
|
||||
if (state.branches[key].byNames[name]) {
|
||||
return state.branches[key].byNames[name];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isFetchBranchesPending(
|
||||
|
||||
Reference in New Issue
Block a user