Skip to content

Commit d871bdd

Browse files
committed
commit before changing branch
1 parent 0720875 commit d871bdd

File tree

8 files changed

+153
-5
lines changed

8 files changed

+153
-5
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,47 @@ ClassMethod Localize()
23162316
}
23172317
}
23182318

2319+
Query Namespaces() As %Query(ROWSPEC = "Namespace:%String,SourceControlClass:%String,Accessible:%Boolean") [ SqlProc ]
2320+
{
2321+
}
2322+
2323+
ClassMethod NamespacesExecute(ByRef qHandle As %Binary) As %Status
2324+
{
2325+
Set sc = ##class(%SYS.Namespace).ListAll(.array)
2326+
Merge qHandle = array
2327+
Set qHandle = ""
2328+
Quit sc
2329+
}
2330+
2331+
ClassMethod NamespacesFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = NamespacesExecute ]
2332+
{
2333+
Set qHandle = $Order(qHandle(qHandle))
2334+
If (qHandle = "") {
2335+
Set AtEnd = 1
2336+
} ElseIf $Extract(qHandle) = "^" {
2337+
Quit ..NamespacesFetch(.qHandle,.Row,.AtEnd)
2338+
} Else {
2339+
Try {
2340+
New $Namespace
2341+
Set $Namespace = qHandle
2342+
Set scc = ##class(%Studio.SourceControl.Interface).SourceControlClassGet()
2343+
Set Row = $ListBuild(qHandle,scc,1)
2344+
} Catch e {
2345+
Set Row = $ListBuild(qHandle,"",0)
2346+
}
2347+
}
2348+
Quit $$$OK
2349+
}
2350+
2351+
ClassMethod NamespacesClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = NamespacesExecute ]
2352+
{
2353+
Quit $$$OK
2354+
}
2355+
2356+
ClassMethod GetContexts() As %DynamicArray{
2357+
2358+
}
2359+
23192360
ClassMethod ConfigureWeb()
23202361
{
23212362
set installNamespace = $Namespace

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
2727
if $isobject($get(responseJSON)) {
2828
do responseJSON.%ToJSON(%data)
2929
}
30-
} elseif $match(pathStart,"git|dirname|hostname|viewonly") {
30+
} elseif $match(pathStart,"git|dirname|hostname|viewonly|contexts") {
3131
if (%request.Method = "GET") {
3232
set %data = ##class(%Stream.TmpCharacter).%New()
3333
// Things not handled from Python backend:
@@ -76,6 +76,9 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
7676
} elseif (pathStart = "dirname") {
7777
do %data.Write(##class(SourceControl.Git.Utils).TempFolder())
7878
set handled = 1
79+
} elseif (pathStart = "contexts") {
80+
set contexts = ##class(SourceControl.Git.Utils).GetContexts()
81+
7982
}
8083
} elseif (%request.Method = "POST") {
8184
// Things not handled from Python backend:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ body {
217217
content: url(../img/tag.svg);
218218
}
219219
#sidebar #sidebar-content #sidebar-context h4:before {
220-
content: url(../img/gear-fill.svg);
220+
content: url(../img/context.svg);
221221
}
222222
#sidebar #sidebar-content #sidebar-context {
223223
position: absolute;
Lines changed: 1 addition & 0 deletions
Loading

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,56 @@ webui.SideBarView = function(mainView, noEventHandlers) {
504504
})
505505
}
506506

507+
self.changeContext = function() {
508+
function removePopup(popup) {
509+
$(popup).children(".modal-fade").modal("hide");
510+
$(".modal-backdrop").remove();
511+
$("#changeContextModal").remove();
512+
}
513+
514+
var popup = $(
515+
'<div class="modal fade" tab-index="-1" id="changeContextModal" role="dialog">' +
516+
'<div class="modal-dialog modal-md" role="document">' +
517+
'<div class="modal-content">' +
518+
'<div class="modal-header">' +
519+
'<h5 class="modal-title">Change Context</h5>' +
520+
'<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui.largeXIcon + '</button>' +
521+
'</div>' +
522+
'<div class="modal-body"></div>' +
523+
'<div class="modal-footer"></div>' +
524+
'</div>' +
525+
'</div>' +
526+
'</div>'
527+
)[0];
528+
529+
$("body").append(popup);
530+
var popupBody = $(".modal-body", popup)[0];
531+
webui.detachChildren(popupBody);
532+
533+
$(
534+
'<div class="">'+
535+
'<h6>Select context for Git Source Control</h6>' +
536+
'<select class="custom-select">'+
537+
'<option selected>context!</option>' +
538+
'</select>' +
539+
'</div>'
540+
).appendTo(popupBody);
541+
542+
var popupFooter = $(".modal-footer", popup)[0];
543+
webui.detachChildren(popupFooter);
544+
545+
$(
546+
'<button class="btn btn-sm btn-primary action-btn" id="chooseContextBtn">Choose Context</button>' +
547+
'<button class="btn btn-sm btn-secondary" id="cancelContextBtn">Cancel</button>'
548+
).appendTo(popupFooter);
549+
550+
$(popup).modal('show');
551+
552+
$('#changeContextModal').find('#cancelContextBtn', '.close').click(function() {
553+
removePopup(popup);
554+
});
555+
}
556+
507557

