From d36c11bf0aff5bd2e0b3fee48c7d7bea30a7be37 Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Thu, 10 Oct 2024 15:40:34 -0400 Subject: [PATCH 01/10] Added context switching to pull page --- cls/_zpkg/isc/sc/git/Socket.cls | 1 + csp/pull.csp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cls/_zpkg/isc/sc/git/Socket.cls b/cls/_zpkg/isc/sc/git/Socket.cls index 0c1dbfaf..9030bcb6 100644 --- a/cls/_zpkg/isc/sc/git/Socket.cls +++ b/cls/_zpkg/isc/sc/git/Socket.cls @@ -13,6 +13,7 @@ ClassMethod Run() { If %request.Get("method") = "preview" { Set branchName = ##class(SourceControl.Git.Utils).GetCurrentBranch() + Write !,"Current namespace: ",$NAMESPACE Write !,"Current branch: ",branchName Do ##class(SourceControl.Git.Utils).RunGitWithArgs(.errStream, .outStream, "fetch") Kill errStream, outStream diff --git a/csp/pull.csp b/csp/pull.csp index b17baad8..f9fcfd6a 100644 --- a/csp/pull.csp +++ b/csp/pull.csp @@ -9,6 +9,17 @@ +
Change Context:  
+
 
@@ -45,6 +56,13 @@ function execute() { } } +function updateContext() { + const contextSelect = document.getElementById('newContext'); + const selectedContext = contextSelect.value; + + window.location.href = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" + selectedContext; +} + preview(); From 9b7cb13b6d6f3aec7948a52d544a4d3d418a7b6b Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Thu, 10 Oct 2024 15:48:39 -0400 Subject: [PATCH 02/10] Fixed GetContexts utils function to return namespaces for WebUI --- CHANGELOG.md | 2 ++ cls/SourceControl/Git/Utils.cls | 24 ++++++++++++++---------- cls/SourceControl/Git/WebUIDriver.cls | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8807f501..15d92997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added 'git push --force' in expert mode (#527) - Add remote repository to settings page (#448) +- Added change context option to pull page (#468) ### Fixed - Fixed display of other users' username in workspace view on Unix (#530) +- Fixed GetContexts utils function to return namespaces for WebUI(#468) ## [2.6.0] - 2024-10-07 diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index f5693a0f..4ce788fb 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -2475,28 +2475,32 @@ ClassMethod Localize() } } -ClassMethod GetContexts() As %DynamicArray +ClassMethod GetContexts(onlyNamespaces As %Boolean) As %DynamicArray { set contexts = [] set namespaces = ..GetGitEnabledNamespaces() set ptr = 0 while $listnext(namespaces,ptr,value) { - do contexts.%Push(value) + if '($FIND(value,"^^")){ + do contexts.%Push(value) + } } set name = "" // Using embedded for backwards compatability - &sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')) - &sql(OPEN C1) - throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg) - &sql(FETCH C1) - while(SQLCODE = 0) { - set package = name - do contexts.%Push(package) + if '(onlyNamespaces) { + &sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM')) + &sql(OPEN C1) + throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg) &sql(FETCH C1) + while(SQLCODE = 0) { + set package = name + do contexts.%Push(package) + &sql(FETCH C1) + } + &sql(CLOSE C1) } - &sql(CLOSE C1) return contexts } diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 5cf2a926..c6d1fbea 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -148,7 +148,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out do discardsInBranch.%ToJSON(%data) set handled = 1 } elseif (pathStart = "contexts") { - set contexts = ##class(SourceControl.Git.Utils).GetContexts() + set contexts = ##class(SourceControl.Git.Utils).GetContexts(1) do contexts.%ToJSON(%data) set handled = 1 } From d4fc10f4e1373835a0bdab5be07068fd72ab8d03 Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Thu, 10 Oct 2024 16:09:41 -0400 Subject: [PATCH 03/10] Added favorite namespaces setting for a user --- CHANGELOG.md | 1 + cls/SourceControl/Git/Settings.cls | 11 ++++++- cls/SourceControl/Git/Utils.cls | 46 ++++++++++++++++++++++++++++++ csp/gitprojectsettings.csp | 29 +++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d92997..49952110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added 'git push --force' in expert mode (#527) - Add remote repository to settings page (#448) - Added change context option to pull page (#468) +- Added favorite namespaces setting for a user (#468, #510) ### Fixed - Fixed display of other users' username in workspace view on Unix (#530) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 58b16522..1c22de17 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -55,6 +55,8 @@ Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class( Property Mappings [ MultiDimensional ]; +Property favoriteNamespaces As %String [ InitialExpression = {##class(SourceControl.Git.Utils).FavoriteNamespaces()} ]; + Method %OnNew() As %Status { set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode() @@ -66,6 +68,10 @@ Method %OnNew() As %Status if ('isDefault) { set ..gitBinPath = gitBinPath } + if ..favoriteNamespaces= "" { + set namespaces = ##class(SourceControl.Git.Utils).GetContexts(1) + set ..favoriteNamespaces = namespaces.%ToJSON() + } quit $$$OK } @@ -119,9 +125,11 @@ Method %Save() As %Status // update value of basicUserMode to reflect the updated setting for basicMode set ..userBasicMode = ##class(SourceControl.Git.Utils).UserBasicMode() - kill @##class(SourceControl.Git.Utils).MappingsNode() merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings + + do ##class(SourceControl.Git.Utils).ConfigureFavoriteNamespaces($username, ..favoriteNamespaces) + quit $$$OK } @@ -152,6 +160,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ] set sequence = $order(orderedProperties(sequence),1,property) quit:sequence="" continue:property="userBasicMode" + continue:property="favoriteNamespaces" do %code.WriteLine(" set value = inst."_property) set prompt = $$$comMemberKeyGet(%class.Name,$$$cCLASSproperty,property,$$$cPROPdescription) set promptQuoted = $$$QUOTE(prompt_":") diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 4ce788fb..f3f5038c 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -72,6 +72,11 @@ ClassMethod SettingsUIReadOnly() As %Status [ CodeMode = expression ] $Get(@..#Storage@("settings","settingsUIReadOnly"), 0) } +ClassMethod FavoriteNamespaces() As %String +{ + quit $get(@..#Storage@("settings", "user", $username, "favNamespaces"),"") +} + /// Returns the current (or previous) value of the flag. ClassMethod Locked(newFlagValue As %Boolean) As %Boolean { @@ -2826,4 +2831,45 @@ ClassMethod SetConfiguredRemote(url) As %String quit output } +ClassMethod ConfigureFavoriteNamespaces(username As %String, favNamespaces As %String) +{ + set newNamespaces = [].%FromJSON(favNamespaces) + set namespaces = ..GetContexts(1) + + set iterator = namespaces.%GetIterator() + while iterator.%GetNext(.key, .value) { + new $Namespace + set $Namespace = value + kill @..#Storage@("settings", "user", $username, "favNamespaces") + set @..#Storage@("settings", "user", $username, "favNamespaces") = favNamespaces + } + + // Delete all the GIT favorite links for the user + set iterator = newNamespaces.%GetIterator() + while iterator.%GetNext(.key, .value) { + set sql = "delete from %SYS_Portal.Users where Username='"_username_"' and Page like '%Git%'" + set statement = ##class(%SQL.Statement).%New() + do ##class(%SQL.Statement).%ExecDirect(statement,sql) + } + + set iterator = newNamespaces.%GetIterator() + while iterator.%GetNext(.key, .value) { + set installNamespace = value + new $Namespace + set $Namespace = "%SYS" + set sql = "insert or update into %SYS_Portal.Users (Username, Page, Data) "_ + "select ID,?,? from Security.Users where ID='"_username_"'" + set caption = "Git: "_installNamespace + set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_installNamespace_"/" + set statement = ##class(%SQL.Statement).%New() + set statement.%SelectMode = 0 + do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link) + set caption = "Git Pull: "_installNamespace + set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE="_installNamespace + do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link) + set sql = "update Security.Applications set GroupById='%ISCMgtPortal' where ID = '/isc/studio/usertemplates'" + do ##class(%SQL.Statement).%ExecDirect(statement,sql) + } +} + } diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 469475cf..2aaf523b 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -550,6 +550,35 @@ body { --> +
+ +
+ +
+

From 975ce77245789cd4b26840c087d79dda7af9ba6d Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Fri, 11 Oct 2024 16:42:15 -0400 Subject: [PATCH 04/10] Switched to sql approach for favorite namespaces --- CHANGELOG.md | 2 +- cls/SourceControl/Git/Settings.cls | 7 ++----- cls/SourceControl/Git/Utils.cls | 33 ++++++++++++++++++------------ csp/gitprojectsettings.csp | 29 ++++++++++++++------------ csp/pull.csp | 7 +++---- 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d91b11bc..7bb6d58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed display of other users' username in workspace view on Unix (#530) -- Fixed GetContexts utils function to return namespaces for WebUI (#468) - Fixed slowness loading some CSP pages with multiple instances sharing a webserver (#540) +- Fixed GetContexts utils function to exclude implied namespaces from the list of namespaces(#468) ## [2.6.0] - 2024-10-07 diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 3079431e..c1b2181b 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -58,7 +58,7 @@ Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class( Property Mappings [ MultiDimensional ]; -Property favoriteNamespaces As %String [ InitialExpression = {##class(SourceControl.Git.Utils).FavoriteNamespaces()} ]; +Property favoriteNamespaces As %DynamicArray; Method %OnNew() As %Status { @@ -71,10 +71,7 @@ Method %OnNew() As %Status if ('isDefault) { set ..gitBinPath = gitBinPath } - if ..favoriteNamespaces= "" { - set namespaces = ##class(SourceControl.Git.Utils).GetContexts(1) - set ..favoriteNamespaces = namespaces.%ToJSON() - } + set ..favoriteNamespaces = ##class(SourceControl.Git.Utils).FavoriteNamespaces() quit $$$OK } diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 7470ddfb..336eae06 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -74,7 +74,9 @@ $Get(@..#Storage@("settings","settingsUIReadOnly"), 0) ClassMethod FavoriteNamespaces() As %String { - quit $get(@..#Storage@("settings", "user", $username, "favNamespaces"),"") + set favNamespaces = [] + do ..GetFavoriteNamespaces(.favNamespaces,[]) + return favNamespaces } /// Returns the current (or previous) value of the flag. @@ -2841,19 +2843,8 @@ ClassMethod SetConfiguredRemote(url) As %String quit output } -ClassMethod ConfigureFavoriteNamespaces(username As %String, favNamespaces As %String) +ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String) { - set newNamespaces = [].%FromJSON(favNamespaces) - set namespaces = ..GetContexts(1) - - set iterator = namespaces.%GetIterator() - while iterator.%GetNext(.key, .value) { - new $Namespace - set $Namespace = value - kill @..#Storage@("settings", "user", $username, "favNamespaces") - set @..#Storage@("settings", "user", $username, "favNamespaces") = favNamespaces - } - // Delete all the GIT favorite links for the user set iterator = newNamespaces.%GetIterator() while iterator.%GetNext(.key, .value) { @@ -2882,4 +2873,20 @@ ClassMethod ConfigureFavoriteNamespaces(username As %String, favNamespaces As %S } } +ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray) { + set allNamespaces = ..GetContexts(1) + set iterator = allNamespaces.%GetIterator() + + while iterator.%GetNext(.key, .value) { + set sql = "select * from %SYS_Portal.Users where username='"_$username_"' and page='Git: "_value_"'" + set statement = ##class(%SQL.Statement).%New() + set res = ##class(%SQL.Statement).%ExecDirect(statement,sql) + if (res.%Next()) { + do favNamespaces.%Push(value) + } else { + do nonFavNamespaces.%Push(value) + } + } +} + } diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 3f49f582..7525cb37 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -130,6 +130,18 @@ body { } set i = i+1 } + + set i = 1 + set contexts = [] + + while ( $Data(%request.Data("favNamespace",i)) ){ + if ($Get(%request.Data("favNamespace",i)) '= "") { + do contexts.%Push($Get(%request.Data("favNamespace",i))) + } + set i = i+1 + } + + set settings.favoriteNamespaces = contexts } do settings.%Save() } @@ -569,23 +581,14 @@ body {
+ set $NAMESPACE = %request.Data("$NAMESPACE",1) set contextList = ##class(SourceControl.Git.Utils).GetContexts(1) set iterator = contextList.%GetIterator() &html<> @@ -57,10 +58,8 @@ function execute() { } function updateContext() { - const contextSelect = document.getElementById('newContext'); - const selectedContext = contextSelect.value; - - window.location.href = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" + selectedContext; + var contextSelect = document.getElementById('newContext'); + window.location.href = "#(%request.URLPrefix)#/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" + contextSelect.value; } preview(); From 016318a59ec960c89da992f53095d64203bdffb6 Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Tue, 15 Oct 2024 13:28:58 -0400 Subject: [PATCH 05/10] Added only namespaces flag for WebUI --- cls/SourceControl/Git/WebUIDriver.cls | 3 ++- git-webui/release/share/git-webui/webui/js/git-webui.js | 8 +++++--- git-webui/src/share/git-webui/webui/js/git-webui.js | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 1158f5fd..56dd35b1 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -152,7 +152,8 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out do discardsInBranch.%ToJSON(%data) set handled = 1 } elseif (pathStart = "contexts") { - set contexts = ##class(SourceControl.Git.Utils).GetContexts(1) + set onlyNamespaces = %request.Data("onlyNamespaces", 1) + set contexts = ##class(SourceControl.Git.Utils).GetContexts(onlyNamespaces) do contexts.%ToJSON(%data) set handled = 1 } 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 891e0383..24f3c95b 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 @@ -614,8 +614,8 @@ webui.SideBarView = function(mainView, noEventHandlers) { }); }; - self.changeContextGet = function() { - $.get("contexts", function(contextList) { + self.changeContextGet = function(onlyNamespaces) { + $.get("contexts", { "onlyNamespaces": onlyNamespaces }, function(contextList) { var contexts = JSON.parse(contextList); self.changeContext(contexts); }); @@ -1050,7 +1050,9 @@ webui.SideBarView = function(mainView, noEventHandlers) { $(".btn-add", self.element).click(self.createNewLocalBranch); $('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches); $("#sidebar-settings", self.element).click(self.goToSettingsPage); - $("#sidebar-context", self.element).click(self.changeContextGet); + $("#sidebar-context", self.element).click(function() { + self.changeContextGet(0); + }); $("#sidebar-home", self.element).click(self.goToHomePage); } 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 891e0383..24f3c95b 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 @@ -614,8 +614,8 @@ webui.SideBarView = function(mainView, noEventHandlers) { }); }; - self.changeContextGet = function() { - $.get("contexts", function(contextList) { + self.changeContextGet = function(onlyNamespaces) { + $.get("contexts", { "onlyNamespaces": onlyNamespaces }, function(contextList) { var contexts = JSON.parse(contextList); self.changeContext(contexts); }); @@ -1050,7 +1050,9 @@ webui.SideBarView = function(mainView, noEventHandlers) { $(".btn-add", self.element).click(self.createNewLocalBranch); $('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches); $("#sidebar-settings", self.element).click(self.goToSettingsPage); - $("#sidebar-context", self.element).click(self.changeContextGet); + $("#sidebar-context", self.element).click(function() { + self.changeContextGet(0); + }); $("#sidebar-home", self.element).click(self.goToHomePage); } From 3d842a51156471c0de23ecea8180480cea5feb69 Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Fri, 18 Oct 2024 15:47:06 -0400 Subject: [PATCH 06/10] Added helper text to be visible without hover --- csp/gitprojectsettings.csp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 7525cb37..6b7e93cf 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -577,7 +577,7 @@ body {
- +
+ Hold the [Ctrl] or [Cmd] key while clicking to select multiple namespaces.

From affc449c7087b7009906dd9e264bfe9a439bdd0d Mon Sep 17 00:00:00 2001 From: isc-akadoo Date: Fri, 18 Oct 2024 15:54:18 -0400 Subject: [PATCH 07/10] Converted dynamic sql to embedded --- cls/SourceControl/Git/Utils.cls | 70 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 336eae06..719e5526 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -2845,45 +2845,53 @@ ClassMethod SetConfiguredRemote(url) As %String ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String) { - // Delete all the GIT favorite links for the user - set iterator = newNamespaces.%GetIterator() - while iterator.%GetNext(.key, .value) { - set sql = "delete from %SYS_Portal.Users where Username='"_username_"' and Page like '%Git%'" - set statement = ##class(%SQL.Statement).%New() - do ##class(%SQL.Statement).%ExecDirect(statement,sql) - } + // Delete all the GIT favorite links for the user + &sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%') set iterator = newNamespaces.%GetIterator() while iterator.%GetNext(.key, .value) { set installNamespace = value - new $Namespace - set $Namespace = "%SYS" - set sql = "insert or update into %SYS_Portal.Users (Username, Page, Data) "_ - "select ID,?,? from Security.Users where ID='"_username_"'" - set caption = "Git: "_installNamespace - set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_installNamespace_"/" - set statement = ##class(%SQL.Statement).%New() - set statement.%SelectMode = 0 - do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link) - set caption = "Git Pull: "_installNamespace - set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE="_installNamespace - do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link) - set sql = "update Security.Applications set GroupById='%ISCMgtPortal' where ID = '/isc/studio/usertemplates'" - do ##class(%SQL.Statement).%ExecDirect(statement,sql) - } -} - -ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray) { + + // Insert Git link + set caption = "Git: " _ installNamespace + set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/" + &sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link)) + + // Insert Git Pull link + set caption = "Git Pull: " _ installNamespace + set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace + &sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link)) + } + + // Update Security.Applications + &sql(UPDATE Security.Applications SET GroupById = '%ISCMgtPortal' WHERE ID = '/isc/studio/usertemplates') +} + +ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray) +{ set allNamespaces = ..GetContexts(1) set iterator = allNamespaces.%GetIterator() + set username = $USERNAME + set pagePrefix = "Git:" + &sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix) + while iterator.%GetNext(.key, .value) { - set sql = "select * from %SYS_Portal.Users where username='"_$username_"' and page='Git: "_value_"'" - set statement = ##class(%SQL.Statement).%New() - set res = ##class(%SQL.Statement).%ExecDirect(statement,sql) - if (res.%Next()) { - do favNamespaces.%Push(value) - } else { + set foundFlag = 0 + &sql(OPEN FavCursor) + throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg) + &sql(FETCH FavCursor) + while (SQLCODE = 0) { + set pageValue = "Git: "_value + if (page = pageValue) { + do favNamespaces.%Push(value) + set foundFlag = 1 + } + &sql(FETCH FavCursor) + } + &sql(CLOSE FavCursor) + + if ('foundFlag) { do nonFavNamespaces.%Push(value) } } From e49a07d37ee9f8cefda40d0c437d13ffcb6ba40f Mon Sep 17 00:00:00 2001 From: Elijah Tamarchenko Date: Mon, 21 Oct 2024 10:13:56 -0400 Subject: [PATCH 08/10] Added more space for the context select --- csp/pull.csp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csp/pull.csp b/csp/pull.csp index 0ab87e95..9623a9d9 100644 --- a/csp/pull.csp +++ b/csp/pull.csp @@ -9,7 +9,7 @@ -
Change Context:  
 	
 		set $NAMESPACE = %request.Data("$NAMESPACE",1)
 		set contextList = ##class(SourceControl.Git.Utils).GetContexts(1)

From f0b6b5b2e16165335d67e05896884ffefc02023e Mon Sep 17 00:00:00 2001
From: Elijah Tamarchenko 
Date: Mon, 21 Oct 2024 11:28:56 -0400
Subject: [PATCH 09/10] Fixed reviewed changes

---
 cls/SourceControl/Git/Utils.cls |  3 ---
 csp/pull.csp                    | 14 ++++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls
index 719e5526..377d4591 100644
--- a/cls/SourceControl/Git/Utils.cls
+++ b/cls/SourceControl/Git/Utils.cls
@@ -2862,9 +2862,6 @@ ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %S
         set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
         &sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
     }
-
-    // Update Security.Applications
-    &sql(UPDATE Security.Applications SET GroupById = '%ISCMgtPortal' WHERE ID = '/isc/studio/usertemplates')
 }
 
 ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
diff --git a/csp/pull.csp b/csp/pull.csp
index 9623a9d9..9c97d849 100644
--- a/csp/pull.csp
+++ b/csp/pull.csp
@@ -11,12 +11,14 @@
 
 
Change Context:  

From 13ff63d521094f2abc31850b92ea78232f63139b Mon Sep 17 00:00:00 2001
From: Elijah Tamarchenko 
Date: Mon, 21 Oct 2024 13:26:01 -0400
Subject: [PATCH 10/10] Fix context changing in pull page

---
 csp/pull.csp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/csp/pull.csp b/csp/pull.csp
index 9c97d849..0b5aa269 100644
--- a/csp/pull.csp
+++ b/csp/pull.csp
@@ -11,13 +11,15 @@
 
 
Change Context: