Skip to content

Commit

Permalink
Enable push/pull buttons for empty repos
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Oct 24, 2024
1 parent 544e89f commit 9a9ab5a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ export interface IToolbarState {
* Panel tab identifier.
*/
tab: number;

/**
* Boolean indicating whether a remote exists.
*/
hasRemote: boolean;
}

/**
Expand All @@ -126,10 +131,24 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
super(props);
this.state = {
branchMenu: false,
tab: 0
tab: 0,
hasRemote: false
};
}

/**
* Check whether or not the repo has any remotes
*/
async componentDidMount(): Promise<void> {
try {
const remotes = await this.props.model.getRemotes();
const hasRemote = remotes.length > 0 ? true : false;
this.setState({ hasRemote });
} catch (err) {
console.error(err);
}
}

/**
* Renders the component.
*
Expand All @@ -154,10 +173,7 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
const activeBranch = this.props.branches.filter(
branch => branch.is_current_branch
);
// FIXME whether the repository as a remote or not should be done through a call to `git remote`
const hasRemote = this.props.branches.some(
branch => branch.is_remote_branch
);
const hasRemote = this.state.hasRemote;
const hasUpstream = activeBranch[0]?.upstream !== null;

return (
Expand Down

0 comments on commit 9a9ab5a

Please sign in to comment.