From 67e01d4c6bc2234f02edf0fd703c79ed6b33116b Mon Sep 17 00:00:00 2001 From: isc-pbarton <9560941+isc-pbarton@users.noreply.github.com> Date: Tue, 5 Sep 2023 13:50:22 -0400 Subject: [PATCH 1/3] option to make settings read-only in web UI --- cls/SourceControl/Git/Settings.cls | 5 +++ cls/SourceControl/Git/Utils.cls | 6 ++++ csp/gitprojectsettings.csp | 50 +++++++++++++++++------------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 15897a04..8b17d4e4 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()} ]; @@ -72,6 +75,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 @@ -168,3 +172,4 @@ Method OnAfterConfigure() As %Boolean } } + diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index ab159efe..6d89d18c 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 { @@ -1983,3 +1988,4 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status } } + diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 14032beb..ad441031 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -62,34 +62,35 @@ 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"{ - set $Property(settings,param) = $Get(%request.Data(param,1)) - } - set i = 1 - set param = "NoFolders" - kill settings.Mappings - - while ( $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 + if ('settings.settingsUIReadOnly) { + if $Data(%request.Data("gitsettings",1)) { + for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace","gitUserName","gitUserEmail"{ + set $Property(settings,param) = $Get(%request.Data(param,1)) + } + set i = 1 + set param = "NoFolders" + kill settings.Mappings + + while ( $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)) + set i = i+1 } - set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data("MappingsPath",i)) - set i = i+1 + do settings.%Save() } - do settings.%Save() }