Skip to content

Added Environment #520

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

Merged
merged 9 commits into from
Oct 11, 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 @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added 'git push --force' in expert mode (#527)
- Add remote repository to settings page (#448)
- Added environment awareness in configuration, and showing of environment name in UI (#124)

### Fixed
- Fixed display of other users' username in workspace view on Unix (#530)
Expand Down
18 changes: 18 additions & 0 deletions cls/SourceControl/Git/Settings.cls
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Property namespaceLevelGitWebApp As %Boolean [ InitialExpression = {##class(Sour
/// Warn when an item has uncommitted changes in a different namespace in this instance
Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).WarnInstanceWideUncommitted()} ];

/// The name of the environment (DEVELOPMENT, TEST, LIVE)
Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class(SourceControl.Git.Utils).EnvironmentName()} ];

Property Mappings [ MultiDimensional ];

Method %OnNew() As %Status
Expand Down Expand Up @@ -110,11 +113,19 @@ Method %Save() As %Status
set @storage@("settings", "compileOnImport") = ..compileOnImport
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
set @storage@("settings", "basicMode") = ..systemBasicMode
set @storage@("settings", "environmentName") = ..environmentName
if ..basicMode = "system" {
kill @storage@("settings", "user", $username, "basicMode")
} else {
set @storage@("settings", "user", $username, "basicMode") = ..basicMode
}
try {
do $SYSTEM.Version.SystemMode(..environmentName)
} catch e {
// no-op; user might not have privileges.
}



// update value of basicUserMode to reflect the updated setting for basicMode
set ..userBasicMode = ##class(SourceControl.Git.Utils).UserBasicMode()
Expand Down Expand Up @@ -171,6 +182,13 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
do %code.WriteLine(" if value = ""System's Default Mode"" { set value = ""system""}")
do %code.WriteLine(" elseif value = ""Yes"" { set value = 1}")
do %code.WriteLine(" elseif value = ""No"" { set value = 0}")
} elseif ((propertyDef) && (propertyDef.Name = "environmentName")) {
do %code.WriteLine(" set list(1) = ""DEVELOPMENT""")
do %code.WriteLine(" set list(2) = ""TEST""")
do %code.WriteLine(" set list(3) = ""LIVE""")
do %code.WriteLine(" set list(4) = ""FAILOVER""")
do %code.WriteLine(" set list(5) = """"")
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetArray("_promptQuoted_",.value,.list,,,,"_defaultPromptFlag_")")
} else {
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
}
Expand Down
10 changes: 10 additions & 0 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ ClassMethod WarnInstanceWideUncommitted() As %Boolean
quit $get(@..#Storage@("settings","warnInstanceWideUncommitted"),1)
}

ClassMethod EnvironmentName() As %String
{
quit $SYSTEM.Version.SystemMode()
}

ClassMethod IsLIVE() As %Boolean
{
quit ..EnvironmentName()="LIVE"
}

ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ]
{
(..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """")
Expand Down
4 changes: 4 additions & 0 deletions cls/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
}
} elseif $extract(pagePath,6,*) = "remote" {
set responseJSON = ..GetRemote()
} elseif $extract(pagePath,6,*) = "environment" {
set responseJSON = {
"environment": (##class(SourceControl.Git.Utils).EnvironmentName())
}
} else {
set %response.Status = ##class(%CSP.REST).#HTTP404NOTFOUND
set responseJSON = {"error":("invalid URI: " _ pagePath)}
Expand Down
16 changes: 15 additions & 1 deletion csp/gitprojectsettings.csp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ body {
set $Property(settings,param) = $Get(%request.Data(param,1))
}
if ('settings.settingsUIReadOnly) {
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch" {
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName" {
set $Property(settings,param) = $Get(%request.Data(param,1))
}

Expand Down Expand Up @@ -300,6 +300,20 @@ body {
</div>
</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>
<div class="col-sm-7">
<select class="form-control" id="environmentName" name="environmentName">
<server>
for envName = "TEST","DEVELOPMENT","LIVE","FAILOVER","" {
// create option with envName, set selected if envName == current environmentName
&html<<option #($CASE(envName, settings.environmentName: "selected", :""))# value=#(envName)#>#(envName)# </option>>
}
</server>
</select>
</div>
</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>
<div class="col-sm-7">
Expand Down
5 changes: 5 additions & 0 deletions git-webui/release/share/git-webui/webui/css/git-webui.css
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,11 @@ body {
#workspace-view .diff-line-offset {
cursor: pointer;
}
#environment {
color: white;
font-size: 1em;
align-self: center;
}
#changedFilesContainer {
max-width: 100% !important;
margin: 0 10px;
Expand Down
10 changes: 10 additions & 0 deletions git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
})
}

self.getEnvironment = function() {
$.get("api/environment", function(environment) {
var env = JSON.parse(environment)["environment"];
$("#environment").text(env)

});
};

self.changeContextGet = function() {
$.get("contexts", function(contextList) {
var contexts = JSON.parse(contextList);
Expand Down Expand Up @@ -974,6 +982,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
self.element = $( '<div id="sidebar">' +
'<a href="#" data-toggle="modal" data-target="#help-modal"><img id="sidebar-logo" src="img/git-logo.png"></a>' +
'<h5 id="packageVersion"></h5>' +
'<h4 id="environment"></h4>'+
'<div id="sidebar-content">' +
'<section id="sidebar-workspace">' +
'<h4>Workspace</h4>' +
Expand Down Expand Up @@ -1051,6 +1060,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}

self.getPackageVersion();
self.getEnvironment()
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
Expand Down
6 changes: 6 additions & 0 deletions git-webui/src/share/git-webui/webui/css/git-webui.less
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,12 @@ body {
}
}

#environment {
color:white;
font-size: 1em;
align-self: center;
}

#changedFilesContainer {
max-width: 100% !important;
margin: 0 10px;
Expand Down
10 changes: 10 additions & 0 deletions git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
})
}

self.getEnvironment = function() {
$.get("api/environment", function(environment) {
var env = JSON.parse(environment)["environment"];
$("#environment").text(env)

});
};

self.changeContextGet = function() {
$.get("contexts", function(contextList) {
var contexts = JSON.parse(contextList);
Expand Down Expand Up @@ -974,6 +982,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
self.element = $( '<div id="sidebar">' +
'<a href="#" data-toggle="modal" data-target="#help-modal"><img id="sidebar-logo" src="img/git-logo.png"></a>' +
'<h5 id="packageVersion"></h5>' +
'<h4 id="environment"></h4>'+
'<div id="sidebar-content">' +
'<section id="sidebar-workspace">' +
'<h4>Workspace</h4>' +
Expand Down Expand Up @@ -1051,6 +1060,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}

self.getPackageVersion();
self.getEnvironment()
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
Expand Down
1 change: 1 addition & 0 deletions test/UnitTest/SourceControl/Git/Initialization.cls
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Method TestRunGitInGarbageContext()
Set settings = ##class(SourceControl.Git.Settings).%New()
Set oldTemp = settings.namespaceTemp
Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"nonexistentdir"
set settings.environmentName = ""
Do $$$AssertStatusOK(settings.%Save())
Try {
Do ##class(%Library.File).RemoveDirectory(settings.namespaceTemp)
Expand Down
Loading