Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…trol into map-expand-env
  • Loading branch information
isc-pbarton committed Nov 19, 2024
2 parents 1e39855 + ebf933e commit b325291
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \<env\> 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

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
24 changes: 23 additions & 1 deletion git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}
});

// Search bar to filter the results
if (idPostfix =='popup') {
var searchBar = $('<input type="text" id="search-input" placeholder="Filter..." style="width:100%">').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] == ')') {
Expand All @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
ref = ' ' + newref;
}
}
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
var cardDiv = $('<div class="card custom-card branch-card">').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);
Expand Down
24 changes: 23 additions & 1 deletion git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}
});

// Search bar to filter the results
if (idPostfix =='popup') {
var searchBar = $('<input type="text" id="search-input" placeholder="Filter..." style="width:100%">').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] == ')') {
Expand All @@ -405,7 +427,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
ref = ' ' + newref;
}
}
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
var cardDiv = $('<div class="card custom-card branch-card">').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);
Expand Down

0 comments on commit b325291

Please sign in to comment.