@finos/legend-application-studio 26.0.2 → 26.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/lib/application/LegendStudioApplicationConfig.d.ts +10 -13
  2. package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
  3. package/lib/application/LegendStudioApplicationConfig.js +11 -10
  4. package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
  5. package/lib/components/ElementIconUtils.d.ts +1 -1
  6. package/lib/components/ElementIconUtils.d.ts.map +1 -1
  7. package/lib/components/ElementIconUtils.js +11 -5
  8. package/lib/components/ElementIconUtils.js.map +1 -1
  9. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.d.ts.map +1 -1
  10. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js +2 -0
  11. package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js.map +1 -1
  12. package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
  13. package/lib/components/editor/editor-group/EditorGroup.js +7 -1
  14. package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
  15. package/lib/components/editor/editor-group/FunctionEditor.d.ts +0 -16
  16. package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
  17. package/lib/components/editor/editor-group/FunctionEditor.js +79 -26
  18. package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
  19. package/lib/components/editor/editor-group/{service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts → INTERNAL__UnknownFunctionActivatorEdtior.d.ts} +2 -2
  20. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.d.ts.map +1 -0
  21. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js +49 -0
  22. package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js.map +1 -0
  23. package/lib/components/editor/editor-group/ModelImporter.js +1 -1
  24. package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
  25. package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts +22 -0
  26. package/lib/components/editor/editor-group/ProtocolValueBuilder.d.ts.map +1 -0
  27. package/lib/components/editor/editor-group/ProtocolValueBuilder.js +88 -0
  28. package/lib/components/editor/editor-group/ProtocolValueBuilder.js.map +1 -0
  29. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
  30. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +5 -1
  31. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  32. package/lib/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.js +1 -1
  33. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts +1 -1
  34. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
  35. package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.js.map +1 -1
  36. package/lib/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.js +1 -1
  37. package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js +3 -3
  38. package/lib/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.js.map +1 -1
  39. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.d.ts.map +1 -1
  40. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js +3 -3
  41. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.js.map +1 -1
  42. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +1 -1
  43. package/lib/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
  44. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js +1 -1
  45. package/lib/components/editor/editor-group/mapping-editor/MappingEditor.js.map +1 -1
  46. package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.d.ts +1 -1
  47. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -0
  48. package/lib/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.js +11 -11
  49. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -0
  50. package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js +4 -4
  51. package/lib/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.js.map +1 -1
  52. package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js +4 -4
  53. package/lib/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.js.map +1 -1
  54. package/lib/components/editor/editor-group/service-editor/ServiceEditor.d.ts.map +1 -1
  55. package/lib/components/editor/editor-group/service-editor/ServiceEditor.js +0 -7
  56. package/lib/components/editor/editor-group/service-editor/ServiceEditor.js.map +1 -1
  57. package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js +3 -3
  58. package/lib/components/editor/editor-group/service-editor/ServicePostValidationEditor.js.map +1 -1
  59. package/lib/components/editor/editor-group/uml-editor/ClassEditor.js +3 -3
  60. package/lib/components/editor/editor-group/uml-editor/ClassEditor.js.map +1 -1
  61. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.d.ts.map +1 -1
  62. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js +6 -2
  63. package/lib/components/editor/editor-group/uml-editor/StereotypeSelector.js.map +1 -1
  64. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.d.ts.map +1 -1
  65. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js +10 -2
  66. package/lib/components/editor/editor-group/uml-editor/TaggedValueEditor.js.map +1 -1
  67. package/lib/components/workspace-setup/WorkspaceSetup.js +1 -1
  68. package/lib/components/workspace-setup/WorkspaceSetup.js.map +1 -1
  69. package/lib/index.css +2 -2
  70. package/lib/index.css.map +1 -1
  71. package/lib/package.json +2 -2
  72. package/lib/stores/LegendStudioApplicationPlugin.d.ts +1 -1
  73. package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
  74. package/lib/stores/editor/EditorGraphState.d.ts +3 -1
  75. package/lib/stores/editor/EditorGraphState.d.ts.map +1 -1
  76. package/lib/stores/editor/EditorGraphState.js +14 -0
  77. package/lib/stores/editor/EditorGraphState.js.map +1 -1
  78. package/lib/stores/editor/EditorStore.d.ts +5 -5
  79. package/lib/stores/editor/EditorStore.d.ts.map +1 -1
  80. package/lib/stores/editor/EditorStore.js +12 -7
  81. package/lib/stores/editor/EditorStore.js.map +1 -1
  82. package/lib/stores/editor/EditorTabManagerState.d.ts.map +1 -1
  83. package/lib/stores/editor/EditorTabManagerState.js +5 -1
  84. package/lib/stores/editor/EditorTabManagerState.js.map +1 -1
  85. package/lib/stores/editor/editor-state/ExternalFormatState.d.ts +3 -3
  86. package/lib/stores/editor/editor-state/ExternalFormatState.d.ts.map +1 -1
  87. package/lib/stores/editor/editor-state/ExternalFormatState.js +14 -14
  88. package/lib/stores/editor/editor-state/ExternalFormatState.js.map +1 -1
  89. package/lib/stores/editor/editor-state/GraphGenerationState.d.ts +2 -2
  90. package/lib/stores/editor/editor-state/GraphGenerationState.d.ts.map +1 -1
  91. package/lib/stores/editor/editor-state/GraphGenerationState.js +1 -1
  92. package/lib/stores/editor/editor-state/GraphGenerationState.js.map +1 -1
  93. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts +34 -0
  94. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.d.ts.map +1 -0
  95. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js +118 -0
  96. package/lib/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.js.map +1 -0
  97. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +10 -8
  98. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
  99. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +16 -13
  100. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
  101. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts +31 -0
  102. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.d.ts.map +1 -0
  103. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js +91 -0
  104. package/lib/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.js.map +1 -0
  105. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts +69 -0
  106. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts.map +1 -0
  107. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js +243 -0
  108. package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js.map +1 -0
  109. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts +2 -0
  110. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts.map +1 -1
  111. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js +8 -1
  112. package/lib/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js.map +1 -1
  113. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts +2 -13
  114. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  115. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +1 -39
  116. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  117. package/lib/stores/editor/utils/MockDataUtils.d.ts +0 -1
  118. package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
  119. package/lib/stores/editor/utils/MockDataUtils.js +7 -20
  120. package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
  121. package/lib/stores/editor/utils/PackageTreeUtils.js +1 -1
  122. package/lib/stores/editor/utils/PackageTreeUtils.js.map +1 -1
  123. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts +3 -1
  124. package/lib/stores/graph-modifier/DomainGraphModifierHelper.d.ts.map +1 -1
  125. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js +4 -1
  126. package/lib/stores/graph-modifier/DomainGraphModifierHelper.js.map +1 -1
  127. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts +1 -0
  128. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.d.ts.map +1 -1
  129. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js +3 -0
  130. package/lib/stores/graph-modifier/STO_Relational_GraphModifierHelper.js.map +1 -1
  131. package/lib/stores/project-view/ProjectViewerStore.js +7 -3
  132. package/lib/stores/project-view/ProjectViewerStore.js.map +1 -1
  133. package/package.json +12 -12
  134. package/src/application/LegendStudioApplicationConfig.ts +14 -20
  135. package/src/components/ElementIconUtils.tsx +14 -2
  136. package/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx +2 -0
  137. package/src/components/editor/editor-group/EditorGroup.tsx +12 -1
  138. package/src/components/editor/editor-group/FunctionEditor.tsx +331 -85
  139. package/src/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.tsx +129 -0
  140. package/src/components/editor/editor-group/ModelImporter.tsx +1 -1
  141. package/src/components/editor/editor-group/ProtocolValueBuilder.tsx +225 -0
  142. package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +26 -1
  143. package/src/components/editor/editor-group/connection-editor/post-processor-editor/MapperPostProcessorEditor.tsx +1 -1
  144. package/src/components/editor/editor-group/element-generation-editor/FileGenerationEditor.tsx +7 -28
  145. package/src/components/editor/editor-group/mapping-editor/EnumerationMappingEditor.tsx +1 -1
  146. package/src/components/editor/editor-group/mapping-editor/FlatDataPropertyMappingEditor.tsx +4 -4
  147. package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationEditor.tsx +2 -3
  148. package/src/components/editor/editor-group/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +1 -1
  149. package/src/components/editor/editor-group/mapping-editor/MappingEditor.tsx +1 -1
  150. package/src/components/editor/{edit-panel/mapping-editor/testable → editor-group/mapping-editor}/MappingTestableEditor.tsx +13 -13
  151. package/src/components/editor/editor-group/mapping-editor/PurePropertyMappingEditor.tsx +5 -5
  152. package/src/components/editor/editor-group/mapping-editor/relational/RelationalPropertyMappingEditor.tsx +5 -5
  153. package/src/components/editor/editor-group/service-editor/ServiceEditor.tsx +0 -10
  154. package/src/components/editor/editor-group/service-editor/ServicePostValidationEditor.tsx +3 -3
  155. package/src/components/editor/editor-group/uml-editor/ClassEditor.tsx +3 -3
  156. package/src/components/editor/editor-group/uml-editor/StereotypeSelector.tsx +12 -11
  157. package/src/components/editor/editor-group/uml-editor/TaggedValueEditor.tsx +18 -20
  158. package/src/components/workspace-setup/WorkspaceSetup.tsx +1 -1
  159. package/src/stores/LegendStudioApplicationPlugin.ts +14 -5
  160. package/src/stores/editor/EditorGraphState.ts +24 -0
  161. package/src/stores/editor/EditorStore.ts +16 -7
  162. package/src/stores/editor/EditorTabManagerState.ts +7 -0
  163. package/src/stores/editor/editor-state/ExternalFormatState.ts +14 -16
  164. package/src/stores/editor/editor-state/GraphGenerationState.ts +3 -2
  165. package/src/stores/editor/editor-state/element-editor-state/FunctionActivatorBuilderState.ts +178 -0
  166. package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +21 -13
  167. package/src/stores/editor/editor-state/element-editor-state/INTERNAL__UnknownFunctionActivatorEditorState.ts +136 -0
  168. package/src/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.ts +364 -0
  169. package/src/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.ts +12 -0
  170. package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +0 -53
  171. package/src/stores/editor/utils/MockDataUtils.ts +7 -28
  172. package/src/stores/editor/utils/PackageTreeUtils.ts +1 -1
  173. package/src/stores/graph-modifier/DomainGraphModifierHelper.ts +9 -1
  174. package/src/stores/graph-modifier/STO_Relational_GraphModifierHelper.ts +6 -0
  175. package/src/stores/project-view/ProjectViewerStore.ts +6 -6
  176. package/tsconfig.json +6 -2
  177. package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.d.ts.map +0 -1
  178. package/lib/components/editor/edit-panel/mapping-editor/testable/MappingTestableEditor.js.map +0 -1
  179. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.d.ts.map +0 -1
  180. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js +0 -39
  181. package/lib/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.js.map +0 -1
  182. package/src/components/editor/editor-group/service-editor/TEMPORARY__SnowflakeServiceDeployer.tsx +0 -79
