Skip to content

Commit 7b010c5

Browse files
committed
Merge branch 'main' into production-change-control
2 parents 6ad0ab4 + d18dd40 commit 7b010c5

File tree

8 files changed

+280
-10
lines changed

8 files changed

+280
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
98
## [2.5.0] - Unreleased
109

1110
### Added
1211
- New UI for the basic mode Sync (#415)
12+
- Allow changing namespaces and IPM package context from web UI (#280)
1313

1414
### Fixed
1515
- Instance wide settings are placed in proper global (#444)

cls/SourceControl/Git/Utils.cls

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,27 @@ ClassMethod Localize()
23782378
}
23792379
}
23802380

2381+
ClassMethod GetContexts() As %DynamicArray
2382+
{
2383+
set contexts = []
2384+
set namespaces = ..GetGitEnabledNamespaces()
2385+
set ptr = 0
2386+
while $listnext(namespaces,ptr,value) {
2387+
do contexts.%Push(value)
2388+
}
2389+
2390+
set query = "SELECT name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')"
2391+
set statement = ##class(%SQL.Statement).%New()
2392+
$$$ThrowOnError(statement.%Prepare(query, 0))
2393+
set packagesResultSet = statement.%Execute()
2394+
throw:packagesResultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(packagesResultSet.%SQLCODE,packagesResultSet.%Message)
2395+
while packagesResultSet.%Next() {
2396+
set package = packagesResultSet.Name
2397+
do contexts.%Push(package)
2398+
}
2399+
return contexts
2400+
}
2401+
23812402
ClassMethod ConfigureWeb()
23822403
{
23832404
set installNamespace = $Namespace
@@ -2480,6 +2501,29 @@ ClassMethod UncommittedWithAction() As %Library.DynamicObject
24802501
quit fileToOtherDevelopers
24812502
}
24822503

2504+
/// Retrieve the list of Namespaces that have git enabled
2505+
ClassMethod GetGitEnabledNamespaces() As %String
2506+
{
2507+
// Get all namespaces
2508+
set allNamespaces = ""
2509+
do ##class(%SYS.Namespace).ListAll(.allNamespaces)
2510+
2511+
set enabledNamespaces = ""
2512+
set namespace = ""
2513+
for {
2514+
set namespace = $ORDER(allNamespaces(namespace))
2515+
quit:namespace=""
2516+
try {
2517+
set sourceControlClass = ##class(%Studio.SourceControl.Interface).SourceControlClassGet(namespace)
2518+
} catch err {
2519+
set sourceControlClass = "" // user does not have access to this namespace
2520+
}
2521+
if (sourceControlClass = "SourceControl.Git.Extension") set enabledNamespaces = enabledNamespaces _ $listbuild(namespace)
2522+
}
2523+
2524+
quit enabledNamespaces
2525+
}
2526+
24832527
ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
24842528
{
24852529
#define sourcedir $System.Util.InstallDirectory()_"devuser/studio/templates/gitsourcecontrol/"
@@ -2635,3 +2679,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
26352679
}
26362680

26372681
}
2682+

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 5 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-command|git|dirname|hostname|viewonly") {
30+
} elseif $match(pathStart,"git-command|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,10 @@ 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+
do contexts.%ToJSON(%data)
82+
set handled = 1
7983
}
8084
} elseif (%request.Method = "POST") {
8185
// Things not handled from Python backend:

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ body {
180180
border-top: 1px solid #1a1a1a;
181181
border-bottom: 1px solid #1a1a1a;
182182
color: #eeeeee;
183-
padding-bottom: 6em;
183+
padding-bottom: 100px;
184184
}
185185
#sidebar #sidebar-content > :first-child,
186-
#sidebar #sidebar-content > :last-child {
186+
#sidebar #sidebar-content > :nth-last-child(2) {
187187
border-top: 1px solid #5e5e5e;
188188
}
189189
#sidebar #sidebar-content h4:before {
@@ -216,6 +216,17 @@ body {
216216
#sidebar #sidebar-content #sidebar-tags h4:before {
217217
content: url(../img/tag.svg);
218218
}
219+
#sidebar #sidebar-content #sidebar-context h4:before {
220+
content: url(../img/context.svg);
221+
}
222+
#sidebar #sidebar-content #sidebar-context {
223+
position: absolute;
224+
bottom: 50px;
225+
width: 16.7em;
226+
padding-bottom: 0.3rem;
227+
margin-bottom: 0;
228+
background-color: #333333;
229+
}
219230
#sidebar #sidebar-content #sidebar-settings h4:before {
220231
content: url(../img/gear-fill.svg);
221232
}

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

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,99 @@ webui.SideBarView = function(mainView, noEventHandlers) {
587587
})
588588
}
589589

