Skip to content

Commit 4ba8b80

Browse files
committed
feat: compile files modified via web application
1 parent 1390575 commit 4ba8b80

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- New UI for the basic mode Sync (#415)
1212
- Allow changing namespaces and IPM package context from web UI (#280)
13+
- Support for editing repo from filesystem perspective via web application (#464)
14+
- Support for downloading a VSCode workspace file from web UI
1315

1416
### Fixed
1517
- Instance wide settings are placed in proper global (#444)
1618
- Added support to switch branch in basic mode from menu (#451)
19+
- Avoid delay/errors in loading interop JS when there is a URL prefix (e.g., instance name in multi-instance webserver configuration)
1720

1821
## [2.4.1] - 2024-08-02
1922

cls/SourceControl/Git/Extension.cls

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ Method AfterUserAction(Type As %Integer, Name As %String, InternalName As %Strin
7474
if menu '= "%SourceMenu", menu'="%SourceContext" {
7575
quit $$$OK
7676
}
77-
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName)
77+
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName, .fromWebApp)
7878
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
7979
set ec = ##class(SourceControl.Git.Utils).AfterUserAction(Type, Name, InternalName, .Answer, .Msg, .Reload)
80+
if fromWebApp {
81+
// Force reload and compile of actual item if underlying file has changed
82+
do ..OnBeforeLoad(InternalName,1,1)
83+
}
8084
quit ec
8185
}
8286

@@ -235,12 +239,12 @@ Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As
235239

236240
/// This is called before the actual load of data to give the chance
237241
/// to load the item from an external format.
238-
Method OnBeforeLoad(InternalName As %String, verbose As %Boolean) As %Status
242+
Method OnBeforeLoad(InternalName As %String, verbose As %Boolean, compile As %Boolean = 0) As %Status
239243
{
240244
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
241245
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName)
242246
if ##class(SourceControl.Git.Utils).IsInSourceControl(InternalName) {
243-
quit ##class(SourceControl.Git.Utils).ImportItem(InternalName,,0)
247+
quit ##class(SourceControl.Git.Utils).ImportItem(InternalName,,0,compile)
244248
}
245249
quit $$$OK
246250
}
@@ -274,14 +278,21 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
274278
{
275279
set sc = $$$OK
276280
try {
277-
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(.InternalName)
281+
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(.InternalName,.fromWebApp,.fullExternalName)
278282
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
279283
if ##class(SourceControl.Git.Utils).IsNamespaceInGit() && ..IsInSourceControl(InternalName) {
280-
set filename = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
281-
$$$ThrowOnError(##class(SourceControl.Git.Utils).RemoveRoutineTSH(InternalName))
282-
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName))
283-
if '##class(SourceControl.Git.Change).IsUncommitted(filename) {
284-
$$$ThrowOnError(##class(SourceControl.Git.Change).SetUncommitted(filename, "edit", InternalName, $username, "", 1, "", "", 0))
284+
if fromWebApp {
285+
if fullExternalName = ##class(SourceControl.Git.Utils).FullExternalName(InternalName) {
286+
// Reimport item into database
287+
$$$ThrowOnError(##class(SourceControl.Git.Utils).ImportItem(InternalName,,1,1))
288+
}
289+
} else {
290+
set filename = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
291+
$$$ThrowOnError(##class(SourceControl.Git.Utils).RemoveRoutineTSH(InternalName))
292+
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName))
293+
if '##class(SourceControl.Git.Change).IsUncommitted(filename) {
294+
$$$ThrowOnError(##class(SourceControl.Git.Change).SetUncommitted(filename, "edit", InternalName, $username, "", 1, "", "", 0))
295+
}
285296
}
286297
}
287298
} catch e {

cls/SourceControl/Git/Utils.cls

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ ClassMethod FullExternalName(ByRef InternalName As %String, ByRef MappingExists
11161116
..TempFolder()_..ExternalName(.InternalName, .MappingExists)
11171117
}
11181118

1119-
ClassMethod NormalizeInternalName(ByRef name As %String) As %String
1119+
ClassMethod NormalizeInternalName(ByRef name As %String, Output fromWebApp As %Boolean = 0, Output cspFilename) As %String
11201120
{
11211121
//Studio passes name of routine with dots as it is in folders
11221122
//e.g. Package.SubPackage.Routine.mac has InternalName = /Package/SubPackage/Routine.mac
@@ -1137,6 +1137,9 @@ ClassMethod NormalizeInternalName(ByRef name As %String) As %String
11371137
set cspFilename = $System.CSP.GetFileName(name)
11381138
if (cspFilename '= "") && (cspFilename [ ..TempFolder()) {
11391139
set name = ..NameToInternalName(cspFilename)
1140+
set fromWebApp = 1
1141+
} else {
1142+
kill cspFilename
11401143
}
11411144
}
11421145

@@ -1253,7 +1256,7 @@ ClassMethod FixProjectCspReferences(projectName As %String) As %Status
12531256

12541257
/// imports file if version in system is newer then version on disk.
12551258
/// if <var>force</var> = 1 then imports in any case.
1256-
ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose As %Boolean = 1) As %Status
1259+
ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose As %Boolean = 1, compile As %Boolean = 0) As %Status
12571260
{
12581261
#dim filename as %String = ..FullExternalName(.InternalName)
12591262
#dim fileTSH = ##class(%File).GetFileDateModified(filename)
@@ -1272,7 +1275,7 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A
12721275
if ($extract(InternalName, 1) = "/"){
12731276
set sc = ..ImportCSPFile(InternalName)
12741277
} else{
1275-
set sc = $system.OBJ.Load(filename,"-l-d")
1278+
set sc = $system.OBJ.Load(filename,$Select(compile:"ck-l",1:"-l-d"))
12761279
}
12771280
}
12781281
if sc {

0 commit comments

Comments
 (0)