Skip to content

Commit 6a2bcfe

Browse files
committed
fix errors with SQL privileges and in Studio
1 parent b381c72 commit 6a2bcfe

File tree

5 files changed

+59
-74
lines changed

5 files changed

+59
-74
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,56 +2315,20 @@ ClassMethod Localize()
23152315
}
23162316
}
23172317

2318-
Query Namespaces() As %Query(ROWSPEC = "Namespace:%String,GitSourceControl:%Boolean,Accessible:%Boolean") [ SqlProc ]
2319-
{
2320-
}
2321-
2322-
ClassMethod NamespacesExecute(ByRef qHandle As %Binary) As %Status
2323-
{
2324-
Set sc = ##class(%SYS.Namespace).ListAll(.array)
2325-
Merge qHandle = array
2326-
Set qHandle = ""
2327-
Quit sc
2328-
}
2329-
2330-
ClassMethod NamespacesFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = NamespacesExecute ]
2331-
{
2332-
Set qHandle = $Order(qHandle(qHandle))
2333-
If (qHandle = "") {
2334-
Set AtEnd = 1
2335-
} ElseIf $Extract(qHandle) = "^" {
2336-
Quit ..NamespacesFetch(.qHandle,.Row,.AtEnd)
2337-
} Else {
2338-
Try {
2339-
New $Namespace
2340-
Set $Namespace = qHandle
2341-
Set scc = ##class(%Studio.SourceControl.Interface).SourceControlClassGet()
2342-
set isGitSC = $select(scc = "SourceControl.Git.Extension":1, 1:0)
2343-
Set Row = $ListBuild(qHandle,isGitSC,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-
23562318
ClassMethod GetContexts() As %DynamicArray
23572319
{
23582320
set contexts = []
2359-
set namespacesResultSet = ..NamespacesFunc()
2360-
while namespacesResultSet.%Next() {
2361-
set namespace = namespacesResultSet.Namespace
2362-
if namespacesResultSet.GitSourceControl && namespacesResultSet.Accessible {
2363-
do contexts.%Push(namespace)
2364-
}
2321+
set namespaces = ..GetGitEnabledNamespaces()
2322+
set ptr = 0
2323+
while $listnext(namespaces,ptr,value) {
2324+
do contexts.%Push(value)
23652325
}
23662326

2367-
set packagesResultSet = ##class(%SQL.Statement).%ExecDirect(, "SELECT name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')")
2327+
set query = "SELECT name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')"
2328+
set statement = ##class(%SQL.Statement).%New()
2329+
$$$ThrowOnError(statement.%Prepare(query, 0))
2330+
set packagesResultSet = statement.%Execute()
2331+
throw:packagesResultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(packagesResultSet.%SQLCODE,packagesResultSet.%Message)
23682332
while packagesResultSet.%Next() {
23692333
set package = packagesResultSet.Name
23702334
do contexts.%Push(package)
@@ -2474,6 +2438,29 @@ ClassMethod UncommittedWithAction() As %Library.DynamicObject
24742438
quit fileToOtherDevelopers
24752439
}
24762440

2441+
/// Retrieve the list of Namespaces that have git enabled
2442+
ClassMethod GetGitEnabledNamespaces() As %String
2443+
{
2444+
// Get all namespaces
2445+
set allNamespaces = ""
2446+
do ##class(%SYS.Namespace).ListAll(.allNamespaces)
2447+
2448+
set enabledNamespaces = ""
2449+
set namespace = ""
2450+
for {
2451+
set namespace = $ORDER(allNamespaces(namespace))
2452+
quit:namespace=""
2453+
try {
2454+
set sourceControlClass = ##class(%Studio.SourceControl.Interface).SourceControlClassGet(namespace)
2455+
} catch err {
2456+
set sourceControlClass = "" // user does not have access to this namespace
2457+
}
2458+
if (sourceControlClass = "SourceControl.Git.Extension") set enabledNamespaces = enabledNamespaces _ $listbuild(namespace)
2459+
}
2460+
2461+
quit enabledNamespaces
2462+
}
2463+
24772464
ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
24782465
{
24792466
#define sourcedir $System.Util.InstallDirectory()_"devuser/studio/templates/gitsourcecontrol/"
@@ -2628,3 +2615,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
26282615
}
26292616

26302617
}
2618+

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
@@ -221,7 +221,7 @@ body {
221221
}
222222
#sidebar #sidebar-content #sidebar-context {
223223
position: absolute;
224-
bottom: 42px;
224+
bottom: 50px;
225225
width: 16.7em;
226226
padding-bottom: 0.3rem;
227227
margin-bottom: 0;

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -654,30 +654,29 @@ webui.SideBarView = function(mainView, noEventHandlers) {
654654

655655
$("#chooseContextBtn").on("click", function() {
656656
self.updateContext($("#chosenContext").val());
657+
removePopup(popup);
657658
});
658659
}
659660

660661
self.getCurrentContext = function() {
661-
var urlParts = window.location.href.split("/");
662-
if (urlParts[urlParts.length - 1] == "") {
663-
// return namespace as context
664-
return urlParts[urlParts.length - 2];
665-
} else {
666-
// return package as context
667-
return urlParts[urlParts.length - 1];
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];
668666
}
667+
return context;
669668
}
670669

671670
self.updateContext = function(context) {
672-
var urlParts = window.location.href.split("/");
671+
var urlParts = window.location.href.split("webuidriver.csp/");
672+
var args = urlParts[1].split("/");
673673
if (context.indexOf(".ZPM") != -1) {
674-
urlParts[urlParts.length - 1] = context;
674+
args[1] = context;
675675
} else {
676-
urlParts[urlParts.length - 1] = "";
677-
urlParts[urlParts.length - 2] = context;
676+
args[0] = context;
677+
args[1] = "";
678678
}
679-
680-
window.location = urlParts.join("/");
679+
window.location = urlParts[0] + "webuidriver.csp/" + args.join("/");
681680
self.currentContext = context;
682681
}
683682

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
@@ -307,7 +307,7 @@ body {
307307

308308
#sidebar-context {
309309
position: absolute;
310-
bottom: 42px;
310+
bottom: 50px;
311311
width: 16.7em;
312312
padding-bottom: 0.3rem;
313313
margin-bottom: 0;

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -653,32 +653,30 @@ webui.SideBarView = function(mainView, noEventHandlers) {
653653
});
654654

655655
$("#chooseContextBtn").on("click", function() {
656-
removePopup(popup);
657656
self.updateContext($("#chosenContext").val());
657+
removePopup(popup);
658658
});
659659
}
660660

661661
self.getCurrentContext = function() {
662-
var urlParts = window.location.href.split("/");
663-
if (urlParts[urlParts.length - 1] == "") {
664-
// return namespace as context
665-
return urlParts[urlParts.length - 2];
666-
} else {
667-
// return package as context
668-
return urlParts[urlParts.length - 1];
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];
669666
}
667+
return context;
670668
}
671669

672670
self.updateContext = function(context) {
673-
var urlParts = window.location.href.split("/");
671+
var urlParts = window.location.href.split("webuidriver.csp/");
672+
var args = urlParts[1].split("/");
674673
if (context.indexOf(".ZPM") != -1) {
675-
urlParts[urlParts.length - 1] = context;
674+
args[1] = context;
676675
} else {
677-
urlParts[urlParts.length - 1] = "";
678-
urlParts[urlParts.length - 2] = context;
676+
args[0] = context;
677+
args[1] = "";
679678
}
680-
681-
window.location = urlParts.join("/");
679+
window.location = urlParts[0] + "webuidriver.csp/" + args.join("/");
682680
self.currentContext = context;
683681
}
684682

0 commit comments

Comments
 (0)