@@ -35,6 +35,7 @@ import { HistorySideBar } from './HistorySideBar';
3535import { RebaseAction } from './RebaseAction' ;
3636import { Toolbar } from './Toolbar' ;
3737import { WarningBox } from './WarningBox' ;
38+ import { Widget } from '@lumino/widgets' ;
3839
3940/**
4041 * Interface describing component properties.
@@ -810,22 +811,29 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
810811 const notebooksWithOutputs =
811812 await this . props . model . checkNotebooksForOutputs ( ) ;
812813
813- if (
814- notebooksWithOutputs . length > 0 &&
815- ! this . props . settings . composite [ 'clearOutputsBeforeCommit' ]
816- ) {
814+ const clearSetting =
815+ this . props . settings . composite [ 'clearOutputsBeforeCommit' ] ;
816+ if ( notebooksWithOutputs . length > 0 && clearSetting == null ) {
817+ const bodyWidget = new Widget ( ) ;
818+ bodyWidget . node . innerHTML = `
819+ <div>
820+ <p>Clear all outputs before committing?</p>
821+ <label>
822+ <input type="checkbox" id="dontAskAgain" /> Save my preference
823+ </label>
824+ </div>
825+ ` ;
826+
817827 const dialog = new Dialog ( {
818828 title : this . props . trans . __ ( 'Notebook outputs detected' ) ,
819- body : `You are about to commit ${ notebooksWithOutputs . length } notebook(s) with outputs.
820- Would you like to clean them before committing? If you prefer not to be asked every time, you can enable the "Clear outputs before commit" option in the settings.` ,
829+ body : bodyWidget ,
821830 buttons : [
822831 Dialog . cancelButton ( {
823- label : this . props . trans . __ ( 'Commit Anyway ' )
832+ label : this . props . trans . __ ( 'Keep Outputs & Commit ' )
824833 } ) ,
825- Dialog . okButton ( {
826- label : this . props . trans . __ ( 'Clean & Commit' )
827- } )
828- ]
834+ Dialog . okButton ( { label : this . props . trans . __ ( 'Clean & Commit' ) } )
835+ ] ,
836+ defaultButton : 0
829837 } ) ;
830838
831839 const result = await dialog . launch ( ) ;
@@ -835,9 +843,14 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
835843 return ;
836844 }
837845 const accepted =
838- typeof result . button . accept === 'boolean'
839- ? result . button . accept
840- : result . button . label === this . props . trans . __ ( 'Clean & Commit' ) ;
846+ result . button . label === this . props . trans . __ ( 'Clean & Commit' ) ;
847+ const checkbox =
848+ bodyWidget . node . querySelector < HTMLInputElement > ( '#dontAskAgain' ) ;
849+
850+ // Remember the user’s choice if checkbox is checked
851+ if ( checkbox ?. checked ) {
852+ this . props . settings . set ( 'clearOutputsBeforeCommit' , accepted ) ;
853+ }
841854 if ( accepted ) {
842855 id = Notification . emit (
843856 this . props . trans . __ ( 'Cleaning notebook outputs…' ) ,
@@ -847,7 +860,8 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
847860
848861 await this . props . model . stripNotebooksOutputs ( notebooksWithOutputs ) ;
849862 }
850- } else if ( this . props . settings . composite [ 'clearOutputsBeforeCommit' ] ) {
863+ } else if ( clearSetting === true ) {
864+ // Always clean before commit
851865 id = Notification . emit (
852866 this . props . trans . __ ( 'Cleaning notebook outputs…' ) ,
853867 'in-progress' ,
0 commit comments