508558
self.checkoutBranch = function(branchType, refName) {
509559
$("#confirm-branch-checkout").remove();
@@ -798,7 +848,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
798848
'<section id="sidebar-tags">' +
799849
'<h4>Tags</h4>' +
800850
'</section>' +
801-
'<section id="sidebar-context">' +
851+
'<section id="sidebar-context" data-toggle="tooltip" data-placement="right" title="Current Context">' +
802852
'<h4>Change Context</h4>' +
803853
'</section>' +
804854
'<section id="sidebar-settings">' +
@@ -827,6 +877,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
827877
$(".btn-add", self.element).click(self.createNewLocalBranch);
828878
$('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches);
829879
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
880+
$("#sidebar-context", self.element).click(self.changeContext);
830881
}
831882
self.getPackageVersion();
832883
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ body {
302302
}
303303

304304
#sidebar-context h4:before {
305-
content: url(../img/gear-fill.svg)
305+
content: url(../img/context.svg)
306306
}
307307

308308
#sidebar-context {
Lines changed: 1 addition & 0 deletions
Loading

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,56 @@ webui.SideBarView = function(mainView, noEventHandlers) {
504504
})
505505
}
506506

507+
self.changeContext = function() {
508+
function removePopup(popup) {
509+
$(popup).children(".modal-fade").modal("hide");
510+
$(".modal-backdrop").remove();
511+
$("#changeContextModal").remove();
512+
}
513+
514+
var popup = $(
515+
'<div class="modal fade" tab-index="-1" id="changeContextModal" role="dialog">' +
516+
'<div class="modal-dialog modal-md" role="document">' +
517+
'<div class="modal-content">' +
518+
'<div class="modal-header">' +
519+
'<h5 class="modal-title">Change Context</h5>' +
520+
'<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui.largeXIcon + '</button>' +
521+
'</div>' +
522+
'<div class="modal-body"></div>' +
523+
'<div class="modal-footer"></div>' +
524+
'</div>' +
525+
'</div>' +
526+
'</div>'
527+
)[0];
528+
529+
$("body").append(popup);
530+
var popupBody = $(".modal-body", popup)[0];
531+
webui.detachChildren(popupBody);
532+
533+
$(
534+
'<div class="">'+
535+
'<h6>Select context for Git Source Control</h6>' +
536+
'<select class="custom-select">'+
537+
'<option selected>context!</option>' +
538+
'</select>' +
539+
'</div>'
540+
).appendTo(popupBody);
541+
542+
var popupFooter = $(".modal-footer", popup)[0];
543+
webui.detachChildren(popupFooter);
544+
545+
$(
546+
'<button class="btn btn-sm btn-primary action-btn" id="chooseContextBtn">Choose Context</button>' +
547+
'<button class="btn btn-sm btn-secondary" id="cancelContextBtn">Cancel</button>'
548+
).appendTo(popupFooter);
549+
550+
$(popup).modal('show');
551+
552+
$('#changeContextModal').find('#cancelContextBtn', '.close').click(function() {
553+
removePopup(popup);
554+
});
555+
}
556+
507557

508558
self.checkoutBranch = function(branchType, refName) {
509559
$("#confirm-branch-checkout").remove();
@@ -798,7 +848,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
798848
'<section id="sidebar-tags">' +
799849
'<h4>Tags</h4>' +
800850
'</section>' +
801-
'<section id="sidebar-context">' +
851+
'<section id="sidebar-context" data-toggle="tooltip" data-placement="right" title="Current Context">' +
802852
'<h4>Change Context</h4>' +
803853
'</section>' +
804854
'<section id="sidebar-settings">' +
@@ -827,6 +877,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
827877
$(".btn-add", self.element).click(self.createNewLocalBranch);
828878
$('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches);
829879
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
880+
$("#sidebar-context", self.element).click(self.changeContext);
830881
}
831882
self.getPackageVersion();
832883
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");

0 commit comments

Comments
 (0)