Skip to content

Commit 29516ab

Browse files
committed
feat: compile files modified via web application
1 parent 06e7e50 commit 29516ab

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,9 +10,12 @@ 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)
18+
- Avoid delay/errors in loading interop JS when there is a URL prefix (e.g., instance name in multi-instance webserver configuration)
1619

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

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

@@ -234,12 +238,12 @@ Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As
234238

235239
/// This is called before the actual load of data to give the chance
236240
/// to load the item from an external format.
237-
Method OnBeforeLoad(InternalName As %String, verbose As %Boolean) As %Status
241+
Method OnBeforeLoad(InternalName As %String, verbose As %Boolean, compile As %Boolean = 0) As %Status
238242
{
239243
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
240244
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName)
241245
if ##class(SourceControl.Git.Utils).IsInSourceControl(InternalName) {
242-
quit ##class(SourceControl.Git.Utils).ImportItem(InternalName,,0)
246+
quit ##class(SourceControl.Git.Utils).ImportItem(InternalName,,0,compile)
243247
}
244248
quit $$$OK
245249
}
@@ -273,14 +277,21 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
273277
{
274278
set sc = $$$OK
275279
try {
276-
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(.InternalName)
280+
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(.InternalName,.fromWebApp,.fullExternalName)
277281
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
278282
if ##class(SourceControl.Git.Utils).IsNamespaceInGit() && ..IsInSourceControl(InternalName) {
279-
set filename = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
280-
$$$ThrowOnError(##class(SourceControl.Git.Utils).RemoveRoutineTSH(InternalName))
281-
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName))
282-
if '##class(SourceControl.Git.Change).IsUncommitted(filename) {
283-
$$$ThrowOnError(##class(SourceControl.Git.Change).SetUncommitted(filename, "edit", InternalName, $username, "", 1, "", "", 0))
283+
if fromWebApp {
284+
if fullExternalName = ##class(SourceControl.Git.Utils).FullExternalName(InternalName) {
285+
// Reimport item into database
286+
$$$ThrowOnError(##class(SourceControl.Git.Utils).ImportItem(InternalName,,1,1))
287+
}
288+
} else {
289+
set filename = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
290+
$$$ThrowOnError(##class(SourceControl.Git.Utils).RemoveRoutineTSH(InternalName))
291+
$$$ThrowOnError(##class(SourceControl.Git.Utils).ExportItem(InternalName))
292+
if '##class(SourceControl.Git.Change).IsUncommitted(filename) {
293+
$$$ThrowOnError(##class(SourceControl.Git.Change).SetUncommitted(filename, "edit", InternalName, $username, "", 1, "", "", 0))
294+
}
284295
}
285296
}
286297
} 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)