diff --git a/CHANGELOG.md b/CHANGELOG.md index 481e8c99..3c047138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ 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) +- Added favorite namespaces setting for a user (#468, #510) - Added environment awareness in configuration, and showing of environment name in UI (#124) ### Fixed @@ -17,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix left-sidebar spacing (#525) - Fixed slowness loading some CSP pages with multiple instances sharing a webserver (#540) - Prevent direct commits to default merge branch in basic mode (#484) +- Fixed GetContexts utils function to exclude implied namespaces from the list of namespaces (#468) - Fixed git path configuration (#463) - Added feedback to settings page (#550) - Fix "Home" navigation to point to current namespace (#548) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 7a41abe7..19181c92 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -58,6 +58,8 @@ Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class( Property Mappings [ MultiDimensional ]; +Property favoriteNamespaces As %DynamicArray; + Method %OnNew() As %Status { set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode() @@ -69,6 +71,7 @@ Method %OnNew() As %Status if ('isDefault) { set ..gitBinPath = gitBinPath } + set ..favoriteNamespaces = ##class(SourceControl.Git.Utils).FavoriteNamespaces() quit $$$OK } @@ -130,9 +133,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 } @@ -163,6 +168,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 5269aedb..406b1840 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -72,6 +72,13 @@ ClassMethod SettingsUIReadOnly() As %Status [ CodeMode = expression ] $Get(@..#Storage@("settings","settingsUIReadOnly"), 0) } +ClassMethod FavoriteNamespaces() As %String +{ + set favNamespaces = [] + do ..GetFavoriteNamespaces(.favNamespaces,[]) + return favNamespaces +} + /// Returns the current (or previous) value of the flag. ClassMethod Locked(newFlagValue As %Boolean) As %Boolean { @@ -2490,28 +2497,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 } @@ -2849,4 +2860,55 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean quit 0 } +ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String) +{ + // 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 + + // 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)) + } +} + +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 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) + } + } +} + } diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 734d78de..60a8f6a4 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -156,7 +156,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() + set onlyNamespaces = %request.Data("onlyNamespaces", 1) + set contexts = ##class(SourceControl.Git.Utils).GetContexts(onlyNamespaces) do contexts.%ToJSON(%data) set handled = 1 } 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/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 6c65f53f..a9a6cdf3 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -151,6 +151,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() } @@ -591,6 +603,27 @@ body { --> +
+ +
+ + Hold the [Ctrl] or [Cmd] key while clicking to select multiple namespaces. +
+

diff --git a/csp/pull.csp b/csp/pull.csp index b17baad8..0b5aa269 100644 --- a/csp/pull.csp +++ b/csp/pull.csp @@ -9,6 +9,22 @@ +
Change Context:  
+
 
@@ -45,6 +61,11 @@ function execute() { } } +function updateContext() { + var contextSelect = document.getElementById('newContext'); + window.location.href = "#(%request.URLPrefix)#/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" + contextSelect.value; +} + preview(); 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 fe1b8540..4d1abd74 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); }); @@ -1051,7 +1051,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 fe1b8540..4d1abd74 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); }); @@ -1051,7 +1051,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); }