Skip to content

Commit ad2965c

Browse files
committed
Merge branch 'main' into issue-591
2 parents e0dac0e + a0b5e47 commit ad2965c

File tree

5 files changed

+93
-55
lines changed

5 files changed

+93
-55
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
- Fix creating new branch from Git Web UI (#591)
5253

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

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: 1 addition & 53 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

@@ -2937,56 +2937,4 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean
29372937
quit 0
29382938
}
29392939

2940-
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
2941-
{
2942-
// Delete all the GIT favorite links for the user
2943-
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
2944-
2945-
set iterator = newNamespaces.%GetIterator()
2946-
while iterator.%GetNext(.key, .value) {
2947-
set installNamespace = value
2948-
2949-
// Insert Git link
2950-
set caption = "Git: " _ installNamespace
2951-
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
2952-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2953-
2954-
// Insert Git Pull link
2955-
set caption = "Git Pull: " _ installNamespace
2956-
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
2957-
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2958-
}
2959-
}
2960-
2961-
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
2962-
{
2963-
set allNamespaces = ..GetContexts(1)
2964-
set iterator = allNamespaces.%GetIterator()
2965-
2966-
set username = $USERNAME
2967-
set pagePrefix = "Git:"
2968-
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
2969-
2970-
while iterator.%GetNext(.key, .value) {
2971-
set foundFlag = 0
2972-
&sql(OPEN FavCursor)
2973-
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2974-
&sql(FETCH FavCursor)
2975-
while (SQLCODE = 0) {
2976-
set pageValue = "Git: "_value
2977-
if (page = pageValue) {
2978-
do favNamespaces.%Push(value)
2979-
set foundFlag = 1
2980-
}
2981-
&sql(FETCH FavCursor)
2982-
}
2983-
&sql(CLOSE FavCursor)
2984-
2985-
if ('foundFlag) {
2986-
do nonFavNamespaces.%Push(value)
2987-
}
2988-
}
2989-
}
2990-
29912940
}
2992-

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Class %zpkg.isc.sc.git.Favorites
2+
{
3+
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %Library.DynamicObject)
4+
{
5+
// Convert to $listbuild
6+
set namespaces = $lb()
7+
set iterator = newNamespaces.%GetIterator()
8+
9+
while iterator.%GetNext(.key, .value) {
10+
set namespaces = namespaces_$lb(value)
11+
}
12+
13+
// Call the private method
14+
try {
15+
do ..SetFavs(username, namespaces)
16+
} catch e {
17+
return e.AsStatus()
18+
}
19+
return $$$OK
20+
}
21+
22+
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
23+
{
24+
try {
25+
set namespaces = ..GetFavs()
26+
set favNamespaces = namespaces.%Get("Favorites")
27+
set nonFavNamespaces = namespaces.%Get("NonFavorites")
28+
} catch e {
29+
return e.AsStatus()
30+
}
31+
return $$$OK
32+
}
33+
34+
ClassMethod GetFavs() As %Library.DynamicObject [ Private, NotInheritable ] {
35+
$$$AddAllRoleTemporary
36+
set allNamespaces = ##class(SourceControl.Git.Utils).GetContexts(1)
37+
38+
set favNamespaces = []
39+
set nonFavNamespaces = []
40+
41+
set username = $USERNAME
42+
set pagePrefix = "Git:"
43+
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
44+
45+
for i=0:1:(allNamespaces.%Size() - 1) {
46+
set namespace = allNamespaces.%Get(i)
47+
set foundFlag = 0
48+
&sql(OPEN FavCursor)
49+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
50+
&sql(FETCH FavCursor)
51+
while (SQLCODE = 0) {
52+
set pageValue = "Git: "_namespace
53+
if (page = pageValue) {
54+
do favNamespaces.%Push(namespace)
55+
set foundFlag = 1
56+
}
57+
&sql(FETCH FavCursor)
58+
}
59+
&sql(CLOSE FavCursor)
60+
61+
if ('foundFlag) {
62+
do nonFavNamespaces.%Push(namespace)
63+
}
64+
}
65+
return {"Favorites": (favNamespaces), "NonFavorites": (nonFavNamespaces)}
66+
}
67+
68+
ClassMethod SetFavs(username As %String, namespaces As %List) [ Private, NotInheritable ] {
69+
$$$AddAllRoleTemporary
70+
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
71+
72+
for i=1:1:$listlength(namespaces) {
73+
set namespace = $listget(namespaces, i)
74+
if (namespace '= "") {
75+
set installNamespace = namespace
76+
77+
// Insert Git link
78+
set caption = "Git: " _ installNamespace
79+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
80+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
81+
82+
// Insert Git Pull link
83+
set caption = "Git Pull: " _ installNamespace
84+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
85+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
86+
}
87+
}
88+
}
89+
}

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)