@@ -2805,8 +2805,21 @@ webui.NewChangedFilesView = function(workspaceView) {
28052805 }
28062806
28072807 } ) ;
2808+
2809+ $ ( "#abortMergeBtn" ) . off ( "click" ) ;
2810+ $ ( "#abortMergeBtn" ) . on ( "click" , function ( ) {
2811+ self . confirmAbortMerge ( ) ;
2812+ } )
28082813 } ) ;
28092814 } ) ;
2815+
2816+ webui . git_command ( [ "rev-parse" , "--quiet" , "--verify" , "MERGE_HEAD" ] , function ( ) {
2817+ // success code with --verify means MERGE_HEAD exists
2818+ $ ( "#abortMergeBtn" ) . show ( ) . prop ( "disabled" , false ) ;
2819+ } , null , function ( ) {
2820+ // error code with --verify means MERGE_HEAD does not exist
2821+ $ ( "#abortMergeBtn" ) . hide ( ) . prop ( "disabled" , true ) ;
2822+ } )
28102823 }
28112824
28122825 self . confirmDiscard = function ( ) {
@@ -2920,6 +2933,63 @@ webui.NewChangedFilesView = function(workspaceView) {
29202933 } ) ;
29212934 }
29222935
2936+ self . confirmAbortMerge = function ( ) {
2937+ function removePopup ( popup ) {
2938+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2939+ $ ( ".modal-backdrop" ) . remove ( ) ;
2940+ $ ( "#confirmAbortMerge" ) . remove ( ) ;
2941+ }
2942+
2943+ var popup = $ (
2944+ '<div class="modal fade" tabindex="-1" id="confirmAbortMerge" role="dialog" data-backdrop="static">' +
2945+ '<div class="modal-dialog modal-md" role="document">' +
2946+ '<div class="modal-content">' +
2947+ '<div class="modal-header">' +
2948+ '<h5 class="modal-title">Confirm Abort Merge</h5>' +
2949+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui . largeXIcon + '</button>' +
2950+ '</div>' +
2951+ '<div class="modal-body"></div>' +
2952+ '<div class="modal-footer"></div>' +
2953+ '</div>' +
2954+ '</div>' +
2955+ '</div>'
2956+ ) [ 0 ] ;
2957+
2958+ $ ( "body" ) . append ( popup ) ;
2959+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2960+ webui . detachChildren ( popupContent ) ;
2961+
2962+ $ (
2963+ '<div class="row">' +
2964+ '<div class="col-sm-1">' +
2965+ webui . warningIcon +
2966+ '</div>' +
2967+ '<div class="col-sm-11">' +
2968+ '<p>A merge is in progress. Are you sure you want to abort it?</p>' +
2969+ '</div>' +
2970+ '</div>'
2971+ ) . appendTo ( popupContent ) ;
2972+
2973+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2974+ webui . detachChildren ( popupFooter ) ;
2975+
2976+ $ (
2977+ '<button class="btn btn-sm btn-warning action-btn" id="confirmAbortMergeBtn">Confirm</button>' +
2978+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelAbortMergeBtn">Cancel</button>'
2979+ ) . appendTo ( popupFooter ) ;
2980+
2981+ $ ( popup ) . modal ( 'show' ) ;
2982+
2983+ $ ( '#confirmAbortMergeBtn' ) . on ( 'click' , function ( ) {
2984+ removePopup ( popup ) ;
2985+ self . abortMerge ( ) ;
2986+ } ) ;
2987+
2988+ $ ( '#confirmAbortMerge' ) . find ( '#cancelAbortMergeBtn, .close' ) . click ( function ( ) {
2989+ removePopup ( popup ) ;
2990+ } ) ;
2991+ }
2992+
29232993 // Popup for when trying to commit to default merge branch in basic mode
29242994 self . noCommitsOnDefault = function ( ) {
29252995 function removePopup ( popup ) {
@@ -3172,6 +3242,13 @@ webui.NewChangedFilesView = function(workspaceView) {
31723242 webui . git_command ( [ "add" , "--" ] . concat ( selectedItems ) , restoreCommand , undefined , restoreCommand ) ;
31733243 }
31743244
3245+ self . abortMerge = function ( ) {
3246+ webui . git_command ( [ "merge" , "--abort" ] , function ( ) {
3247+ workspaceView . update ( ) ;
3248+ } ) ;
3249+ $ ( "#abortMergeBtn" ) . hide ( ) . prop ( "disabled" , true ) ;
3250+ }
3251+
31753252 self . amend = function ( message , details ) {
31763253 if ( self . commitMsgEmpty ( ) ) {
31773254 $ . ajax ( {
@@ -3274,6 +3351,7 @@ webui.NewChangedFilesView = function(workspaceView) {
32743351 '<button type="button" class="btn btn-outline-primary file-action-button" id="amendBtn" disabled> Amend </button>' +
32753352 '<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled> Stash </button>' +
32763353 '<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled> Discard </button>' +
3354+ '<button type="button" class="btn btn-warning file-action-button" style="display: none" id="abortMergeBtn" disabled> Abort Merge </button>' +
32773355 '</div>' +
32783356 '</div>' +
32793357 '</div>' +
0 commit comments