@@ -10,16 +10,15 @@ import {
1010} from '../style/BranchHeaderStyle' ;
1111
1212export interface ICommitBoxProps {
13- hasStagedFiles : boolean ;
14- commitAllStagedFiles : ( message : string ) => Promise < void > ;
13+ hasFiles : boolean ;
14+ commitFunc : ( message : string ) => Promise < void > ;
1515}
1616
1717export interface ICommitBoxState {
1818 /**
1919 * Commit message
2020 */
2121 value : string ;
22- disableSubmit : boolean ;
2322}
2423
2524export class CommitBox extends React . Component <
@@ -29,8 +28,7 @@ export class CommitBox extends React.Component<
2928 constructor ( props : ICommitBoxProps ) {
3029 super ( props ) ;
3130 this . state = {
32- value : '' ,
33- disableSubmit : true
31+ value : ''
3432 } ;
3533 }
3634
@@ -45,24 +43,15 @@ export class CommitBox extends React.Component<
4543 /** Initalize commit message input box */
4644 initializeInput = ( ) : void => {
4745 this . setState ( {
48- value : '' ,
49- disableSubmit : true
46+ value : ''
5047 } ) ;
5148 } ;
5249
5350 /** Handle input inside commit message box */
5451 handleChange = ( event : any ) : void => {
55- if ( event . target . value && event . target . value !== '' ) {
56- this . setState ( {
57- value : event . target . value ,
58- disableSubmit : false
59- } ) ;
60- } else {
61- this . setState ( {
62- value : event . target . value ,
63- disableSubmit : true
64- } ) ;
65- }
52+ this . setState ( {
53+ value : event . target . value
54+ } ) ;
6655 } ;
6756
6857 /** Update state of commit message input box */
@@ -86,22 +75,22 @@ export class CommitBox extends React.Component<
8675 >
8776 < textarea
8877 className = { classes ( textInputStyle , stagedCommitMessageStyle ) }
89- disabled = { ! this . props . hasStagedFiles }
78+ disabled = { ! this . props . hasFiles }
9079 placeholder = {
91- this . props . hasStagedFiles
80+ this . props . hasFiles
9281 ? 'Input message to commit staged changes'
9382 : 'Stage your changes before commit'
9483 }
9584 value = { this . state . value }
9685 onChange = { this . handleChange }
9786 />
9887 < input
99- className = { this . checkReadyForSubmit ( this . props . hasStagedFiles ) }
88+ className = { this . checkReadyForSubmit ( this . props . hasFiles ) }
10089 type = "button"
10190 title = "Commit"
102- disabled = { this . state . disableSubmit }
91+ disabled = { ! ( this . props . hasFiles && this . state . value ) }
10392 onClick = { ( ) => {
104- this . props . commitAllStagedFiles ( this . state . value ) ;
93+ this . props . commitFunc ( this . state . value ) ;
10594 this . initializeInput ( ) ;
10695 } }
10796 />
0 commit comments