Skip to content

Commit 5f1a1e5

Browse files
authored
Merge branch 'main' into issue-549
2 parents aa661ce + 708ce31 commit 5f1a1e5

File tree

14 files changed

+248
-45
lines changed

14 files changed

+248
-45
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,26 @@ 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)
16+
- Warning on sync page if other users have unstaged changes (#493)
17+
- Added "Export System Default Settings" menu item (#544)
1418

1519
### Fixed
1620
- Fixed display of other users' username in workspace view on Unix (#530)
1721
- Fix left-sidebar spacing (#525)
1822
- Fixed slowness loading some CSP pages with multiple instances sharing a webserver (#540)
1923
- Prevent direct commits to default merge branch in basic mode (#484)
24+
- Fixed GetContexts utils function to exclude implied namespaces from the list of namespaces (#468)
2025
- Fixed git path configuration (#463)
2126
- Added feedback to settings page (#550)
2227
- Fix "Home" navigation to point to current namespace (#548)
2328
- Fixed issues when user checks out nonexistent branch (#549)
2429
- Fixed checking out branch with uncommitted work (#539)
30+
- Make sure more fetch calls prune the remote branches (#471)
31+
- Force export of item if it has been modified (#354)
32+
- Production configuration page no longer closes Sync/WebUI when operations there change the production (#542)
2533

2634
## [2.6.0] - 2024-10-07
2735

cls/SourceControl/Git/Extension.cls

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ XData Menu
2929
<MenuItem Name="NewBranch" />
3030
<MenuItem Name="SwitchBranch" />
3131
<MenuItem Separator="true"/>
32+
<MenuItem Name="ExportSystemDefaults" />
3233
<MenuItem Name="Export" />
3334
<MenuItem Name="ExportForce" />
3435
<MenuItem Name="Import" />
@@ -125,6 +126,7 @@ Method LocalizeName(name As %String) As %String
125126
"Settings":$$$Text("@Settings@Settings"),
126127
"Init":$$$Text("@Init@Initialize"),
127128
"GitWebUI":$$$Text("@GitWebUI@Launch Git UI"),
129+
"ExportSystemDefaults":$$$Text("@ExportSystemDefaults@Export System Default Settings"),
128130
"Export":$$$Text("@Export@Export All"),
129131
"ExportForce":$$$Text("@ExportForce@Export All (Force)"),
130132
"Import":$$$Text("@Import@Import All"),
@@ -160,6 +162,11 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
160162
quit ..OnSourceMenuContextItem(InternalName,name,.Enabled,.DisplayName)
161163
}
162164

165+
if name = "ExportSystemDefaults" {
166+
set Enabled = ##class(%Library.EnsembleMgr).IsEnsembleNamespace()
167+
quit $$$OK
168+
}
169+
163170
if ##class(SourceControl.Git.Utils).BasicMode() {
164171
set Enabled = $CASE(name,
165172
"Status": 1,
@@ -171,7 +178,6 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
171178
"Sync": 1,
172179
"": 1,
173180
:-1
174-
175181
)
176182
} else {
177183
set Enabled = $CASE(name,
@@ -328,7 +334,8 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
328334
} else {
329335
set filename = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
330336
$$$ThrowOnError(##class(SourceControl.Git.Utils).RemoveRoutineTSH(InternalName))
331-
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName))
337+
set forceExport = (InternalName'= "") && ($data(..Modified(InternalName)))
338+
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName,,forceExport))
332339
if '##class(SourceControl.Git.Change).IsUncommitted(filename) {
333340
$$$ThrowOnError(##class(SourceControl.Git.Change).SetUncommitted(filename, "edit", InternalName, $username, "", 1, "", "", 0))
334341
}

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/StreamServer.cls

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ ClassMethod OnPage() As %Status
88
{
99
if (%stream '= $$$NULLOREF) && $data(%base)#2 {
1010
set sourceControlInclude = ##class(SourceControl.Git.Utils).GetSourceControlInclude()
11+
set bodyAttrs = ##class(SourceControl.Git.Utils).ProductionConfigBodyAttributes()
12+
set configScript = ##class(SourceControl.Git.Utils).ProductionConfigScript()
1113
while '%stream.AtEnd {
12-
set text = %stream.Read()
14+
set text = %stream.Read(1000000)
1315
set text = $replace(text,"{{baseHref}}",..EscapeHTML(%base))
14-
write $replace(text,"{{sourceControlInclude}}",sourceControlInclude)
16+
set text = $replace(text,"{{bodyAttrs}}",bodyAttrs)
17+
write $replace(text,"{{sourceControlInclude}}",sourceControlInclude_$$$NL_configScript)
1518
}
1619
quit $$$OK
1720
}

cls/SourceControl/Git/Utils.cls

Lines changed: 124 additions & 12 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
{
@@ -251,6 +258,8 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
251258
if ec {
252259
write !,"==export done==",!
253260
}
261+
} elseif (menuItemName = "ExportSystemDefaults") {
262+
set ec = ..ExportSystemDefaults()
254263
} elseif (menuItemName = "Import") {
255264
set ec = ..ImportAll()
256265
set Reload = 1
@@ -576,7 +585,7 @@ ClassMethod Push(remote As %String = "origin", force As %Boolean = 0) As %Status
576585

577586
ClassMethod Fetch(ByRef diffFiles) As %Status
578587
{
579-
do ..RunGitCommand("fetch", .errStream, .outStream)
588+
do ..RunGitCommand("fetch", .errStream, .outStream, "--prune")
580589
write !, "Fetch done"
581590
kill errStream, outStream
582591
do ..RunGitCommand("diff", .errStream, .outStream, "..origin/"_..GetCurrentBranch(), "--name-only")
@@ -1630,6 +1639,13 @@ ClassMethod ExportAll(force As %Boolean = 0) As %Status
16301639
quit ..ExportRoutines(force)
16311640
}
16321641

1642+
ClassMethod ExportSystemDefaults() As %Status
1643+
{
1644+
new %SourceControl
1645+
do ##class(%Studio.SourceControl.Interface).SourceControlCreate()
1646+
quit %SourceControl.OnAfterSave("Ens.Config.DefaultSettings.ESD")
1647+
}
1648+
16331649
/// if <var>force</var> = 1 then we import item even if timestamp in system is newer
16341650
ClassMethod ImportAll(force As %Boolean = 0) As %Status
16351651
{
@@ -1852,7 +1868,7 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18521868
set diffBase = ..GetCurrentBranch()
18531869
}
18541870

1855-
do ..RunGitCommand("fetch", .errorStream, .outputStream)
1871+
do ..RunGitCommand("fetch", .errorStream, .outputStream,"--prune")
18561872
kill errorStream, outputStream
18571873
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errorStream,.outputStream, diffBase_$Case(diffCompare,"":"",:"..")_diffCompare, "--name-status")
18581874
do ..ParseDiffStream(outputStream,,.files)
@@ -2505,28 +2521,32 @@ ClassMethod Localize()
25052521
}
25062522
}
25072523

2508-
ClassMethod GetContexts() As %DynamicArray
2524+
ClassMethod GetContexts(onlyNamespaces As %Boolean) As %DynamicArray
25092525
{
25102526
set contexts = []
25112527
set namespaces = ..GetGitEnabledNamespaces()
25122528
set ptr = 0
25132529
while $listnext(namespaces,ptr,value) {
2514-
do contexts.%Push(value)
2530+
if '($FIND(value,"^^")){
2531+
do contexts.%Push(value)
2532+
}
25152533
}
25162534

25172535
set name = ""
25182536

25192537
// Using embedded for backwards compatability
2520-
&sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM'))
2521-
&sql(OPEN C1)
2522-
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2523-
&sql(FETCH C1)
2524-
while(SQLCODE = 0) {
2525-
set package = name
2526-
do contexts.%Push(package)
2538+
if '(onlyNamespaces) {
2539+
&sql(DECLARE C1 CURSOR FOR SELECT name into :name from %Library.RoutineMgr_StudioOpenDialog('*.ZPM'))
2540+
&sql(OPEN C1)
2541+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
25272542
&sql(FETCH C1)
2543+
while(SQLCODE = 0) {
2544+
set package = name
2545+
do contexts.%Push(package)
2546+
&sql(FETCH C1)
2547+
}
2548+
&sql(CLOSE C1)
25282549
}
2529-
&sql(CLOSE C1)
25302550

25312551
return contexts
25322552
}
@@ -2598,6 +2618,47 @@ ClassMethod GetSourceControlInclude(prefix As %String = {%request.URLPrefix}) As
25982618
1: "")
25992619
}
26002620

2621+
XData ProductionConfigScript [ MimeType = text/javascript ]
2622+
{
2623+
function checkProductionConfigLoad() {
2624+
timerState(false);
2625+
}
2626+
2627+
function checkProductionConfigUnload() {
2628+
timerState(true);
2629+
}
2630+
2631+
function timerState(start) {
2632+
if (window.parent && window.parent.opener && window.parent.opener.zenPage) {
2633+
if (start && window.parent.opener.zenPage.startTimers) {
2634+
window.parent.opener.zenPage.startTimers();
2635+
}
2636+
if (!start && window.parent.opener.zenPage.stopTimers) {
2637+
window.parent.opener.zenPage.stopTimers();
2638+
}
2639+
}
2640+
}
2641+
}
2642+
2643+
ClassMethod ProductionConfigScript() As %String [ CodeMode = objectgenerator ]
2644+
{
2645+
do %code.WriteLine(" set html = ""<script type='text/javascript'>""_$c(13,10)")
2646+
set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen(%compiledclass.Name,%compiledmethod.Name,,.sc)
2647+
$$$ThrowOnError(sc)
2648+
while 'xdata.Data.AtEnd {
2649+
set line = xdata.Data.ReadLine()
2650+
do %code.WriteLine(" set html = html_"_$$Quote^%qcr(line)_"_$c(13,10)")
2651+
}
2652+
do %code.WriteLine(" set html = html_$c(13,10)_""</script>""")
2653+
do %code.WriteLine(" quit html")
2654+
quit $$$OK
2655+
}
2656+
2657+
ClassMethod ProductionConfigBodyAttributes() As %String [ CodeMode = expression ]
2658+
{
2659+
"onload='checkProductionConfigLoad()' onbeforeunload='checkProductionConfigUnload()'"
2660+
}
2661+
26012662
ClassMethod UncommittedWithAction() As %Library.DynamicObject
26022663
{
26032664
do ##class(SourceControl.Git.Change).RefreshUncommitted()
@@ -2864,4 +2925,55 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean
28642925
quit 0
28652926
}
28662927

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

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

0 commit comments

Comments
 (0)