-
Notifications
You must be signed in to change notification settings - Fork 9
Sync webui #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Sync webui #441
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d6f265e
implemented Presync part of webui
isc-hwojnick 3cd0382
feat: new UI for the basic mode sync
isc-hwojnick 285e0dc
fix: made UI xss safe and not namespace hard coded
isc-hwojnick 02823a3
fix: removed static namespace change
isc-hwojnick f418206
Merge branch 'main' into sync-webui
isc-hwojnick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> | ||
<link rel="stylesheet" type="text/css" href="css/git-webui.css" /> | ||
#(##class(SourceControl.Git.Utils).GetSourceControlInclude())# | ||
<style type="text/css"> | ||
h1, h2 { | ||
margin-top: 10px | ||
} | ||
|
||
.A::after { | ||
content: "Added"; | ||
position: absolute; | ||
right: 10px; | ||
} | ||
|
||
.D::after { | ||
content: "Deleted"; | ||
position: absolute; | ||
right: 10px; | ||
} | ||
|
||
.M::after { | ||
content: "Modified"; | ||
position: absolute; | ||
right: 10px; | ||
} | ||
|
||
.R::after { | ||
content: "Renamed"; | ||
position: absolute; | ||
right: 10px; | ||
} | ||
|
||
.section-header { | ||
margin: 20px 0 15px 0 | ||
} | ||
|
||
#syncBtn { | ||
position: absolute; | ||
right: 15px; | ||
margin-top: 10px; | ||
} | ||
|
||
.output-header { | ||
margin-top: 120px; | ||
} | ||
.output { | ||
|
||
margin-bottom: 20px; | ||
border: 1.5px solid darkgray; | ||
padding: 10px; | ||
border-radius: 4px; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<server> | ||
set settings = ##class(SourceControl.Git.Settings).%New() | ||
|
||
set uncommittedWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user") | ||
set commitMsg = ##class(SourceControl.Git.Utils).GenerateCommitMessageFromFiles(uncommittedWithAction) | ||
set filesToSync = ($length(commitMsg) > 0) | ||
set fileSectionDisplay = $select( | ||
filesToSync = 1: "block", | ||
1: "none" | ||
) | ||
set noFileDisplay = $select( | ||
filesToSync = 0: "block", | ||
1: "none" | ||
) | ||
|
||
set outputDisplay = "none" | ||
|
||
</server> | ||
|
||
<div class="container"> | ||
<h1 class="text-center">Sync Repository</h1> | ||
<div class="row"> | ||
<div class="offset-sm-2 col-sm-8"> | ||
<div style="display: #(fileSectionDisplay)#"> | ||
<h3 class="section-header">Files to be committed with sync:</h3> | ||
<ul class="list-group"> | ||
<server> | ||
set iterator = uncommittedWithAction.%GetIterator() | ||
while iterator.%GetNext(,.uncommitted) { | ||
set action = uncommitted.%Get("action") | ||
set file = uncommitted.%Get("file") | ||
&html<<li class="list-group-item #(..EscapeHTML(action))#">#(..EscapeHTML(file))#</li>> | ||
} | ||
</server> | ||
</ul> | ||
<h3 class="section-header">Sync commit message:</h3> | ||
<input class="form-control" type="text" name="syncMsg" id="syncMsg" value="#(..EscapeHTML(commitMsg))#"> | ||
</div> | ||
<div style="display: #(noFileDisplay)#"> | ||
<h2 class="text-center">No files to commit with sync</h2> | ||
</div> | ||
<h3 class="section-header">Sync details:</h3> | ||
<p>Upon syncing, the local repository will pull the changes from remote and commit the newest changes before committing and pushing</p> | ||
<server> | ||
|
||
if settings.defaultMergeBranch '= "" { | ||
&html<<p>Local changes will be merged with #(..EscapeHTML(settings.defaultMergeBranch))# after receiving the latest changes</p>> | ||
} | ||
</server> | ||
|
||
<button class="btn btn-lg btn-primary" id="syncBtn" onClick="disableInput(); #server(..PerformSync(self.document.getElementById('syncMsg').value))#">Sync</button> | ||
<div> | ||
<h3 class="output-header" id="outputHeader" style="display: #(outputDisplay)#">Sync output: </h3> | ||
<div class="container output" id="outputContainer" style="display: #(outputDisplay)#"> | ||
<pre id="outputBox"></pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
<script type="text/javascript"> | ||
function disableInput() { | ||
document.getElementById('syncMsg').disabled = true; | ||
document.getElementById('syncBtn').innerHTML = 'Syncing...'; | ||
document.getElementById('syncBtn').disabled = true; | ||
} | ||
</script> | ||
<script language="cache" method="PerformSync" arguments="syncMsg:%String"> | ||
&js<document.getElementById('outputContainer').style.display = 'block'> | ||
&js<document.getElementById('outputHeader').style.display = 'block'> | ||
set buffer = ##class(SourceControl.Git.Util.Buffer).%New() | ||
do buffer.BeginCaptureOutput() | ||
|
||
set st = ##class(SourceControl.Git.Utils).Sync(syncMsg) | ||
|
||
set out = ##class(%Stream.GlobalCharacter).%New() | ||
do buffer.EndCaptureOutput(.out) | ||
while 'out.AtEnd { | ||
set line = out.ReadLine() | ||
set escapedLine = ..EscapeHTML(line) | ||
set escapedLine = $replace(escapedLine, $char(10), "<br>") | ||
|
||
&js< | ||
var outputContainer = document.getElementById('outputBox'); | ||
var lineText = "#(escapedLine)#"; | ||
var lineTextNode = document.createTextNode(lineText); | ||
outputContainer.innerHTML += lineText + "<br>"; | ||
> | ||
} | ||
&js<document.getElementById('syncBtn').innerHTML = 'Synced'> | ||
</script> | ||
</html> | ||
<script method='OnPreHTTP' language='cache' runat='server' returntype='%Boolean'> | ||
try { | ||
set %session.UseSessionCookie = 1 // Always set back to autodetect | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be worth refactoring this to a shared method somewhere since many places use it. Doesn't need to happen in this PR though. |
||
set %session.CookiePath = "" // Always clear | ||
if (%request.UserAgent [ " Code/") { | ||
// Workaround for VSCode webview | ||
set %session.SessionScope = 0 // none; allowed because... | ||
set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it | ||
} | ||
} catch e { | ||
// ignore; may occur on platform versions without the above properties | ||
} | ||
quit 1 | ||
</script> | ||
<script method='OnPreHyperEvent' arguments="class:%String,method:%String" language='cache' runat='server' returntype='%Status'> | ||
try { | ||
set %session.UseSessionCookie = 1 // Always set back to autodetect | ||
set %session.CookiePath = "" // Always clear | ||
if (%request.UserAgent [ " Code/") { | ||
// Workaround for VSCode webview | ||
set %session.SessionScope = 0 // none; allowed because... | ||
set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it | ||
} | ||
} catch e { | ||
// ignore; may occur on platform versions without the above properties | ||
} | ||
quit 1 | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.