Skip to content

Commit d4fc10f

Browse files
committed
Added favorite namespaces setting for a user
1 parent 9b7cb13 commit d4fc10f

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Added 'git push --force' in expert mode (#527)
1212
- Add remote repository to settings page (#448)
1313
- Added change context option to pull page (#468)
14+
- Added favorite namespaces setting for a user (#468, #510)
1415

1516
### Fixed
1617
- Fixed display of other users' username in workspace view on Unix (#530)

cls/SourceControl/Git/Settings.cls

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(
5555

5656
Property Mappings [ MultiDimensional ];
5757

58+
Property favoriteNamespaces As %String [ InitialExpression = {##class(SourceControl.Git.Utils).FavoriteNamespaces()} ];
59+
5860
Method %OnNew() As %Status
5961
{
6062
set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode()
@@ -66,6 +68,10 @@ Method %OnNew() As %Status
6668
if ('isDefault) {
6769
set ..gitBinPath = gitBinPath
6870
}
71+
if ..favoriteNamespaces= "" {
72+
set namespaces = ##class(SourceControl.Git.Utils).GetContexts(1)
73+
set ..favoriteNamespaces = namespaces.%ToJSON()
74+
}
6975
quit $$$OK
7076
}
7177

@@ -119,9 +125,11 @@ Method %Save() As %Status
119125
// update value of basicUserMode to reflect the updated setting for basicMode
120126
set ..userBasicMode = ##class(SourceControl.Git.Utils).UserBasicMode()
121127

122-
123128
kill @##class(SourceControl.Git.Utils).MappingsNode()
124129
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
130+
131+
do ##class(SourceControl.Git.Utils).ConfigureFavoriteNamespaces($username, ..favoriteNamespaces)
132+
125133
quit $$$OK
126134
}
127135

@@ -152,6 +160,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
152160
set sequence = $order(orderedProperties(sequence),1,property)
153161
quit:sequence=""
154162
continue:property="userBasicMode"
163+
continue:property="favoriteNamespaces"
155164
do %code.WriteLine(" set value = inst."_property)
156165
set prompt = $$$comMemberKeyGet(%class.Name,$$$cCLASSproperty,property,$$$cPROPdescription)
157166
set promptQuoted = $$$QUOTE(prompt_":")

cls/SourceControl/Git/Utils.cls

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ ClassMethod SettingsUIReadOnly() As %Status [ CodeMode = expression ]
7272
$Get(@..#Storage@("settings","settingsUIReadOnly"), 0)
7373
}
7474

75+
ClassMethod FavoriteNamespaces() As %String
76+
{
77+
quit $get(@..#Storage@("settings", "user", $username, "favNamespaces"),"")
78+
}
79+
7580
/// Returns the current (or previous) value of the flag.
7681
ClassMethod Locked(newFlagValue As %Boolean) As %Boolean
7782
{
@@ -2826,4 +2831,45 @@ ClassMethod SetConfiguredRemote(url) As %String
28262831
quit output
28272832
}
28282833

2834+
ClassMethod ConfigureFavoriteNamespaces(username As %String, favNamespaces As %String)
2835+
{
2836+
set newNamespaces = [].%FromJSON(favNamespaces)
2837+
set namespaces = ..GetContexts(1)
2838+
2839+
set iterator = namespaces.%GetIterator()
2840+
while iterator.%GetNext(.key, .value) {
2841+
new $Namespace
2842+
set $Namespace = value
2843+
kill @..#Storage@("settings", "user", $username, "favNamespaces")
2844+
set @..#Storage@("settings", "user", $username, "favNamespaces") = favNamespaces
2845+
}
2846+
2847+
// Delete all the GIT favorite links for the user
2848+
set iterator = newNamespaces.%GetIterator()
2849+
while iterator.%GetNext(.key, .value) {
2850+
set sql = "delete from %SYS_Portal.Users where Username='"_username_"' and Page like '%Git%'"
2851+
set statement = ##class(%SQL.Statement).%New()
2852+
do ##class(%SQL.Statement).%ExecDirect(statement,sql)
2853+
}
2854+
2855+
set iterator = newNamespaces.%GetIterator()
2856+
while iterator.%GetNext(.key, .value) {
2857+
set installNamespace = value
2858+
new $Namespace
2859+
set $Namespace = "%SYS"
2860+
set sql = "insert or update into %SYS_Portal.Users (Username, Page, Data) "_
2861+
"select ID,?,? from Security.Users where ID='"_username_"'"
2862+
set caption = "Git: "_installNamespace
2863+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_installNamespace_"/"
2864+
set statement = ##class(%SQL.Statement).%New()
2865+
set statement.%SelectMode = 0
2866+
do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link)
2867+
set caption = "Git Pull: "_installNamespace
2868+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE="_installNamespace
2869+
do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link)
2870+
set sql = "update Security.Applications set GroupById='%ISCMgtPortal' where ID = '/isc/studio/usertemplates'"
2871+
do ##class(%SQL.Statement).%ExecDirect(statement,sql)
2872+
}
2873+
}
2874+
28292875
}

csp/gitprojectsettings.csp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,35 @@ body {
550550
</div> -->
551551
</div>
552552

553+
<div class="form-group row mb-3">
554+
<label for="addToFav" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Favorite namespaces for user. For Windows/Mac: Hold down the control(ctrl)/command(cmd) button to select multiple options.">Favorite Namespaces</label>
555+
<div class="col-sm-7">
556+
<select multiple class="form-control" id="addToFav" name="favNamespace">
557+
<server>
558+
set contextList = ##class(SourceControl.Git.Utils).GetContexts(1)
559+
set selectedNamespaces = [].%FromJSON(settings.favoriteNamespaces)
560+
set iterator = selectedNamespaces.%GetIterator()
561+
while iterator.%GetNext(.key, .value) {
562+
&html<<option selected value=#(value)#>#(value)#</option>>
563+
set k = -1
564+
set citerator = contextList.%GetIterator()
565+
while citerator.%GetNext(.ckey, .cvalue) {
566+
if (cvalue = value) {
567+
set k = ckey
568+
}
569+
}
570+
if (k > -1) {
571+
do contextList.%Remove(k)
572+
}
573+
}
574+
set iterator = contextList.%GetIterator()
575+
while iterator.%GetNext(.key, .value) {
576+
&html<<option value=#(value)#>#(value)#</option>>
577+
}
578+
</server>
579+
</select>
580+
</div>
581+
</div>
553582
<br/>
554583
</fieldset>
555584

0 commit comments

Comments
 (0)