@@ -2269,13 +2269,12 @@ webui.NewChangedFilesView = function(workspaceView) {
22692269
22702270 } ) ;
22712271
2272- $ ( "amendBtn" ) . off ( "click" ) ;
2272+ $ ( "# amendBtn" ) . off ( "click" ) ;
22732273 $ ( "#amendBtn" ) . on ( "click" , function ( ) {
22742274 if ( selectedItemsFromOtherUser . length > 0 ) {
22752275 self . confirmActionOnOtherUsersChanges ( "amend" ) ;
22762276 } else {
2277- var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2278- self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2277+ self . confirmAmend ( ) ;
22792278 }
22802279 } ) ;
22812280
@@ -2301,6 +2300,64 @@ webui.NewChangedFilesView = function(workspaceView) {
23012300 } ) ;
23022301 }
23032302
2303+ self . confirmAmend = function ( ) {
2304+ function removePopup ( popup ) {
2305+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2306+ $ ( ".modal-backdrop" ) . remove ( ) ;
2307+ $ ( "#confirmAmend" ) . remove ( ) ;
2308+ }
2309+
2310+ var popup = $ (
2311+ '<div class="modal fade" tabindex="-1" id="confirmAmend" role="dialog" data-backdrop="static">' +
2312+ '<div class="modal-dialog modal-md" role="document">' +
2313+ '<div class="modal-content">' +
2314+ '<div class="modal-header">' +
2315+ '<h5 class="modal-title">Confirm amend</h5>' +
2316+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui . largeXIcon + '</button>' +
2317+ '</div>' +
2318+ '<div class="modal-body"></div>' +
2319+ '<div class="modal-footer"></div>' +
2320+ '</div>' +
2321+ '</div>' +
2322+ '</div>'
2323+ ) [ 0 ] ;
2324+
2325+ $ ( "body" ) . append ( popup ) ;
2326+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2327+ webui . detachChildren ( popupContent ) ;
2328+
2329+ $ (
2330+ '<div class="row">' +
2331+ '<div class="col-sm-1">' +
2332+ webui . warningIcon +
2333+ '</div>' +
2334+ '<div class="col-sm-11">' +
2335+ '<p>Careful, amending commits will rewrite the branch history. The amended commit will not be pushed to remote, even if the previous commit was.</p>' + // Removed extra closing </p> tag
2336+ '</div>' +
2337+ '</div>'
2338+ ) . appendTo ( popupContent ) ;
2339+
2340+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2341+ webui . detachChildren ( popupFooter ) ;
2342+
2343+ $ (
2344+ '<button class="btn btn-sm btn-warning action-btn" id="confirmAmendBtn">Confirm amend</button>' +
2345+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelAmendBtn">Cancel</button>'
2346+ ) . appendTo ( popupFooter ) ;
2347+
2348+ $ ( popup ) . modal ( 'show' ) ;
2349+
2350+ $ ( '#confirmAmendBtn' ) . on ( 'click' , function ( ) {
2351+ removePopup ( popup ) ;
2352+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2353+ self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2354+ } ) ;
2355+
2356+ $ ( '#confirmAmend' ) . find ( '#cancelAmendBtn, .close' ) . click ( function ( ) {
2357+ removePopup ( popup ) ;
2358+ } ) ;
2359+ }
2360+
23042361 self . confirmActionOnOtherUsersChanges = function ( action ) {
23052362 function removeWarningModal ( popup ) {
23062363 $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
@@ -2337,6 +2394,12 @@ webui.NewChangedFilesView = function(workspaceView) {
23372394 } ) ;
23382395
23392396 $ ( '</ul>' ) . appendTo ( popupContent ) ;
2397+
2398+ if ( action == "amend" ) {
2399+ $ ( '<div>' +
2400+ '<p>Careful, amending commits will rewrite the branch history. The amended commit will not be pushed to remote, even if the previous commit was.</p>' +
2401+ '</div>' ) . appendTo ( popupContent ) ;
2402+ }
23402403
23412404 var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
23422405 webui . detachChildren ( popupFooter ) ;
@@ -2352,14 +2415,15 @@ webui.NewChangedFilesView = function(workspaceView) {
23522415 $ ( '#confirmActionBtn' ) . on ( 'click' , function ( ) {
23532416 removeWarningModal ( popup ) ;
23542417 if ( action == "commit" ) {
2355- var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2356- self . commit ( commitMessage ) ;
2418+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2419+ self . commit ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
23572420 } else if ( action == "discard" ) {
23582421 self . discard ( ) ;
23592422 } else if ( action == "stash" ) {
23602423 self . stash ( ) ;
2361- } else if ( axtion == "amend" ) {
2362- self . amend ( ) ;
2424+ } else if ( action == "amend" ) {
2425+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2426+ self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
23632427 }
23642428 } ) ;
23652429
@@ -2487,22 +2551,19 @@ webui.NewChangedFilesView = function(workspaceView) {
24872551
24882552 self . amend = function ( message , details ) {
24892553 var selectedFilesAsString = selectedItems . join ( " " ) ;
2490- console . log ( selectedItems . length ) ;
24912554 if ( self . commitMsgEmpty ( ) ) {
24922555 webui . git ( "add " + selectedFilesAsString ) ;
24932556 webui . git ( "commit --amend --no-edit -- " + selectedFilesAsString , function ( output ) {
24942557 webui . showSuccess ( output ) ;
24952558 workspaceView . update ( ) ;
24962559 } )
24972560 } else if ( selectedItems . length != 0 ) {
2498- console . log ( "bad" ) ;
24992561 webui . git ( "add " + selectedFilesAsString ) ;
25002562 webui . git ( 'commit --amend -m "' + message + '" -m "' + details + '" -- ' + selectedFilesAsString , function ( output ) {
25012563 webui . showSuccess ( output ) ;
25022564 workspaceView . update ( ) ;
25032565 } )
25042566 } else {
2505- console . log ( "here" ) ;
25062567 webui . git ( 'commit --amend --allow-empty -m "' + message + '" -m "' + details + '"' , function ( output ) {
25072568 webui . showSuccess ( output ) ;
25082569 workspaceView . update ( ) ;
0 commit comments