Skip to content

Commit 5ee8952

Browse files
committed
Merge branch 'main' into issue-525
2 parents 5bde6f5 + c086dcf commit 5ee8952

File tree

10 files changed

+80
-1
lines changed

10 files changed

+80
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Added 'git push --force' in expert mode (#527)
1212
- Add remote repository to settings page (#448)
13+
- Added environment awareness in configuration, and showing of environment name in UI (#124)
1314

1415
### Fixed
1516
- Fixed display of other users' username in workspace view on Unix (#530)

cls/SourceControl/Git/Settings.cls

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Property namespaceLevelGitWebApp As %Boolean [ InitialExpression = {##class(Sour
5353
/// Warn when an item has uncommitted changes in a different namespace in this instance
5454
Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).WarnInstanceWideUncommitted()} ];
5555

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

5861
Method %OnNew() As %Status
@@ -110,11 +113,19 @@ Method %Save() As %Status
110113
set @storage@("settings", "compileOnImport") = ..compileOnImport
111114
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
112115
set @storage@("settings", "basicMode") = ..systemBasicMode
116+
set @storage@("settings", "environmentName") = ..environmentName
113117
if ..basicMode = "system" {
114118
kill @storage@("settings", "user", $username, "basicMode")
115119
} else {
116120
set @storage@("settings", "user", $username, "basicMode") = ..basicMode
117121
}
122+
try {
123+
do $SYSTEM.Version.SystemMode(..environmentName)
124+
} catch e {
125+
// no-op; user might not have privileges.
126+
}
127+
128+
118129

119130
// update value of basicUserMode to reflect the updated setting for basicMode
120131
set ..userBasicMode = ##class(SourceControl.Git.Utils).UserBasicMode()
@@ -171,6 +182,13 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
171182
do %code.WriteLine(" if value = ""System's Default Mode"" { set value = ""system""}")
172183
do %code.WriteLine(" elseif value = ""Yes"" { set value = 1}")
173184
do %code.WriteLine(" elseif value = ""No"" { set value = 0}")
185+
} elseif ((propertyDef) && (propertyDef.Name = "environmentName")) {
186+
do %code.WriteLine(" set list(1) = ""DEVELOPMENT""")
187+
do %code.WriteLine(" set list(2) = ""TEST""")
188+
do %code.WriteLine(" set list(3) = ""LIVE""")
189+
do %code.WriteLine(" set list(4) = ""FAILOVER""")
190+
do %code.WriteLine(" set list(5) = """"")
191+
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetArray("_promptQuoted_",.value,.list,,,,"_defaultPromptFlag_")")
174192
} else {
175193
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
176194
}

cls/SourceControl/Git/Utils.cls

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ ClassMethod WarnInstanceWideUncommitted() As %Boolean
163163
quit $get(@..#Storage@("settings","warnInstanceWideUncommitted"),1)
164164
}
165165

166+
ClassMethod EnvironmentName() As %String
167+
{
168+
quit $SYSTEM.Version.SystemMode()
169+
}
170+
171+
ClassMethod IsLIVE() As %Boolean
172+
{
173+
quit ..EnvironmentName()="LIVE"
174+
}
175+
166176
ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ]
167177
{
168178
(..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """")

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
2828
}
2929
} elseif $extract(pagePath,6,*) = "remote" {
3030
set responseJSON = ..GetRemote()
31+
} elseif $extract(pagePath,6,*) = "environment" {
32+
set responseJSON = {
33+
"environment": (##class(SourceControl.Git.Utils).EnvironmentName())
34+
}
3135
} else {
3236
set %response.Status = ##class(%CSP.REST).#HTTP404NOTFOUND
3337
set responseJSON = {"error":("invalid URI: " _ pagePath)}

csp/gitprojectsettings.csp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ body {
8686
set $Property(settings,param) = $Get(%request.Data(param,1))
8787
}
8888
if ('settings.settingsUIReadOnly) {
89-
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch" {
89+
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName" {
9090
set $Property(settings,param) = $Get(%request.Data(param,1))
9191
}
9292

@@ -300,6 +300,20 @@ body {
300300
</div>
301301
</div>
302302

303+
<div class="form-group row mb-3">
304+
<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>
305+
<div class="col-sm-7">
306+
<select class="form-control" id="environmentName" name="environmentName">
307+
<server>
308+
for envName = "TEST","DEVELOPMENT","LIVE","FAILOVER","" {
309+
// create option with envName, set selected if envName == current environmentName
310+
&html<<option #($CASE(envName, settings.environmentName: "selected", :""))# value=#(envName)#>#(envName)# </option>>
311+
}
312+
</server>
313+
</select>
314+
</div>
315+
</div>
316+
303317
<div class="form-group row mb-3">
304318
<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>
305319
<div class="col-sm-7">

git-webui/release/share/git-webui/webui/css/git-webui.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,11 @@ body {
903903
#workspace-view .diff-line-offset {
904904
cursor: pointer;
905905
}
906+
#environment {
907+
color: white;
908+
font-size: 1em;
909+
align-self: center;
910+
}
906911
#changedFilesContainer {
907912
max-width: 100% !important;
908913
margin: 0 10px;

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
606606
})
607607
}
608608

