Skip to content

Commit fc3c599

Browse files
committed
Merge remote-tracking branch 'origin/main' into production-change-control
2 parents 4ea1312 + 750a363 commit fc3c599

File tree

15 files changed

+290
-24
lines changed

15 files changed

+290
-24
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.6.0] - Unreleased
9+
10+
### Added
11+
- Files in uncommitted queue in any namespace warn users when opened except for in VSCode (#370)
12+
13+
### Added
14+
- Added link back to IRIS management portal from Settings, Git WebUI pages (#449)
15+
16+
### Fixed
17+
- Changed prompts in configure from 0/1 to no/yes (#461)
18+
- Added warnings when user is using incompatible git version (#488)
19+
- Fixed the back button navigation between WebUI and Settings page (#361)
20+
821
## [2.5.0] - 2024-09-24
922

1023
### Added

cls/SourceControl/Git/API.cls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ ClassMethod Configure()
1717
}
1818
set gitExists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
1919
set gitBinPath = ##class(SourceControl.Git.Utils).GitBinPath(.isDefault)
20+
21+
// Make sure they are using an appropriate git version
22+
if (+$PIECE(version,"version ",2))<2.31 {
23+
write !!, "WARNING: You are using an older version of git which is not compatible with git-source-control. Please upgrade to git version 2.31.0 or greater to continue"
24+
write !!, "Cancelling git-source-control configuration..."
25+
quit
26+
}
2027
if gitExists && isDefault {
2128
// Note: version starts with "git version"
2229
write !,version," is available via PATH. You may enter a path to a different version if needed."

cls/SourceControl/Git/Change.cls

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,51 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles,
185185
quit sc
186186
}
187187

188+
Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%String,Namespace:%String")
189+
{
190+
}
191+
192+
ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
193+
{
194+
set qHandle("q") = "SELECT InternalName, ChangedBy FROM SourceControl_Git.Change"
195+
set namespaces = ##class(SourceControl.Git.Utils).GetGitEnabledNamespaces()
196+
set tPtr = 0
197+
set qHandle("i") = 1
198+
new $namespace
199+
while $LISTNEXT(namespaces, tPtr, tValue) {
200+
set namespace = $ZCONVERT(tValue, "U")
201+
if '(namespace [ "^") {
202+
set $NAMESPACE = namespace
203+
set statement = ##class(%SQL.Statement).%New()
204+
$$$ThrowOnError(statement.%Prepare(qHandle("q"), 0))
205+
set resultSet = statement.%Execute()
206+
throw:resultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message)
207+
while resultSet.%Next(.sc) {
208+
$$$ThrowOnError(sc)
209+
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = resultSet.%GetData(1)
210+
set qHandle("changes", qHandle("changes"), "User") = resultSet.%GetData(2)
211+
set qHandle("changes", qHandle("changes"), "Namespace") = namespace
212+
}
213+
}
214+
}
215+
216+
Quit $$$OK
217+
}
218+
219+
ClassMethod InstanceUncommittedFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = InstanceUncommittedExecute ]
220+
{
221+
set i = qHandle("i")
222+
if $data(qHandle("changes",i))=10 {
223+
set Row = $listbuild(qHandle("changes", i, "InternalName"), qHandle("changes", i, "User"), qHandle("changes", i, "Namespace"))
224+
}
225+
if i >= $get(qHandle("changes"),0) {
226+
set AtEnd = 1
227+
} else {
228+
set qHandle("i") = $increment(qHandle("i"))
229+
}
230+
Quit $$$OK
231+
}
232+
188233
Storage Default
189234
{
190235
<Data name="ChangeDefaultData">
@@ -237,3 +282,4 @@ Storage Default
237282
}
238283

239284
}
285+

cls/SourceControl/Git/Extension.cls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,29 @@ XData Menu
4444

