Skip to content

Commit 6fb94ff

Browse files
authored
Improve commit box and commit diff (#1113)
* Improve some styling * Refactor commit files list * Improve UX * Fix endless refreshing of diff list * Stop pulling commit diff when not needed Bring state closer to component * Display buttons if item hovered or focused * Improve commit box behavior * Add integration test for commits diff * Fix jest tests
1 parent 6f10777 commit 6fb94ff

23 files changed

+527
-576
lines changed

src/components/CommitBox.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class CommitBox extends React.Component<
181181
const disabled = !this._canCommit();
182182
const title = !this.props.hasFiles
183183
? this.props.trans.__('Disabled: No files are staged for commit')
184-
: !this.props.summary
184+
: !this.props.summary && !this.props.amend
185185
? this.props.trans.__('Disabled: No commit message summary')
186186
: this.props.label;
187187

@@ -192,28 +192,34 @@ export class CommitBox extends React.Component<
192192
'Summary (%1 to commit)',
193193
shortcutHint
194194
);
195-
const dirtyStagedFilesWarningTitle = this.props.trans.__('Warning');
196-
const dirtyStagedFilesWarningContent = this.props.trans.__(
197-
'Looks like you still have unsaved staged files. Remember to save and stage all needed changes before committing!'
195+
const warningTitle = this.props.trans.__('Warning');
196+
const warningContent = this.props.trans.__(
197+
'You have unsaved staged files. You probably want to save and stage all needed changes before committing.'
198198
);
199199
return (
200200
<div className={classes(commitFormClass, 'jp-git-CommitBox')}>
201201
{this.props.warnDirtyStagedFiles && (
202202
<WarningBox
203203
headerIcon={<WarningRoundedIcon />}
204-
title={dirtyStagedFilesWarningTitle}
205-
content={dirtyStagedFilesWarningContent}
204+
title={warningTitle}
205+
content={warningContent}
206+
/>
207+
)}
208+
{!this.props.amend && (
209+
<CommitMessage
210+
error={
211+
this.props.hasFiles &&
212+
!this.props.amend &&
213+
this.props.summary.length === 0
214+
}
215+
trans={this.props.trans}
216+
summary={this.props.summary}
217+
summaryPlaceholder={summaryPlaceholder}
218+
description={this.props.description}
219+
setSummary={this.props.setSummary}
220+
setDescription={this.props.setDescription}
206221
/>
207222
)}
208-
<CommitMessage
209-
trans={this.props.trans}
210-
summary={this.props.summary}
211-
summaryPlaceholder={summaryPlaceholder}
212-
description={this.props.description}
213-
disabled={this.props.amend}
214-
setSummary={this.props.setSummary}
215-
setDescription={this.props.setDescription}
216-
/>
217223
<ButtonGroup ref={this._anchorRef} fullWidth={true} size="small">
218224
<Button
219225
classes={{

0 commit comments

Comments
 (0)