Skip to content

Commit da4af48

Browse files
ktaletskfcollonval
authored andcommitted
Enable 'commit and push' button label
1 parent 9f122e8 commit da4af48

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/components/CommitBox.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { TranslationBundle } from '@jupyterlab/translation';
1010
import { CommandRegistry } from '@lumino/commands';
1111
import { CommandIDs } from '../tokens';
12+
import { Git } from '../tokens';
1213

1314
/**
1415
* Interface describing component properties.
@@ -19,6 +20,11 @@ export interface ICommitBoxProps {
1920
*/
2021
commands: CommandRegistry;
2122

23+
/**
24+
* Current list of branches.
25+
*/
26+
branches: Git.IBranch[];
27+
2228
/**
2329
* Boolean indicating whether to use simplified commit-and-push instead of commit button
2430
*/
@@ -98,6 +104,8 @@ export class CommitBox extends React.Component<
98104
? this.props.trans.__('Disabled: No commit message summary')
99105
: !this.props.useCommitAndPush
100106
? this.props.trans.__('Commit')
107+
: !this.props.branches.some(branch => branch.is_remote_branch)
108+
? this.props.trans.__('Disabled: No remote repository defined')
101109
: this.props.trans.__('Commit and push');
102110

103111
const shortcutHint = CommandRegistry.formatKeystroke(
@@ -132,7 +140,9 @@ export class CommitBox extends React.Component<
132140
className={commitButtonClass}
133141
type="button"
134142
title={title}
135-
value={this.props.trans.__('Commit')}
143+
value={!this.props.useCommitAndPush
144+
? this.props.trans.__('Commit')
145+
: this.props.trans.__('Commit and push')}
136146
disabled={disabled}
137147
onClick={this._onCommitSubmit}
138148
/>
@@ -144,7 +154,10 @@ export class CommitBox extends React.Component<
144154
* Whether a commit can be performed (files are staged and summary is not empty).
145155
*/
146156
private _canCommit(): boolean {
147-
return !!(this.props.hasFiles && this.state.summary);
157+
const canAlsoPush = this.props.useCommitAndPush
158+
? this.props.branches.some(branch => branch.is_remote_branch)
159+
: true;
160+
return !!(this.props.hasFiles && this.state.summary && canAlsoPush);
148161
}
149162

150163
/**

src/components/GitPanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
383383
useCommitAndPush={this.props.settings.composite['useCommitAndPush'] as boolean}
384384
onCommit={this.commitMarkedFiles}
385385
commands={this.props.commands}
386+
branches={this.state.branches}
386387
/>
387388
) : (
388389
<CommitBox
@@ -391,6 +392,7 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
391392
useCommitAndPush={this.props.settings.composite['useCommitAndPush'] as boolean}
392393
onCommit={this.commitStagedFiles}
393394
commands={this.props.commands}
395+
branches={this.state.branches}
394396
/>
395397
)}
396398
</React.Fragment>

0 commit comments

Comments
 (0)