@@ -18,7 +18,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
18
18
  import { observer } from 'mobx-react-lite';
19
19
  import {
20
20
  FunctionEditorState,
21
- FUNCTION_SPEC_TAB,
21
+ FUNCTION_EDITOR_TAB,
22
22
  } from '../../../stores/editor/editor-state/element-editor-state/FunctionEditorState.js';
23
23
  import {
24
24
  CORE_DND_TYPE,
@@ -28,6 +28,7 @@ import {
28
28
  import {
29
29
  assertErrorThrown,
30
30
  prettyCONSTName,
31
+ returnUndefOnError,
31
32
  UnsupportedOperationError,
32
33
  } from '@finos/legend-shared';
33
34
  import { useDrag, useDrop } from 'react-dnd';
@@ -45,6 +46,18 @@ import {
45
46
  Panel,
46
47
  PanelContent,
47
48
  PanelDnDEntry,
49
+ Dialog,
50
+ ModalHeader,
51
+ ModalBody,
52
+ ModalFooter,
53
+ ModalTitle,
54
+ CaretDownIcon,
55
+ DropdownMenu,
56
+ LaunchIcon,
57
+ BlankPanelContent,
58
+ MenuContent,
59
+ MenuContentItem,
60
+ Modal,
48
61
  } from '@finos/legend-art';
49
62
  import { LEGEND_STUDIO_TEST_ID } from '../../../__lib__/LegendStudioTesting.js';
50
63
  import {
@@ -77,6 +90,9 @@ import {
77
90
  stub_RawVariableExpression,
78
91
  getFunctionNameWithPath,
79
92
  getFunctionSignature,
93
+ generateFunctionPrettyName,
94
+ extractAnnotatedElementDocumentation,
95
+ getClassProperty,
80
96
  } from '@finos/legend-graph';
81
97
  import {
82
98
  type ApplicationStore,
@@ -111,6 +127,8 @@ import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../__lib
111
127
  import { LambdaEditor } from '@finos/legend-query-builder';
112
128
  import type { EditorStore } from '../../../stores/editor/EditorStore.js';
113
129
  import { graph_renameElement } from '../../../stores/graph-modifier/GraphModifierHelper.js';
130
+ import { ProtocolValueBuilder } from './ProtocolValueBuilder.js';
131
+ import type { ProtocolValueBuilderState } from '../../../stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js';
114
132
 
115
133
  enum FUNCTION_PARAMETER_TYPE {
116
134
  CLASS = 'CLASS',
@@ -118,9 +136,7 @@ enum FUNCTION_PARAMETER_TYPE {
118
136
  PRIMITIVE = 'PRIMITIVE',
119
137
  }
120
138
 
121
- export const getFunctionParameterType = (
122
- type: Type,
123
- ): FUNCTION_PARAMETER_TYPE => {
139
+ const getFunctionParameterType = (type: Type): FUNCTION_PARAMETER_TYPE => {
124
140
  if (type instanceof PrimitiveType) {
125
141
  return FUNCTION_PARAMETER_TYPE.PRIMITIVE;
126
142
  } else if (type instanceof Enumeration) {
@@ -312,7 +328,7 @@ const ParameterBasicEditor = observer(
312
328
  </div>
313
329
  )}
314
330
  <input
315
- className="property-basic-editor__name"
331
+ className="property-basic-editor__name input--dark"
316
332
  disabled={isReadOnly}
317
333
  value={parameter.name}
318
334
  spellCheck={false}
@@ -327,6 +343,7 @@ const ParameterBasicEditor = observer(
327
343
  value={selectedType}
328
344
  placeholder="Choose a type..."
329
345
  filterOption={filterOption}
346
+ darkMode={true}
330
347
  />
331
348
  )}
332
349
  {!isReadOnly && !isEditingType && (
@@ -419,7 +436,7 @@ const ParameterBasicEditor = observer(
419
436
  </div>
420
437
  {!isReadOnly && (
421
438
  <button
422
- className="uml-element-editor__remove-btn"
439
+ className="uml-element-editor__remove-btn btn--dark btn--caution"
423
440
  disabled={isReadOnly}
424
441
  onClick={deleteParameter}
425
442
  tabIndex={-1}
@@ -521,6 +538,7 @@ const ReturnTypeEditor = observer(
521
538
  value={selectedType}
522
539
  placeholder="Choose a type..."
523
540
  filterOption={filterOption}
541
+ darkMode={true}
524
542
  />
525
543
  )}
526
544
  {!isReadOnly && !isEditingType && (
@@ -612,7 +630,7 @@ const ReturnTypeEditor = observer(
612
630
  />
613
631
  </div>
614
632
  <button
615
- className="uml-element-editor__remove-btn"
633
+ className="uml-element-editor__remove-btn btn--dark btn--caution"
616
634
  disabled={true}
617
635
  tabIndex={-1}
618
636
  >
@@ -623,16 +641,17 @@ const ReturnTypeEditor = observer(
623
641
  },
624
642
  );
625
643
 
626
- export const FunctionMainEditor = observer(
644
+ const FunctionDefinitionEditor = observer(
627
645
  (props: {
628
- functionElement: ConcreteFunctionDefinition;
629
- isReadOnly: boolean;
630
646
  functionEditorState: FunctionEditorState;
647
+ isReadOnly: boolean;
631
648
  }) => {
649
+ const { functionEditorState, isReadOnly } = props;
632
650
  const editorStore = useEditorStore();
633
651
  const applicationStore = useApplicationStore();
634
- const { functionElement, isReadOnly, functionEditorState } = props;
635
- const lambdaEditorState = functionEditorState.functionBodyEditorState;
652
+ const lambdaEditorState = functionEditorState.functionDefinitionEditorState;
653
+ const functionElement = functionEditorState.functionElement;
654
+
636
655
  // Parameters
637
656
  const addParameter = (): void => {
638
657
  function_addParameter(
@@ -676,15 +695,16 @@ export const FunctionMainEditor = observer(
676
695
  }),
677
696
  [handleDropParameter],
678
697
  );
698
+
679
699
  return (
680
- <div className="panel__content function-editor__element">
681
- <div className="function-editor__element__item">
682
- <div className="function-editor__element__item__header">
683
- <div className="function-editor__element__item__header__title">
700
+ <div className="function-editor__definition">
701
+ <div className="function-editor__definition__item">
702
+ <div className="function-editor__definition__item__header">
703
+ <div className="function-editor__definition__item__header__title">
684
704
  PARAMETERS
685
705
  </div>
686
706
  <button
687
- className="function-editor__element__item__header__add-btn"
707
+ className="function-editor__definition__item__header__add-btn btn--dark"
688
708
  disabled={isReadOnly}
689
709
  onClick={addParameter}
690
710
  tabIndex={-1}
@@ -701,7 +721,7 @@ export const FunctionMainEditor = observer(
701
721
  />
702
722
  <div
703
723
  ref={dropParameterRef}
704
- className={clsx('function-editor__element__item__content', {
724
+ className={clsx('function-editor__definition__item__content', {
705
725
  'panel__content__lists--dnd-over':
706
726
  isParameterDragOver && !isReadOnly,
707
727
  })}
@@ -715,11 +735,16 @@ export const FunctionMainEditor = observer(
715
735
  isReadOnly={isReadOnly}
716
736
  />
717
737
  ))}
738
+ {functionElement.parameters.length === 0 && (
739
+ <div className="function-editor__definition__item__content--empty">
740
+ No parameters
741
+ </div>
742
+ )}
718
743
  </div>
719
744
  </div>
720
- <div className="function-editor__element__item">
721
- <div className="function-editor__element__item__header">
722
- <div className="function-editor__element__item__header__title">
745
+ <div className="function-editor__definition__item">
746
+ <div className="function-editor__definition__item__header">
747
+ <div className="function-editor__definition__item__header__title">
723
748
  LAMBDA
724
749
  </div>
725
750
  <div className="">
@@ -730,21 +755,20 @@ export const FunctionMainEditor = observer(
730
755
  </div>
731
756
  </div>
732
757
  <div
733
- className={clsx('function-editor__element__item__content', {
758
+ className={clsx('function-editor__definition__item__content', {
734
759
  backdrop__element: Boolean(
735
- functionEditorState.functionBodyEditorState.parserError,
760
+ functionEditorState.functionDefinitionEditorState.parserError,
736
761
  ),
737
762
  })}
738
763
  >
739
764
  <LambdaEditor
740
- className="function-editor__element__lambda-editor"
765
+ className="function-editor__definition__lambda-editor lambda-editor--dark"
741
766
  disabled={
742
767
  lambdaEditorState.isConvertingFunctionBodyToString || isReadOnly
743
768
  }
744
769
  lambdaEditorState={lambdaEditorState}
745
- expectedType={functionElement.returnType.value}
746
770
  forceBackdrop={false}
747
- forceExpansion={true}
771
+ autoFocus={true}
748
772
  />
749
773
  </div>
750
774
  </div>
@@ -753,6 +777,91 @@ export const FunctionMainEditor = observer(
753
777
  },
754
778
  );
755
779
 
780
+ const FunctionActivatorContentBuilder = observer(
781
+ (props: {
782
+ functionEditorState: FunctionEditorState;
783
+ valueBuilderState: ProtocolValueBuilderState;
784
+ }) => {
785
+ const { functionEditorState, valueBuilderState } = props;
786
+ const builderState = functionEditorState.activatorBuilderState;
787
+
788
+ // name
789
+ const nameInputRef = useRef<HTMLInputElement>(null);
790
+ const nameValidationErrorMessage =
791
+ builderState.activatorName.length === 0
792
+ ? 'Element name cannot be empty'
793
+ : builderState.isDuplicated
794
+ ? `Element of the same path already existed`
795
+ : undefined;
796
+ useEffect(() => {
797
+ nameInputRef.current?.focus();
798
+ nameInputRef.current?.select();
799
+ }, [valueBuilderState]);
800
+
801
+ // function
802
+ const functionFieldProperty = returnUndefOnError(() =>
803
+ getClassProperty(valueBuilderState.type, 'function'),
804
+ );
805
+ const functionFieldDocumentation = functionFieldProperty
806
+ ? extractAnnotatedElementDocumentation(functionFieldProperty)
807
+ : undefined;
808
+
809
+ return (
810
+ <>
811
+ <div className="panel__content__form">
812
+ <div className="panel__content__form__section">
813
+ <div className="panel__content__form__section__header__label">
814
+ Name
815
+ </div>
816
+ <div className="input-group">
817
+ <input
818
+ className="panel__content__form__section__input"
819
+ spellCheck={false}
820
+ ref={nameInputRef}
821
+ value={builderState.activatorName}
822
+ onChange={(event) =>
823
+ builderState.setActivatorName(event.target.value)
824
+ }
825
+ />
826
+ {nameValidationErrorMessage && (
827
+ <div className="input-group__error-message">
828
+ {nameValidationErrorMessage}
829
+ </div>
830
+ )}
831
+ </div>
832
+ </div>
833
+ <div className="panel__content__form__section">
834
+ <div className="panel__content__form__section__header__label">
835
+ Function
836
+ </div>
837
+ {functionFieldDocumentation && (
838
+ <div className="panel__content__form__section__header__prompt">
839
+ {functionFieldDocumentation}
840
+ </div>
841
+ )}
842
+ <input
843
+ className="panel__content__form__section__input"
844
+ spellCheck={false}
845
+ disabled={true}
846
+ value={generateFunctionPrettyName(
847
+ functionEditorState.functionElement,
848
+ {
849
+ fullPath: true,
850
+ spacing: false,
851
+ },
852
+ )}
853
+ />
854
+ </div>
855
+ <div className="panel__content__form__section">
856
+ <div className="panel__content__form__section__divider"></div>
857
+ </div>
858
+ </div>
859
+ <ProtocolValueBuilder builderState={valueBuilderState} />
860
+ </>
861
+ );
862
+ },
863
+ );
864
+
756
865
  export const FunctionEditor = observer(() => {
757
866
  const editorStore = useEditorStore();
758
867
  const applicationStore = useApplicationStore();
@@ -763,10 +872,10 @@ export const FunctionEditor = observer(() => {
763
872
  const selectedTab = functionEditorState.selectedTab;
764
873
  let addButtonTitle = '';
765
874
  switch (selectedTab) {
766
- case FUNCTION_SPEC_TAB.TAGGED_VALUES:
875
+ case FUNCTION_EDITOR_TAB.TAGGED_VALUES:
767
876
  addButtonTitle = 'Add stereotype';
768
877
  break;
769
- case FUNCTION_SPEC_TAB.STEREOTYPES:
878
+ case FUNCTION_EDITOR_TAB.STEREOTYPES:
770
879
  addButtonTitle = 'Add tagged value';
771
880
  break;
772
881
  default:
@@ -775,12 +884,12 @@ export const FunctionEditor = observer(() => {
775
884
  // Tagged Values and Stereotype
776
885
  const add = (): void => {
777
886
  if (!isReadOnly) {
778
- if (selectedTab === FUNCTION_SPEC_TAB.TAGGED_VALUES) {
887
+ if (selectedTab === FUNCTION_EDITOR_TAB.TAGGED_VALUES) {
779
888
  annotatedElement_addTaggedValue(
780
889
  functionElement,
781
890
  stub_TaggedValue(stub_Tag(stub_Profile())),
782
891
  );
783
- } else if (selectedTab === FUNCTION_SPEC_TAB.STEREOTYPES) {
892
+ } else if (selectedTab === FUNCTION_EDITOR_TAB.STEREOTYPES) {
784
893
  annotatedElement_addStereotype(
785
894
  functionElement,
786
895
  StereotypeExplicitReference.create(stub_Stereotype(stub_Profile())),
@@ -849,13 +958,19 @@ export const FunctionEditor = observer(() => {
849
958
  (): void =>
850
959
  annotatedElement_deleteTaggedValue(functionElement, val);
851
960
  const changeTab =
852
- (tab: FUNCTION_SPEC_TAB): (() => void) =>
961
+ (tab: FUNCTION_EDITOR_TAB): (() => void) =>
853
962
  (): void =>
854
963
  functionEditorState.setSelectedTab(tab);
855
964
 
965
+ const activate = (): void => {
966
+ flowResult(functionEditorState.activatorBuilderState.activate()).catch(
967
+ applicationStore.alertUnhandledError,
968
+ );
969
+ };
970
+
856
971
  useEffect(() => {
857
972
  flowResult(
858
- functionEditorState.functionBodyEditorState.convertLambdaObjectToGrammarString(
973
+ functionEditorState.functionDefinitionEditorState.convertLambdaObjectToGrammarString(
859
974
  true,
860
975
  true,
861
976
  ),
@@ -867,7 +982,7 @@ export const FunctionEditor = observer(() => {
867
982
  );
868
983
 
869
984
  return (
870
- <div className="function-editor">
985
+ <div className="function-editor uml-editor uml-editor--dark">
871
986
  <Panel>
872
987
  <div className="panel__header">
873
988
  <div className="panel__header__title">
@@ -884,7 +999,7 @@ export const FunctionEditor = observer(() => {
884
999
  </div>
885
1000
  <div className="panel__header function-editor__tabs__header">
886
1001
  <div className="function-editor__tabs">
887
- {Object.values(FUNCTION_SPEC_TAB).map((tab) => (
1002
+ {Object.values(FUNCTION_EDITOR_TAB).map((tab) => (
888
1003
  <div
889
1004
  key={tab}
890
1005
  onClick={changeTab(tab)}
@@ -897,9 +1012,140 @@ export const FunctionEditor = observer(() => {
897
1012
  ))}
898
1013
  </div>
899
1014
  <div className="panel__header__actions">
1015
+ {editorStore.applicationStore.config.options
1016
+ .TEMPORARY__enableFunctionActivatorSupport && (
1017
+ <>
1018
+ <DropdownMenu
1019
+ className="function-editor__activate-btn"
1020
+ content={
1021
+ <MenuContent>
1022
+ {editorStore.graphState.functionActivatorConfigurations.map(
1023
+ (config) => (
1024
+ <MenuContentItem
1025
+ key={config.uuid}
1026
+ className="function-editor__activator__selector__option"
1027
+ onClick={() =>
1028
+ functionEditorState.activatorBuilderState.setCurrentActivatorConfiguration(
1029
+ config,
1030
+ )
1031
+ }
1032
+ title={config.description}
1033
+ >
1034
+ <div className="function-editor__activator__selector__option__name">
1035
+ {config.name}
1036
+ </div>
1037
+ <div className="function-editor__activator__selector__option__description">
1038
+ {config.description}
1039
+ </div>
1040
+ </MenuContentItem>
1041
+ ),
1042
+ )}
1043
+ </MenuContent>
1044
+ }
1045
+ menuProps={{
1046
+ anchorOrigin: { vertical: 'bottom', horizontal: 'right' },
1047
+ transformOrigin: { vertical: 'top', horizontal: 'right' },
1048
+ }}
1049
+ >
1050
+ <div className="function-editor__activate-btn__label">
1051
+ <div className="function-editor__activate-btn__label__icon">
1052
+ <LaunchIcon />
1053
+ </div>
1054
+ <div className="function-editor__activate-btn__label__title">
1055
+ Activate
1056
+ </div>
1057
+ </div>
1058
+ <div className="function-editor__activate-btn__dropdown-btn">
1059
+ <CaretDownIcon />
1060
+ </div>
1061
+ </DropdownMenu>
1062
+ {functionEditorState.activatorBuilderState
1063
+ .currentActivatorConfiguration && (
1064
+ <Dialog
1065
+ open={Boolean(
1066
+ functionEditorState.activatorBuilderState
1067
+ .currentActivatorConfiguration,
1068
+ )}
1069
+ onClose={() =>
1070
+ functionEditorState.activatorBuilderState.setCurrentActivatorConfiguration(
1071
+ undefined,
1072
+ )
1073
+ }
1074
+ classes={{
1075
+ root: 'editor-modal__root-container',
1076
+ container: 'editor-modal__container',
1077
+ paper: 'editor-modal__content',
1078
+ }}
1079
+ // NOTE: this is a safer way compared to using <form> as it will not trigger click event
1080
+ // on nested button
1081
+ // See https://stackoverflow.com/questions/11353105/why-browser-trigger-a-click-event-instead-of-a-submit-in-a-form
1082
+ // See https://stackoverflow.com/questions/3350247/how-to-prevent-form-from-being-submitted
1083
+ // See https://gomakethings.com/how-to-prevent-buttons-from-causing-a-form-to-submit-with-html/
1084
+ onKeyDown={(event) => {
1085
+ if (event.code === 'Enter' && !event.shiftKey) {
1086
+ event.preventDefault();
1087
+ activate();
1088
+ }
1089
+ }}
1090
+ >
1091
+ <Modal darkMode={true} className="editor-modal">
1092
+ <ModalHeader>
1093
+ <ModalTitle
1094
+ title={`Function Activator: ${functionEditorState.activatorBuilderState.currentActivatorConfiguration.name}`}
1095
+ />
1096
+ </ModalHeader>
1097
+ <ModalBody>
1098
+ <div className="function-editor__activator-builder">
1099
+ {functionEditorState.activatorBuilderState
1100
+ .functionActivatorProtocolValueBuilderState && (
1101
+ <FunctionActivatorContentBuilder
1102
+ functionEditorState={functionEditorState}
1103
+ valueBuilderState={
1104
+ functionEditorState.activatorBuilderState
1105
+ .functionActivatorProtocolValueBuilderState
1106
+ }
1107
+ />
1108
+ )}
1109
+ {!functionEditorState.activatorBuilderState
1110
+ .functionActivatorProtocolValueBuilderState && (
1111
+ <BlankPanelContent>
1112
+ No activator chosen
1113
+ </BlankPanelContent>
1114
+ )}
1115
+ </div>
1116
+ </ModalBody>
1117
+ <ModalFooter>
1118
+ <button
1119
+ className="btn btn--dark function-editor__activator__btn"
1120
+ type="submit"
1121
+ disabled={
1122
+ !functionEditorState.activatorBuilderState.isValid
1123
+ }
1124
+ onClick={activate}
1125
+ >
1126
+ Activate
1127
+ </button>
1128
+ <button
1129
+ className="btn btn--dark"
1130
+ onClick={() =>
1131
+ functionEditorState.activatorBuilderState.setCurrentActivatorConfiguration(
1132
+ undefined,
1133
+ )
1134
+ }
1135
+ >
1136
+ Close
1137
+ </button>
1138
+ </ModalFooter>
1139
+ </Modal>
1140
+ </Dialog>
1141
+ )}
1142
+ </>
1143
+ )}
900
1144
  <button
901
1145
  className="panel__header__action"
902
- disabled={isReadOnly || selectedTab === FUNCTION_SPEC_TAB.GENERAL}
1146
+ disabled={
1147
+ isReadOnly || selectedTab === FUNCTION_EDITOR_TAB.DEFINITION
1148
+ }
903
1149
  onClick={add}
904
1150
  tabIndex={-1}
905
1151
  title={addButtonTitle}
@@ -908,56 +1154,56 @@ export const FunctionEditor = observer(() => {
908
1154
  </button>
909
1155
  </div>
910
1156
  </div>
911
- {selectedTab === FUNCTION_SPEC_TAB.GENERAL ? (
912
- <FunctionMainEditor
913
- functionEditorState={functionEditorState}
914
- functionElement={functionElement}
915
- isReadOnly={isReadOnly}
916
- />
917
- ) : (
918
- <PanelContent>
919
- {selectedTab === FUNCTION_SPEC_TAB.TAGGED_VALUES && (
920
- <div
921
- ref={dropTaggedValueRef}
922
- className={clsx('panel__content__lists', {
923
- 'panel__content__lists--dnd-over':
924
- isTaggedValueDragOver && !isReadOnly,
925
- })}
926
- >
927
- <TaggedValueDragPreviewLayer />
928
- {functionElement.taggedValues.map((taggedValue) => (
929
- <TaggedValueEditor
930
- annotatedElement={functionElement}
931
- key={taggedValue._UUID}
932
- taggedValue={taggedValue}
933
- deleteValue={_deleteTaggedValue(taggedValue)}
934
- isReadOnly={isReadOnly}
935
- />
936
- ))}
937
- </div>
938
- )}
939
- {selectedTab === FUNCTION_SPEC_TAB.STEREOTYPES && (
940
- <div
941
- ref={dropStereotypeRef}
942
- className={clsx('panel__content__lists', {
943
- 'panel__content__lists--dnd-over':
944
- isStereotypeDragOver && !isReadOnly,
945
- })}
946
- >
947
- <StereotypeDragPreviewLayer />
948
- {functionElement.stereotypes.map((stereotype) => (
949
- <StereotypeSelector
950
- key={stereotype.value._UUID}
951
- annotatedElement={functionElement}
952
- stereotype={stereotype}
953
- deleteStereotype={_deleteStereotype(stereotype)}
954
- isReadOnly={isReadOnly}
955
- />
956
- ))}
957
- </div>
958
- )}
959
- </PanelContent>
960
- )}
1157
+ <PanelContent>
1158
+ {selectedTab === FUNCTION_EDITOR_TAB.DEFINITION && (
1159
+ <FunctionDefinitionEditor
1160
+ functionEditorState={functionEditorState}
1161
+ isReadOnly={isReadOnly}
1162
+ />
1163
+ )}
1164
+ {selectedTab === FUNCTION_EDITOR_TAB.TAGGED_VALUES && (
1165
+ <div
1166
+ ref={dropTaggedValueRef}
1167
+ className={clsx('panel__content__lists', {
1168
+ 'panel__content__lists--dnd-over':
1169
+ isTaggedValueDragOver && !isReadOnly,
1170
+ })}
1171
+ >
1172
+ <TaggedValueDragPreviewLayer />
1173
+ {functionElement.taggedValues.map((taggedValue) => (
1174
+ <TaggedValueEditor
1175
+ annotatedElement={functionElement}
1176
+ key={taggedValue._UUID}
1177
+ taggedValue={taggedValue}
1178
+ deleteValue={_deleteTaggedValue(taggedValue)}
1179
+ isReadOnly={isReadOnly}
1180
+ darkTheme={true}
1181
+ />
1182
+ ))}
1183
+ </div>
1184
+ )}
1185
+ {selectedTab === FUNCTION_EDITOR_TAB.STEREOTYPES && (
1186
+ <div
1187
+ ref={dropStereotypeRef}
1188
+ className={clsx('panel__content__lists', {
1189
+ 'panel__content__lists--dnd-over':
1190
+ isStereotypeDragOver && !isReadOnly,
1191
+ })}
1192
+ >
1193
+ <StereotypeDragPreviewLayer />
1194
+ {functionElement.stereotypes.map((stereotype) => (
1195
+ <StereotypeSelector
1196
+ key={stereotype.value._UUID}
1197
+ annotatedElement={functionElement}
1198
+ stereotype={stereotype}
1199
+ deleteStereotype={_deleteStereotype(stereotype)}
1200
+ isReadOnly={isReadOnly}
1201
+ darkTheme={true}
1202
+ />
1203
+ ))}
1204
+ </div>
1205
+ )}
1206
+ </PanelContent>
961
1207
  </Panel>
962
1208
  </div>
963
1209
  );