Skip to content

Commit ef21533

Browse files
committed
Allow favorites changing for all users
1 parent 01ee816 commit ef21533

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4848
- Fixed sending OS error when git pull encounters error (#545)
4949
- Fixed suppressing editing of locked classes (#301)
5050
- Fixed importing CSP files (#251)
51+
- Fixed changing favorites for users without permissions (#587)
5152

5253
## [2.6.0] - 2024-10-07
5354

cls/SourceControl/Git/Settings.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Method %Save() As %Status
136136
kill @##class(SourceControl.Git.Utils).MappingsNode()
137137
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
138138

139-
do ##class(SourceControl.Git.Utils).ConfigureFavoriteNamespaces($username, ..favoriteNamespaces)
139+
do ##class(%zpkg.isc.sc.git.Favorites).ConfigureFavoriteNamespaces($username, ..favoriteNamespaces)
140140

141141
quit $$$OK
142142
}

cls/SourceControl/Git/Utils.cls

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $Get(@..#Storage@("settings","settingsUIReadOnly"), 0)
7575
ClassMethod FavoriteNamespaces() As %String
7676
{
7777
set favNamespaces = []
78-
do ..GetFavoriteNamespaces(.favNamespaces,[])
78+
do ##class(%zpkg.isc.sc.git.Favorites).GetFavoriteNamespaces(.favNamespaces,[])
7979
return favNamespaces
8080
}
8181

@@ -612,7 +612,7 @@ ClassMethod GetCurrentRevision() As %String
612612
quit revision
613613
}
614614

615-
ClassMethod Pull(remote As %String = "origin", pTerminateOnError As %Boolean=0) As %Status
615+
ClassMethod Pull(remote As %String = "origin", pTerminateOnError As %Boolean = 0) As %Status
616616
{
617617
New %gitSCOutputFlag
618618
Set %gitSCOutputFlag = 1
@@ -2985,4 +2985,3 @@ ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef no
29852985
}
29862986

29872987
}
2988-

cls/_zpkg/isc/sc/git/Favorites.cls

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Class %zpkg.isc.sc.git.Favorites Extends %RegisteredObject
2+
{
3+
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
4+
{
5+
$$$AddAllRoleTemporary
6+
// Delete all the GIT favorite links for the user
7+
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
8+
9+
set iterator = newNamespaces.%GetIterator()
10+
while iterator.%GetNext(.key, .value) {
11+
set installNamespace = value
12+
13+
// Insert Git link
14+
set caption = "Git: " _ installNamespace
15+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
16+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
17+
18+
// Insert Git Pull link
19+
set caption = "Git Pull: " _ installNamespace
20+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
21+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
22+
}
23+
}
24+
25+
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
26+
{
27+
$$$AddAllRoleTemporary
28+
set allNamespaces = ##class(SourceControl.Git.Utils).GetContexts(1)
29+
set iterator = allNamespaces.%GetIterator()
30+
31+
set username = $USERNAME
32+
set pagePrefix = "Git:"
33+
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
34+
35+
while iterator.%GetNext(.key, .value) {
36+
set foundFlag = 0
37+
&sql(OPEN FavCursor)
38+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
39+
&sql(FETCH FavCursor)
40+
while (SQLCODE = 0) {
41+
set pageValue = "Git: "_value
42+
if (page = pageValue) {
43+
do favNamespaces.%Push(value)
44+
set foundFlag = 1
45+
}
46+
&sql(FETCH FavCursor)
47+
}
48+
&sql(CLOSE FavCursor)
49+
50+
if ('foundFlag) {
51+
do nonFavNamespaces.%Push(value)
52+
}
53+
}
54+
}
55+
}

csp/gitprojectsettings.csp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ body {
614614
<server>
615615
set nonFavNamespaces = []
616616
set selectedNamespaces = []
617-
do ##class(SourceControl.Git.Utils).GetFavoriteNamespaces(.selectedNamespaces,.nonFavNamespaces)
617+
do ##class(%zpkg.isc.sc.git.Favorites).GetFavoriteNamespaces(.selectedNamespaces,.nonFavNamespaces)
618618
set iterator = selectedNamespaces.%GetIterator()
619619
while iterator.%GetNext(.key, .value) {
620620
&html<<option selected value=#(value)#>#(value)#</option>>

0 commit comments

Comments
 (0)