Skip to content

Commit f2ef459

Browse files
authored
Merge pull request #538 from intersystems/fix-468
Simplify favorites and landing page for multi-namespace setup
2 parents daae595 + fff9b25 commit f2ef459

File tree

9 files changed

+149
-18
lines changed

9 files changed

+149
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Added 'git push --force' in expert mode (#527)
1212
- Add remote repository to settings page (#448)
13+
- Added change context option to pull page (#468)
14+
- Added favorite namespaces setting for a user (#468, #510)
1315
- Added environment awareness in configuration, and showing of environment name in UI (#124)
1416

1517
### Fixed
1618
- Fixed display of other users' username in workspace view on Unix (#530)
1719
- Fix left-sidebar spacing (#525)
1820
- Fixed slowness loading some CSP pages with multiple instances sharing a webserver (#540)
1921
- Prevent direct commits to default merge branch in basic mode (#484)
22+
- Fixed GetContexts utils function to exclude implied namespaces from the list of namespaces (#468)
2023
- Fixed git path configuration (#463)
2124
- Added feedback to settings page (#550)
2225
- Fix "Home" navigation to point to current namespace (#548)

cls/SourceControl/Git/Settings.cls

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class(
5858

5959
Property Mappings [ MultiDimensional ];
6060

61+
Property favoriteNamespaces As %DynamicArray;
62+
6163
Method %OnNew() As %Status
6264
{
6365
set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode()
@@ -69,6 +71,7 @@ Method %OnNew() As %Status
6971
if ('isDefault) {
7072
set ..gitBinPath = gitBinPath
7173
}
74+
set ..favoriteNamespaces = ##class(SourceControl.Git.Utils).FavoriteNamespaces()
7275
quit $$$OK
7376
}
7477

@@ -130,9 +133,11 @@ Method %Save() As %Status
130133
// update value of basicUserMode to reflect the updated setting for basicMode
131134
set ..userBasicMode = ##class(SourceControl.Git.Utils).UserBasicMode()
132135

133-
134136
kill @##class(SourceControl.Git.Utils).MappingsNode()
135137
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
138+
139+
do ##class(SourceControl.Git.Utils).ConfigureFavoriteNamespaces($username, ..favoriteNamespaces)
140+
136141
quit $$$OK
137142
}
138143

@@ -163,6 +168,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
163168
set sequence = $order(orderedProperties(sequence),1,property)
164169
quit:sequence=""
165170
continue:property="userBasicMode"
171+
continue:property="favoriteNamespaces"
166172
do %code.WriteLine(" set value = inst."_property)
167173
set prompt = $$$comMemberKeyGet(%class.Name,$$$cCLASSproperty,property,$$$cPROPdescription)
168174
set promptQuoted = $$$QUOTE(prompt_":")

cls/SourceControl/Git/Utils.cls

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

75+
ClassMethod FavoriteNamespaces() As %String
76+
{
77+
set favNamespaces = []
78+
do ..GetFavoriteNamespaces(.favNamespaces,[])
79+
return favNamespaces
80+
}
81+
7582
/// Returns the current (or previous) value of the flag.
7683
ClassMethod Locked(newFlagValue As %Boolean) As %Boolean
7784
{
@@ -2490,28 +2497,32 @@ ClassMethod Localize()
24902497
}
24912498
}
24922499

2493-
ClassMethod GetContexts() As %DynamicArray
2500+
ClassMethod GetContexts(onlyNamespaces As %Boolean) As %DynamicArray
24942501
{
24952502
set contexts = []
24962503
set namespaces = ..GetGitEnabledNamespaces()
24972504
set ptr = 0
24982505
while $listnext(namespaces,ptr,value) {
2499-
do contexts.%Push(value)
2506+
if '($FIND(value,"^^")){
2507+
do contexts.%Push(value)
2508+
}
25002509
}
25012510

25022511
set name = ""
25032512

25042513
// Using embedded for backwards compatability
2505-
&sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM'))
2506-
&sql(OPEN C1)
2507-
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2508-
&sql(FETCH C1)
2509-
while(SQLCODE = 0) {
2510-
set package = name
2511-
do contexts.%Push(package)
2514+
if '(onlyNamespaces) {
2515+
&sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM'))
2516+
&sql(OPEN C1)
2517+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
25122518
&sql(FETCH C1)
2519+
while(SQLCODE = 0) {
2520+
set package = name
2521+
do contexts.%Push(package)
2522+
&sql(FETCH C1)
2523+
}
2524+
&sql(CLOSE C1)
25132525
}
2514-
&sql(CLOSE C1)
25152526

25162527
return contexts
25172528
}
@@ -2849,4 +2860,55 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean
28492860
quit 0
28502861
}
28512862

2863+
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
2864+
{
2865+
// Delete all the GIT favorite links for the user
2866+
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
2867+
2868+
set iterator = newNamespaces.%GetIterator()
2869+
while iterator.%GetNext(.key, .value) {
2870+
set installNamespace = value
2871+
2872+
// Insert Git link
2873+
set caption = "Git: " _ installNamespace
2874+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
2875+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2876+
2877+
// Insert Git Pull link
2878+
set caption = "Git Pull: " _ installNamespace
2879+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
2880+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2881+
}
2882+
}
2883+
2884+
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
2885+
{
2886+
set allNamespaces = ..GetContexts(1)
2887+
set iterator = allNamespaces.%GetIterator()
2888+
2889+
set username = $USERNAME
2890+
set pagePrefix = "Git:"
2891+
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
2892+
2893+
while iterator.%GetNext(.key, .value) {
2894+
set foundFlag = 0
2895+
&sql(OPEN FavCursor)
2896+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2897+
&sql(FETCH FavCursor)
2898+
while (SQLCODE = 0) {
2899+
set pageValue = "Git: "_value
2900+
if (page = pageValue) {
2901+
do favNamespaces.%Push(value)
2902+
set foundFlag = 1
2903+
}
2904+
&sql(FETCH FavCursor)
2905+
}
2906+
&sql(CLOSE FavCursor)
2907+
2908+
if ('foundFlag) {
2909+
do nonFavNamespaces.%Push(value)
2910+
}
2911+
}
2912+
}
2913+
28522914
}

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
156156
do discardsInBranch.%ToJSON(%data)
157157
set handled = 1
158158
} elseif (pathStart = "contexts") {
159-
set contexts = ##class(SourceControl.Git.Utils).GetContexts()
159+
set onlyNamespaces = %request.Data("onlyNamespaces", 1)
160+
set contexts = ##class(SourceControl.Git.Utils).GetContexts(onlyNamespaces)
160161
do contexts.%ToJSON(%data)
161162
set handled = 1
162163
}

cls/_zpkg/isc/sc/git/Socket.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ClassMethod Run()
1313
{
1414
If %request.Get("method") = "preview" {
1515
Set branchName = ##class(SourceControl.Git.Utils).GetCurrentBranch()
16+
Write !,"Current namespace: ",$NAMESPACE
1617
Write !,"Current branch: ",branchName
1718
Do ##class(SourceControl.Git.Utils).RunGitWithArgs(.errStream, .outStream, "fetch")
1819
Kill errStream, outStream

csp/gitprojectsettings.csp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ body {
151151
}
152152
set i = i+1
153153
}
154+
155+
set i = 1
156+
set contexts = []
157+
158+
while ( $Data(%request.Data("favNamespace",i)) ){
159+
if ($Get(%request.Data("favNamespace",i)) '= "") {
160+
do contexts.%Push($Get(%request.Data("favNamespace",i)))
161+
}
162+
set i = i+1
163+
}
164+
165+
set settings.favoriteNamespaces = contexts
154166
}
155167
do settings.%Save()
156168
}
@@ -591,6 +603,27 @@ body {
591603
</div> -->
592604
</div>
593605

606+
<div class="form-group row mb-3">
607+
<label for="addToFav" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Favorite namespaces for user to add link on Home page.">Favorite Namespaces</label>
608+
<div class="col-sm-7">
609+
<select multiple class="form-control" id="addToFav" name="favNamespace">
610+
<server>
611+
set nonFavNamespaces = []
612+
set selectedNamespaces = []
613+
do ##class(SourceControl.Git.Utils).GetFavoriteNamespaces(.selectedNamespaces,.nonFavNamespaces)
614+
set iterator = selectedNamespaces.%GetIterator()
615+
while iterator.%GetNext(.key, .value) {
616+
&html<<option selected value=#(value)#>#(value)#</option>>
617+
}
618+
set iterator = nonFavNamespaces.%GetIterator()
619+
while iterator.%GetNext(.key, .value) {
620+
&html<<option value=#(value)#>#(value)#</option>>
621+
}
622+
</server>
623+
</select>
624+
<small> Hold the [Ctrl] or [Cmd] key while clicking to select multiple namespaces.</small>
625+
</div>
626+
</div>
594627
<br/>
595628
</fieldset>
596629

csp/pull.csp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@
99
<link rel="stylesheet" type="text/css" href="css/git-webui.css" />
1010
</head>
1111
<body>
12+
<pre for="contextSelect" style="padding-top: 2em;white-space: pre-wrap;height: 60px;">Change Context: <select id="newContext" onchange="updateContext()">
13+
<server>
14+
if $Data(%request.Data("$NAMESPACE",1),namespace)#2 {
15+
set $NAMESPACE = namespace
16+
set contextList = ##class(SourceControl.Git.Utils).GetContexts(1)
17+
set iterator = contextList.%GetIterator()
18+
&html<<option>#(namespace)#</option>>
19+
while iterator.%GetNext(.key, .value) {
20+
if (namespace '= value) {
21+
&html<<option value="#(value)#">#(value)#</option>>
22+
}
23+
}
24+
}
25+
</server>
26+
</select>
27+
</pre>
1228
<pre id="preview" style="white-space: pre-wrap;">
1329
</pre>
1430
<button id="execute" onclick="execute()" disabled="true">Pull and Load Changes</button>
@@ -45,6 +61,11 @@ function execute() {
4561
}
4662
}
4763

64+
function updateContext() {
65+
var contextSelect = document.getElementById('newContext');
66+
window.location.href = "#(%request.URLPrefix)#/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" + contextSelect.value;
67+
}
68+
4869
preview();
4970
</script>
5071
</body>

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ webui.SideBarView = function(mainView, noEventHandlers) {
614614
});
615615
};
616616

617-
self.changeContextGet = function() {
618-
$.get("contexts", function(contextList) {
617+
self.changeContextGet = function(onlyNamespaces) {
618+
$.get("contexts", { "onlyNamespaces": onlyNamespaces }, function(contextList) {
619619
var contexts = JSON.parse(contextList);
620620
self.changeContext(contexts);
621621
});
@@ -1051,7 +1051,9 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10511051
$(".btn-add", self.element).click(self.createNewLocalBranch);
10521052
$('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches);
10531053
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
1054-
$("#sidebar-context", self.element).click(self.changeContextGet);
1054+
$("#sidebar-context", self.element).click(function() {
1055+
self.changeContextGet(0);
1056+
});
10551057
$("#sidebar-home", self.element).click(self.goToHomePage);
10561058
}
10571059

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ webui.SideBarView = function(mainView, noEventHandlers) {
614614
});
615615
};
616616

617-
self.changeContextGet = function() {
618-
$.get("contexts", function(contextList) {
617+
self.changeContextGet = function(onlyNamespaces) {
618+
$.get("contexts", { "onlyNamespaces": onlyNamespaces }, function(contextList) {
619619
var contexts = JSON.parse(contextList);
620620
self.changeContext(contexts);
621621
});
@@ -1051,7 +1051,9 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10511051
$(".btn-add", self.element).click(self.createNewLocalBranch);
10521052
$('.btn-prune-remote-branches', self.element).click(self.pruneRemoteBranches);
10531053
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
1054-
$("#sidebar-context", self.element).click(self.changeContextGet);
1054+
$("#sidebar-context", self.element).click(function() {
1055+
self.changeContextGet(0);
1056+
});
10551057
$("#sidebar-home", self.element).click(self.goToHomePage);
10561058
}
10571059

0 commit comments

Comments
 (0)