diff --git a/CHANGELOG.md b/CHANGELOG.md index 87f68158..08a76457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ 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) - Mapping configuration supports parameter expansion of \ to the environment name (#640) +- Added saving settings as system default for new namespaces (#535) +- Added filtering through branch names in UI (#615) ## [2.7.1] - 2024-11-13 diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index ed533baa..2171b9f0 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -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 { @@ -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) +} + } diff --git a/cls/_zpkg/isc/sc/git/Defaults.cls b/cls/_zpkg/isc/sc/git/Defaults.cls new file mode 100644 index 00000000..4ce7dc7c --- /dev/null +++ b/cls/_zpkg/isc/sc/git/Defaults.cls @@ -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 +} + +} \ No newline at end of file diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 19d5f9cd..8264b3fa 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -165,6 +165,10 @@ body { } set settings.favoriteNamespaces = contexts + + if ($get(%request.Data("proxySubmitButton",1)) = "saveDefaults") { + do settings.SaveDefaults() + } } set err = "" try { @@ -226,7 +230,7 @@ body {
- +
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version) @@ -345,7 +349,7 @@ body {
- +
@@ -375,14 +379,14 @@ body {
- +
- +
@@ -403,14 +407,14 @@ body {
- +
- +
- +
@@ -440,7 +444,7 @@ body {
- +
- +
@@ -649,7 +653,7 @@ body {
- +
+ + + +
+ Settings saved as default are bolded +
@@ -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; diff --git a/git-webui/release/share/git-webui/webui/js/git-webui.js b/git-webui/release/share/git-webui/webui/js/git-webui.js index 6a7972f5..7c3acf18 100644 --- a/git-webui/release/share/git-webui/webui/js/git-webui.js +++ b/git-webui/release/share/git-webui/webui/js/git-webui.js @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) { } }); + // Search bar to filter the results + if (idPostfix =='popup') { + var searchBar = $('').appendTo(accordionDiv)[0]; + searchBar.onkeyup = function(){ + let branchCards = accordionDiv.getElementsByClassName("branch-card"); + + var filter = searchBar.value.toUpperCase().replaceAll('/', '-'); + + for (let i = 0; i < branchCards.length; i++) { + let card = branchCards[i] + let cardHeader = card.querySelector('.card-header'); + if (cardHeader) { + if (cardHeader.id.toUpperCase().indexOf(filter) > -1) { + card.style.display = ''; + } else { + card.style.display = 'none'; + } + } + } + }; + } + for (var i = 0; i < refs.length && i < maxRefsCount; ++i) { var ref = refs[i] + ""; // Get a copy of it if (ref[2] == '(' && ref[ref.length - 1] == ')') { @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) { ref = ' ' + newref; } } - var cardDiv = $('
').appendTo(accordionDiv)[0]; + var cardDiv = $('
').appendTo(accordionDiv)[0]; if (id.indexOf("local-branches") > -1) { // parses the output of git branch --verbose --verbose var matches = /^\*?\s*([\w-.@&_\/]+)\s+([^\s]+)\s+(\[.*\])?.*/.exec(ref); diff --git a/git-webui/src/share/git-webui/webui/js/git-webui.js b/git-webui/src/share/git-webui/webui/js/git-webui.js index 6a7972f5..7c3acf18 100644 --- a/git-webui/src/share/git-webui/webui/js/git-webui.js +++ b/git-webui/src/share/git-webui/webui/js/git-webui.js @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) { } }); + // Search bar to filter the results + if (idPostfix =='popup') { + var searchBar = $('').appendTo(accordionDiv)[0]; + searchBar.onkeyup = function(){ + let branchCards = accordionDiv.getElementsByClassName("branch-card"); + + var filter = searchBar.value.toUpperCase().replaceAll('/', '-'); + + for (let i = 0; i < branchCards.length; i++) { + let card = branchCards[i] + let cardHeader = card.querySelector('.card-header'); + if (cardHeader) { + if (cardHeader.id.toUpperCase().indexOf(filter) > -1) { + card.style.display = ''; + } else { + card.style.display = 'none'; + } + } + } + }; + } + for (var i = 0; i < refs.length && i < maxRefsCount; ++i) { var ref = refs[i] + ""; // Get a copy of it if (ref[2] == '(' && ref[ref.length - 1] == ')') { @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) { ref = ' ' + newref; } } - var cardDiv = $('
').appendTo(accordionDiv)[0]; + var cardDiv = $('
').appendTo(accordionDiv)[0]; if (id.indexOf("local-branches") > -1) { // parses the output of git branch --verbose --verbose var matches = /^\*?\s*([\w-.@&_\/]+)\s+([^\s]+)\s+(\[.*\])?.*/.exec(ref);