Skip to content

Commit c34fa58

Browse files
committed
by default, lock editing of decomposed productions in the IDE
1 parent 201ccd7 commit c34fa58

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

cls/SourceControl/Git/Extension.cls

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ ClassMethod FullExternalName(InternalName As %String) As %String
408408

409409
Method IsReadOnly(InternalName As %String) As %Boolean
410410
{
411-
quit ##class(SourceControl.Git.Utils).Locked()
411+
set settings = ##class(SourceControl.Git.Settings).%New()
412+
quit ##class(SourceControl.Git.Utils).Locked()
413+
|| (##class(SourceControl.Git.Utils).ItemIsProductionToDecompose($get(InternalName))
414+
&& 'settings.decomposeProdAllowIDE
415+
&& '##class(SourceControl.Git.Production).IsEnsPortal())
412416
}
413417

414418
/// Called before the item is saved to the database it is passed
@@ -439,7 +443,7 @@ Method OnBeforeSave(InternalName As %String, Location As %String = "", Object As
439443
Method GetStatus(ByRef InternalName As %String, ByRef IsInSourceControl As %Boolean, ByRef Editable As %Boolean, ByRef IsCheckedOut As %Boolean, ByRef UserCheckedOut As %String) As %Status
440444
{
441445
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(.InternalName)
442-
set Editable='..IsReadOnly(),IsCheckedOut=1,UserCheckedOut=""
446+
set Editable='..IsReadOnly($get(InternalName)),IsCheckedOut=1,UserCheckedOut=""
443447
set filename=##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
444448
set IsInSourceControl=(filename'=""&&($$$FileExists(filename)))
445449
if filename="" quit $$$OK
@@ -505,4 +509,3 @@ Method CheckCommitterIdentity(Settings As SourceControl.Git.Settings, ByRef Acti
505509
}
506510

507511
}
508-

cls/SourceControl/Git/Settings.cls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Property settingsUIReadOnly As %Boolean [ InitialExpression = {##class(SourceCon
2626
/// Interoperability productions are source-controlled under separate files for each configuration item
2727
Property decomposeProductions As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).DecomposeProductions()} ];
2828

29+
/// Allow editing a decomposed production class in an IDE
30+
Property decomposeProdAllowIDE As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).DecomposeProdAllowIDE()} ];
31+
2932
/// Attribution: Git username for user ${username}
3033
Property gitUserName As %String(MAXLEN = 255) [ InitialExpression = {##class(SourceControl.Git.Utils).GitUserName()} ];
3134

@@ -156,6 +159,7 @@ Method %Save() As %Status
156159
if (..decomposeProductions & ($data(..Mappings("PTD"))<10)) {
157160
set ..Mappings("PTD","*") = "ptd/" // configure a default mapping for PTD items
158161
}
162+
set @storage@("settings","decomposeProdAllowIDE") = ..decomposeProdAllowIDE
159163

160164
kill @##class(SourceControl.Git.Utils).MappingsNode()
161165
merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings

cls/SourceControl/Git/Utils.cls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ ClassMethod DecomposeProductions() As %Boolean [ CodeMode = expression ]
7777
$Get(@..#Storage@("settings","decomposeProductions"), 0)
7878
}
7979

80+
ClassMethod DecomposeProdAllowIDE() As %Boolean [ CodeMode = expression ]
81+
{
82+
$Get(@..#Storage@("settings","decomposeProdAllowIDE"), 0)
83+
}
84+
8085
/// Returns the current (or previous) value of the flag.
8186
ClassMethod Locked(newFlagValue As %Boolean) As %Boolean
8287
{

csp/gitprojectsettings.csp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ body {
9696

9797
set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1)
9898
set settings.decomposeProductions = ($Get(%request.Data("decomposeProductions", 1)) = 1)
99+
set settings.decomposeProdAllowIDE = ($Get(%request.Data("decomposeProdAllowIDE", 1)) = 1)
99100

100101
if ($Get(%request.Data("basicMode", 1)) = 1) {
101102
set settings.basicMode = 1
@@ -384,6 +385,18 @@ body {
384385
</div>
385386
</div>
386387
</div>
388+
<div class="form-group row mb-3">
389+
<label for="decomposeProdAllowIDE" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top"
390+
title="If true, a decomposed production class may be edited through VS Code or Studio">
391+
Decomposed Productions Allow IDE</label>
392+
<div class="col-sm-7">
393+
<div class="custom-control custom-switch custom-switch-no-border">
394+
<input class="custom-control-input" name="decomposeProdAllowIDE" type="checkbox"
395+
id="decomposeProdAllowIDE" #($select(settings.decomposeProdAllowIDE:"checked",1:""))# value="1">
396+
<label class="custom-control-label" for="decomposeProdAllowIDE"></label>
397+
</div>
398+
</div>
399+
</div>
387400

388401
<div class="form-group row mb-3 mapping-input-group">
389402
<div class="offset-sm-1 col-sm-3">

docs/production-decomposition.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ The feature may be enabled by checking the "Decompose Productions" box in the Gi
66

77
If there are existing productions in the namespace, they should be migrated to the new decomposed format by running `do ##class(SourceControl.Git.API).BaselineProductions()`. You may then use the Git Web UI to view, commit, and push the corresponding changes. This method should be run in a single namespace and then deployed to other namespaces through normal git-source-control deployment mechanisms.
88

9+
## Editing productions in the IDE
10+
There are a couple of limitations related to editing a production class directly in an integrated development environment (Studio or VS Code).
11+
- Any elements of the class definition other than the production definition (for example, methods, parameters, or a custom superclass) are not source controlled if production decomposition is enabled. A recommended workaround is to move these items to a separate utility class.
12+
- The hooks in the IDE are not able to detect which specific production items are being edited. As a result, if any item has an uncommitted change from a different user, you will be blocked from editing the production in the IDE entirely.
13+
As a result of these limitations, editing decomposed productions in the IDE is prohibited by default. To enable it, enable the "Decomposed Productions Allow IDE" setting on the settings page.
14+
915
## Known Limitations
10-
- The source control hooks for Production Decomposition are currently only supported when editing via the Interoperability Portal. Editing the production class directly in VS Code or Studio may overwrite other users' changes.
1116
- Any custom methods, parameters, etc. in the production class will not be source controlled if Production Decomposition is enabled. A recommended workaround is to move these items to a separate utility class.
1217
- Production Decomposition is not supported for deployment of changes to productions using the InterSystems Package Manager.

0 commit comments

Comments
 (0)