9
9
import { TranslationBundle } from '@jupyterlab/translation' ;
10
10
import { CommandRegistry } from '@lumino/commands' ;
11
11
import { CommandIDs } from '../tokens' ;
12
+ import { Git } from '../tokens' ;
12
13
13
14
/**
14
15
* Interface describing component properties.
@@ -19,6 +20,11 @@ export interface ICommitBoxProps {
19
20
*/
20
21
commands : CommandRegistry ;
21
22
23
+ /**
24
+ * Current list of branches.
25
+ */
26
+ branches : Git . IBranch [ ] ;
27
+
22
28
/**
23
29
* Boolean indicating whether to use simplified commit-and-push instead of commit button
24
30
*/
@@ -98,6 +104,8 @@ export class CommitBox extends React.Component<
98
104
? this . props . trans . __ ( 'Disabled: No commit message summary' )
99
105
: ! this . props . useCommitAndPush
100
106
? this . props . trans . __ ( 'Commit' )
107
+ : ! this . props . branches . some ( branch => branch . is_remote_branch )
108
+ ? this . props . trans . __ ( 'Disabled: No remote repository defined' )
101
109
: this . props . trans . __ ( 'Commit and push' ) ;
102
110
103
111
const shortcutHint = CommandRegistry . formatKeystroke (
@@ -132,7 +140,9 @@ export class CommitBox extends React.Component<
132
140
className = { commitButtonClass }
133
141
type = "button"
134
142
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' ) }
136
146
disabled = { disabled }
137
147
onClick = { this . _onCommitSubmit }
138
148
/>
@@ -144,7 +154,10 @@ export class CommitBox extends React.Component<
144
154
* Whether a commit can be performed (files are staged and summary is not empty).
145
155
*/
146
156
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 ) ;
148
161
}
149
162
150
163
/**
0 commit comments