@@ -11,6 +11,7 @@ export default function CommitComponent(props) {
11
11
const [ commitDone , setCommitDone ] = useState ( false ) ;
12
12
const [ commitError , setCommitError ] = useState ( false ) ;
13
13
const [ loadingCommit , setLoadingCommit ] = useState ( false ) ;
14
+ const [ commitMessageWarning , setCommitMessageWarning ] = useState ( false ) ;
14
15
15
16
const commitRef = useRef ( ) ;
16
17
@@ -101,7 +102,8 @@ export default function CommitComponent(props) {
101
102
{ ! commitDone ? (
102
103
< div className = "git-ops--commit--wrapper" >
103
104
< div className = "git-ops--commit--header" >
104
- { stagedCount } Changes to commit...
105
+ { stagedCount } { stagedCount > 1 ? "Changes" : "Change" } to
106
+ commit...
105
107
</ div >
106
108
< div className = "overflow-auto" style = { { height : "300px" } } >
107
109
{ stagedFilesState . map ( ( stagedFile ) => {
@@ -116,12 +118,36 @@ export default function CommitComponent(props) {
116
118
} ) }
117
119
</ div >
118
120
< div className = "text-xl my-4" > Commit Message</ div >
121
+ { commitMessageWarning ? (
122
+ < div className = "font-sans font-semibold italic p-2 border-b border-dotted border-orange-500 text-yellow-600" >
123
+ < span role = "img" aria-label = "suggestion" >
124
+ 💡
125
+ </ span >
126
+ < span className = "mx-1" >
127
+ It is usually a good practice to limit the commit message to
128
+ 50 characters
129
+ </ span >
130
+ < div className = "my-1 font-sans text-sm font-semibold text-yellow-700" >
131
+ For additional content, include a line break and enter the
132
+ messages
133
+ </ div >
134
+ </ div >
135
+ ) : null }
119
136
< textarea
120
137
className = "git-ops--commit--message"
121
138
placeholder = "Enter commit message"
122
139
cols = "20"
123
140
rows = "5"
124
141
ref = { commitRef }
142
+ onChange = { ( e ) => {
143
+ const content = e . currentTarget . value ;
144
+ const len = content . split ( "\n" ) [ 0 ] . length ;
145
+ if ( len > 50 ) {
146
+ setCommitMessageWarning ( true ) ;
147
+ } else {
148
+ setCommitMessageWarning ( false ) ;
149
+ }
150
+ } }
125
151
> </ textarea >
126
152
{ commitError ? (
127
153
< div className = "git-ops--commit--alert--failed" >
0 commit comments