Skip to content

Commit 0836ea0

Browse files
committed
mostly finished ui revamp
1 parent 5d37a75 commit 0836ea0

File tree

4 files changed

+160
-50
lines changed

4 files changed

+160
-50
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,10 @@ body {
860860
#changedFilesContainer {
861861
max-width: 100% !important;
862862
margin: 0 10px;
863+
overflow-y: auto;
863864
}
864865
#changedFilesContainer .file-area {
865866
padding-top: 15px;
866-
overflow-y: scroll;
867867
}
868868
#changedFilesContainer .file-area .select-all {
869869
border-bottom: 2px solid black;
@@ -910,7 +910,6 @@ body {
910910
}
911911
#changedFilesContainer .commit-area {
912912
padding-top: 15px;
913-
overflow-y: scroll;
914913
}
915914
#changedFilesContainer .commit-area .button-group .btn {
916915
margin-right: 5px;

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

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,13 @@ webui.NewChangedFilesView = function(workspaceView) {
25112511

25122512
self.update = function() {
25132513
$(fileList).empty();
2514+
selectedItems = [];
2515+
$('#stashBtn').prop("disabled", true);
2516+
$('#discardBtn').prop("disabled", true);
2517+
$('#commitBtn').prop("disabled", true);
2518+
$("#commitMsg").val("");
2519+
$("#commitMsgDetail").val("");
2520+
$('#selectAllFiles').prop('checked', false);
25142521
webui.git("status -u --porcelain", function(data) {
25152522
$.get("api/uncommitted", function (uncommitted) {
25162523
var uncommittedItems = JSON.parse(uncommitted)["current user's changes"];
@@ -2561,19 +2568,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25612568

25622569
});
25632570
$(".changes-checkbox").change(function() {
2564-
var fileName = this.id;
2565-
var fileIndex = selectedItems.indexOf(fileName);
2566-
if (this.checked) {
2567-
if (fileIndex == -1) {
2568-
selectedItems.push(fileName);
2569-
}
2570-
} else {
2571-
$('#selectAllFiles').prop('checked', false);
2572-
if (fileIndex > -1) {
2573-
selectedItems.splice(fileIndex, 1);
2574-
}
2575-
}
2576-
self.updateButtons();
2571+
self.afterFileChecked(this);
25772572
});
25782573

25792574
$("#commitMsg").on("input", function() {
@@ -2583,22 +2578,51 @@ webui.NewChangedFilesView = function(workspaceView) {
25832578
$('.changes-check').on("click", function() {
25842579
self.unhighlightPrevious();
25852580
$(this).addClass("diffed-file");
2586-
self.fileToDiff = $(this).attr("data-filename");
2581+
fileToDiff = $(this).attr("data-filename");
25872582
self.refreshDiff();
25882583

25892584
});
25902585

2591-
$('#selectAllFiles').on("input", function() {
2592-
if ($(this).checked) {
2586+
$('#selectAllFiles').on("change", function() {
2587+
if (this.checked) {
25932588
self.selectAll();
25942589
} else {
25952590
self.deselectAll();
25962591
}
2597-
})
2592+
});
2593+
2594+
$("#commitBtn").on("click", function() {
2595+
var commitMessage = $('#commitMsg').val() + "\n" + $("#commitMsgDetail").val()
2596+
self.commit(commitMessage);
2597+
});
2598+
2599+
$("#discardBtn").on("click", function() {
2600+
self.discard();
2601+
});
2602+
2603+
$("#stashBtn").on("click", function() {
2604+
self.stash();
2605+
});
25982606
});
25992607
});
26002608
}
26012609

2610+
self.afterFileChecked = function(element) {
2611+
var fileName = element.id;
2612+
var fileIndex = selectedItems.indexOf(fileName);
2613+
if (element.checked) {
2614+
if (fileIndex == -1) {
2615+
selectedItems.push(fileName);
2616+
}
2617+
} else {
2618+
$('#selectAllFiles').prop('checked', false);
2619+
if (fileIndex > -1) {
2620+
selectedItems.splice(fileIndex, 1);
2621+
}
2622+
}
2623+
self.updateButtons();
2624+
}
2625+
26022626
self.handleCheckEvent = function(file) {
26032627
var fileIndex = selectedItems.indexOf(file);
26042628
if (fileIndex > -1) {
@@ -2635,20 +2659,51 @@ webui.NewChangedFilesView = function(workspaceView) {
26352659
}
26362660

26372661
self.selectAll = function() {
2638-
2662+
Array.from(fileList.children).forEach(function(fileDiv, index) {
2663+
fileDiv.children[0].checked = true;
2664+
self.afterFileChecked(fileDiv.children[0]);
2665+
});
26392666
}
26402667

26412668
self.deselectAll = function() {
2642-
2669+
Array.from(fileList.children).forEach(function(fileDiv, index) {
2670+
fileDiv.children[0].checked = false;
2671+
self.afterFileChecked(fileDiv.children[0])
2672+
});
26432673
}
26442674

26452675
self.unhighlightPrevious = function(){
2646-
$('[data-filename="' + self.fileToDiff + '"]').removeClass("diffed-file");
2676+
$('[data-filename="' + fileToDiff + '"]').removeClass("diffed-file");
26472677
}
26482678

26492679
self.refreshDiff = function() {
2650-
self.fileToDiff;
2651-
workspaceView.diffView.update("diff", [], self.fileToDiff, "stage");
2680+
fileToDiff;
2681+
workspaceView.diffView.update("diff", [], fileToDiff, "stage");
2682+
}
2683+
2684+
self.stash = function() {
2685+
var selectedFilesAsString = selectedItems.join(" ");
2686+
webui.git("stash push -- " + selectedFilesAsString, function(output){
2687+
webui.showSuccess(output);
2688+
workspaceView.update();
2689+
});
2690+
}
2691+
2692+
self.discard = function() {
2693+
var selectedFilesAsString = selectedItems.join(" ");
2694+
webui.git("restore -- " + selectedFilesAsString, function(output) {
2695+
// webui.showSuccess(output);
2696+
workspaceView.update();
2697+
});
2698+
}
2699+
2700+
self.commit = function(message) {
2701+
var selectedFilesAsString = selectedItems.join(" ");
2702+
webui.git("add " + selectedFilesAsString);
2703+
webui.git('commit -m "' + message + '" -- ' + selectedFilesAsString, function(output) {
2704+
webui.showSuccess(output);
2705+
workspaceView.update()
2706+
});
26522707
}
26532708

26542709
self.element = $(
@@ -2666,7 +2721,7 @@ webui.NewChangedFilesView = function(workspaceView) {
26662721
'<input type="area" class="form-control" id="commitMsg" placeholder="Enter commit message (required, 72 character limit)">' +
26672722
'</div>' +
26682723
'<div class="form-group">' +
2669-
'<textarea class="form-control" id="commitMsgDetail" placeholder="Enter commit details (optional, no character limit)"></textarea>' +
2724+
'<textarea class="form-control" id="commitMsgDetail" rows="4" placeholder="Enter commit details (optional, no character limit)"></textarea>' +
26702725
'</div>' +
26712726
'<div class="button-group">' +
26722727
'<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled> Commit </button>' +
@@ -2681,6 +2736,7 @@ webui.NewChangedFilesView = function(workspaceView) {
26812736
var fileList = $(".changed-files-list", fileListContainer)[0];
26822737
var selectedItems = [];
26832738
var fileToDiff;
2739+
26842740
}
26852741

26862742
/*

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,10 +831,10 @@ body {
831831
#changedFilesContainer {
832832
max-width: 100% !important;
833833
margin: 0 10px;
834+
overflow-y: auto;
834835
.file-area {
835836
// padding-left: 20px;
836837
padding-top: 15px;
837-
overflow-y: scroll;
838838

839839
.select-all {
840840

@@ -897,7 +897,6 @@ body {
897897

898898
.commit-area {
899899
padding-top: 15px;
900-
overflow-y: scroll;
901900

902901
.button-group {
903902
.btn {

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,13 @@ webui.NewChangedFilesView = function(workspaceView) {
25112511

25122512
self.update = function() {
25132513
$(fileList).empty();
2514+
selectedItems = [];
2515+
$('#stashBtn').prop("disabled", true);
2516+
$('#discardBtn').prop("disabled", true);
2517+
$('#commitBtn').prop("disabled", true);
2518+
$("#commitMsg").val("");
2519+
$("#commitMsgDetail").val("");
2520+
$('#selectAllFiles').prop('checked', false);
25142521
webui.git("status -u --porcelain", function(data) {
25152522
$.get("api/uncommitted", function (uncommitted) {
25162523
var uncommittedItems = JSON.parse(uncommitted)["current user's changes"];
@@ -2561,19 +2568,7 @@ webui.NewChangedFilesView = function(workspaceView) {
25612568

25622569
});
25632570
$(".changes-checkbox").change(function() {
2564-
var fileName = this.id;
2565-
var fileIndex = selectedItems.indexOf(fileName);
2566-
if (this.checked) {
2567-
if (fileIndex == -1) {
2568-
selectedItems.push(fileName);
2569-
}
2570-
} else {
2571-
$('#selectAllFiles').prop('checked', false);
2572-
if (fileIndex > -1) {
2573-
selectedItems.splice(fileIndex, 1);
2574-
}
2575-
}
2576-
self.updateButtons();
2571+
self.afterFileChecked(this);
25772572
});
25782573

25792574
$("#commitMsg").on("input", function() {
@@ -2583,22 +2578,51 @@ webui.NewChangedFilesView = function(workspaceView) {
25832578
$('.changes-check').on("click", function() {
25842579
self.unhighlightPrevious();
25852580
$(this).addClass("diffed-file");
2586-
self.fileToDiff = $(this).attr("data-filename");
2581+
fileToDiff = $(this).attr("data-filename");
25872582
self.refreshDiff();
25882583

25892584
});
25902585

2591-
$('#selectAllFiles').on("input", function() {
2592-
if ($(this).checked) {
2586+
$('#selectAllFiles').on("change", function() {
2587+
if (this.checked) {
25932588
self.selectAll();
25942589
} else {
25952590
self.deselectAll();
25962591
}
2597-
})
2592+
});
2593+
2594+
$("#commitBtn").on("click", function() {
2595+
var commitMessage = $('#commitMsg').val() + "\n" + $("#commitMsgDetail").val()
2596+
self.commit(commitMessage);
2597+
});
2598+
2599+
$("#discardBtn").on("click", function() {
2600+
self.discard();
2601+
});
2602+
2603+
$("#stashBtn").on("click", function() {
2604+
self.stash();
2605+
});
25982606
});
25992607
});
26002608
}
26012609

2610+
self.afterFileChecked = function(element) {
2611+
var fileName = element.id;
2612+
var fileIndex = selectedItems.indexOf(fileName);
2613+
if (element.checked) {
2614+
if (fileIndex == -1) {
2615+
selectedItems.push(fileName);
2616+
}
2617+
} else {
2618+
$('#selectAllFiles').prop('checked', false);
2619+
if (fileIndex > -1) {
2620+
selectedItems.splice(fileIndex, 1);
2621+
}
2622+
}
2623+
self.updateButtons();
2624+
}
2625+
26022626
self.handleCheckEvent = function(file) {
26032627
var fileIndex = selectedItems.indexOf(file);
26042628
if (fileIndex > -1) {
@@ -2635,20 +2659,51 @@ webui.NewChangedFilesView = function(workspaceView) {
26352659
}
26362660

26372661
self.selectAll = function() {
2638-
2662+
Array.from(fileList.children).forEach(function(fileDiv, index) {
2663+
fileDiv.children[0].checked = true;
2664+
self.afterFileChecked(fileDiv.children[0]);
2665+
});
26392666
}
26402667

26412668
self.deselectAll = function() {
2642-
2669+
Array.from(fileList.children).forEach(function(fileDiv, index) {
2670+
fileDiv.children[0].checked = false;
2671+
self.afterFileChecked(fileDiv.children[0])
2672+
});
26432673
}
26442674

26452675
self.unhighlightPrevious = function(){
2646-
$('[data-filename="' + self.fileToDiff + '"]').removeClass("diffed-file");
2676+
$('[data-filename="' + fileToDiff + '"]').removeClass("diffed-file");
26472677
}
26482678

26492679
self.refreshDiff = function() {
2650-
self.fileToDiff;
2651-
workspaceView.diffView.update("diff", [], self.fileToDiff, "stage");
2680+
fileToDiff;
2681+
workspaceView.diffView.update("diff", [], fileToDiff, "stage");
2682+
}
2683+
2684+
self.stash = function() {
2685+
var selectedFilesAsString = selectedItems.join(" ");
2686+
webui.git("stash push -- " + selectedFilesAsString, function(output){
2687+
webui.showSuccess(output);
2688+
workspaceView.update();
2689+
});
2690+
}
2691+
2692+
self.discard = function() {
2693+
var selectedFilesAsString = selectedItems.join(" ");
2694+
webui.git("restore -- " + selectedFilesAsString, function(output) {
2695+
// webui.showSuccess(output);
2696+
workspaceView.update();
2697+
});
2698+
}
2699+
2700+
self.commit = function(message) {
2701+
var selectedFilesAsString = selectedItems.join(" ");
2702+
webui.git("add " + selectedFilesAsString);
2703+
webui.git('commit -m "' + message + '" -- ' + selectedFilesAsString, function(output) {
2704+
webui.showSuccess(output);
2705+
workspaceView.update()
2706+
});
26522707
}
26532708

26542709
self.element = $(
@@ -2666,7 +2721,7 @@ webui.NewChangedFilesView = function(workspaceView) {
26662721
'<input type="area" class="form-control" id="commitMsg" placeholder="Enter commit message (required, 72 character limit)">' +
26672722
'</div>' +
26682723
'<div class="form-group">' +
2669-
'<textarea class="form-control" id="commitMsgDetail" placeholder="Enter commit details (optional, no character limit)"></textarea>' +
2724+
'<textarea class="form-control" id="commitMsgDetail" rows="4" placeholder="Enter commit details (optional, no character limit)"></textarea>' +
26702725
'</div>' +
26712726
'<div class="button-group">' +
26722727
'<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled> Commit </button>' +
@@ -2681,6 +2736,7 @@ webui.NewChangedFilesView = function(workspaceView) {
26812736
var fileList = $(".changed-files-list", fileListContainer)[0];
26822737
var selectedItems = [];
26832738
var fileToDiff;
2739+
26842740
}
26852741

26862742
/*

0 commit comments

Comments
 (0)