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

add system settings #634

Merged
merged 6 commits into from
Nov 18, 2024
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
- Production Decomposition mode allows controlling interoperability productions as individual files for each host (#469)
- Added saving settings as system default for new namespaces (#535)

## [2.7.1] - 2024-11-13

Expand Down
22 changes: 22 additions & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ ClassMethod CreateNamespaceTempFolder() As %Status
ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
{
do %code.WriteLine(" set inst = ..%New()")
do %code.WriteLine(" do inst.RetrieveDefaults()")
set defaultPromptFlag = $$$DisableBackupCharMask + $$$TrapCtrlCMask + $$$EnableQuitCharMask + $$$DisableHelpCharMask + $$$DisableHelpContextCharMask + $$$TrapErrorMask
set property = ""
for {
Expand Down Expand Up @@ -483,4 +484,25 @@ Method ConfigureBinPath(ByRef path As %String) As %Boolean
return 1
}

Method RetrieveDefaults() As %Boolean
{
do ##class(%zpkg.isc.sc.git.Defaults).GetDefaultSettings(.settings)
set iterator = settings.%GetIterator()
while iterator.%GetNext(.key, .value) {
set $property($this,key) = value
}
return $$$OK
}

Method SaveDefaults() As %Boolean
{
set defaults = {}
set items = $lb("gitBinPath", "pullEventClass", "percentClassReplace", "environmentName", "systemBasicMode", "defaultMergeBranch", "mappedItemsReadOnly", "compileOnImport")
for i=1:1:$LISTLENGTH(items) {
set property = $listget(items,i)
do defaults.%Set(property, $property($this, property))
}
return ##class(%zpkg.isc.sc.git.Defaults).SetDefaultSettings(defaults)
}

}
62 changes: 62 additions & 0 deletions cls/_zpkg/isc/sc/git/Defaults.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Class %zpkg.isc.sc.git.Defaults
{

ClassMethod GetDefaults() As %Library.DynamicObject [ NotInheritable, Private ]
{
set defaults = {}
set storage = "^%SYS(""SourceControl"",""Git"",""defaults"")"
$$$AddAllRoleTemporary

set key = $order(@storage@(""))
while key '= "" {
do defaults.%Set(key, $get(@storage@(key)))
set key = $order(@storage@(key))
}
return defaults
}

ClassMethod GetDefaultSettings(ByRef defaults As %Library.DynamicObject) As %Status
{
try {
set defaults = ..GetDefaults()
} catch e {
return e.AsStatus()
}
return $$$OK
}

ClassMethod SetDefaults(defaults As %Library.DynamicObject) As %Status [ NotInheritable, Private ]
{

$$$AddAllRoleTemporary
set storage = "^%SYS(""SourceControl"",""Git"",""defaults"")"
k @storage
set iterator = defaults.%GetIterator()

while iterator.%GetNext(.key, .value) {
set @storage@(key) = value
}

return $$$OK
}

ClassMethod SetDefaultSettings(defaults As %Library.DynamicObject) As %Status [ NotInheritable ]
{

set newDefaults = {}

set iterator = defaults.%GetIterator()

while iterator.%GetNext(.key, .value) {
do newDefaults.%Set(key, value)
}

try {
do ..SetDefaults(newDefaults)
} catch e {
return e.AsStatus()
}
return $$$OK
}

}
44 changes: 32 additions & 12 deletions csp/gitprojectsettings.csp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ body {
}

set settings.favoriteNamespaces = contexts

if ($get(%request.Data("proxySubmitButton",1)) = "saveDefaults") {
do settings.SaveDefaults()
}
}
set err = ""
try {
Expand Down Expand Up @@ -226,7 +230,7 @@ body {

<fieldset id="namespaceSettings">
<div class="form-group row mb-3">
<label for="gitBinPath" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to the Git executable">Path to git.exe</label>
<label for="gitBinPath" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to the Git executable"><b>Path to git.exe</b></label>
<div class="col-sm-7">
<server>
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
Expand Down Expand Up @@ -345,7 +349,7 @@ body {
</server>

<div class="form-group row mb-3">
<label for="pullEventClass" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Handler class for git pull">Pull Event Class</label>
<label for="pullEventClass" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Handler class for git pull"><b>Pull Event Class</b></label>
<div class="col-sm-7">
<select class="form-control" id="pullEventClass" name="pullEventClass">
<server>
Expand All @@ -361,7 +365,7 @@ body {
</div>

<div class="form-group row mb-3">
<label for="environmentName" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Environment Name">Environment Name</label>
<label for="environmentName" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Environment Name"><b>Environment Name</b></label>
<div class="col-sm-7">
<select class="form-control" id="environmentName" name="environmentName">
<server>
Expand All @@ -375,14 +379,14 @@ body {
</div>

<div class="form-group row mb-3">
<label for="percentClassReplace" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Character(s) to replace '%' with for percent classes while exporting them out to the filesystem. By default, the '%' is removed.">'%' Replacement on Export</label>
<label for="percentClassReplace" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Character(s) to replace '%' with for percent classes while exporting them out to the filesystem. By default, the '%' is removed."><b>'%' Replacement on Export</b></label>
<div class="col-sm-7">
<input type="text" class="form-control" id="percentClassReplace" name="percentClassReplace" value='#(..EscapeHTML(settings.percentClassReplace))#' placeholder="_, __, <empty>, etc."/>
</div>
</div>

<div class="form-group row mb-3">
<label for="systemBasicMode" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Enable basic mode for all users, which reduces the number of menu options and requires less knowledge of git. This is suitable for a single-developer (non-shared) namespace."> Basic Mode as System Default</label>
<label for="systemBasicMode" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Enable basic mode for all users, which reduces the number of menu options and requires less knowledge of git. This is suitable for a single-developer (non-shared) namespace."><b> Basic Mode as System Default</b></label>
<div class="col-sm-7">

<div class="custom-control custom-switch custom-switch-no-border">
Expand All @@ -403,14 +407,14 @@ body {
</div>

<div class="form-group row mb-3">
<label for="defaultMergeBranch" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="In basic mode, the Sync operation will merge changes from this remote branch (leave blank for no branch)">Default merge branch</label>
<label for="defaultMergeBranch" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="In basic mode, the Sync operation will merge changes from this remote branch (leave blank for no branch)"><b>Default merge branch</b></label>
<div class="col-sm-7">
<input type="text" class="form-control" id="defaultMergeBranch" name="defaultMergeBranch" value='#(..EscapeHTML(settings.defaultMergeBranch))#' placeholder="sample-remote-branch">
</div>
</div>

<div class="form-group row mb-3">
<label for="remoteRepo" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Url to Remote repository">Remote Repository</label>
<label for="remoteRepo" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Url to Remote repository"><b>Remote Repository</b></label>
<div class="col-sm-7">
<input type="text" class="form-control" id="remoteRepo" name="remoteRepo" value='#(..EscapeHTML(remote))#' placeholder="ex. [email protected]:User/UserRepo.git"/>
<div class = "neutral-feedback">
Expand All @@ -420,7 +424,7 @@ body {
</div>

<div class="form-group row mb-3">
<label for="mappedItemsReadOnly" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Whether items mapped from a database other than this namespace's default routine database should be read-only. If enabled, mapped items won't be saved to source control or exported. NOTE: These are different from the mappings configured in this settings page"> Treat Mapped Items as Read-only</label>
<label for="mappedItemsReadOnly" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Whether items mapped from a database other than this namespace's default routine database should be read-only. If enabled, mapped items won't be saved to source control or exported. NOTE: These are different from the mappings configured in this settings page"><b> Treat Mapped Items as Read-only</b></label>
<div class="col-sm-7">

<div class="custom-control custom-switch custom-switch-no-border">
Expand All @@ -440,7 +444,7 @@ body {

</div>
<div class="form-group row mb-3">
<label for="compileOnImport" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="If true, the Import All options will compile imported options using the configured pull event handler">Compile Items on Import</label>
<label for="compileOnImport" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="If true, the Import All options will compile imported options using the configured pull event handler"><b>Compile Items on Import</b></label>
<div class="col-sm-7">
<div class="custom-control custom-switch custom-switch-no-border">
<input class="custom-control-input" name="compileOnImport" type="checkbox"
Expand Down Expand Up @@ -586,7 +590,7 @@ body {
</div>

<div class="form-group row mb-3">
<label for="gitUserEmail" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="<git-username-on-remote>@remote.com">Git Committer Email </label>
<label for="gitUserEmail" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="<git-username-on-remote>@remote.com">Git Committer Email</label>
<div class="col-sm-7">
<input type="email" class="form-control" id="gitUserEmail" name="gitUserEmail" value='#(..EscapeHTML(settings.gitUserEmail))#'/>
</div>
Expand Down Expand Up @@ -649,7 +653,7 @@ body {
</div>

<div class="form-group row mb-3">
<label for="addToFav" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Favorite namespaces for user to add link on Home page.">Favorite Namespaces</label>
<label for="addToFav" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Favorite namespaces for user to add link on Home page.">*Favorite Namespaces</label>
<div class="col-sm-7">
<select multiple class="form-control" id="addToFav" name="favNamespace">
<server>
Expand All @@ -674,7 +678,12 @@ body {

<div class="form-group row mb-3">
<div class="col-sm-12 text-center">
<input type='submit' class="btn-lg btn-primary" value = 'Save'/>
<input type="hidden" id="proxySubmitButton" name="proxySubmitButton" value="Save">
<input type='submit' class="btn-lg btn-primary" value = 'Save' name="Save"/>
<input type="submit" class="btn-lg btn-primary" id="saveDefaults" value = 'Save as Instance Defaults' title="Save these settings as default for new instances" name="saveDefaults"/>
<div>
<small> Settings saved as default are <b>bolded </b> </small>
</div>
</div>
</div>

Expand All @@ -701,6 +710,17 @@ function getSocket(urlPostfix) {
return new WebSocket(socketURL);
}

var submitForm = function(e) {
e.preventDefault();
e.stopPropagation();
var proxySubmitButton = document.getElementById('proxySubmitButton');
proxySubmitButton.value = "saveDefaults";
var form = document.getElementById('settingsForm');
form.submit();
}

document.getElementById('saveDefaults').addEventListener('click',submitForm,false);

function init() {
disableActionButtons();
var root = document.getElementById("namespaceTemp").value;
Expand Down
Loading