Skip to content

Commit 2811ffa

Browse files
committed
Merge branch 'ui-revamp' of https://github.com/intersystems/git-source-control into ui-revamp
2 parents 97bf8fb + 97a0155 commit 2811ffa

File tree

6 files changed

+288
-34
lines changed

6 files changed

+288
-34
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 {

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Class SourceControl.Git.WebUIDriver
22
{
3+
34

45
ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Output handled As %Boolean = 0, Output %data As %Stream.Object)
56
{

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,18 @@ body {
913913
position: absolute;
914914
right: 5px;
915915
}
916+
#changedFilesContainer .file-area .other-user-label svg {
917+
margin-right: 5px;
918+
}
916919
#changedFilesContainer .commit-area {
917920
padding-top: 15px;
918921
}
919922
#changedFilesContainer .commit-area .button-group .btn {
920923
margin-right: 5px;
921924
}
925+
#confirmAction li {
926+
margin-left: 20%;
927+
}
922928
#commit-explorer-view #commit-explorer-navigator-view .panel .panel-body {
923929
flex: 1 1 0px;
924930
-webkit-flex: 1 1 0px;

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

Lines changed: 135 additions & 17 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){
@@ -2512,6 +2512,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25122512
self.update = function() {
25132513
$(fileList).empty();
25142514
selectedItems = [];
2515+
selectedItemsFromOtherUser = [];
25152516
$('#stashBtn').prop("disabled", true);
25162517
$('#discardBtn').prop("disabled", true);
25172518
$('#commitBtn').prop("disabled", true);
@@ -2523,15 +2524,35 @@ webui.NewChangedFilesView = function(workspaceView) {
25232524
$.get("api/uncommitted", function (uncommitted) {
25242525
var uncommittedItems = JSON.parse(uncommitted)["current user's changes"];
25252526
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+
25282536
formCheck.attr("data-filename", model);
25292537

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+
25312546
checkboxInput.attr('id', model);
25322547
formCheck.append(checkboxInput);
25332548

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+
25352556
checkboxLabel.addClass(workingTreeStatus);
25362557
checkboxLabel.attr('for', model);
25372558
formCheck.append(checkboxLabel);
@@ -2542,6 +2563,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25422563
// $(item).click(self.select);
25432564

25442565
}
2566+
25452567
webui.splitLines(data).forEach(function(line) {
25462568
var indexStatus = line[0];
25472569
var workingTreeStatus = line[1];
@@ -2564,7 +2586,9 @@ webui.NewChangedFilesView = function(workspaceView) {
25642586
}
25652587

25662588
if (isForCurrentUser) {
2567-
addItemToFileList(fileList, workingTreeStatus, model);
2589+
addItemToFileList(fileList, workingTreeStatus, model, false);
2590+
} else {
2591+
addItemToFileList(fileList, workingTreeStatus, model, true);
25682592
}
25692593

25702594
});
@@ -2593,21 +2617,104 @@ webui.NewChangedFilesView = function(workspaceView) {
25932617
});
25942618
$("#commitBtn").off("click");
25952619
$("#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+
25982627
});
25992628

26002629
$("#discardBtn").off("click");
26012630
$("#discardBtn").on("click", function() {
2602-
self.discard();
2631+
if (selectedItemsFromOtherUser.length > 0) {
2632+
self.confirmActionOnOtherUsersChanges("discard");
2633+
} else {
2634+
self.discard();
2635+
}
26032636
});
26042637

26052638
$("#stashBtn").off("click");
26062639
$("#stashBtn").on("click", function() {
2607-
self.stash();
2640+
if (selectedItemsFromOtherUser.length > 0) {
2641+
self.confirmActionOnOtherUsersChanges("stash");
2642+
} else {
2643+
self.stash();
2644+
}
2645+
26082646
});
26092647
});
26102648
});
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+
26112718
}
26122719

26132720
self.afterFileChecked = function(element) {
@@ -2617,14 +2724,23 @@ webui.NewChangedFilesView = function(workspaceView) {
26172724
if (fileIndex == -1) {
26182725
selectedItems.push(fileName);
26192726
}
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) {
26212733
$('#selectAllFiles').prop('checked', true);
26222734
}
26232735
} else {
26242736
$('#selectAllFiles').prop('checked', false);
26252737
if (fileIndex > -1) {
26262738
selectedItems.splice(fileIndex, 1);
26272739
}
2740+
2741+
if ($(element).hasClass("other-user") && (selectedItemsFromOtherUser.indexOf(fileName) > -1)) {
2742+
selectedItemsFromOtherUser.splice(selectedItems.indexOf(fileName), 1);
2743+
}
26282744
}
26292745
self.updateButtons();
26302746
}
@@ -2665,16 +2781,16 @@ webui.NewChangedFilesView = function(workspaceView) {
26652781
}
26662782

26672783
self.selectAll = function() {
2668-
Array.from(fileList.children).forEach(function(fileDiv, index) {
2784+
Array.prototype.slice.call(fileList.children).forEach(function(fileDiv, index) {
26692785
fileDiv.children[0].checked = true;
26702786
self.afterFileChecked(fileDiv.children[0]);
26712787
});
26722788
}
26732789

26742790
self.deselectAll = function() {
2675-
Array.from(fileList.children).forEach(function(fileDiv, index) {
2791+
Array.prototype.slice.call(fileList.children).forEach(function(fileDiv, index) {
26762792
fileDiv.children[0].checked = false;
2677-
self.afterFileChecked(fileDiv.children[0])
2793+
self.afterFileChecked(fileDiv.children[0]);
26782794
});
26792795
}
26802796

@@ -2697,17 +2813,18 @@ webui.NewChangedFilesView = function(workspaceView) {
26972813

26982814
self.discard = function() {
26992815
var selectedFilesAsString = selectedItems.join(" ");
2700-
webui.git("restore -- " + selectedFilesAsString, function(output) {
2816+
webui.git("restore -- " + selectedFilesAsString, function() {
27012817
workspaceView.update();
27022818
});
27032819
}
27042820

27052821
self.commit = function(message) {
27062822
var selectedFilesAsString = selectedItems.join(" ");
2823+
27072824
webui.git("add " + selectedFilesAsString);
27082825
webui.git('commit -m "' + message + '" -- ' + selectedFilesAsString, function(output) {
27092826
webui.showSuccess(output);
2710-
workspaceView.update()
2827+
workspaceView.update();
27112828
});
27122829
}
27132830

@@ -2740,6 +2857,7 @@ webui.NewChangedFilesView = function(workspaceView) {
27402857
var fileListContainer = $(".file-area", self.element)[0];
27412858
var fileList = $(".changed-files-list", fileListContainer)[0];
27422859
var selectedItems = [];
2860+
var selectedItemsFromOtherUser = [];
27432861
var fileToDiff;
27442862

27452863
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,10 @@ body {
898898
position: absolute;
899899
right: 5px;
900900
}
901+
902+
.other-user-label svg {
903+
margin-right: 5px;
904+
}
901905

902906
}
903907

@@ -912,6 +916,12 @@ body {
912916
}
913917
}
914918

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

0 commit comments

Comments
 (0)