590-
590+
self.changeContextGet = function() {
591+
$.get("contexts", function(contextList) {
592+
var contexts = JSON.parse(contextList);
593+
self.changeContext(contexts);
594+
});
595+
}
596+
597+
self.changeContext = function(contexts) {
598+
599+
function removePopup(popup) {
600+
$(popup).children(".modal-fade").modal("hide");
601+
$(".modal-backdrop").remove();
602+
$("#changeContextModal").remove();
603+
}
604+
605+
var popup = $(
606+
'<div class="modal fade" tab-index="-1" id="changeContextModal" role="dialog">' +
607+
'<div class="modal-dialog modal-md" role="document">' +
608+
'<div class="modal-content">' +
609+
'<div class="modal-header">' +
610+
'<h5 class="modal-title">Change Context</h5>' +
611+
'<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui.largeXIcon + '</button>' +
612+
'</div>' +
613+
'<div class="modal-body"></div>' +
614+
'<div class="modal-footer"></div>' +
615+
'</div>' +
616+
'</div>' +
617+
'</div>'
618+
)[0];
619+
620+
$("body").append(popup);
621+
var popupBody = $(".modal-body", popup)[0];
622+
webui.detachChildren(popupBody);
623+
624+
$(
625+
'<div class="">'+
626+
'<h6>Select context for Git Source Control</h6>' +
627+
'<select id="chosenContext" class="custom-select">'+
628+
'</select>' +
629+
'</div>'
630+
).appendTo(popupBody);
631+
632+
var selectDropdown = $(".custom-select", popupBody)[0];
633+
634+
contexts.forEach(function(context) {
635+
$(
636+
'<option value="' + context + '" ' + (context == self.currentContext ? "selected" : "") + ' >' + context + '</option>'
637+
).appendTo(selectDropdown);
638+
})
639+
640+
641+
var popupFooter = $(".modal-footer", popup)[0];
642+
webui.detachChildren(popupFooter);
643+
644+
$(
645+
'<button class="btn btn-sm btn-primary action-btn" id="chooseContextBtn">Choose Context</button>' +
646+
'<button class="btn btn-sm btn-secondary" id="cancelContextBtn">Cancel</button>'
647+
).appendTo(popupFooter);
648+
649+
$(popup).modal('show');
650+
651+
$('#changeContextModal').find('#cancelContextBtn', '.close').click(function() {
652+
removePopup(popup);
653+
});
654+
655+
$("#chooseContextBtn").on("click", function() {
656+
self.updateContext($("#chosenContext").val());
657+
removePopup(popup);
658+
});
659+
}
660+
661+
self.getCurrentContext = function() {
662+
var args = window.location.href.split("webuidriver.csp/")[1].split("/");
663+
var context = args[0];
664+
if (args[1] && (args[1].indexOf(".ZPM") != -1)) {
665+
context = args[1];
666+
}
667+
return context;
668+
}
669+
670+
self.updateContext = function(context) {
671+
var urlParts = window.location.href.split("webuidriver.csp/");
672+
var args = urlParts[1].split("/");
673+
if (context.indexOf(".ZPM") != -1) {
674+
args[1] = context;
675+
} else {
676+
args[0] = context;
677+
args[1] = "";
678+
}
679+
window.location = urlParts[0] + "webuidriver.csp/" + args.join("/");
680+
self.currentContext = context;
681+
}
682+
591683
self.checkoutBranch = function(branchType, refName) {
592684
$("#confirm-branch-checkout").remove();
593685

@@ -855,7 +947,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
855947
};
856948

857949
self.mainView = mainView;
858-
950+
self.currentContext = self.getCurrentContext();
859951
self.element = $( '<div id="sidebar">' +
860952
'<a href="#" data-toggle="modal" data-target="#help-modal"><img id="sidebar-logo" src="img/git-logo.png"></a>' +
861953
'<h5 id="packageVersion"></h5>' +
@@ -881,6 +973,9 @@ webui.SideBarView = function(mainView, noEventHandlers) {
881973
'<section id="sidebar-tags">' +
882974
'<h4>Tags</h4>' +
883975
'</section>' +
976+
'<section id="sidebar-context" data-toggle="tooltip" data-placement="right" title="' + self.currentContext + '">' +
977+
'<h4>Change Context</h4>' +
978+
'</section>' +
884979
'<section id="sidebar-settings">' +
885980
'<h4>Settings</h4>' +
886981
'</section>' +
@@ -907,7 +1002,10 @@ webui.SideBarView = function(mainView, noEventHandlers) {
9071002
$(".btn-add", self.element).click(self.createNewLocalBranch);
9081003
$('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches);
9091004
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
1005+
$("#sidebar-context", self.element).click(self.changeContextGet);
9101006
}
1007+
1008+
9111009
self.getPackageVersion();
9121010
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
9131011
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ body {
255255
border-top: 1px solid darken(@gray-dark, 10%);
256256
border-bottom: 1px solid darken(@gray-dark, 10%);
257257
color: @gray-lighter;
258-
padding-bottom: 6em;
258+
padding-bottom: 100px;
259259

260-
> :first-child, >:last-child {
260+
> :first-child, >:nth-last-child(2) {
261261
border-top: 1px solid darken(@separator-line, 50%);
262262
}
263263

@@ -301,6 +301,19 @@ body {
301301
content: url(../img/tag.svg);
302302
}
303303

304+
#sidebar-context h4:before {
305+
content: url(../img/context.svg)
306+
}
307+
308+
#sidebar-context {
309+
position: absolute;
310+
bottom: 50px;
311+
width: 16.7em;
312+
padding-bottom: 0.3rem;
313+
margin-bottom: 0;
314+
background-color: rgba(51, 51, 51, 1);
315+
}
316+
304317
#sidebar-settings h4:before {
305318
content: url(../img/gear-fill.svg);
306319
}
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)