@@ -2327,8 +2327,8 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
2327
2327
} ) ;
2328
2328
2329
2329
2330
- $ ( '<button class="btn btn-sm btn-danger float-right " id="confirm-staging">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2331
- '<button class="btn btn-sm btn-secondary float-right " id="cancel-staging">Cancel</button>' ) . appendTo ( popupContent ) ;
2330
+ $ ( '<button class="btn btn-sm btn-danger" id="confirm-staging">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2331
+ '<button class="btn btn-sm btn-secondary" id="cancel-staging">Cancel</button>' ) . appendTo ( popupContent ) ;
2332
2332
$ ( popup ) . modal ( 'show' ) ;
2333
2333
2334
2334
$ ( "#confirm-unavailable-staging" ) . on ( 'click' , '#confirm-staging' , function ( e ) {
@@ -2512,6 +2512,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2512
2512
self . update = function ( ) {
2513
2513
$ ( fileList ) . empty ( ) ;
2514
2514
selectedItems = [ ] ;
2515
+ selectedItemsFromOtherUser = [ ] ;
2515
2516
$ ( '#stashBtn' ) . prop ( "disabled" , true ) ;
2516
2517
$ ( '#discardBtn' ) . prop ( "disabled" , true ) ;
2517
2518
$ ( '#commitBtn' ) . prop ( "disabled" , true ) ;
@@ -2523,15 +2524,35 @@ webui.NewChangedFilesView = function(workspaceView) {
2523
2524
$ . get ( "api/uncommitted" , function ( uncommitted ) {
2524
2525
var uncommittedItems = JSON . parse ( uncommitted ) [ "current user's changes" ] ;
2525
2526
self . filesCount = 0 ;
2526
- function addItemToFileList ( fileList , workingTreeStatus , model ) {
2527
- var formCheck = $ ( '<div class="form-check changes-check"></div>' ) ;
2527
+ function addItemToFileList ( fileList , workingTreeStatus , model , isOtherUserChange ) {
2528
+
2529
+ var formCheck ;
2530
+ if ( isOtherUserChange ) {
2531
+ formCheck = $ ( '<div class="form-check changes-check other-user"></div>' ) ;
2532
+ } else {
2533
+ formCheck = $ ( '<div class="form-check changes-check"></div>' ) ;
2534
+ }
2535
+
2528
2536
formCheck . attr ( "data-filename" , model ) ;
2529
2537
2530
- var checkboxInput = $ ( '<input class="form-check-input changes-checkbox" type="checkbox" value="">' ) ;
2538
+ var checkboxInput ;
2539
+
2540
+ if ( isOtherUserChange ) {
2541
+ checkboxInput = $ ( '<input class="form-check-input changes-checkbox other-user" type="checkbox" value="">' ) ;
2542
+ } else {
2543
+ checkboxInput = $ ( '<input class="form-check-input changes-checkbox" type="checkbox" value="">' ) ;
2544
+ }
2545
+
2531
2546
checkboxInput . attr ( 'id' , model ) ;
2532
2547
formCheck . append ( checkboxInput ) ;
2533
2548
2534
- var checkboxLabel = $ ( '<label class="form-check-label file-item-label"></label>' ) . text ( model ) ;
2549
+ var checkboxLabel ;
2550
+ if ( isOtherUserChange ) {
2551
+ checkboxLabel = $ ( '<label class="form-check-label file-item-label other-user-label" data-toggle="tooltip" title="File changed by another user">' + webui . peopleIcon + '</label>' ) . append ( model ) ;
2552
+ } else {
2553
+ checkboxLabel = $ ( '<label class="form-check-label file-item-label"></label>' ) . text ( model ) ;
2554
+ }
2555
+
2535
2556
checkboxLabel . addClass ( workingTreeStatus ) ;
2536
2557
checkboxLabel . attr ( 'for' , model ) ;
2537
2558
formCheck . append ( checkboxLabel ) ;
@@ -2542,6 +2563,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2542
2563
// $(item).click(self.select);
2543
2564
2544
2565
}
2566
+
2545
2567
webui . splitLines ( data ) . forEach ( function ( line ) {
2546
2568
var indexStatus = line [ 0 ] ;
2547
2569
var workingTreeStatus = line [ 1 ] ;
@@ -2564,7 +2586,9 @@ webui.NewChangedFilesView = function(workspaceView) {
2564
2586
}
2565
2587
2566
2588
if ( isForCurrentUser ) {
2567
- addItemToFileList ( fileList , workingTreeStatus , model ) ;
2589
+ addItemToFileList ( fileList , workingTreeStatus , model , false ) ;
2590
+ } else {
2591
+ addItemToFileList ( fileList , workingTreeStatus , model , true ) ;
2568
2592
}
2569
2593
2570
2594
} ) ;
@@ -2593,21 +2617,104 @@ webui.NewChangedFilesView = function(workspaceView) {
2593
2617
} ) ;
2594
2618
$ ( "#commitBtn" ) . off ( "click" ) ;
2595
2619
$ ( "#commitBtn" ) . on ( "click" , function ( ) {
2596
- var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( )
2597
- self . commit ( commitMessage ) ;
2620
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2621
+ self . confirmActionOnOtherUsersChanges ( "commit" ) ;
2622
+ } else {
2623
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2624
+ self . commit ( commitMessage ) ;
2625
+ }
2626
+
2598
2627
} ) ;
2599
2628
2600
2629
$ ( "#discardBtn" ) . off ( "click" ) ;
2601
2630
$ ( "#discardBtn" ) . on ( "click" , function ( ) {
2602
- self . discard ( ) ;
2631
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2632
+ self . confirmActionOnOtherUsersChanges ( "discard" ) ;
2633
+ } else {
2634
+ self . discard ( ) ;
2635
+ }
2603
2636
} ) ;
2604
2637
2605
2638
$ ( "#stashBtn" ) . off ( "click" ) ;
2606
2639
$ ( "#stashBtn" ) . on ( "click" , function ( ) {
2607
- self . stash ( ) ;
2640
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2641
+ self . confirmActionOnOtherUsersChanges ( "stash" ) ;
2642
+ } else {
2643
+ self . stash ( ) ;
2644
+ }
2645
+
2608
2646
} ) ;
2609
2647
} ) ;
2610
2648
} ) ;
2649
+ }
2650
+
2651
+ self . confirmActionOnOtherUsersChanges = function ( action ) {
2652
+ function removeWarningModal ( popup ) {
2653
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2654
+ $ ( ".modal-backdrop" ) . remove ( ) ;
2655
+ $ ( "#confirmAction" ) . remove ( ) ;
2656
+ }
2657
+
2658
+ var popup = $ ( '<div class="modal fade" tab-index="-1" id="confirmAction" role="dialog" data-backdrop="static">' +
2659
+ '<div class="modal-dialog modal-md" role="document">' +
2660
+ '<div class="modal-content">' +
2661
+ '<div class="modal-header">' +
2662
+ '<h5 class="modal-title">Confirm ' + action + '</h5>' +
2663
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' +
2664
+ webui . largeXIcon +
2665
+ '</button>' +
2666
+ '</div>' +
2667
+ '<div class="modal-body"></div>' +
2668
+ '<div class="modal-footer"></div>' +
2669
+ '</div>' +
2670
+ '</div>' +
2671
+ '</div>' ) [ 0 ] ;
2672
+ $ ( "body" ) . append ( popup ) ;
2673
+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2674
+ webui . detachChildren ( popupContent ) ;
2675
+
2676
+
2677
+ $ ( '<div class="row"><div class="col-sm-1">' +
2678
+ webui . warningIcon +
2679
+ '</div>' +
2680
+ '<div class="col-sm-11">The following files were changed by other users. Are you sure you want to ' + action + ' them?</div></div><ul>' ) . appendTo ( popupContent ) ;
2681
+
2682
+ selectedItemsFromOtherUser . forEach ( function ( file ) {
2683
+ $ ( '<li>' + file + '</li>' ) . appendTo ( popupContent ) ;
2684
+ } ) ;
2685
+
2686
+ $ ( '</ul>' ) . appendTo ( popupContent ) ;
2687
+
2688
+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2689
+ webui . detachChildren ( popupFooter ) ;
2690
+
2691
+
2692
+
2693
+ $ ( '<button class="btn btn-sm btn-warning action-btn" id="confirmActionBtn">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2694
+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelActionBtn">Cancel</button>' ) . appendTo ( popupFooter ) ;
2695
+
2696
+ $ ( popup ) . modal ( 'show' ) ;
2697
+
2698
+
2699
+ $ ( '#confirmActionBtn' ) . on ( 'click' , function ( ) {
2700
+ removeWarningModal ( popup ) ;
2701
+ if ( action == "commit" ) {
2702
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2703
+ self . commit ( commitMessage ) ;
2704
+ } else if ( action == "discard" ) {
2705
+ self . discard ( ) ;
2706
+ } else if ( action == "stash" ) {
2707
+ self . stash ( ) ;
2708
+ }
2709
+ } ) ;
2710
+
2711
+ $ ( '#confirmAction' ) . find ( '#cancelAction, .close' ) . click ( function ( ) {
2712
+ removeWarningModal ( popup ) ;
2713
+ } )
2714
+
2715
+
2716
+
2717
+
2611
2718
}
2612
2719
2613
2720
self . afterFileChecked = function ( element ) {
@@ -2617,14 +2724,23 @@ webui.NewChangedFilesView = function(workspaceView) {
2617
2724
if ( fileIndex == - 1 ) {
2618
2725
selectedItems . push ( fileName ) ;
2619
2726
}
2620
- if ( selectedItems . length == Array . from ( fileList . children ) . length ) {
2727
+
2728
+ if ( $ ( element ) . hasClass ( "other-user" ) && ( selectedItemsFromOtherUser . indexOf ( fileName ) == - 1 ) ) {
2729
+ selectedItemsFromOtherUser . push ( fileName ) ;
2730
+ }
2731
+
2732
+ if ( selectedItems . length == Array . prototype . slice . call ( fileList . children ) . length ) {
2621
2733
$ ( '#selectAllFiles' ) . prop ( 'checked' , true ) ;
2622
2734
}
2623
2735
} else {
2624
2736
$ ( '#selectAllFiles' ) . prop ( 'checked' , false ) ;
2625
2737
if ( fileIndex > - 1 ) {
2626
2738
selectedItems . splice ( fileIndex , 1 ) ;
2627
2739
}
2740
+
2741
+ if ( $ ( element ) . hasClass ( "other-user" ) && ( selectedItemsFromOtherUser . indexOf ( fileName ) > - 1 ) ) {
2742
+ selectedItemsFromOtherUser . splice ( selectedItems . indexOf ( fileName ) , 1 ) ;
2743
+ }
2628
2744
}
2629
2745
self . updateButtons ( ) ;
2630
2746
}
@@ -2665,16 +2781,16 @@ webui.NewChangedFilesView = function(workspaceView) {
2665
2781
}
2666
2782
2667
2783
self . selectAll = function ( ) {
2668
- Array . from ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2784
+ Array . prototype . slice . call ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2669
2785
fileDiv . children [ 0 ] . checked = true ;
2670
2786
self . afterFileChecked ( fileDiv . children [ 0 ] ) ;
2671
2787
} ) ;
2672
2788
}
2673
2789
2674
2790
self . deselectAll = function ( ) {
2675
- Array . from ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2791
+ Array . prototype . slice . call ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2676
2792
fileDiv . children [ 0 ] . checked = false ;
2677
- self . afterFileChecked ( fileDiv . children [ 0 ] )
2793
+ self . afterFileChecked ( fileDiv . children [ 0 ] ) ;
2678
2794
} ) ;
2679
2795
}
2680
2796
@@ -2697,17 +2813,18 @@ webui.NewChangedFilesView = function(workspaceView) {
2697
2813
2698
2814
self . discard = function ( ) {
2699
2815
var selectedFilesAsString = selectedItems . join ( " " ) ;
2700
- webui . git ( "restore -- " + selectedFilesAsString , function ( output ) {
2816
+ webui . git ( "restore -- " + selectedFilesAsString , function ( ) {
2701
2817
workspaceView . update ( ) ;
2702
2818
} ) ;
2703
2819
}
2704
2820
2705
2821
self . commit = function ( message ) {
2706
2822
var selectedFilesAsString = selectedItems . join ( " " ) ;
2823
+
2707
2824
webui . git ( "add " + selectedFilesAsString ) ;
2708
2825
webui . git ( 'commit -m "' + message + '" -- ' + selectedFilesAsString , function ( output ) {
2709
2826
webui . showSuccess ( output ) ;
2710
- workspaceView . update ( )
2827
+ workspaceView . update ( ) ;
2711
2828
} ) ;
2712
2829
}
2713
2830
@@ -2740,6 +2857,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2740
2857
var fileListContainer = $ ( ".file-area" , self . element ) [ 0 ] ;
2741
2858
var fileList = $ ( ".changed-files-list" , fileListContainer ) [ 0 ] ;
2742
2859
var selectedItems = [ ] ;
2860
+ var selectedItemsFromOtherUser = [ ] ;
2743
2861
var fileToDiff ;
2744
2862
2745
2863
}
0 commit comments