diff --git a/CHANGELOG.md b/CHANGELOG.md index 47fbd8a3..13957879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Import All has been added to public-facing API (#891) +- Web UI workspace view now has an option to abort merge in progress (#895) ## Fixed -- Web UI workspace view labels changes as Unmerged if there are merge conflicts (#890) +- Web UI workspace view labels changes as Merge Conflict if there are unmerged changes (#890) ## [2.14.0] - 2025-11-07 diff --git a/git-webui/release/share/git-webui/webui/css/git-webui.css b/git-webui/release/share/git-webui/webui/css/git-webui.css index bc9565a5..d5958433 100644 --- a/git-webui/release/share/git-webui/webui/css/git-webui.css +++ b/git-webui/release/share/git-webui/webui/css/git-webui.css @@ -982,7 +982,7 @@ body { right: 5px; } #changedFilesContainer .file-area .U::after { - content: "Unmerged"; + content: "Merge Conflict"; position: absolute; right: 5px; color: red; diff --git a/git-webui/release/share/git-webui/webui/js/git-webui.js b/git-webui/release/share/git-webui/webui/js/git-webui.js index b34d1886..ff17702d 100644 --- a/git-webui/release/share/git-webui/webui/js/git-webui.js +++ b/git-webui/release/share/git-webui/webui/js/git-webui.js @@ -2805,8 +2805,21 @@ webui.NewChangedFilesView = function(workspaceView) { } }); + + $("#abortMergeBtn").off("click"); + $("#abortMergeBtn").on("click", function() { + self.confirmAbortMerge(); + }) }); }); + + webui.git_command(["rev-parse", "--quiet", "--verify", "MERGE_HEAD"], function () { + // success code with --verify means MERGE_HEAD exists + $("#abortMergeBtn").show().prop("disabled",false); + }, null, function() { + // error code with --verify means MERGE_HEAD does not exist + $("#abortMergeBtn").hide().prop("disabled",true); + }) } self.confirmDiscard = function() { @@ -2920,6 +2933,63 @@ webui.NewChangedFilesView = function(workspaceView) { }); } + self.confirmAbortMerge = function() { + function removePopup(popup) { + $(popup).children(".modal-fade").modal("hide"); + $(".modal-backdrop").remove(); + $("#confirmAbortMerge").remove(); + } + + var popup = $( + '' + )[0]; + + $("body").append(popup); + var popupContent = $(".modal-body", popup)[0]; + webui.detachChildren(popupContent); + + $( + '
' + + '
' + + webui.warningIcon + + '
' + + '
' + + '

A merge is in progress. Are you sure you want to abort it?

' + + '
' + + '
' + ).appendTo(popupContent); + + var popupFooter = $(".modal-footer", popup)[0]; + webui.detachChildren(popupFooter); + + $( + '' + + '' + ).appendTo(popupFooter); + + $(popup).modal('show'); + + $('#confirmAbortMergeBtn').on('click', function() { + removePopup(popup); + self.abortMerge(); + }); + + $('#confirmAbortMerge').find('#cancelAbortMergeBtn, .close').click(function() { + removePopup(popup); + }); + } + // Popup for when trying to commit to default merge branch in basic mode self.noCommitsOnDefault = function () { function removePopup(popup) { @@ -3172,6 +3242,13 @@ webui.NewChangedFilesView = function(workspaceView) { webui.git_command(["add", "--"].concat(selectedItems), restoreCommand,undefined,restoreCommand); } + self.abortMerge = function() { + webui.git_command(["merge", "--abort"], function() { + workspaceView.update(); + }); + $("#abortMergeBtn").hide().prop("disabled",true); + } + self.amend = function(message, details) { if (self.commitMsgEmpty()) { $.ajax({ @@ -3274,6 +3351,7 @@ webui.NewChangedFilesView = function(workspaceView) { '' + '' + '' + + '' + '' + '' + '' + diff --git a/git-webui/src/share/git-webui/webui/css/git-webui.less b/git-webui/src/share/git-webui/webui/css/git-webui.less index e5a9e3ea..3183206a 100644 --- a/git-webui/src/share/git-webui/webui/css/git-webui.less +++ b/git-webui/src/share/git-webui/webui/css/git-webui.less @@ -985,7 +985,7 @@ body { } .U::after { - content: "Unmerged"; + content: "Merge Conflict"; position: absolute; right: 5px; color: red; diff --git a/git-webui/src/share/git-webui/webui/js/git-webui.js b/git-webui/src/share/git-webui/webui/js/git-webui.js index b34d1886..ff17702d 100644 --- a/git-webui/src/share/git-webui/webui/js/git-webui.js +++ b/git-webui/src/share/git-webui/webui/js/git-webui.js @@ -2805,8 +2805,21 @@ webui.NewChangedFilesView = function(workspaceView) { } }); + + $("#abortMergeBtn").off("click"); + $("#abortMergeBtn").on("click", function() { + self.confirmAbortMerge(); + }) }); }); + + webui.git_command(["rev-parse", "--quiet", "--verify", "MERGE_HEAD"], function () { + // success code with --verify means MERGE_HEAD exists + $("#abortMergeBtn").show().prop("disabled",false); + }, null, function() { + // error code with --verify means MERGE_HEAD does not exist + $("#abortMergeBtn").hide().prop("disabled",true); + }) } self.confirmDiscard = function() { @@ -2920,6 +2933,63 @@ webui.NewChangedFilesView = function(workspaceView) { }); } + self.confirmAbortMerge = function() { + function removePopup(popup) { + $(popup).children(".modal-fade").modal("hide"); + $(".modal-backdrop").remove(); + $("#confirmAbortMerge").remove(); + } + + var popup = $( + '' + )[0]; + + $("body").append(popup); + var popupContent = $(".modal-body", popup)[0]; + webui.detachChildren(popupContent); + + $( + '
' + + '
' + + webui.warningIcon + + '
' + + '
' + + '

A merge is in progress. Are you sure you want to abort it?

' + + '
' + + '
' + ).appendTo(popupContent); + + var popupFooter = $(".modal-footer", popup)[0]; + webui.detachChildren(popupFooter); + + $( + '' + + '' + ).appendTo(popupFooter); + + $(popup).modal('show'); + + $('#confirmAbortMergeBtn').on('click', function() { + removePopup(popup); + self.abortMerge(); + }); + + $('#confirmAbortMerge').find('#cancelAbortMergeBtn, .close').click(function() { + removePopup(popup); + }); + } + // Popup for when trying to commit to default merge branch in basic mode self.noCommitsOnDefault = function () { function removePopup(popup) { @@ -3172,6 +3242,13 @@ webui.NewChangedFilesView = function(workspaceView) { webui.git_command(["add", "--"].concat(selectedItems), restoreCommand,undefined,restoreCommand); } + self.abortMerge = function() { + webui.git_command(["merge", "--abort"], function() { + workspaceView.update(); + }); + $("#abortMergeBtn").hide().prop("disabled",true); + } + self.amend = function(message, details) { if (self.commitMsgEmpty()) { $.ajax({ @@ -3274,6 +3351,7 @@ webui.NewChangedFilesView = function(workspaceView) { '' + '' + '' + + '' + '' + '' + '' +