Skip to content
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

Added configurable flag to make settings UI read-only #281

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Web UI includes a "Push Branch" button for local branches that are ahead of upstream
- Support for making the Settings UI read-only through `##class(SourceControl.Git.API).Configure()` (#258)
- Stash option in the Web UI now includes untracked files
- Added "Status" menu item to editor menu (#285)

Expand Down
5 changes: 5 additions & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Property pullEventClass As %String(MAXLEN = 255) [ InitialExpression = {##class(
/// Character to replace % symbol when importing %-classes into the file systems
Property percentClassReplace As %String [ InitialExpression = {##class(SourceControl.Git.Utils).PercentClassReplace()} ];

/// Git project settings are read-only in the web user interface
Property settingsUIReadOnly As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).SettingsUIReadOnly()} ];

/// Attribution: Git username for user ${username}
Property gitUserName As %String(MAXLEN = 255) [ InitialExpression = {##class(SourceControl.Git.Utils).GitUserName()} ];

Expand Down Expand Up @@ -76,6 +79,7 @@ Method %Save() As %Status
set @storage@("settings","ssh","privateKeyFile") = ..privateKeyFile
set @storage@("settings","pullEventClass") = ..pullEventClass
set @storage@("settings","percentClassReplace") = ..percentClassReplace
set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly

kill @##class(SourceControl.Git.Utils).MappingsNode()
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings
Expand Down Expand Up @@ -173,3 +177,4 @@ Method OnAfterConfigure() As %Boolean
}

}

5 changes: 5 additions & 0 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ ClassMethod PercentClassReplace() As %Status [ CodeMode = expression ]
$Get(@..#Storage@("settings","percentClassReplace"), "")
}

ClassMethod SettingsUIReadOnly() As %Status [ CodeMode = expression ]
{
$Get(@..#Storage@("settings","settingsUIReadOnly"), 0)
}

/// Returns the current (or previous) value of the flag.
ClassMethod Locked(newFlagValue As %Boolean) As %Boolean
{
Expand Down
41 changes: 27 additions & 14 deletions csp/gitprojectsettings.csp
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,33 @@ body {
set webuiURL = ##class(SourceControl.Git.WebUIDriver).GetURLPrefix(%request, webuiURL)

set settings = ##class(SourceControl.Git.Settings).%New()

if $Data(%request.Data("gitsettings",1)) {
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace","gitUserName","gitUserEmail"{
for param="gitUserName","gitUserEmail" {
set $Property(settings,param) = $Get(%request.Data(param,1))
}
set i = 1
set param = "NoFolders"
kill settings.Mappings

while ( $Data(%request.Data("MappingsExt",i)) ){
if ('settings.settingsUIReadOnly) {
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace" {
set $Property(settings,param) = $Get(%request.Data(param,1))
}
set i = 1
set param = "NoFolders"
kill settings.Mappings

while ( $Data(%request.Data("MappingsExt",i)) ){
if ($get(%request.Data("MappingsExt",i)) '= "") {
if ($Get(%request.Data(param,i)) = "NoFolders"){
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i)), $Get(%request.Data(param,i))) = 1
}
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data("MappingsPath",i))
if ($Get(%request.Data(param,i)) = "NoFolders"){
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i)), $Get(%request.Data(param,i))) = 1
}
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data("MappingsPath",i))
}
set i = i+1
}
set i = i+1
}
do settings.%Save()
}
</server>
<div class = 'container'>
<form method='post'>
<form id="settingsForm" method='post'>
<input type="hidden" name="Namespace" value="#(..EscapeHTML(namespace))#" />
<input type="hidden" name="gitsettings" value="1" />
<div class="col-sm-12"><br></div>
Expand All @@ -108,10 +112,11 @@ body {
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-11">
<h3>Settings for namespace #(..EscapeHTML(namespace))#</h3><br/>
<h3>Settings for namespace #(..EscapeHTML(namespace))# #($select(settings.settingsUIReadOnly:"(read-only)",1:""))#</h3><br/>
</div>
</div>

<fieldset id="namespaceSettings">
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<label for="gitBinPath" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to the Git executable">Path to git.exe</label>
Expand Down Expand Up @@ -342,6 +347,7 @@ body {
}
</script>
</div>
</fieldset>

<br/>
<div class="row">
Expand All @@ -360,6 +366,7 @@ body {

<br/>

<fieldset id="userSettings">
<div class="form-group row mb-3">
<div class="col-sm-1"></div>
<label for="gitUserName" class="col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Firstname Lastname">Git Committer Name </label>
Expand All @@ -377,6 +384,7 @@ body {
</div>

<br/>
</fieldset>

<div class="form-group row mb-3">
<div class="col-sm-12 text-center">
Expand Down Expand Up @@ -446,6 +454,11 @@ $(function () {
});
$(function()
{
if (#(settings.settingsUIReadOnly)#) {
$(document).ready( function() {
$("#namespaceSettings input, select").attr("disabled",true);
})
}
$(document).on('click', '.btn-add', function(e)
{
e.preventDefault();
Expand Down
Loading