Skip to content

Commit 8f926a8

Browse files
committed
fix: production config page no longer closes UIs
1 parent f2ef459 commit 8f926a8

File tree

6 files changed

+54
-12
lines changed

6 files changed

+54
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Added feedback to settings page (#550)
2525
- Fix "Home" navigation to point to current namespace (#548)
2626
- Force export of item if it has been modified (#354)
27+
- Production configuration page no longer closes Sync/WebUI when operations there change the production (#542)
2728

2829
## [2.6.0] - 2024-10-07
2930

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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,6 +2594,43 @@ ClassMethod GetSourceControlInclude(prefix As %String = {%request.URLPrefix}) As
25942594
1: "")
25952595
}
25962596

2597+
XData ProductionConfigScript [ MimeType = text/javascript ]
2598+
{
2599+
var reenableRefresh = false;
2600+
2601+
function checkProductionConfigLoad() {
2602+
if (window.parent && window.parent.opener && window.parent.opener.zenPage && window.parent.opener.zenPage.enableAutoRefresh) {
2603+
reenableRefresh = window.parent.opener.zenPage.enableAutoRefresh;
2604+
window.parent.opener.zenPage.enableAutoRefresh = false;
2605+
}
2606+
}
2607+
2608+
function checkProductionConfigUnload() {
2609+
if (reenableRefresh) {
2610+
window.parent.opener.zenPage.enableAutoRefresh = true;
2611+
}
2612+
}
2613+
}
2614+
2615+
ClassMethod ProductionConfigScript() As %String [ CodeMode = objectgenerator ]
2616+
{
2617+
do %code.WriteLine(" set html = ""<script type='text/javascript'>""_$c(13,10)")
2618+
set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen(%compiledclass.Name,%compiledmethod.Name,,.sc)
2619+
$$$ThrowOnError(sc)
2620+
while 'xdata.Data.AtEnd {
2621+
set line = xdata.Data.ReadLine()
2622+
do %code.WriteLine(" set html = html_"_$$Quote^%qcr(line)_"_$c(13,10)")
2623+
}
2624+
do %code.WriteLine(" set html = html_$c(13,10)_""</script>""")
2625+
do %code.WriteLine(" quit html")
2626+
quit $$$OK
2627+
}
2628+
2629+
ClassMethod ProductionConfigBodyAttributes() As %String [ CodeMode = expression ]
2630+
{
2631+
"onload='checkProductionConfigLoad()' onbeforeunload='checkProductionConfigUnload()'"
2632+
}
2633+
25972634
ClassMethod UncommittedWithAction() As %Library.DynamicObject
25982635
{
25992636
do ##class(SourceControl.Git.Change).RefreshUncommitted()

csp/sync.csp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,16 @@
8484

8585

8686
</style>
87+
<script type="text/javascript">
88+
function disableInput() {
89+
document.getElementById('syncMsg').disabled = true;
90+
document.getElementById('syncBtn').innerHTML = 'Syncing...';
91+
document.getElementById('syncBtn').disabled = true;
92+
}
93+
</script>
94+
#(##class(SourceControl.Git.Utils).ProductionConfigScript())#
8795
</head>
88-
<body>
96+
<body #(##class(SourceControl.Git.Utils).ProductionConfigBodyAttributes())#>
8997
<server>
9098
set settings = ##class(SourceControl.Git.Settings).%New()
9199

@@ -158,13 +166,6 @@
158166

159167
</div>
160168
</body>
161-
<script type="text/javascript">
162-
function disableInput() {
163-
document.getElementById('syncMsg').disabled = true;
164-
document.getElementById('syncBtn').innerHTML = 'Syncing...';
165-
document.getElementById('syncBtn').disabled = true;
166-
}
167-
</script>
168169
<script language="cache" method="PerformSync" arguments="syncMsg:%String">
169170
&js<document.getElementById('outputContainer').style.display = 'block'>
170171
&js<document.getElementById('outputHeader').style.display = 'block'>

git-webui/release/share/git-webui/webui/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<link rel="stylesheet" type="text/css" href="css/git-webui.css" />
2929
<link rel="icon" href="img/git-icon.png" />
3030
</head>
31-
<body>
31+
<body {{bodyAttrs}}>
3232
<!-- Error modal dialog -->
3333
<div class="modal fade" id="error-modal" tabindex="-1" role="dialog">
3434
<div class="modal-dialog">

git-webui/src/share/git-webui/webui/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<link rel="stylesheet" type="text/css" href="css/git-webui.css" />
2929
<link rel="icon" href="img/git-icon.png" />
3030
</head>
31-
<body>
31+
<body {{bodyAttrs}}>
3232
<!-- Error modal dialog -->
3333
<div class="modal fade" id="error-modal" tabindex="-1" role="dialog">
3434
<div class="modal-dialog">

0 commit comments

Comments
 (0)