@@ -2,12 +2,11 @@ import * as React from 'react';
2
2
import TextareaAutosize from 'react-textarea-autosize' ;
3
3
import { classes } from 'typestyle' ;
4
4
import {
5
- stagedCommitButtonDisabledStyle ,
6
- stagedCommitButtonReadyStyle ,
7
- stagedCommitButtonStyle ,
8
- stagedCommitMessageStyle ,
9
- stagedCommitStyle ,
10
- textInputStyle
5
+ commitFormClass ,
6
+ commitSummaryClass ,
7
+ commitDescriptionClass ,
8
+ commitButtonClass ,
9
+ commitButtonDisabledClass
11
10
} from '../style/CommitBox' ;
12
11
13
12
/**
@@ -70,49 +69,39 @@ export class CommitBox extends React.Component<
70
69
* @returns fragment
71
70
*/
72
71
render ( ) {
72
+ const disabled = ! ( this . props . hasFiles && this . state . summary ) ;
73
73
return (
74
- < form className = { stagedCommitStyle } >
75
- < textarea
76
- className = { classes ( textInputStyle , stagedCommitMessageStyle ) }
74
+ < form className = { commitFormClass } >
75
+ < input
76
+ className = { commitSummaryClass }
77
+ type = "text"
77
78
placeholder = "Summary (required)"
78
79
value = { this . state . summary }
79
80
onChange = { this . _onSummaryChange }
80
81
onKeyPress = { this . _onSummaryKeyPress }
81
82
/>
82
83
< TextareaAutosize
83
- className = { classes ( textInputStyle , stagedCommitMessageStyle ) }
84
- minRows = { 2 }
84
+ className = { commitDescriptionClass }
85
+ minRows = { 5 }
85
86
placeholder = "Description"
86
87
value = { this . state . description }
87
88
onChange = { this . _onDescriptionChange }
88
- onKeyPress = { this . _onDescriptionKeyPress }
89
89
/>
90
90
< input
91
- className = { this . _commitButtonStyle ( ) }
91
+ className = { classes (
92
+ commitButtonClass ,
93
+ disabled ? commitButtonDisabledClass : null
94
+ ) }
92
95
type = "button"
93
96
title = "Commit"
94
- disabled = { ! ( this . props . hasFiles && this . state . summary ) }
97
+ value = "Commit"
98
+ disabled = { disabled }
95
99
onClick = { this . _onCommitClick }
96
100
/>
97
101
</ form >
98
102
) ;
99
103
}
100
104
101
- /**
102
- * Returns classes for toggling (and styling) the commit button.
103
- *
104
- * @returns classes to apply
105
- */
106
- private _commitButtonStyle = ( ) : string => {
107
- if ( this . props . hasFiles ) {
108
- if ( this . state . summary . length === 0 ) {
109
- return classes ( stagedCommitButtonStyle , stagedCommitButtonReadyStyle ) ;
110
- }
111
- return stagedCommitButtonStyle ;
112
- }
113
- return classes ( stagedCommitButtonStyle , stagedCommitButtonDisabledStyle ) ;
114
- } ;
115
-
116
105
/**
117
106
* Callback invoked upon clicking a commit message submit button.
118
107
*
@@ -137,24 +126,6 @@ export class CommitBox extends React.Component<
137
126
} ) ;
138
127
} ;
139
128
140
- /**
141
- * Callback invoked upon a `'keypress'` event when entering a commit message description.
142
- *
143
- * ## Notes
144
- *
145
- * - Prevents triggering a `'submit'` action when hitting the `ENTER` key while entering a commit message description.
146
- *
147
- * @param event - event object
148
- */
149
- private _onDescriptionKeyPress ( event : any ) : void {
150
- if ( event . which === 13 ) {
151
- event . preventDefault ( ) ;
152
- this . setState ( {
153
- description : this . state . description + '\n'
154
- } ) ;
155
- }
156
- }
157
-
158
129
/**
159
130
* Callback invoked upon updating a commit message summary.
160
131
*
0 commit comments