Skip to content

Commit 97a0155

Browse files
committed
now works with other user's uncommitted changes
1 parent 43a11e1 commit 97a0155

File tree

5 files changed

+196
-170
lines changed

5 files changed

+196
-170
lines changed

cls/SourceControl/Git/API.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Class SourceControl.Git.API
44
/// Configures settings for Git integration
55
ClassMethod Configure()
66
{
7+
//
78
set sc = $$$OK
89
set initTLevel = $tlevel
910
try {

git-webui/release/share/git-webui/webui/css/git-webui.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,15 +913,18 @@ body {
913913
position: absolute;
914914
right: 5px;
915915
}
916-
#changedFilesContainer .file-area .other-user-label::before {
917-
content: "HI";
916+
#changedFilesContainer .file-area .other-user-label svg {
917+
margin-right: 5px;
918918
}
919919
#changedFilesContainer .commit-area {
920920
padding-top: 15px;
921921
}
922922
#changedFilesContainer .commit-area .button-group .btn {
923923
margin-right: 5px;
924924
}
925+
#confirmAction li {
926+
margin-left: 20%;
927+
}
925928
#commit-explorer-view #commit-explorer-navigator-view .panel .panel-body {
926929
flex: 1 1 0px;
927930
-webkit-flex: 1 1 0px;

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 91 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,8 +2327,8 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
23272327
});
23282328

23292329

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);
23322332
$(popup).modal('show');
23332333

23342334
$("#confirm-unavailable-staging").on('click', '#confirm-staging', function(e){
@@ -2548,7 +2548,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25482548

25492549
var checkboxLabel;
25502550
if (isOtherUserChange) {
2551-
checkboxLabel = $('<label class="form-check-label file-item-label other-user-label"></label>').text(model);
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);
25522552
} else {
25532553
checkboxLabel = $('<label class="form-check-label file-item-label"></label>').text(model);
25542554
}
@@ -2588,7 +2588,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25882588
if (isForCurrentUser) {
25892589
addItemToFileList(fileList, workingTreeStatus, model, false);
25902590
} else {
2591-
addItemToFileList(fileList, workingTreeStatus, model, true)
2591+
addItemToFileList(fileList, workingTreeStatus, model, true);
25922592
}
25932593

25942594
});
@@ -2617,81 +2617,104 @@ webui.NewChangedFilesView = function(workspaceView) {
26172617
});
26182618
$("#commitBtn").off("click");
26192619
$("#commitBtn").on("click", function() {
2620-
var commitMessage = $('#commitMsg').val() + "\n" + $("#commitMsgDetail").val()
2621-
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+
26222627
});
26232628

26242629
$("#discardBtn").off("click");
26252630
$("#discardBtn").on("click", function() {
2626-
self.discard();
2631+
if (selectedItemsFromOtherUser.length > 0) {
2632+
self.confirmActionOnOtherUsersChanges("discard");
2633+
} else {
2634+
self.discard();
2635+
}
26272636
});
26282637

26292638
$("#stashBtn").off("click");
26302639
$("#stashBtn").on("click", function() {
2631-
self.stash();
2640+
if (selectedItemsFromOtherUser.length > 0) {
2641+
self.confirmActionOnOtherUsersChanges("stash");
2642+
} else {
2643+
self.stash();
2644+
}
2645+
26322646
});
26332647
});
26342648
});
26352649
}
26362650