609+
self.getEnvironment = function() {
610+
$.get("api/environment", function(environment) {
611+
var env = JSON.parse(environment)["environment"];
612+
$("#environment").text(env)
613+
614+
});
615+
};
616+
609617
self.changeContextGet = function() {
610618
$.get("contexts", function(contextList) {
611619
var contexts = JSON.parse(contextList);
@@ -974,6 +982,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
974982
self.element = $( '<div id="sidebar">' +
975983
'<a href="#" data-toggle="modal" data-target="#help-modal"><img id="sidebar-logo" src="img/git-logo.png"></a>' +
976984
'<h5 id="packageVersion"></h5>' +
985+
'<h4 id="environment"></h4>'+
977986
'<div id="sidebar-content">' +
978987
'<section id="sidebar-workspace">' +
979988
'<h4>Workspace</h4>' +
@@ -1051,6 +1060,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10511060
}
10521061

10531062
self.getPackageVersion();
1063+
self.getEnvironment()
10541064
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
10551065
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
10561066
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");

git-webui/src/share/git-webui/webui/css/git-webui.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,12 @@ body {
887887
}
888888
}
889889

890+
#environment {
891+
color:white;
892+
font-size: 1em;
893+
align-self: center;
894+
}
895+
890896
#changedFilesContainer {
891897
max-width: 100% !important;
892898
margin: 0 10px;

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
606606
})
607607
}
608608

609+
self.getEnvironment = function() {
610+
$.get("api/environment", function(environment) {
611+
var env = JSON.parse(environment)["environment"];
612+
$("#environment").text(env)
613+
614+
});
615+
};
616+
609617
self.changeContextGet = function() {
610618
$.get("contexts", function(contextList) {
611619
var contexts = JSON.parse(contextList);
@@ -974,6 +982,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
974982
self.element = $( '<div id="sidebar">' +
975983
'<a href="#" data-toggle="modal" data-target="#help-modal"><img id="sidebar-logo" src="img/git-logo.png"></a>' +
976984
'<h5 id="packageVersion"></h5>' +
985+
'<h4 id="environment"></h4>'+
977986
'<div id="sidebar-content">' +
978987
'<section id="sidebar-workspace">' +
979988
'<h4>Workspace</h4>' +
@@ -1051,6 +1060,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10511060
}
10521061

10531062
self.getPackageVersion();
1063+
self.getEnvironment()
10541064
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
10551065
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
10561066
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");

test/UnitTest/SourceControl/Git/Initialization.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Method TestRunGitInGarbageContext()
2222
Set settings = ##class(SourceControl.Git.Settings).%New()
2323
Set oldTemp = settings.namespaceTemp
2424
Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"nonexistentdir"
25+
set settings.environmentName = ""
2526
Do $$$AssertStatusOK(settings.%Save())
2627
Try {
2728
Do ##class(%Library.File).RemoveDirectory(settings.namespaceTemp)

0 commit comments

Comments
 (0)