diff --git a/CHANGELOG.md b/CHANGELOG.md index c9fc0404..a2738c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 5e3ed17a..3facb068 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -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()} ]; @@ -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 @@ -173,3 +177,4 @@ Method OnAfterConfigure() As %Boolean } } + diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 5c622371..0242a4e5 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -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 { diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index b89a782b..f06acdeb 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -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() }