26372651
self.confirmActionOnOtherUsersChanges = function(action) {
2638-
function removeWarningModal(popup) {
2639-
$(popup).children(".modal-fade").modal("hide");
2640-
$(".modal-backdrop").remove();
2641-
$("#confirmAction").remove();
2642-
modalOpen = false;
2643-
}
2644-
2645-
var popup = $( '<div class="modal fade" id="confirmAction" role="dialog" data-backdrop="static">' +
2646-
'<div class="modal-dialog modal-md">' +
2647-
'<div class="modal-content>' +
2648-
'<div class="modal-header">' +
2649-
'<h5 class="modal-title">Confirm ' + action + '</h5>' +
2650-
'<button type="button" class="btn btn-default close" data-dismiss="modal">'+
2651-
webui.largeXIcon+
2652-
'</button>' +
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>' +
26532669
'</div>' +
2654-
'<div class="modal-body"></div>' +
26552670
'</div>' +
2656-
'</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+
26572691

2658-
'</div>')[0];
2659-
$("body").append(popup);
2660-
var popupContent = $(".modal-body", popup)[0];
2661-
webui.detachChildren(popupContent);
2662-
$('<div class="row"><div class="col-sm-1">'+
2663-
webui.warningIcon+
2664-
'</div>'+
2665-
'<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);
2666-
2667-
selectedItemsFromOtherUser.forEach(function(file, index){
2668-
$('<li>'+ file +'</li>').appendTo(popupContent);
2669-
});
2670-
2671-
$('</ul>').appendTo(popupContent);
2672-
2673-
$('<button class="btn btn-sm btn-warning float-right" id="confirmActionBtn">' + action.charAt(0).toUpperCase()+action.substring(1) + '</button>' +
2674-
'<button class="btn btn-sm btn-secondary float-right" id="cancelActionBtn">Cancel</button>').appendTo(popupContent);
2675-
2676-
$(popup).modal('show');
2677-
var modalOpen = true;
2678-
2679-
var actionConfirmed = false;
2680-
2681-
$('#confirmAction').on('click', '#confirmActionBtn', function() {
2682-
actionConfirmed = true;
2683-
removeWarningModal(popup);
2684-
});
2685-
2686-
$('#confirmAction').find('#cancelAction, .close').click(function() {
2687-
removeWarningModal(popup);
2688-
})
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+
26892698

2690-
while(modalOpen) {
2691-
// spin
2692-
}
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+
26932717

2694-
return actionConfirmed;
26952718
}
26962719

26972720
self.afterFileChecked = function(element) {
@@ -2702,11 +2725,11 @@ webui.NewChangedFilesView = function(workspaceView) {
27022725
selectedItems.push(fileName);
27032726
}
27042727

2705-
if (element.hasClass("other-user") && (selectedItems.indexOf(fileName) == -1)) {
2728+
if ($(element).hasClass("other-user") && (selectedItemsFromOtherUser.indexOf(fileName) == -1)) {
27062729
selectedItemsFromOtherUser.push(fileName);
27072730
}
27082731

2709-
if (selectedItems.length == Array.from(fileList.children).length) {
2732+
if (selectedItems.length == Array.prototype.slice.call(fileList.children).length) {
27102733
$('#selectAllFiles').prop('checked', true);
27112734
}
27122735
} else {
@@ -2715,7 +2738,7 @@ webui.NewChangedFilesView = function(workspaceView) {
27152738
selectedItems.splice(fileIndex, 1);
27162739
}
27172740

2718-
if (element.hasClass("other-user") && (selectedItems.indexOf(fileName) > -1)) {
2741+
if ($(element).hasClass("other-user") && (selectedItemsFromOtherUser.indexOf(fileName) > -1)) {
27192742
selectedItemsFromOtherUser.splice(selectedItems.indexOf(fileName), 1);
27202743
}
27212744
}
@@ -2758,16 +2781,16 @@ webui.NewChangedFilesView = function(workspaceView) {
27582781
}
27592782

27602783
self.selectAll = function() {
2761-
Array.from(fileList.children).forEach(function(fileDiv, index) {
2784+
Array.prototype.slice.call(fileList.children).forEach(function(fileDiv, index) {
27622785
fileDiv.children[0].checked = true;
27632786
self.afterFileChecked(fileDiv.children[0]);
27642787
});
27652788
}
27662789

27672790
self.deselectAll = function() {
2768-
Array.from(fileList.children).forEach(function(fileDiv, index) {
2791+
Array.prototype.slice.call(fileList.children).forEach(function(fileDiv, index) {
27692792
fileDiv.children[0].checked = false;
2770-
self.afterFileChecked(fileDiv.children[0])
2793+
self.afterFileChecked(fileDiv.children[0]);
27712794
});
27722795
}
27732796

@@ -2782,11 +2805,6 @@ webui.NewChangedFilesView = function(workspaceView) {
27822805

27832806
self.stash = function() {
27842807
var selectedFilesAsString = selectedItems.join(" ");
2785-
if (selectedItemsFromOtherUser.length > 0) {
2786-
if (!this.confirmActionOnOtherUsersChanges("stash")) {
2787-
return
2788-
}
2789-
}
27902808
webui.git("stash push -- " + selectedFilesAsString, function(output){
27912809
webui.showSuccess(output);
27922810
workspaceView.update();
@@ -2795,28 +2813,18 @@ webui.NewChangedFilesView = function(workspaceView) {
27952813

27962814
self.discard = function() {
27972815
var selectedFilesAsString = selectedItems.join(" ");
2798-
if (selectedItemsFromOtherUser.length > 0) {
2799-
if (!this.confirmActionOnOtherUsersChanges("discard")) {
2800-
return
2801-
}
2802-
}
2803-
webui.git("restore -- " + selectedFilesAsString, function(output) {
2816+
webui.git("restore -- " + selectedFilesAsString, function() {
28042817
workspaceView.update();
28052818
});
28062819
}
28072820

28082821
self.commit = function(message) {
28092822
var selectedFilesAsString = selectedItems.join(" ");
28102823

2811-
if (selectedItemsFromOtherUser.length > 0) {
2812-
if (!this.confirmActionOnOtherUsersChanges("commit")) {
2813-
return
2814-
}
2815-
}
28162824
webui.git("add " + selectedFilesAsString);
28172825
webui.git('commit -m "' + message + '" -- ' + selectedFilesAsString, function(output) {
28182826
webui.showSuccess(output);
2819-
workspaceView.update()
2827+
workspaceView.update();
28202828
});
28212829
}
28222830

git-webui/src/share/git-webui/webui/css/git-webui.less

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ body {
899899
right: 5px;
900900
}
901901

902-
.other-user-label::before {
903-
content: "HI";
902+
.other-user-label svg {
903+
margin-right: 5px;
904904
}
905905

906906
}
@@ -916,6 +916,12 @@ body {
916916
}
917917
}
918918

919+
#confirmAction {
920+
li {
921+
margin-left: 20%;
922+
}
923+
}
924+
919925
#commit-explorer-view {
920926
#commit-explorer-navigator-view {
921927
.panel {

0 commit comments

Comments
 (0)