Skip to content

Commit 3cd0382

Browse files
committed
feat: new UI for the basic mode sync
1 parent d6f265e commit 3cd0382

File tree

3 files changed

+91
-21
lines changed

3 files changed

+91
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.5.0] - Unreleased
9+
10+
### Added
11+
- New UI for the basic mode Sync (#415)
12+
813
## [2.4.1] - Unreleased
914

1015
### Fixed

cls/SourceControl/Git/Utils.cls

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,19 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
253253
set Action = 7
254254
quit $$$OK
255255
} elseif (menuItemName = "Sync") {
256-
if ..CheckForUncommittedFiles() {
257-
set Target = "Enter a commit message for the sync operation"
258-
set Action = 7
259-
set Msg = ..PreSync()
260-
} else {
261-
set Target = ""
262-
do ..Sync("",.Target)
263-
if (Target '= "") {
264-
set Action = 6
265-
}
266-
}
256+
#; if ..CheckForUncommittedFiles() {
257+
#; set Target = "Enter a commit message for the sync operation"
258+
#; set Action = 7
259+
#; set Msg = ..PreSync()
260+
#; } else {
261+
#; set Target = ""
262+
#; do ..Sync("",.Target)
263+
#; if (Target '= "") {
264+
#; set Action = 6
265+
#; }
266+
#; }
267+
set Action = 2 + externalBrowser
268+
set Target = urlPrefix _ "/isc/studio/usertemplates/gitsourcecontrol/sync.csp"
267269

268270
quit $$$OK
269271
} elseif (menuItemName = "Push") {

csp/sync.csp

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<server>set $NAMESPACE = "USER"</server>
1010
#(##class(SourceControl.Git.Utils).GetSourceControlInclude())#
1111
<style type="text/css">
12-
h1 {
12+
h1, h2 {
1313
margin-top: 10px
1414
}
15+
1516
.A::after {
1617
content: "Added";
1718
position: absolute;
@@ -46,8 +47,11 @@
4647
margin-top: 10px;
4748
}
4849

50+
.output-header {
51+
margin-top: 120px;
52+
}
4953
.output {
50-
margin-top: 100px;
54+
5155
margin-bottom: 20px;
5256
border: 1.5px solid darkgray;
5357
padding: 10px;
@@ -72,6 +76,8 @@
7276
1: "none"
7377
)
7478

79+
set outputDisplay = "none"
80+
7581
</server>
7682

7783
<div class="container">
@@ -94,7 +100,7 @@
94100
<input class="form-control" type="text" name="syncMsg" id="syncMsg" value="#(commitMsg)#">
95101
</div>
96102
<div style="display: #(noFileDisplay)#">
97-
<h1 class="text-center">No files to commit with sync</h1>
103+
<h2 class="text-center">No files to commit with sync</h2>
98104
</div>
99105
<h3 class="section-header">Sync details:</h3>
100106
<p>Upon syncing, the local repository will pull the changes from remote and commit the newest changes before committing and pushing</p>
@@ -105,20 +111,77 @@
105111
}
106112
</server>
107113

108-
<button class="btn btn-lg btn-primary" id="syncBtn" onClick="#server(..PerformSync())#">Sync</button>
114+
<button class="btn btn-lg btn-primary" id="syncBtn" onClick="disableInput()">Sync</button>
109115
<div>
110-
<div class="container output">
111-
116+
<h3 class="output-header" id="outputHeader" style="display: #(outputDisplay)#">Sync output: </h3>
117+
<div class="container output" id="outputContainer" style="display: #(outputDisplay)#">
118+
<pre id="outputBox"></pre>
112119
</div>
113120
</div>
114121
</div>
115122
</div>
116123

117124
</div>
118125
</body>
126+
<script type="text/javascript">
127+
function disableInput() {
128+
document.getElementById('syncMsg').disabled = true;
129+
document.getElementById('syncBtn').innerHTML = 'Syncing...';
130+
document.getElementById('syncBtn').disabled = true;
131+
#server(..PerformSync(self.document.getElementById('syncMsg').value))#
132+
}
133+
</script>
134+
<script language="cache" method="PerformSync" arguments="syncMsg:%String">
135+
&js<document.getElementById('outputContainer').style.display = 'block'>
136+
&js<document.getElementById('outputHeader').style.display = 'block'>
137+
set $NAMESPACE = "USER"
138+
set buffer = ##class(SourceControl.Git.Util.Buffer).%New()
139+
do buffer.BeginCaptureOutput()
140+
141+
set st = ##class(SourceControl.Git.Utils).Sync(syncMsg)
142+
143+
set out = ##class(%Stream.GlobalCharacter).%New()
144+
do buffer.EndCaptureOutput(.out)
145+
while 'out.AtEnd {
146+
set line = out.ReadLine()
147+
set escapedLine = ..EscapeHTML(line)
148+
set escapedLine = $replace(escapedLine, $char(10), "<br>")
119149

120-
<script language="cache" method="PerformSync">
121-
&js<document.getElementById('syncBtn').innerHTML = 'Syncing...'>
122-
&js<document.getElementById('syncBtn').disabled = true>
150+
&js<
151+
var outputContainer = document.getElementById('outputBox');
152+
var lineText = "#(escapedLine)#";
153+
var lineTextNode = document.createTextNode(lineText);
154+
outputContainer.innerHTML += lineText + "<br>";
155+
>
156+
}
157+
&js<document.getElementById('syncBtn').innerHTML = 'Synced'>
123158
</script>
124-
</html>
159+
</html>
160+
<script method='OnPreHTTP' language='cache' runat='server' returntype='%Boolean'>
161+
try {
162+
set %session.UseSessionCookie = 1 // Always set back to autodetect
163+
set %session.CookiePath = "" // Always clear
164+
if (%request.UserAgent [ " Code/") {
165+
// Workaround for VSCode webview
166+
set %session.SessionScope = 0 // none; allowed because...
167+
set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
168+
}
169+
} catch e {
170+
// ignore; may occur on platform versions without the above properties
171+
}
172+
quit 1
173+
</script>
174+
<script method='OnPreHyperEvent' arguments="class:%String,method:%String" language='cache' runat='server' returntype='%Status'>
175+
try {
176+
set %session.UseSessionCookie = 1 // Always set back to autodetect
177+
set %session.CookiePath = "" // Always clear
178+
if (%request.UserAgent [ " Code/") {
179+
// Workaround for VSCode webview
180+
set %session.SessionScope = 0 // none; allowed because...
181+
set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
182+
}
183+
} catch e {
184+
// ignore; may occur on platform versions without the above properties
185+
}
186+
quit 1
187+
</script>

0 commit comments

Comments
 (0)