4545
Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status
4646
{
47+
set settings = ##class(SourceControl.Git.Settings).%New()
4748
// If namespace change event
4849
if Type = 1, Name = 5 {
4950
// reroute to Status menu option
5051
set Name = "%SourceMenu,Status"
5152
}
5253

54+
if (Type = 1) && (Name = 3) {
55+
if settings.warnInstanceWideUncommitted {
56+
// if item is being edited in a different namespace, opening it will display an alert. Editing in this namespace will remove the alert.
57+
set filename = ##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
58+
do ##class(SourceControl.Git.Change).GetUncommitted(filename,.tAction)
59+
if '$data(tAction) {
60+
set user = "", inNamespace = ""
61+
if ##class(SourceControl.Git.Utils).InstanceWideUncommittedCheck(InternalName, .user, .inNamespace) {
62+
set Target = "Warning: Item " _ InternalName _ " is currently being modified by " _ user _ " in namespace " _ inNamespace _ "."
63+
write !, Target
64+
set Action = 6
65+
}
66+
}
67+
}
68+
}
69+
5370
if (Type = 1) && ((Name = 1) || (Name = 7)) {
5471
do ..AddToSourceControl(InternalName)
5572
}

cls/SourceControl/Git/Settings.cls

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Property compileOnImport As %Boolean [ InitialExpression = {##class(SourceContro
5353
/// Define a namespace-level web application allowing access to multiple git repos across separate namespaces
5454
Property namespaceLevelGitWebApp As %Boolean [ InitialExpression = {##class(SourceControl.Git.Settings).HasNamespaceWebApp()} ];
5555

56+
/// Warn when an item has uncommitted changes in a different namespace in this instance
57+
Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).WarnInstanceWideUncommitted()} ];
58+
5659
Property Mappings [ MultiDimensional ];
5760

5861
Method %OnNew() As %Status
@@ -133,6 +136,7 @@ Method %Save() As %Status
133136
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly
134137
set @storage@("settings", "defaultMergeBranch") = ..defaultMergeBranch
135138
set @storage@("settings", "compileOnImport") = ..compileOnImport
139+
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
136140
set @storage@("settings", "basicMode") = ..systemBasicMode
137141
if ..basicMode = "system" {
138142
kill @storage@("settings", "user", $username, "basicMode")
@@ -223,7 +227,24 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
223227
set prompt = $$$comMemberKeyGet(%class.Name,$$$cCLASSproperty,property,$$$cPROPdescription)
224228
set promptQuoted = $$$QUOTE(prompt_":")
225229
set promptQuoted = $replace(promptQuoted,"${username}","'""_$Username_""'")
226-
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
230+
set propertyDef = ##class(%Dictionary.PropertyDefinition).%OpenId("SourceControl.Git.Settings||"_property_"")
231+
if ((propertyDef) && (propertyDef.Type = "%Boolean")) {
232+
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetYesNo("_promptQuoted_",.value,,"_defaultPromptFlag_")")
233+
} elseif ((propertyDef) && (propertyDef.Name = "basicMode")) {
234+
set basicModePromptFlag = defaultPromptFlag + $$$MatchExactArrayMask + $$$InitialDisplayMask
235+
do %code.WriteLine(" set list(1) = ""Yes""")
236+
do %code.WriteLine(" set list(2) = ""No""")
237+
do %code.WriteLine(" set list(3) = ""System's Default Mode""")
238+
do %code.WriteLine(" if inst.userBasicMode = ""system"" { set value = ""System's Default Mode""}")
239+
do %code.WriteLine(" elseif inst.userBasicMode = 1 { set value = ""Yes""}")
240+
do %code.WriteLine(" elseif inst.userBasicMode = 0 { set value = ""No""}")
241+
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetArray("_promptQuoted_",.value,.list,,,,"_basicModePromptFlag_")")
242+
do %code.WriteLine(" if value = ""System's Default Mode"" { set value = ""system""}")
243+
do %code.WriteLine(" elseif value = ""Yes"" { set value = 1}")
244+
do %code.WriteLine(" elseif value = ""No"" { set value = 0}")
245+
} else {
246+
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
247+
}
227248
do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }")
228249
do %code.WriteLine(" set inst."_property_" = value")
229250

cls/SourceControl/Git/Utils.cls

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

166+
ClassMethod WarnInstanceWideUncommitted() As %Boolean
167+
{
168+
quit $get(@..#Storage@("settings","warnInstanceWideUncommitted"),1)
169+
}
170+
166171
ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ]
167172
{
168173
(..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """")
@@ -2593,6 +2598,25 @@ ClassMethod GetGitEnabledNamespaces() As %String
25932598
quit enabledNamespaces
25942599
}
25952600

2601+
/// Returns true if the given item has uncommitted changes on a different namespace in this instance.
2602+
ClassMethod InstanceWideUncommittedCheck(InternalName As %String, Output User, Output Namespace) As %Boolean
2603+
{
2604+
set isUncommitted = 0
2605+
set resultSet = ##class(SourceControl.Git.Change).InstanceUncommittedFunc()
2606+
throw:resultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message)
2607+
while resultSet.%Next(.sc) {
2608+
$$$ThrowOnError(sc)
2609+
set fileName = resultSet.InternalName
2610+
if (InternalName = fileName) && (resultSet.Namespace '= $namespace) {
2611+
set isUncommitted = 1
2612+
set User = resultSet.User
2613+
set Namespace = resultSet.Namespace
2614+
}
2615+
}
2616+
2617+
quit isUncommitted
2618+
}
2619+
25962620
ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
25972621
{
25982622
#define sourcedir $System.Util.InstallDirectory()_"devuser/studio/templates/gitsourcecontrol/"
@@ -2748,3 +2772,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
27482772
}
27492773

27502774
}
2775+

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
2020
set responseJSON = ..GetSettingsURL(%request)
2121
} elseif $extract(pagePath, 6, *) = "get-package-version"{
2222
set responseJSON = ..GetPackageVersion()
23+
} elseif $extract(pagePath, 6, *) = "git-version" {
24+
set responseJSON = ..GetGitVersion()
25+
} elseif $extract(pagePath,6,*) = "home"{
26+
set responseJSON = {
27+
"url": (..GetHomeURL())
28+
}
2329
} else {
2430
set %response.Status = ##class(%CSP.REST).#HTTP404NOTFOUND
2531
set responseJSON = {"error":("invalid URI: " _ pagePath)}
@@ -331,4 +337,20 @@ ClassMethod GetPackageVersion() As %Library.DynamicObject
331337
quit {"version": (version)}
332338
}
333339

340+
ClassMethod GetGitVersion() As %Library.DynamicObject
341+
{
342+
set gitExists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
343+
set version = +$PIECE(version,"version ",2)
344+
quit {"version": (version)}
345+
}
346+
347+
ClassMethod GetHomeURL() As %String
348+
{
349+
set prefix = ""
350+
if $IsObject($Get(%request)) {
351+
set prefix = $Piece(%request.Application,%request.AppMatch)
352+
}
353+
quit prefix_"/csp/sys/UtilHome.csp"
354+
}
355+
334356
}

csp/gitprojectsettings.csp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ body {
4040
#webuiURL {
4141
display: none;
4242
}
43+
#homeURL {
44+
display: none;
45+
}
4346

4447
.custom-switch {
4548
padding: 0.4rem 0.5rem 0 2.75rem;
@@ -73,6 +76,7 @@ body {
7376
set version = ##class(SourceControl.Git.Utils).GetPackageVersion()
7477
set webuiURL = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_namespace_"/?CSPSHARE=1"
7578
set webuiURL = ##class(SourceControl.Git.WebUIDriver).GetURLPrefix(%request, webuiURL)
79+
set homeURL = ##class(SourceControl.Git.WebUIDriver).GetHomeURL()
7680

7781
set settings = ##class(SourceControl.Git.Settings).%New()
7882
if (%request.Method="POST") && $Data(%request.Data("gitsettings",1)) {
@@ -143,12 +147,17 @@ body {
143147
<input type="hidden" name="gitsettings" value="1" />
144148
<div class="col-sm-12"><br></div>
145149
<div class="row">
146-
<div class="offset-sm-1 col-sm-8">
150+
<div class="offset-sm-1 col-sm-7" id="settingsTitle">
147151
<h1>Git Project Settings</h1>
148152
<h3> Package version: #(version)# </h3>
149153
</div>
150154

151-
<div class="col-sm-2">
155+
<div class="col-sm-4" id="settingsNavBtn">
156+
<button class="btn btn-lg btn-outline-dark" id="goToHome">Home
157+
</button>
158+
<div id="homeURL">
159+
#(homeURL)#
160+
</div>
152161
<button class="btn btn-lg btn-outline-dark" id="goToWebUI">Go to WebUI
153162
</button>
154163
<div id="webuiURL">
@@ -566,6 +575,17 @@ body {
566575
<script src="js/popper.min.js"></script>
567576
<script src="js/bootstrap.min.js"></script>
568577
<script type="text/javascript">
578+
579+
// Removing the home button if not a top-level page
580+
if ((window !== window.parent) || (navigator.userAgent.indexOf('MSIE 7') > -1) || (navigator.userAgent.indexOf(" Code/") > -1)) {
581+
$("#goToHome", self.element).remove();
582+
$("#homeURL", self.element).remove();
583+
$('#settingsTitle').removeClass('col-sm-7');
584+
$('#settingsNavBtn').removeClass('col-sm-4');
585+
$('#settingsTitle').addClass('col-sm-8');
586+
$('#settingsNavBtn').addClass('col-sm-2');
587+
}
588+
569589
function getSocket(urlPostfix) {
570590
var socketURL = window.location.href.replace('http','ws').replace('gitprojectsettings.csp','_zpkg.isc.sc.git.Socket.cls') + "&" + urlPostfix;
571591
return new WebSocket(socketURL);
@@ -657,8 +677,12 @@ $(function()
657677

658678
$(document).on('click', "#goToWebUI", function(e){
659679
e.preventDefault();
660-
console.log($("#webuiURL")[0].innerText);
661-
window.location.replace($("#webuiURL")[0].innerText);
680+
window.location.href = $("#webuiURL")[0].innerText;
681+
})
682+
683+
$(document).on('click', "#goToHome", function(e){
684+
e.preventDefault();
685+
window.location.href = $("#homeURL")[0].innerText;
662686
})
663687
});
664688

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ body {
183183
padding-bottom: 100px;
184184
}
185185
#sidebar #sidebar-content > :first-child,
186-
#sidebar #sidebar-content > :nth-last-child(3) {
186+
#sidebar #sidebar-content > :last-child {
187187
border-top: 1px solid #5e5e5e;
188188
}
189189
#sidebar #sidebar-content h4:before {
@@ -227,7 +227,7 @@ body {
227227
}
228228
#sidebar #sidebar-content #sidebar-vscode {
229229
position: absolute;
230-
bottom: 80px;
230+
bottom: 90px;
231231
width: 16.7em;
232232
background-color: #333333;
233233
}
@@ -239,7 +239,7 @@ body {
239239
}
240240
#sidebar #sidebar-content #sidebar-context {
241241
position: absolute;
242-
bottom: 40px;
242+
bottom: 50px;
243243
width: 16.7em;
244244
background-color: #333333;
245245
}
@@ -251,7 +251,19 @@ body {
251251
}
252252
#sidebar #sidebar-content #sidebar-settings {
253253
position: absolute;
254-
bottom: 0px;
254+
bottom: 10px;
255+
width: 16.7em;
256+
background-color: #333333;
257+
}
258+
#sidebar #sidebar-content #sidebar-home h4 {
259+
padding: 0px;
260+
}
261+
#sidebar #sidebar-content #sidebar-home h4:before {
262+
content: url(../img/home.svg);
263+
}
264+
#sidebar #sidebar-content #sidebar-home {
265+
position: absolute;
266+
bottom: 130px;
255267
width: 16.7em;
256268
background-color: #333333;
257269
}
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)