@elyx-code/editor-ui 0.0.2
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.
- package/README.md +2 -0
- package/package.json +109 -0
- package/src/App.tsx +31 -0
- package/src/Router.tsx +115 -0
- package/src/__mocks__/defaultModuleMock.ts +1 -0
- package/src/__mocks__/fileMock.ts +1 -0
- package/src/__mocks__/styleMock.ts +1 -0
- package/src/assets/Clock-11.1s-18px.svg +16 -0
- package/src/assets/Clock-11.1s-28px.svg +16 -0
- package/src/assets/authentication.svg +1 -0
- package/src/assets/canvas-backdrop-0.png +0 -0
- package/src/assets/canvas-backdrop-1.png +0 -0
- package/src/assets/canvas-backdrop-2.png +0 -0
- package/src/assets/canvas-backdrop-3.png +0 -0
- package/src/assets/canvas-backdrop-4.png +0 -0
- package/src/assets/canvas-backdrop-5.png +0 -0
- package/src/assets/canvas-backdrop.png +0 -0
- package/src/assets/checkmark-animation.gif +0 -0
- package/src/assets/checkmark-animation.mp4 +0 -0
- package/src/assets/code-formatting/format-black.svg +6 -0
- package/src/assets/code-formatting/format-dark-grey.svg +6 -0
- package/src/assets/code-formatting/format-light-grey.svg +6 -0
- package/src/assets/code-formatting/format-white.svg +6 -0
- package/src/assets/code-formatting/inline-black.svg +5 -0
- package/src/assets/code-formatting/inline-dark-grey.svg +5 -0
- package/src/assets/code-formatting/inline-light-grey.svg +5 -0
- package/src/assets/code-formatting/inline-white.svg +5 -0
- package/src/assets/contained-logo-full-word.png +0 -0
- package/src/assets/cron-job-color.png +0 -0
- package/src/assets/cron-job.png +0 -0
- package/src/assets/database-table-color.png +0 -0
- package/src/assets/database-table.png +0 -0
- package/src/assets/datatype-icons/black/any.svg +1 -0
- package/src/assets/datatype-icons/black/binary.svg +1 -0
- package/src/assets/datatype-icons/black/boolean.svg +3 -0
- package/src/assets/datatype-icons/black/date-time.svg +3 -0
- package/src/assets/datatype-icons/black/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/black/key-file.svg +1 -0
- package/src/assets/datatype-icons/black/list.svg +3 -0
- package/src/assets/datatype-icons/black/null.svg +3 -0
- package/src/assets/datatype-icons/black/number.svg +13 -0
- package/src/assets/datatype-icons/black/project.svg +12 -0
- package/src/assets/datatype-icons/black/sql-program.svg +2 -0
- package/src/assets/datatype-icons/black/text.svg +3 -0
- package/src/assets/datatype-icons/black/unknown.svg +3 -0
- package/src/assets/datatype-icons/black/uuid.svg +4 -0
- package/src/assets/datatype-icons/black/void.svg +1 -0
- package/src/assets/datatype-icons/dark-grey/any.svg +1 -0
- package/src/assets/datatype-icons/dark-grey/boolean.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/date-time.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/dark-grey/list.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/null.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/number.svg +13 -0
- package/src/assets/datatype-icons/dark-grey/project.svg +12 -0
- package/src/assets/datatype-icons/dark-grey/sql-program.svg +2 -0
- package/src/assets/datatype-icons/dark-grey/text.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/unknown.svg +3 -0
- package/src/assets/datatype-icons/dark-grey/uuid.svg +4 -0
- package/src/assets/datatype-icons/dark-grey/void.svg +1 -0
- package/src/assets/datatype-icons/light-grey/any.svg +1 -0
- package/src/assets/datatype-icons/light-grey/boolean.svg +3 -0
- package/src/assets/datatype-icons/light-grey/date-time.svg +3 -0
- package/src/assets/datatype-icons/light-grey/definition-entity.svg +6 -0
- package/src/assets/datatype-icons/light-grey/list.svg +3 -0
- package/src/assets/datatype-icons/light-grey/null.svg +3 -0
- package/src/assets/datatype-icons/light-grey/number.svg +13 -0
- package/src/assets/datatype-icons/light-grey/project.svg +12 -0
- package/src/assets/datatype-icons/light-grey/sql-program.svg +2 -0
- package/src/assets/datatype-icons/light-grey/text.svg +3 -0
- package/src/assets/datatype-icons/light-grey/unknown.svg +3 -0
- package/src/assets/datatype-icons/light-grey/uuid.svg +4 -0
- package/src/assets/datatype-icons/light-grey/void.svg +1 -0
- package/src/assets/edit.png +0 -0
- package/src/assets/execution.svg +13 -0
- package/src/assets/favicon.svg +14 -0
- package/src/assets/file-search.svg +1 -0
- package/src/assets/http-endpoint.png +0 -0
- package/src/assets/image-input-placeholder.png +0 -0
- package/src/assets/logo-full-word-white.png +0 -0
- package/src/assets/logo-full-word.png +0 -0
- package/src/assets/password.svg +85 -0
- package/src/assets/pencil.png +0 -0
- package/src/assets/publish-project-rich-icon-2.svg +1 -0
- package/src/assets/publish-project-rich-icon.svg +1 -0
- package/src/assets/relational-database.png +0 -0
- package/src/assets/resources.svg +3 -0
- package/src/assets/resume-icon-14px.png +0 -0
- package/src/assets/server.png +0 -0
- package/src/assets/small-status/checkmark.svg +4 -0
- package/src/assets/small-status/error.svg +4 -0
- package/src/assets/small-status/loading.svg +4 -0
- package/src/assets/small-status/skipped.svg +11 -0
- package/src/assets/sql-connection-config.svg +1 -0
- package/src/assets/sql-row-transformer.svg +1 -0
- package/src/assets/ssl-certificate-config.svg +1 -0
- package/src/assets/sync.svg +1 -0
- package/src/assets/testing-logic-icon.svg +1 -0
- package/src/assets/versions.svg +25 -0
- package/src/assets/visual-programming-icon.svg +1 -0
- package/src/assets/warning-sign-24px.png +0 -0
- package/src/auth/index.ts +318 -0
- package/src/components/DialogLoader.tsx +94 -0
- package/src/components/EntityDialogHeader.tsx +110 -0
- package/src/components/EntityDialogSectionHeader.tsx +214 -0
- package/src/components/GalleryAddExternalIntegrationInfoDialog.tsx +87 -0
- package/src/components/GenerateProjectStartingLogicPromptDialog.tsx +281 -0
- package/src/components/LegacyRouteRedirector.tsx +55 -0
- package/src/components/ProPlanChip.tsx +23 -0
- package/src/components/ReportBugDialog.tsx +412 -0
- package/src/components/RequestIntegrationAccessDialog.tsx +261 -0
- package/src/components/UseTemplateProjectDialog.tsx +193 -0
- package/src/components/WorkspaceLayout.tsx +152 -0
- package/src/components/animated-svg/AnimatedCheckmark.tsx +41 -0
- package/src/components/animated-svg/AnimatedCrossmark.tsx +51 -0
- package/src/components/animated-svg/AnimatedEmailSending.tsx +38 -0
- package/src/components/animated-svg/AnimatedLoading.tsx +72 -0
- package/src/components/animated-svg/animated-svg.css +239 -0
- package/src/components/canvas/Canvas.tsx +16 -0
- package/src/components/canvas/CreateEntityMenu.tsx +2020 -0
- package/src/components/canvas/canvas.css +10 -0
- package/src/components/canvas/create-entity-menu.css +579 -0
- package/src/components/canvas-search/CanvasSearch.tsx +501 -0
- package/src/components/canvas-search/canvas-search.css +126 -0
- package/src/components/canvas-settings-menu/CanvasSettingsMenuButton.tsx +515 -0
- package/src/components/canvas-settings-menu/canvas-settings-menu.css +96 -0
- package/src/components/circular-image-upload/CircularImageUpload.tsx +113 -0
- package/src/components/circular-image-upload/circular-image-upload.css +69 -0
- package/src/components/costs/CostsDialog.tsx +459 -0
- package/src/components/data-type/DataTypeBuilder.tsx +3127 -0
- package/src/components/data-type/data-type-builder.css +45 -0
- package/src/components/dialogs/BetaAcknowledgeDialog.tsx +43 -0
- package/src/components/dialogs/ComplexDataDialog.tsx +458 -0
- package/src/components/dialogs/CronBuilderDialog.tsx +2145 -0
- package/src/components/dialogs/ExternalIntegrationConnections.tsx +565 -0
- package/src/components/dialogs/JsonEditorDialog.tsx +1392 -0
- package/src/components/dialogs/StringEditorDialog.tsx +268 -0
- package/src/components/dialogs/argument-declaration/ArgumentDeclaration.tsx +1167 -0
- package/src/components/dialogs/argument-declaration/ArgumentDeclarationDialogContent.tsx +128 -0
- package/src/components/dialogs/beta-dialog.css +165 -0
- package/src/components/dialogs/condition/Condition.tsx +431 -0
- package/src/components/dialogs/condition/ConditionDialogContent.tsx +126 -0
- package/src/components/dialogs/definition-entity/DefinitionEntityDialogContent.tsx +973 -0
- package/src/components/dialogs/function-call/FunctionCall.tsx +442 -0
- package/src/components/dialogs/function-call/FunctionCallDialogContent.tsx +126 -0
- package/src/components/dialogs/function-declaration/FunctionDeclaration.tsx +926 -0
- package/src/components/dialogs/function-declaration/FunctionDeclarationDialogContent.tsx +124 -0
- package/src/components/dialogs/generating-project-starting-logic-overlay/GeneratingProjectStartingLogicOverlay.tsx +176 -0
- package/src/components/dialogs/generating-project-starting-logic-overlay/generating-project-starting-logic-overlay.css +13 -0
- package/src/components/dialogs/global-event/GlobalEvent.tsx +475 -0
- package/src/components/dialogs/global-event/GlobalEventDialogContent.tsx +126 -0
- package/src/components/dialogs/help/HelpDialog.tsx +217 -0
- package/src/components/dialogs/help/HelpDilalogHomeContent.tsx +178 -0
- package/src/components/dialogs/help/help-dialog.css +116 -0
- package/src/components/dialogs/help/help-icon/HelpIconButton.tsx +41 -0
- package/src/components/dialogs/help/help-icon/help-icon.css +9 -0
- package/src/components/dialogs/input-map/InputMap.tsx +635 -0
- package/src/components/dialogs/input-map/InputMapDialogContent.tsx +126 -0
- package/src/components/dialogs/json-editor-dialog.css +4 -0
- package/src/components/dialogs/loop/Loop.tsx +650 -0
- package/src/components/dialogs/loop/LoopDialogContent.tsx +122 -0
- package/src/components/dialogs/operation/Operation.tsx +440 -0
- package/src/components/dialogs/operation/OperationDialogContent.tsx +126 -0
- package/src/components/dialogs/output-map/OutputMap.tsx +536 -0
- package/src/components/dialogs/output-map/OutputMapDialogContent.tsx +126 -0
- package/src/components/dialogs/property/Property.tsx +1490 -0
- package/src/components/dialogs/property/PropertyDialogContent.tsx +106 -0
- package/src/components/dialogs/search-statement/ColumnSelector.tsx +334 -0
- package/src/components/dialogs/search-statement/ConditionBuilder.tsx +750 -0
- package/src/components/dialogs/search-statement/DataAggregationSection.tsx +621 -0
- package/src/components/dialogs/search-statement/DataSourceSelection.tsx +734 -0
- package/src/components/dialogs/search-statement/EntityMetadataSection.tsx +135 -0
- package/src/components/dialogs/search-statement/FilterConditionsSection.tsx +151 -0
- package/src/components/dialogs/search-statement/InlineInputMap.tsx +153 -0
- package/src/components/dialogs/search-statement/LiteralValue.tsx +616 -0
- package/src/components/dialogs/search-statement/MainSourceAndInputsSection.tsx +271 -0
- package/src/components/dialogs/search-statement/NestedSearchStatementBuilder.tsx +170 -0
- package/src/components/dialogs/search-statement/OutputFormatSection.tsx +1779 -0
- package/src/components/dialogs/search-statement/ResultsSection.tsx +344 -0
- package/src/components/dialogs/search-statement/SearchStatementBuilder.tsx +251 -0
- package/src/components/dialogs/search-statement/SearchStatementDialogContent.tsx +398 -0
- package/src/components/dialogs/search-statement/ValueSelector.tsx +766 -0
- package/src/components/dialogs/search-statement/search-statement-context.tsx +1630 -0
- package/src/components/dialogs/search-statement/search-statement-dialog.css +56 -0
- package/src/components/dialogs/search-statement/test.sql +111 -0
- package/src/components/dialogs/value-descriptor/ValueDescriptor.tsx +824 -0
- package/src/components/dialogs/value-descriptor/ValueDescriptorDialogContent.tsx +124 -0
- package/src/components/dialogs/variable-declaration/VariableDeclaration.tsx +836 -0
- package/src/components/dialogs/variable-declaration/VariableDeclarationDialogContent.tsx +106 -0
- package/src/components/dialogs/variable-instance/VariableInstance.tsx +443 -0
- package/src/components/dialogs/variable-instance/VariableInstanceDialogContent.tsx +124 -0
- package/src/components/draggable-entity-card/ArgumentDeclaration.tsx +736 -0
- package/src/components/draggable-entity-card/CollapseEntityButton.tsx +170 -0
- package/src/components/draggable-entity-card/ConditionCard.tsx +1062 -0
- package/src/components/draggable-entity-card/ConnectionDeleteButton.tsx +309 -0
- package/src/components/draggable-entity-card/DataTypeIcon.tsx +624 -0
- package/src/components/draggable-entity-card/DraggableEntityCard.tsx +617 -0
- package/src/components/draggable-entity-card/ErrorMapProperty.tsx +464 -0
- package/src/components/draggable-entity-card/EventCard.tsx +700 -0
- package/src/components/draggable-entity-card/ExecutionInProgressValue.tsx +327 -0
- package/src/components/draggable-entity-card/FunctionDeclarationCard.tsx +819 -0
- package/src/components/draggable-entity-card/InputMapProperty.tsx +1067 -0
- package/src/components/draggable-entity-card/InternalCall.tsx +978 -0
- package/src/components/draggable-entity-card/InternalCallExecutionNode.tsx +643 -0
- package/src/components/draggable-entity-card/LogicScopeCallerNode.tsx +262 -0
- package/src/components/draggable-entity-card/LoopCard.tsx +791 -0
- package/src/components/draggable-entity-card/MainValueInput.tsx +523 -0
- package/src/components/draggable-entity-card/MainValueOutput.tsx +458 -0
- package/src/components/draggable-entity-card/MethodDeclaration.tsx +1088 -0
- package/src/components/draggable-entity-card/NestedCondition.tsx +1025 -0
- package/src/components/draggable-entity-card/OutputMapProperty.tsx +843 -0
- package/src/components/draggable-entity-card/PassthroughEntityCard.tsx +1247 -0
- package/src/components/draggable-entity-card/ReturnedError.tsx +549 -0
- package/src/components/draggable-entity-card/SmallSuccessFailureNodes.tsx +523 -0
- package/src/components/draggable-entity-card/SuccessFailureNodes.tsx +509 -0
- package/src/components/draggable-entity-card/TestEntityButton.tsx +946 -0
- package/src/components/draggable-entity-card/TestMenu.tsx +523 -0
- package/src/components/draggable-entity-card/TestMenuValidationDropdown.tsx +84 -0
- package/src/components/draggable-entity-card/UnreachableMarker.tsx +114 -0
- package/src/components/draggable-entity-card/VariableCard.tsx +1577 -0
- package/src/components/draggable-entity-card/VariableScopeMarker.tsx +117 -0
- package/src/components/draggable-entity-card/collapse-entity-button.css +44 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityCard.tsx +1181 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityIcon.tsx +36 -0
- package/src/components/draggable-entity-card/definition-entity/DefinitionEntityProperty.tsx +478 -0
- package/src/components/draggable-entity-card/definition-entity/DynamicFooterActions.tsx +112 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/ExportCredentialsFooterAction.tsx +461 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/RestablishConnectionFooterAction.tsx +199 -0
- package/src/components/draggable-entity-card/definition-entity/actions/external-integration-connection/restablish-connection-footer-action.css +85 -0
- package/src/components/draggable-entity-card/definition-entity/actions/google-drive/GoogleDriveFilePickerAPIFooterAction.tsx +277 -0
- package/src/components/draggable-entity-card/definition-entity/actions/google-drive/google-drive-file-picker-api-footer-action.css +107 -0
- package/src/components/draggable-entity-card/definition-entity/actions/persisted-entity/DatabaseFooterAction.tsx +452 -0
- package/src/components/draggable-entity-card/definition-entity/actions/persisted-entity/database-footer-action.css +86 -0
- package/src/components/draggable-entity-card/definition-entity/definition-entity-card.css +17 -0
- package/src/components/draggable-entity-card/draggable-entity-card.css +1140 -0
- package/src/components/draggable-entity-card/entity-locked-icon/EntityLockedIcon.tsx +133 -0
- package/src/components/draggable-entity-card/entity-locked-icon/entity-locked.css +8 -0
- package/src/components/draggable-entity-card/expand-properties-icon-button/ExpandPropertiesIconButton.tsx +84 -0
- package/src/components/draggable-entity-card/expand-properties-icon-button/expand-properties-icon-button.css +21 -0
- package/src/components/draggable-entity-card/implement-entity-icon/ImplementEntityIcon.tsx +74 -0
- package/src/components/draggable-entity-card/implement-entity-icon/implement-entity-icon.css +13 -0
- package/src/components/draggable-entity-card/logic-error/LogicErrorIconMenu.tsx +424 -0
- package/src/components/draggable-entity-card/logic-error/logic-error.css +23 -0
- package/src/components/draggable-entity-card/new-card-input-button/NewCardInputButton.tsx +193 -0
- package/src/components/draggable-entity-card/new-card-input-button/NewDynamicInputButton.tsx +214 -0
- package/src/components/draggable-entity-card/new-card-input-button/new-card-input-button.css +71 -0
- package/src/components/draggable-entity-card/new-card-output-button/NewCardOutputButton.tsx +192 -0
- package/src/components/draggable-entity-card/new-card-output-button/new-card-output-button.css +71 -0
- package/src/components/draggable-entity-card/termination-statement/TerminationStatementCard.tsx +1543 -0
- package/src/components/draggable-entity-card/termination-statement/termination-statement-card.css +17 -0
- package/src/components/draggable-entity-card/test-entity-button.css +55 -0
- package/src/components/draggable-entity-card/test-menu.css +181 -0
- package/src/components/draggable-entity-card/unreachable-marker.css +43 -0
- package/src/components/draggable-entity-card/variable-scope-marker.css +22 -0
- package/src/components/dynamic-value/DynamicValue.tsx +2395 -0
- package/src/components/dynamic-value/DynamicValueEntry.tsx +1957 -0
- package/src/components/dynamic-value/dynamic-value.css +230 -0
- package/src/components/editor/ElyxMonacoEditor.tsx +38 -0
- package/src/components/entity-error/EntityErrorListItem.tsx +47 -0
- package/src/components/entity-error/entity-error.css +198 -0
- package/src/components/entity-icon/EntityIcon.tsx +292 -0
- package/src/components/entity-icon/entity-icon.css +39 -0
- package/src/components/gallery-card/CreateNewProject.tsx +222 -0
- package/src/components/gallery-card/GalleryCard.tsx +171 -0
- package/src/components/gallery-card/MarketplaceCard.tsx +87 -0
- package/src/components/gallery-card/ProjectDuplicationCard.tsx +575 -0
- package/src/components/gallery-card/gallery-card.css +25 -0
- package/src/components/notifications/NotificationsIconButton.tsx +124 -0
- package/src/components/notifications/NotificationsPanel.tsx +385 -0
- package/src/components/notifications/notifications.css +189 -0
- package/src/components/online-users/LocalOnlineUsers.tsx +175 -0
- package/src/components/online-users/PageOnlineUsers.tsx +297 -0
- package/src/components/online-users/online-users.css +72 -0
- package/src/components/page-backdrop/PageBackdrop.tsx +8 -0
- package/src/components/page-backdrop/page-backdrop.css +7 -0
- package/src/components/project-configuration/DeleteProjectConfirmationDialog.tsx +134 -0
- package/src/components/project-configuration/ProjectConfigurationDialog.tsx +972 -0
- package/src/components/project-configuration/ProjectDataForm.tsx +121 -0
- package/src/components/project-configuration/UnpublishProjectConfirmationDialog.tsx +162 -0
- package/src/components/project-configuration/project-configuration-content.css +209 -0
- package/src/components/project-name/ProjectName.tsx +2025 -0
- package/src/components/project-name/project-name.css +599 -0
- package/src/components/publishing/Publication.tsx +133 -0
- package/src/components/publishing/history/PublicationHistoryContent.tsx +414 -0
- package/src/components/publishing/history/PublicationHistoryDialog.tsx +234 -0
- package/src/components/publishing/preview/PublicationPreviewDialog.tsx +1158 -0
- package/src/components/publishing/preview/PublishingPriceForecast.tsx +160 -0
- package/src/components/publishing/preview/PublishingResourcesDetails.tsx +91 -0
- package/src/components/publishing/publication-sequence/PublishingSequenceContent.tsx +375 -0
- package/src/components/publishing/publication-sequence/PublishingSequenceDialog.tsx +344 -0
- package/src/components/publishing/publishing-dialog.css +142 -0
- package/src/components/publishing/utils.ts +227 -0
- package/src/components/resources/ResourcesDialog.tsx +591 -0
- package/src/components/resources/UpgradeBanner.tsx +102 -0
- package/src/components/resources/codebase/CodebaseDetails.tsx +156 -0
- package/src/components/resources/cron-job/CronJobsList.tsx +532 -0
- package/src/components/resources/functions/FunctionsList.tsx +454 -0
- package/src/components/resources/http-api/HttpAPI.tsx +566 -0
- package/src/components/resources/http-api/HttpAPIClientModule.tsx +37 -0
- package/src/components/resources/logs/LogsViewer.tsx +768 -0
- package/src/components/resources/query.ts +74 -0
- package/src/components/resources/relational-database/DatabaseTable.tsx +905 -0
- package/src/components/resources/relational-database/RelationalDatabase.tsx +83 -0
- package/src/components/resources/relational-database/RelationalDatabaseSecrets.tsx +361 -0
- package/src/components/resources/resources-dialog.css +74 -0
- package/src/components/test-relational-database/DatabaseTable.tsx +913 -0
- package/src/components/test-relational-database/TestDatabaseDialogContent.tsx +670 -0
- package/src/components/test-relational-database/query.ts +74 -0
- package/src/components/toolbar/ToolBar.tsx +236 -0
- package/src/components/toolbar/toolbar.css +78 -0
- package/src/components/transaction-history/TransactionHistoryDialog.tsx +268 -0
- package/src/components/user/CurrentUserAvatar.tsx +65 -0
- package/src/components/user/UserChip.tsx +62 -0
- package/src/components/user/user.css +39 -0
- package/src/components/user-profile/ChangePasswordForm.tsx +67 -0
- package/src/components/user-profile/OwnUserProfileContent.tsx +665 -0
- package/src/components/user-profile/PublicUserProfileContent.tsx +99 -0
- package/src/components/user-profile/UserDataForm.tsx +75 -0
- package/src/components/user-profile/UserProfileDialog.tsx +110 -0
- package/src/components/user-profile/user-profile-content.css +25 -0
- package/src/config.ts +130 -0
- package/src/globals.d.ts +13 -0
- package/src/index.html +27 -0
- package/src/index.tsx +23 -0
- package/src/lib/badge/Badge.tsx +35 -0
- package/src/lib/badge/badge.css +32 -0
- package/src/lib/button/Button.tsx +129 -0
- package/src/lib/button/button.css +145 -0
- package/src/lib/canvas/canvas-undo-redo.ts +263 -0
- package/src/lib/canvas/defs.ts +170 -0
- package/src/lib/canvas/index.test.ts +189 -0
- package/src/lib/canvas/index.ts +6999 -0
- package/src/lib/canvas/utils.ts +59 -0
- package/src/lib/card/Card.tsx +62 -0
- package/src/lib/card/LoadingCard.tsx +82 -0
- package/src/lib/card/card.css +259 -0
- package/src/lib/chip/Chip.tsx +79 -0
- package/src/lib/chip/chip.css +0 -0
- package/src/lib/dialog/Dialog.tsx +122 -0
- package/src/lib/dialog/SmallDialog.tsx +61 -0
- package/src/lib/dialog/dialog.css +40 -0
- package/src/lib/display-data-structure/index.tsx +21 -0
- package/src/lib/dropdown/CanvasDropdownMenuCard.tsx +68 -0
- package/src/lib/dropdown/CanvasDropdownMenuCardOption.tsx +136 -0
- package/src/lib/dropdown/DropdownButton.tsx +104 -0
- package/src/lib/dropdown/DropdownMenuCard.tsx +324 -0
- package/src/lib/dropdown/DropdownMenuPopup.tsx +27 -0
- package/src/lib/dropdown/dropdown-button.css +76 -0
- package/src/lib/dropdown/dropdown-menu.css +151 -0
- package/src/lib/json-editor/RawJsonEditor.tsx +137 -0
- package/src/lib/json-editor/json-editor.css +35 -0
- package/src/lib/loader/Loader.tsx +120 -0
- package/src/lib/loader/loader.css +38 -0
- package/src/lib/pagination/Pagination.tsx +64 -0
- package/src/lib/popup/CanvasPopupBaseComponent.tsx +103 -0
- package/src/lib/popup/Popup.tsx +243 -0
- package/src/lib/popup/popup.css +16 -0
- package/src/lib/table/RowForm.tsx +301 -0
- package/src/lib/table/Table.tsx +1069 -0
- package/src/lib/table/table.css +249 -0
- package/src/lib/table/types.ts +108 -0
- package/src/lib/text-area/TextArea.tsx +183 -0
- package/src/lib/text-area/text-area.css +156 -0
- package/src/lib/text-field/TextField.tsx +218 -0
- package/src/lib/text-field/index.ts +8 -0
- package/src/lib/text-field/text-field.css +201 -0
- package/src/lib/tooltip/Tooltip.tsx +24 -0
- package/src/lib/tooltip/tooltip.css +17 -0
- package/src/localization/index.ts +47 -0
- package/src/main.css +343 -0
- package/src/pages/Auth.tsx +848 -0
- package/src/pages/Editor.tsx +883 -0
- package/src/pages/ErrorPage.tsx +179 -0
- package/src/pages/Gallery.tsx +1693 -0
- package/src/pages/NewPaymentMethodCallback.tsx +53 -0
- package/src/pages/NotFoundPage.tsx +126 -0
- package/src/pages/PricingPlans.tsx +155 -0
- package/src/pages/auth.css +304 -0
- package/src/pages/gallery.css +421 -0
- package/src/payments/index.ts +187 -0
- package/src/popup-notification/index.ts +90 -0
- package/src/services/database/index.ts +1 -0
- package/src/services/database/utils.ts +1301 -0
- package/src/services/editor/CanvasElement.tsx +2934 -0
- package/src/services/editor/CanvasElementConnectionDeleteButton.ts +204 -0
- package/src/services/editor/CanvasPopup.tsx +749 -0
- package/src/services/editor/EditorService.ts +8157 -0
- package/src/services/editor/area.ts +1312 -0
- package/src/services/editor/connections.ts +1019 -0
- package/src/services/editor/create/condition.ts +25 -0
- package/src/services/editor/create/definition-entity.ts +29 -0
- package/src/services/editor/create/function-call.ts +25 -0
- package/src/services/editor/create/global-event.ts +33 -0
- package/src/services/editor/create/loop.ts +25 -0
- package/src/services/editor/create/operation.ts +30 -0
- package/src/services/editor/create/utils.ts +140 -0
- package/src/services/editor/create/variable-declaration.ts +135 -0
- package/src/services/editor/create/variable-instance.ts +100 -0
- package/src/services/editor/editor-ui-extensions-context.ts +43 -0
- package/src/services/editor/entities-metadata.json +9310 -0
- package/src/services/editor/icons.ts +1093 -0
- package/src/services/editor/index.ts +1 -0
- package/src/services/editor/layout.ts +102 -0
- package/src/services/editor/modules/built-in-function-implementations/base.ts +14 -0
- package/src/services/editor/modules/built-in-function-implementations/create-persisted-entity/index.ts +56 -0
- package/src/services/editor/modules/built-in-function-implementations/delete-persisted-entity/index.ts +55 -0
- package/src/services/editor/modules/built-in-function-implementations/index.ts +4 -0
- package/src/services/editor/modules/built-in-function-implementations/update-persisted-entity/index.ts +56 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/get-files.ts +183 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/list-drives.ts +124 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/list-root-folders.ts +125 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/smart-fetch-document.ts +702 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-drive/upload-document.ts +535 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-gemini/generate-content.ts +193 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-mail/get-emails.ts +586 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/google-mail/send-email.ts +386 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/index.ts +12 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/channels.ts +240 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/messages.ts +210 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/replies.ts +200 -0
- package/src/services/editor/modules/operations-implementations/external-integrations/slack/send-message.ts +177 -0
- package/src/services/editor/modules/operations-implementations/index.ts +1 -0
- package/src/services/editor/modules/search-node-implementation/index.ts +42 -0
- package/src/services/editor/modules/sql-migrations-generation.tsx +1054 -0
- package/src/services/editor/publication/publication.ts +578 -0
- package/src/services/editor/ui.ts +1348 -0
- package/src/services/editor/utils.ts +5868 -0
- package/src/services/editor/value-store.ts +619 -0
- package/src/services/execution/built-in-function-implementations.ts +422 -0
- package/src/services/execution/index.ts +4747 -0
- package/src/services/execution/logic.ts +121 -0
- package/src/services/execution/test-instance.tsx +2296 -0
- package/src/services/execution/utils.ts +33 -0
- package/src/services/execution/value-resolution.test.ts +424 -0
- package/src/services/execution/value-resolution.ts +4087 -0
- package/src/services/integrations/ExternalIntegrationsService.ts +439 -0
- package/src/services/integrations/api.ts +175 -0
- package/src/services/local-relational-database/idb_helper.ts +66 -0
- package/src/services/local-relational-database/index.ts +3308 -0
- package/src/services/local-relational-database/utils.ts +403 -0
- package/src/services/notifications/index.ts +525 -0
- package/src/services/user/index.ts +144 -0
- package/src/setupTests.ts +1 -0
- package/src/socket/socket.ts +248 -0
- package/src/socket/utils.ts +10 -0
- package/src/store/workspace.ts +12 -0
- package/src/theme.ts +19 -0
- package/src/utils/DOM.ts +39 -0
- package/src/utils/date.ts +169 -0
- package/src/utils/index.ts +158 -0
- package/src/utils/react.tsx +679 -0
- package/src/utils/testing.ts +103 -0
|
@@ -0,0 +1,2934 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CanvasObject, DraggableObject } from '../../lib/canvas';
|
|
3
|
+
import {
|
|
4
|
+
ConnectionNodeType,
|
|
5
|
+
IConnectionDrawingOptions,
|
|
6
|
+
EditorService
|
|
7
|
+
} from '.';
|
|
8
|
+
import {
|
|
9
|
+
ArgumentDeclarationState,
|
|
10
|
+
BreakStatementState,
|
|
11
|
+
CallableEntityState,
|
|
12
|
+
CallerEntityState,
|
|
13
|
+
CanvasEntityState,
|
|
14
|
+
ChangeSet,
|
|
15
|
+
ChangeSetEntityChangeType,
|
|
16
|
+
ConditionState,
|
|
17
|
+
ContinueStatementState,
|
|
18
|
+
createStateFromTypeAndSubscribe,
|
|
19
|
+
DefinitionEntityState,
|
|
20
|
+
DraggablePassThroughCallableEntityState,
|
|
21
|
+
EntryPointEntityState,
|
|
22
|
+
ExecutableEntityState,
|
|
23
|
+
FunctionCallState,
|
|
24
|
+
FunctionDeclarationState,
|
|
25
|
+
getDeclaration,
|
|
26
|
+
getFirstNonLoopScopeOwner,
|
|
27
|
+
getScopeOwner,
|
|
28
|
+
getTouchedCanvasEntitiesFromChangeSet,
|
|
29
|
+
GlobalEventNames,
|
|
30
|
+
GlobalEventState,
|
|
31
|
+
IActionDescriptorTransfer,
|
|
32
|
+
IFunctionDeclarationTransfer,
|
|
33
|
+
InputMapState,
|
|
34
|
+
InstalledProjectState,
|
|
35
|
+
InternalCallState,
|
|
36
|
+
LoopState,
|
|
37
|
+
OperationState,
|
|
38
|
+
OutputMapState,
|
|
39
|
+
PassThroughCallableEntityState,
|
|
40
|
+
ProjectState,
|
|
41
|
+
resolveEntityName,
|
|
42
|
+
ReturnStatementState,
|
|
43
|
+
SearchState,
|
|
44
|
+
TerminationEntityState,
|
|
45
|
+
UserManagedEntityState,
|
|
46
|
+
ValueDescriptorState,
|
|
47
|
+
ValueReadingEntityState,
|
|
48
|
+
ValueWritingEntityState,
|
|
49
|
+
VariableDeclarationState,
|
|
50
|
+
VariableState,
|
|
51
|
+
READABLE_ENTITY_TYPES,
|
|
52
|
+
flattenRelatedCanvasElementsOnTheRight,
|
|
53
|
+
mapActionDescriptorToTypeItRepresents,
|
|
54
|
+
ENTRY_POINT_TYPES,
|
|
55
|
+
EntityType,
|
|
56
|
+
filterOutDuplicateEntitiesAsync,
|
|
57
|
+
DataTypeState,
|
|
58
|
+
BUILT_IN_BASE_ENTITY_IDS,
|
|
59
|
+
PrimitiveEntityState,
|
|
60
|
+
IPrimitiveEntityTransfer,
|
|
61
|
+
StateMutationAction,
|
|
62
|
+
BaseEntityNames,
|
|
63
|
+
toKebabCase
|
|
64
|
+
} from '@elyx-code/project-logic-tree';
|
|
65
|
+
import {
|
|
66
|
+
getCanvasEntityDraggableContainerDOMId,
|
|
67
|
+
highlightElement,
|
|
68
|
+
highlighOverlappingElements,
|
|
69
|
+
getEntityIdFromCanvasId
|
|
70
|
+
} from './ui';
|
|
71
|
+
import DraggableEntityCard from '../../components/draggable-entity-card/DraggableEntityCard';
|
|
72
|
+
import VariableCard from '../../components/draggable-entity-card/VariableCard';
|
|
73
|
+
import LoopCard from '../../components/draggable-entity-card/LoopCard';
|
|
74
|
+
import FunctionDeclarationCard from '../../components/draggable-entity-card/FunctionDeclarationCard';
|
|
75
|
+
import PassthroughEntityCard from '../../components/draggable-entity-card/PassthroughEntityCard';
|
|
76
|
+
import ConditionCard from '../../components/draggable-entity-card/ConditionCard';
|
|
77
|
+
import EventCard from '../../components/draggable-entity-card/EventCard';
|
|
78
|
+
import TerminationStatementCard from '../../components/draggable-entity-card/termination-statement/TerminationStatementCard';
|
|
79
|
+
import DefinitionEntityCard from '../../components/draggable-entity-card/definition-entity/DefinitionEntityCard';
|
|
80
|
+
import { validateConnectionDeletion } from '../../components/draggable-entity-card/ConnectionDeleteButton';
|
|
81
|
+
import {
|
|
82
|
+
createRoot,
|
|
83
|
+
IComponentLifecycleProps,
|
|
84
|
+
ReactRoot
|
|
85
|
+
} from '../../utils/react';
|
|
86
|
+
import CreateEntityMenu, {
|
|
87
|
+
ICreateEntityMenuProps
|
|
88
|
+
} from '../../components/canvas/CreateEntityMenu';
|
|
89
|
+
import { createVariableInstanceFromDeclaration } from './create/variable-instance';
|
|
90
|
+
import { createFunctionCallFromFunctionDeclaration } from './create/function-call';
|
|
91
|
+
import { createGlobalEventFromActionDescriptor } from './create/global-event';
|
|
92
|
+
import { createConditionFromActionDescriptor } from './create/condition';
|
|
93
|
+
import { createOperationFromActionDescriptor } from './create/operation';
|
|
94
|
+
import { createVariableDeclarationFromWritter } from './create/variable-declaration';
|
|
95
|
+
import { createDefinitionEntityFromBuiltInBaseEntity } from './create/definition-entity';
|
|
96
|
+
import { createLoopFromActionDescriptor } from './create/loop';
|
|
97
|
+
import { popupNotification } from '../../popup-notification';
|
|
98
|
+
import {
|
|
99
|
+
findNextAvailableName,
|
|
100
|
+
resolveNewParentFromConnectionsScopeOwner
|
|
101
|
+
} from './create/utils';
|
|
102
|
+
import { filterOutNonCanvasEntities } from './utils';
|
|
103
|
+
import notifications from '../notifications';
|
|
104
|
+
import { Logger, YieldOptions, YieldTracker } from '@elyx-code/common-ts-utils';
|
|
105
|
+
import { disconnect } from './CanvasElementConnectionDeleteButton';
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
This file declares a class that holds all state related to a rendered canvas card element.
|
|
109
|
+
This includes:
|
|
110
|
+
- Project entity
|
|
111
|
+
- Draggable object of the canvas
|
|
112
|
+
- The react root node that starts its own tree for this card on the canvas
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
export interface IBaseCanvasCardProps<T = CanvasEntityState> {
|
|
116
|
+
// disabled: boolean;
|
|
117
|
+
entity: T;
|
|
118
|
+
canvasElement: CanvasEntityElement;
|
|
119
|
+
project: EditorService;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ICanvasElementOptions {
|
|
123
|
+
onReady?: (htmlElement: HTMLElement) => void;
|
|
124
|
+
debug?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ICanvasElementComponentProps
|
|
128
|
+
extends IBaseCanvasCardProps, IComponentLifecycleProps {}
|
|
129
|
+
|
|
130
|
+
export class CanvasEntityElement {
|
|
131
|
+
draggableObject!: DraggableObject;
|
|
132
|
+
component!: React.FC<IBaseCanvasCardProps>;
|
|
133
|
+
node!: ReactRoot;
|
|
134
|
+
entity: CanvasEntityState;
|
|
135
|
+
props: IBaseCanvasCardProps;
|
|
136
|
+
initialized: boolean = false;
|
|
137
|
+
|
|
138
|
+
// Parent canvas service
|
|
139
|
+
project: EditorService;
|
|
140
|
+
|
|
141
|
+
constructor(project: EditorService, entity: CanvasEntityState) {
|
|
142
|
+
this.project = project;
|
|
143
|
+
this.entity = entity;
|
|
144
|
+
this.props = {
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
disabled: this.entity.suggestion,
|
|
147
|
+
entity: this.entity,
|
|
148
|
+
canvasElement: this,
|
|
149
|
+
project: this.project
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get ref() {
|
|
154
|
+
return this.node.ref;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get ready() {
|
|
158
|
+
return this.node.mounted;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
get cardBody(): HTMLElement | null {
|
|
162
|
+
return (
|
|
163
|
+
this.node.ref?.querySelector('.canvas-draggable-card__body') || null
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async init(
|
|
168
|
+
options: { debug?: boolean } = { debug: false }
|
|
169
|
+
): Promise<CanvasEntityElement> {
|
|
170
|
+
this.initialized = true;
|
|
171
|
+
|
|
172
|
+
if (options.debug) {
|
|
173
|
+
debugger;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (this.project.destroyed) {
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
await this.render(options);
|
|
181
|
+
|
|
182
|
+
if (options.debug) {
|
|
183
|
+
debugger;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.project.resolveConnections([this], options);
|
|
187
|
+
|
|
188
|
+
if (options.debug) {
|
|
189
|
+
debugger;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.draggableObject.onUpdate((config) => {
|
|
193
|
+
if (config.selected) {
|
|
194
|
+
(config.element.firstChild as HTMLElement)?.classList.add(
|
|
195
|
+
'selected'
|
|
196
|
+
);
|
|
197
|
+
} else if (
|
|
198
|
+
!config.selected &&
|
|
199
|
+
(config.element.firstChild as HTMLElement)?.classList.contains(
|
|
200
|
+
'selected'
|
|
201
|
+
)
|
|
202
|
+
) {
|
|
203
|
+
(config.element.firstChild as HTMLElement)?.classList.remove(
|
|
204
|
+
'selected'
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Removing the menu if it is open
|
|
209
|
+
this.project.hideEntityCreationMenu();
|
|
210
|
+
|
|
211
|
+
// If the current entity being moved is an entry point type entity and it is collapsed,
|
|
212
|
+
// We need to move all the children entities with it
|
|
213
|
+
if (
|
|
214
|
+
ENTRY_POINT_TYPES.includes(this.entity.type) &&
|
|
215
|
+
(this.entity as GlobalEventState).collapsed
|
|
216
|
+
) {
|
|
217
|
+
// Move all the children entities by the same amount
|
|
218
|
+
const layout = this.project.resolveInitialChildrenPositions(
|
|
219
|
+
this.entity,
|
|
220
|
+
flattenRelatedCanvasElementsOnTheRight(this.entity),
|
|
221
|
+
null
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const xOffset = config.coordinates.x - this.entity.x;
|
|
225
|
+
const yOffset = config.coordinates.y - this.entity.y;
|
|
226
|
+
|
|
227
|
+
layout.forEach((childEntity) => {
|
|
228
|
+
childEntity.metaSync(
|
|
229
|
+
{
|
|
230
|
+
x: childEntity.x + xOffset,
|
|
231
|
+
y: childEntity.y + yOffset
|
|
232
|
+
},
|
|
233
|
+
null
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
} else if (this.entity.type === EntityType.DefinitionEntity) {
|
|
237
|
+
const methods = (this.entity as DefinitionEntityState).methods;
|
|
238
|
+
|
|
239
|
+
methods.forEach((method) => {
|
|
240
|
+
if (method.collapsed) {
|
|
241
|
+
const layout =
|
|
242
|
+
this.project.resolveInitialChildrenPositions(
|
|
243
|
+
this.entity,
|
|
244
|
+
flattenRelatedCanvasElementsOnTheRight(method),
|
|
245
|
+
null
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const xOffset = config.coordinates.x - this.entity.x;
|
|
249
|
+
const yOffset = config.coordinates.y - this.entity.y;
|
|
250
|
+
|
|
251
|
+
layout.forEach((childEntity) => {
|
|
252
|
+
childEntity.metaSync(
|
|
253
|
+
{
|
|
254
|
+
x: childEntity.x + xOffset,
|
|
255
|
+
y: childEntity.y + yOffset
|
|
256
|
+
},
|
|
257
|
+
null
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Update the entity's coordinates
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
this.entity.metaSync(
|
|
267
|
+
{
|
|
268
|
+
x: config.coordinates.x,
|
|
269
|
+
y: config.coordinates.y
|
|
270
|
+
},
|
|
271
|
+
null
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
// @ts-ignore This recalculates the styling state of the connections
|
|
275
|
+
// this.node.component.disabledConnectionsNotInTest?.();
|
|
276
|
+
|
|
277
|
+
return config;
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
this.draggableObject.onBeforeUpdate((newConfig) => {
|
|
281
|
+
if (!!newConfig.overlaps.length) {
|
|
282
|
+
let hasHighlighted: boolean = false;
|
|
283
|
+
|
|
284
|
+
newConfig.overlaps.forEach((overlap) => {
|
|
285
|
+
// Find an overlap where there is a connection
|
|
286
|
+
if (overlap.altCoords?.connection) {
|
|
287
|
+
const canvasElement = this.project.getElement(
|
|
288
|
+
getEntityIdFromCanvasId(
|
|
289
|
+
overlap.altCoords.overlappingObject.id
|
|
290
|
+
)
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
if (!canvasElement) {
|
|
294
|
+
return newConfig;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const ownElement =
|
|
298
|
+
this.cardBody ||
|
|
299
|
+
this.ref ||
|
|
300
|
+
this.draggableObject.element;
|
|
301
|
+
const otherElement =
|
|
302
|
+
canvasElement.cardBody ||
|
|
303
|
+
canvasElement.ref ||
|
|
304
|
+
canvasElement.draggableObject.element;
|
|
305
|
+
|
|
306
|
+
highlighOverlappingElements(ownElement, otherElement);
|
|
307
|
+
|
|
308
|
+
hasHighlighted = true;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
if (!hasHighlighted) {
|
|
313
|
+
return newConfig;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Return the old config so the object doesn't move when it overlaps
|
|
317
|
+
return {
|
|
318
|
+
...newConfig,
|
|
319
|
+
coordinates: {
|
|
320
|
+
x:
|
|
321
|
+
newConfig.overlaps[0].altCoords
|
|
322
|
+
?.nextValidCoordinates.x ||
|
|
323
|
+
this.draggableObject.x,
|
|
324
|
+
y:
|
|
325
|
+
newConfig.overlaps[0].altCoords
|
|
326
|
+
?.nextValidCoordinates.y ||
|
|
327
|
+
this.draggableObject.y
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Do nothing
|
|
333
|
+
return newConfig;
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
this.draggableObject.onRestore(() => {
|
|
337
|
+
let actionName =
|
|
338
|
+
`restore-${this.entity.type}` as StateMutationAction;
|
|
339
|
+
|
|
340
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
341
|
+
new ChangeSet(
|
|
342
|
+
this.project.logic,
|
|
343
|
+
ProjectState.sessionAuthor,
|
|
344
|
+
new Date().toISOString(),
|
|
345
|
+
this.entity,
|
|
346
|
+
false,
|
|
347
|
+
actionName
|
|
348
|
+
)
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
this.entity.restore({}, changeSet);
|
|
352
|
+
|
|
353
|
+
// Re-append to the canvas
|
|
354
|
+
this.project.canvas?.canvasElement.appendChild(
|
|
355
|
+
this.draggableObject.element
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
this.project.renderAndCloseChangeSet(changeSet);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
this.draggableObject.onScrollToThis(() => {
|
|
362
|
+
// Highlight the element
|
|
363
|
+
const element =
|
|
364
|
+
this.cardBody || this.ref || this.draggableObject.element;
|
|
365
|
+
highlightElement(element);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
this.draggableObject.onDisable(() => {
|
|
369
|
+
this.render();
|
|
370
|
+
|
|
371
|
+
// We enable the connections after the node update to avoid overriding any untracked DOM changes
|
|
372
|
+
this.project.disableAllConnections(this.draggableObject);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
this.draggableObject.onEnable(() => {
|
|
376
|
+
this.render();
|
|
377
|
+
|
|
378
|
+
// We enable the connections after the node update to avoid overriding any untracked DOM changes
|
|
379
|
+
this.project.enableAllConnections(this.draggableObject);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
this.draggableObject.onDoubleClick(() => {
|
|
383
|
+
if (!this.project.READ_ONLY) {
|
|
384
|
+
const typesWithoutDialogs = [
|
|
385
|
+
EntityType.ReturnStatement,
|
|
386
|
+
EntityType.BreakStatement,
|
|
387
|
+
EntityType.ContinueStatement
|
|
388
|
+
];
|
|
389
|
+
|
|
390
|
+
if (
|
|
391
|
+
typesWithoutDialogs.includes(this.entity.type as EntityType)
|
|
392
|
+
) {
|
|
393
|
+
// No dialog to open for these entities
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
EditorService.navigate(
|
|
398
|
+
`${this.project.editorBasePath}/entity/${this.entity.type}/${this.entity.id}`
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
this.draggableObject.onBeforeDeleteConnection((connection, config) => {
|
|
404
|
+
let targetEntity: UserManagedEntityState | null = null;
|
|
405
|
+
let sourceEntity: UserManagedEntityState | null = null;
|
|
406
|
+
|
|
407
|
+
try {
|
|
408
|
+
sourceEntity = this.project.logic.get(
|
|
409
|
+
getEntityIdFromCanvasId(connection.startId)
|
|
410
|
+
) as UserManagedEntityState;
|
|
411
|
+
|
|
412
|
+
targetEntity = this.project.logic.get(
|
|
413
|
+
getEntityIdFromCanvasId(connection.endId)
|
|
414
|
+
) as UserManagedEntityState;
|
|
415
|
+
} catch (e) {
|
|
416
|
+
// Ignore errors parsing IDs
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (sourceEntity && targetEntity) {
|
|
420
|
+
const reasons = validateConnectionDeletion(
|
|
421
|
+
connection,
|
|
422
|
+
sourceEntity,
|
|
423
|
+
targetEntity,
|
|
424
|
+
this.project
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
if (reasons.length > 0) {
|
|
428
|
+
popupNotification({
|
|
429
|
+
color: 'warning',
|
|
430
|
+
text: reasons[0]
|
|
431
|
+
});
|
|
432
|
+
return { blockDelete: true };
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
debugger;
|
|
436
|
+
|
|
437
|
+
if (!config.batchDelete) {
|
|
438
|
+
// Remove the connection
|
|
439
|
+
const deleteConnectionChangeSet =
|
|
440
|
+
this.project.logic.addChangeSet(
|
|
441
|
+
new ChangeSet(
|
|
442
|
+
this.project.logic,
|
|
443
|
+
ProjectState.sessionAuthor,
|
|
444
|
+
new Date().toISOString(),
|
|
445
|
+
this.project.logic,
|
|
446
|
+
false,
|
|
447
|
+
StateMutationAction.DisconnectNodes
|
|
448
|
+
)
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
debugger;
|
|
452
|
+
|
|
453
|
+
disconnect(
|
|
454
|
+
sourceEntity,
|
|
455
|
+
targetEntity,
|
|
456
|
+
connection,
|
|
457
|
+
deleteConnectionChangeSet
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
debugger;
|
|
461
|
+
|
|
462
|
+
// Remove delete connection button
|
|
463
|
+
this.project.hideConnectionDeleteButtonElement();
|
|
464
|
+
|
|
465
|
+
debugger;
|
|
466
|
+
|
|
467
|
+
this.project.renderAndCloseChangeSet(
|
|
468
|
+
deleteConnectionChangeSet
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
return { skipTargetCheck: true };
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async remove(removeOptions?: { quiet: boolean }): Promise<void> {
|
|
480
|
+
await this.node.unmount();
|
|
481
|
+
|
|
482
|
+
this.draggableObject.offBeforeDelete();
|
|
483
|
+
// this.draggableObject.offUpdate();
|
|
484
|
+
// this.draggableObject.offRestore();
|
|
485
|
+
// this.draggableObject.offScrollToThis();
|
|
486
|
+
// this.draggableObject.offDisable();
|
|
487
|
+
// this.draggableObject.offEnable();
|
|
488
|
+
// this.draggableObject.offBeforeUpdate();
|
|
489
|
+
|
|
490
|
+
this.project.canvas?.removeDraggableObject(
|
|
491
|
+
this.draggableObject,
|
|
492
|
+
removeOptions
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async render(
|
|
497
|
+
options: { debug?: boolean } = { debug: false }
|
|
498
|
+
): Promise<CanvasEntityElement> {
|
|
499
|
+
if (options.debug) {
|
|
500
|
+
debugger;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (this.project.destroyed) {
|
|
504
|
+
return this;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
let parentEntryPoint: EntryPointEntityState | null = null;
|
|
508
|
+
|
|
509
|
+
const parent = getScopeOwner(this.entity, this.project.logic);
|
|
510
|
+
|
|
511
|
+
if (ENTRY_POINT_TYPES.includes(parent?.type as EntityType)) {
|
|
512
|
+
parentEntryPoint = parent as EntryPointEntityState;
|
|
513
|
+
} else if (parent?.type === EntityType.Loop) {
|
|
514
|
+
parentEntryPoint = parent.body;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (!this.draggableObject) {
|
|
518
|
+
if (options.debug) {
|
|
519
|
+
debugger;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const domElement = document.createElement('div');
|
|
523
|
+
|
|
524
|
+
// Append to canvas element
|
|
525
|
+
this.project.canvas?.canvasElement.appendChild(domElement);
|
|
526
|
+
|
|
527
|
+
this.draggableObject = this.project.canvas?.draggable({
|
|
528
|
+
id: getCanvasEntityDraggableContainerDOMId(this.entity),
|
|
529
|
+
// Create temporary div
|
|
530
|
+
element: domElement,
|
|
531
|
+
coordinates: {
|
|
532
|
+
x: this.entity.x,
|
|
533
|
+
y: this.entity.y
|
|
534
|
+
},
|
|
535
|
+
// @ts-ignore because not all entities currently have the 'suggestion' property
|
|
536
|
+
disabled: this.entity.suggestion
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (
|
|
541
|
+
!!this.draggableObject &&
|
|
542
|
+
(!this.draggableObject?.element ||
|
|
543
|
+
!document.contains(this.draggableObject.element))
|
|
544
|
+
) {
|
|
545
|
+
if (options.debug) {
|
|
546
|
+
debugger;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const domElement = document.createElement('div');
|
|
550
|
+
|
|
551
|
+
this.project.canvas?.canvasElement.appendChild(domElement);
|
|
552
|
+
|
|
553
|
+
this.draggableObject.element = domElement;
|
|
554
|
+
this.draggableObject.setup();
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (options.debug) {
|
|
558
|
+
debugger;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
let resolvedProps: IBaseCanvasCardProps;
|
|
562
|
+
|
|
563
|
+
switch (this.entity.type) {
|
|
564
|
+
case EntityType.DefinitionEntity:
|
|
565
|
+
this.component =
|
|
566
|
+
DefinitionEntityCard as React.FC<IBaseCanvasCardProps>;
|
|
567
|
+
resolvedProps = {
|
|
568
|
+
...(this
|
|
569
|
+
.props as IBaseCanvasCardProps<DefinitionEntityState>)
|
|
570
|
+
} as IBaseCanvasCardProps<DefinitionEntityState>;
|
|
571
|
+
break;
|
|
572
|
+
case EntityType.GlobalEvent: {
|
|
573
|
+
this.component = EventCard as React.FC<IBaseCanvasCardProps>;
|
|
574
|
+
resolvedProps = {
|
|
575
|
+
...(this.props as IBaseCanvasCardProps<GlobalEventState>)
|
|
576
|
+
} as IBaseCanvasCardProps<GlobalEventState>;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
case EntityType.Condition: {
|
|
580
|
+
this.component =
|
|
581
|
+
ConditionCard as React.FC<IBaseCanvasCardProps>;
|
|
582
|
+
resolvedProps = {
|
|
583
|
+
...(this.props as IBaseCanvasCardProps<ConditionState>)
|
|
584
|
+
} as IBaseCanvasCardProps<ConditionState>;
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
case EntityType.Operation:
|
|
588
|
+
case EntityType.Search:
|
|
589
|
+
case EntityType.FunctionCall: {
|
|
590
|
+
this.component =
|
|
591
|
+
PassthroughEntityCard as React.FC<IBaseCanvasCardProps>;
|
|
592
|
+
resolvedProps = {
|
|
593
|
+
...(this
|
|
594
|
+
.props as IBaseCanvasCardProps<DraggablePassThroughCallableEntityState>)
|
|
595
|
+
} as IBaseCanvasCardProps<DraggablePassThroughCallableEntityState>;
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
case EntityType.FunctionDeclaration: {
|
|
599
|
+
this.component =
|
|
600
|
+
FunctionDeclarationCard as React.FC<IBaseCanvasCardProps>;
|
|
601
|
+
resolvedProps = {
|
|
602
|
+
...(this
|
|
603
|
+
.props as IBaseCanvasCardProps<FunctionDeclarationState>)
|
|
604
|
+
} as IBaseCanvasCardProps<FunctionDeclarationState>;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
case EntityType.Loop: {
|
|
608
|
+
this.component = LoopCard as React.FC<IBaseCanvasCardProps>;
|
|
609
|
+
resolvedProps = {
|
|
610
|
+
...(this.props as IBaseCanvasCardProps<LoopState>)
|
|
611
|
+
} as IBaseCanvasCardProps<LoopState>;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
case EntityType.ReturnStatement:
|
|
615
|
+
case EntityType.BreakStatement:
|
|
616
|
+
case EntityType.ContinueStatement: {
|
|
617
|
+
this.component =
|
|
618
|
+
TerminationStatementCard as React.FC<IBaseCanvasCardProps>;
|
|
619
|
+
resolvedProps = {
|
|
620
|
+
...(this
|
|
621
|
+
.props as IBaseCanvasCardProps<TerminationEntityState>)
|
|
622
|
+
} as IBaseCanvasCardProps<TerminationEntityState>;
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
case EntityType.VariableDeclaration:
|
|
626
|
+
case EntityType.VariableInstance:
|
|
627
|
+
this.component = VariableCard as React.FC<IBaseCanvasCardProps>;
|
|
628
|
+
resolvedProps = {
|
|
629
|
+
...(this.props as IBaseCanvasCardProps<VariableState>)
|
|
630
|
+
} as IBaseCanvasCardProps<VariableState>;
|
|
631
|
+
break;
|
|
632
|
+
default:
|
|
633
|
+
this.component =
|
|
634
|
+
DraggableEntityCard as React.FC<IBaseCanvasCardProps>;
|
|
635
|
+
resolvedProps = {
|
|
636
|
+
...(this
|
|
637
|
+
.props as IBaseCanvasCardProps<InstalledProjectState>)
|
|
638
|
+
} as IBaseCanvasCardProps<InstalledProjectState>;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (options.debug) {
|
|
643
|
+
debugger;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (
|
|
647
|
+
!!this.draggableObject &&
|
|
648
|
+
!!document.contains(this.draggableObject.element)
|
|
649
|
+
) {
|
|
650
|
+
if (options.debug) {
|
|
651
|
+
debugger;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (!this.node) {
|
|
655
|
+
if (options.debug) {
|
|
656
|
+
debugger;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
this.node = createRoot('#' + this.draggableObject.id);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (options.debug) {
|
|
663
|
+
debugger;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (
|
|
667
|
+
!parentEntryPoint?.collapsed ||
|
|
668
|
+
parentEntryPoint?.id === this.entity.id
|
|
669
|
+
) {
|
|
670
|
+
await this.node.render(this.component, resolvedProps, null, {
|
|
671
|
+
debug: options.debug,
|
|
672
|
+
onError: (error) => {
|
|
673
|
+
Logger.log('Error handler worked: ', error);
|
|
674
|
+
this.project.events.emit('canvas-react-error', error);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
this.draggableObject.update(
|
|
679
|
+
{
|
|
680
|
+
coordinates: {
|
|
681
|
+
x: this.entity.x,
|
|
682
|
+
y: this.entity.y
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
{ quiet: true, skipOverlapCheck: true }
|
|
686
|
+
);
|
|
687
|
+
|
|
688
|
+
// Recalculate canvas connections
|
|
689
|
+
this.draggableObject.updateConnections();
|
|
690
|
+
|
|
691
|
+
if (this.project.canvas?.disabled) {
|
|
692
|
+
this.project.disableAllConnections(this.draggableObject);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (
|
|
698
|
+
this.draggableObject.x !== this.entity.x ||
|
|
699
|
+
this.draggableObject.y !== this.entity.y
|
|
700
|
+
) {
|
|
701
|
+
this.draggableObject.update(
|
|
702
|
+
{
|
|
703
|
+
coordinates: {
|
|
704
|
+
x: this.entity.x,
|
|
705
|
+
y: this.entity.y
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
{ quiet: true, skipOverlapCheck: true }
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (options.debug) {
|
|
713
|
+
debugger;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return this;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
disableAllConnections() {
|
|
720
|
+
// Disable all the connections if the object is already marked as disabled for another reason
|
|
721
|
+
this.draggableObject.connections.forEach((connection) => {
|
|
722
|
+
if (!connection.disabled) {
|
|
723
|
+
connection.disable();
|
|
724
|
+
connection.element.classList.add('disabled');
|
|
725
|
+
|
|
726
|
+
if (connection.complementaryLineElement) {
|
|
727
|
+
connection.complementaryLineElement.classList.add(
|
|
728
|
+
'disabled'
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
enableAllConnections() {
|
|
736
|
+
// Enable all the connections if the object is already marked as disabled for another reason
|
|
737
|
+
this.draggableObject.connections.forEach((connection) => {
|
|
738
|
+
if (connection.disabled) {
|
|
739
|
+
connection.enable();
|
|
740
|
+
connection.element.classList.remove('disabled');
|
|
741
|
+
|
|
742
|
+
if (connection.complementaryLineElement) {
|
|
743
|
+
connection.complementaryLineElement.classList.remove(
|
|
744
|
+
'disabled'
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
export interface ICanvasMenuElementBaseProps {
|
|
753
|
+
connectedNodeType: ConnectionNodeType;
|
|
754
|
+
// Only the source entity or the target entity can be defined at the same time
|
|
755
|
+
connectedSource?:
|
|
756
|
+
| CallerEntityState
|
|
757
|
+
| ArgumentDeclarationState
|
|
758
|
+
| OutputMapState
|
|
759
|
+
| ValueDescriptorState
|
|
760
|
+
| VariableState;
|
|
761
|
+
connectedTarget?: ExecutableEntityState | InputMapState | VariableState;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
export interface ICanvasMenuElementComponentProps
|
|
765
|
+
extends ICanvasMenuElementBaseProps, IComponentLifecycleProps {}
|
|
766
|
+
|
|
767
|
+
export class CanvasMenuElement {
|
|
768
|
+
canvasObject!: CanvasObject;
|
|
769
|
+
component!: React.FC<ICreateEntityMenuProps>;
|
|
770
|
+
node!: ReactRoot;
|
|
771
|
+
coordinates: { x: number; y: number };
|
|
772
|
+
connectionOptions: IConnectionDrawingOptions | null = null;
|
|
773
|
+
props: ICanvasMenuElementBaseProps;
|
|
774
|
+
|
|
775
|
+
// Parent canvas service
|
|
776
|
+
project: EditorService;
|
|
777
|
+
|
|
778
|
+
constructor(
|
|
779
|
+
project: EditorService,
|
|
780
|
+
config: {
|
|
781
|
+
coordinates: { x: number; y: number };
|
|
782
|
+
connectionOptions: IConnectionDrawingOptions | null;
|
|
783
|
+
} = {
|
|
784
|
+
coordinates: { x: 0, y: 0 },
|
|
785
|
+
connectionOptions: null
|
|
786
|
+
}
|
|
787
|
+
) {
|
|
788
|
+
this.project = project;
|
|
789
|
+
this.coordinates = config.coordinates;
|
|
790
|
+
this.connectionOptions = config.connectionOptions;
|
|
791
|
+
this.props = {
|
|
792
|
+
connectedNodeType: config.connectionOptions?.nodeType,
|
|
793
|
+
connectedSource: config.connectionOptions?.source,
|
|
794
|
+
connectedTarget: config.connectionOptions?.target
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
get ref() {
|
|
799
|
+
return this.node.ref;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
get ready() {
|
|
803
|
+
return this.node.mounted;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
async init(): Promise<CanvasMenuElement> {
|
|
807
|
+
if (this.project.destroyed) {
|
|
808
|
+
return this;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
await this.render();
|
|
812
|
+
|
|
813
|
+
this.canvasObject.onBeforeDelete(() => {
|
|
814
|
+
this.canvasObject.element.remove();
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
return this;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
async remove(): Promise<void> {
|
|
821
|
+
await this.node.unmount();
|
|
822
|
+
|
|
823
|
+
this.canvasObject.offBeforeDelete();
|
|
824
|
+
// this.canvasObject.offUpdate();
|
|
825
|
+
// this.canvasObject.offRestore();
|
|
826
|
+
|
|
827
|
+
this.canvasObject.remove();
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
async addNewEntitiesToCanvasFromRootEntity(
|
|
831
|
+
root: CanvasEntityState,
|
|
832
|
+
changeSet: ChangeSet,
|
|
833
|
+
options: YieldOptions = {}
|
|
834
|
+
) {
|
|
835
|
+
const tracker = YieldTracker.from(options);
|
|
836
|
+
|
|
837
|
+
// @ts-ignore don't remove, the type calculation doesn't work and it says the intersection is to complex to render
|
|
838
|
+
root.metaSync(
|
|
839
|
+
{
|
|
840
|
+
x: this.coordinates.x,
|
|
841
|
+
y: this.coordinates.y
|
|
842
|
+
},
|
|
843
|
+
changeSet
|
|
844
|
+
);
|
|
845
|
+
|
|
846
|
+
this.project.canvasLayout.push(root);
|
|
847
|
+
|
|
848
|
+
const relatedEntitiesRight =
|
|
849
|
+
flattenRelatedCanvasElementsOnTheRight(root);
|
|
850
|
+
const otherEntitiesCreatedAsSideEffects: CanvasEntityState[] =
|
|
851
|
+
getTouchedCanvasEntitiesFromChangeSet(changeSet);
|
|
852
|
+
|
|
853
|
+
// If any entity in the 'other' entities list is not directly connected to the root entity,
|
|
854
|
+
// Add a notification to inform the user
|
|
855
|
+
|
|
856
|
+
const disconnectedTouched = otherEntitiesCreatedAsSideEffects.filter(
|
|
857
|
+
(entity) =>
|
|
858
|
+
!relatedEntitiesRight.some(
|
|
859
|
+
(related) => related.id === entity.id
|
|
860
|
+
) && entity.id !== root.id
|
|
861
|
+
);
|
|
862
|
+
|
|
863
|
+
const disconnectedAdded = disconnectedTouched.filter((entity) =>
|
|
864
|
+
changeSet?.hasAdded(entity.id)
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
if (!!disconnectedAdded.length) {
|
|
868
|
+
const firstEntity = disconnectedAdded[0];
|
|
869
|
+
const otherNumberOfEntities = disconnectedAdded.length - 1;
|
|
870
|
+
|
|
871
|
+
let suffix = '.';
|
|
872
|
+
|
|
873
|
+
if (otherNumberOfEntities > 0) {
|
|
874
|
+
suffix = `, alongside another ${otherNumberOfEntities} entities.`;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
popupNotification({
|
|
878
|
+
text: `A ${
|
|
879
|
+
READABLE_ENTITY_TYPES[firstEntity.type].singular
|
|
880
|
+
} ${resolveEntityName(
|
|
881
|
+
firstEntity,
|
|
882
|
+
this.project.logic
|
|
883
|
+
)} was also automatically created${suffix}`
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
disconnectedAdded.forEach((ent, i) => {
|
|
888
|
+
// Given initial coordinates
|
|
889
|
+
ent.metaSync(
|
|
890
|
+
{
|
|
891
|
+
x: this.coordinates.x - (i + 1) * 500,
|
|
892
|
+
y: this.coordinates.y - (i + 1) * 500
|
|
893
|
+
},
|
|
894
|
+
changeSet
|
|
895
|
+
);
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
const positionedRelatedEntitiesRight =
|
|
899
|
+
this.project.resolveInitialChildrenPositions(
|
|
900
|
+
root,
|
|
901
|
+
relatedEntitiesRight,
|
|
902
|
+
changeSet
|
|
903
|
+
);
|
|
904
|
+
|
|
905
|
+
const allEntitiesUnfiltered = [
|
|
906
|
+
root,
|
|
907
|
+
...disconnectedTouched,
|
|
908
|
+
...positionedRelatedEntitiesRight
|
|
909
|
+
];
|
|
910
|
+
|
|
911
|
+
const allEntitiesToRender = (await filterOutDuplicateEntitiesAsync(
|
|
912
|
+
allEntitiesUnfiltered,
|
|
913
|
+
{ tracker }
|
|
914
|
+
)) as CanvasEntityState[];
|
|
915
|
+
|
|
916
|
+
const canvasEntitiesTouched: CanvasEntityState[] =
|
|
917
|
+
getTouchedCanvasEntitiesFromChangeSet(changeSet);
|
|
918
|
+
|
|
919
|
+
const entitiesRemoved: UserManagedEntityState[] = Object.values(
|
|
920
|
+
changeSet.removed
|
|
921
|
+
);
|
|
922
|
+
|
|
923
|
+
if (changeSet.open) {
|
|
924
|
+
for (const entity of canvasEntitiesTouched) {
|
|
925
|
+
// This is to re-calculate missing entities, and/or add suggestions
|
|
926
|
+
entity.afterAllChildrenInitialized(changeSet);
|
|
927
|
+
|
|
928
|
+
await tracker.tick();
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const oldProjectErrors = await this.project.getAllProjectLogicErrors({
|
|
933
|
+
tracker
|
|
934
|
+
});
|
|
935
|
+
await this.project.validateProjectState({ tracker });
|
|
936
|
+
const newProjectErrors = await this.project.getAllProjectLogicErrors({
|
|
937
|
+
tracker
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
this.project.emit('before-change-set-close', changeSet);
|
|
941
|
+
|
|
942
|
+
const uniqueDeletedEntities =
|
|
943
|
+
filterOutNonCanvasEntities(entitiesRemoved);
|
|
944
|
+
|
|
945
|
+
// Remove any `oldProjectErrors` no longer present in the `newProjectErrors`
|
|
946
|
+
const errorsToRemove = oldProjectErrors.filter(
|
|
947
|
+
(error) =>
|
|
948
|
+
!newProjectErrors.some((newError) => newError.id === error.id)
|
|
949
|
+
);
|
|
950
|
+
|
|
951
|
+
for (const error of errorsToRemove) {
|
|
952
|
+
// Remove errors from the notification store
|
|
953
|
+
notifications.remove(
|
|
954
|
+
this.project.PROJECT_NOTIFICATIONS_CHANNEL,
|
|
955
|
+
error.id
|
|
956
|
+
);
|
|
957
|
+
|
|
958
|
+
this.project.emit(error.entity.id, {});
|
|
959
|
+
|
|
960
|
+
await tracker.tick();
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
await Promise.all([
|
|
964
|
+
this.project.render(allEntitiesToRender, {
|
|
965
|
+
debug: false
|
|
966
|
+
}),
|
|
967
|
+
uniqueDeletedEntities.map(async (ent) => {
|
|
968
|
+
this.project.removeValueByOwnerId(ent.id);
|
|
969
|
+
await this.project.getElement(ent.id)?.remove({ quiet: true });
|
|
970
|
+
delete this.project.elements[ent.id];
|
|
971
|
+
})
|
|
972
|
+
]);
|
|
973
|
+
|
|
974
|
+
await this.project.test?.validateAsync({ tracker });
|
|
975
|
+
|
|
976
|
+
await this.project.validateProjectState({ tracker });
|
|
977
|
+
|
|
978
|
+
if (EditorService.SAVING_ENABLED && !this.project.READ_ONLY) {
|
|
979
|
+
changeSet?.close({ persistType: 'parallel' });
|
|
980
|
+
}
|
|
981
|
+
changeSet = null;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
async render(): Promise<CanvasMenuElement> {
|
|
985
|
+
if (this.project.destroyed) {
|
|
986
|
+
return this;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
if (!this.canvasObject) {
|
|
990
|
+
const domElement = document.createElement('div');
|
|
991
|
+
|
|
992
|
+
// Append to canvas element
|
|
993
|
+
this.project.canvas?.canvasElement.appendChild(domElement);
|
|
994
|
+
|
|
995
|
+
this.canvasObject = this.project.canvas?.object({
|
|
996
|
+
id: 'create-entity-menu',
|
|
997
|
+
// Create temporary div
|
|
998
|
+
element: domElement,
|
|
999
|
+
deletable: true,
|
|
1000
|
+
selectable: false,
|
|
1001
|
+
coordinates: {
|
|
1002
|
+
x: this.coordinates.x,
|
|
1003
|
+
y: this.coordinates.y
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
if (
|
|
1009
|
+
!this.canvasObject.element ||
|
|
1010
|
+
!document.contains(this.canvasObject.element)
|
|
1011
|
+
) {
|
|
1012
|
+
const domElement = document.createElement('div');
|
|
1013
|
+
|
|
1014
|
+
this.project.canvas?.canvasElement.appendChild(domElement);
|
|
1015
|
+
|
|
1016
|
+
this.canvasObject.element = domElement;
|
|
1017
|
+
this.canvasObject.setup();
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
this.component = CreateEntityMenu;
|
|
1021
|
+
|
|
1022
|
+
const resolvedProps: ICreateEntityMenuProps = {
|
|
1023
|
+
canvasObject: this.canvasObject,
|
|
1024
|
+
...(this.props as ICanvasMenuElementBaseProps),
|
|
1025
|
+
project: this.project,
|
|
1026
|
+
onCreateBaseEntity: async (entityType) => {
|
|
1027
|
+
// Based on the entity type, navigate the user to the correct entity creation dialog
|
|
1028
|
+
switch (entityType) {
|
|
1029
|
+
case EntityType.DefinitionEntity: {
|
|
1030
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1031
|
+
new ChangeSet(
|
|
1032
|
+
this.project.logic,
|
|
1033
|
+
ProjectState.sessionAuthor,
|
|
1034
|
+
new Date().toISOString(),
|
|
1035
|
+
this.project.logic,
|
|
1036
|
+
false,
|
|
1037
|
+
StateMutationAction.CreateNewDef
|
|
1038
|
+
)
|
|
1039
|
+
);
|
|
1040
|
+
|
|
1041
|
+
const newEntityTransfer =
|
|
1042
|
+
DefinitionEntityState.new(changeSet);
|
|
1043
|
+
newEntityTransfer.name = findNextAvailableName(
|
|
1044
|
+
'New definition',
|
|
1045
|
+
this.project.logic.entities
|
|
1046
|
+
);
|
|
1047
|
+
|
|
1048
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1049
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1050
|
+
newEntityTransfer.parent =
|
|
1051
|
+
this.project.logic.toReference();
|
|
1052
|
+
|
|
1053
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1054
|
+
newEntityTransfer,
|
|
1055
|
+
this.project.logic
|
|
1056
|
+
) as DefinitionEntityState;
|
|
1057
|
+
|
|
1058
|
+
newInstance.hydrateAncestors();
|
|
1059
|
+
newInstance.addSelfToProject(changeSet);
|
|
1060
|
+
|
|
1061
|
+
changeSet.add(
|
|
1062
|
+
newInstance,
|
|
1063
|
+
ChangeSetEntityChangeType.Added
|
|
1064
|
+
);
|
|
1065
|
+
|
|
1066
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1067
|
+
|
|
1068
|
+
EditorService.navigate(
|
|
1069
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1070
|
+
);
|
|
1071
|
+
|
|
1072
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1073
|
+
newInstance,
|
|
1074
|
+
changeSet
|
|
1075
|
+
);
|
|
1076
|
+
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
case EntityType.FunctionDeclaration: {
|
|
1080
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1081
|
+
new ChangeSet(
|
|
1082
|
+
this.project.logic,
|
|
1083
|
+
ProjectState.sessionAuthor,
|
|
1084
|
+
new Date().toISOString(),
|
|
1085
|
+
this.project.logic,
|
|
1086
|
+
false,
|
|
1087
|
+
StateMutationAction.CreateNewFuncDecl
|
|
1088
|
+
)
|
|
1089
|
+
);
|
|
1090
|
+
|
|
1091
|
+
const newEntityTransfer =
|
|
1092
|
+
FunctionDeclarationState.new(changeSet);
|
|
1093
|
+
newEntityTransfer.name = findNextAvailableName(
|
|
1094
|
+
'Custom trigger',
|
|
1095
|
+
this.project.logic.functions
|
|
1096
|
+
);
|
|
1097
|
+
|
|
1098
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1099
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1100
|
+
newEntityTransfer.parent =
|
|
1101
|
+
this.project.logic.toReference();
|
|
1102
|
+
|
|
1103
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1104
|
+
newEntityTransfer,
|
|
1105
|
+
this.project.logic
|
|
1106
|
+
) as FunctionDeclarationState;
|
|
1107
|
+
|
|
1108
|
+
newInstance.hydrateAncestors();
|
|
1109
|
+
newInstance.addSelfToProject(changeSet);
|
|
1110
|
+
|
|
1111
|
+
changeSet.add(
|
|
1112
|
+
newInstance,
|
|
1113
|
+
ChangeSetEntityChangeType.Added
|
|
1114
|
+
);
|
|
1115
|
+
|
|
1116
|
+
if (
|
|
1117
|
+
this.connectionOptions?.nodeType ===
|
|
1118
|
+
ConnectionNodeType.CalledBy &&
|
|
1119
|
+
!!this.connectionOptions?.target
|
|
1120
|
+
) {
|
|
1121
|
+
newInstance.addCall(
|
|
1122
|
+
this.connectionOptions
|
|
1123
|
+
.target as CallableEntityState,
|
|
1124
|
+
changeSet
|
|
1125
|
+
);
|
|
1126
|
+
(
|
|
1127
|
+
this.connectionOptions
|
|
1128
|
+
.target as CallableEntityState
|
|
1129
|
+
).addEntryCaller(
|
|
1130
|
+
newInstance,
|
|
1131
|
+
changeSet,
|
|
1132
|
+
// To recalculate its scope automatically
|
|
1133
|
+
true
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1138
|
+
|
|
1139
|
+
EditorService.navigate(
|
|
1140
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1141
|
+
);
|
|
1142
|
+
|
|
1143
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1144
|
+
newInstance,
|
|
1145
|
+
changeSet
|
|
1146
|
+
);
|
|
1147
|
+
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
case EntityType.VariableDeclaration: {
|
|
1151
|
+
if (
|
|
1152
|
+
!!this.connectionOptions?.source &&
|
|
1153
|
+
this.connectionOptions?.nodeType ===
|
|
1154
|
+
ConnectionNodeType.PropertyOut
|
|
1155
|
+
) {
|
|
1156
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1157
|
+
new ChangeSet(
|
|
1158
|
+
this.project.logic,
|
|
1159
|
+
ProjectState.sessionAuthor,
|
|
1160
|
+
new Date().toISOString(),
|
|
1161
|
+
this.project.logic,
|
|
1162
|
+
false,
|
|
1163
|
+
StateMutationAction.CreateNewVarDecl
|
|
1164
|
+
)
|
|
1165
|
+
);
|
|
1166
|
+
|
|
1167
|
+
const newVariableDeclarationInstance =
|
|
1168
|
+
createVariableDeclarationFromWritter(
|
|
1169
|
+
this.connectionOptions
|
|
1170
|
+
.source as ValueWritingEntityState,
|
|
1171
|
+
this.connectionOptions,
|
|
1172
|
+
this.project.logic,
|
|
1173
|
+
changeSet
|
|
1174
|
+
);
|
|
1175
|
+
|
|
1176
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1177
|
+
newVariableDeclarationInstance,
|
|
1178
|
+
changeSet
|
|
1179
|
+
);
|
|
1180
|
+
} else {
|
|
1181
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1182
|
+
new ChangeSet(
|
|
1183
|
+
this.project.logic,
|
|
1184
|
+
ProjectState.sessionAuthor,
|
|
1185
|
+
new Date().toISOString(),
|
|
1186
|
+
this.project.logic,
|
|
1187
|
+
false,
|
|
1188
|
+
StateMutationAction.CreateNewVarDecl
|
|
1189
|
+
)
|
|
1190
|
+
);
|
|
1191
|
+
|
|
1192
|
+
const newEntityTransfer =
|
|
1193
|
+
VariableDeclarationState.new(changeSet);
|
|
1194
|
+
newEntityTransfer.name = findNextAvailableName(
|
|
1195
|
+
'Variable',
|
|
1196
|
+
this.project.logic.getVariableDeclarations()
|
|
1197
|
+
);
|
|
1198
|
+
|
|
1199
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1200
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1201
|
+
newEntityTransfer.parent =
|
|
1202
|
+
this.project.logic.toReference();
|
|
1203
|
+
|
|
1204
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1205
|
+
newEntityTransfer,
|
|
1206
|
+
this.project.logic
|
|
1207
|
+
) as VariableDeclarationState;
|
|
1208
|
+
|
|
1209
|
+
newInstance.hydrateAncestors();
|
|
1210
|
+
newInstance.addSelfToProject(changeSet);
|
|
1211
|
+
|
|
1212
|
+
changeSet.add(
|
|
1213
|
+
newInstance,
|
|
1214
|
+
ChangeSetEntityChangeType.Added
|
|
1215
|
+
);
|
|
1216
|
+
|
|
1217
|
+
const builtInPrimitiveStringEntity =
|
|
1218
|
+
this.project.logic.getBuiltIn(
|
|
1219
|
+
BUILT_IN_BASE_ENTITY_IDS['primitive-entity']
|
|
1220
|
+
.string.id
|
|
1221
|
+
) as PrimitiveEntityState;
|
|
1222
|
+
|
|
1223
|
+
// Add 'string' data-type as default
|
|
1224
|
+
const dataTypeTransfer =
|
|
1225
|
+
DataTypeState.new(changeSet);
|
|
1226
|
+
dataTypeTransfer.parent = newInstance.toReference();
|
|
1227
|
+
dataTypeTransfer.entity =
|
|
1228
|
+
(builtInPrimitiveStringEntity?.toJSON() as IPrimitiveEntityTransfer) ||
|
|
1229
|
+
null;
|
|
1230
|
+
|
|
1231
|
+
const dataTypeInstance =
|
|
1232
|
+
createStateFromTypeAndSubscribe(
|
|
1233
|
+
dataTypeTransfer,
|
|
1234
|
+
this.project.logic
|
|
1235
|
+
) as DataTypeState;
|
|
1236
|
+
|
|
1237
|
+
dataTypeInstance.hydrateAncestors();
|
|
1238
|
+
dataTypeInstance.addSelfToProject(changeSet);
|
|
1239
|
+
|
|
1240
|
+
changeSet.add(
|
|
1241
|
+
dataTypeInstance,
|
|
1242
|
+
ChangeSetEntityChangeType.Added
|
|
1243
|
+
);
|
|
1244
|
+
|
|
1245
|
+
dataTypeInstance.initChildren(changeSet);
|
|
1246
|
+
|
|
1247
|
+
if (
|
|
1248
|
+
this.connectionOptions?.nodeType ===
|
|
1249
|
+
ConnectionNodeType.CalledBy &&
|
|
1250
|
+
!!this.connectionOptions?.target
|
|
1251
|
+
) {
|
|
1252
|
+
newInstance.addSuccessCall(
|
|
1253
|
+
this.connectionOptions
|
|
1254
|
+
.target as CallableEntityState,
|
|
1255
|
+
changeSet,
|
|
1256
|
+
// To recalculate its scope automatically
|
|
1257
|
+
true
|
|
1258
|
+
);
|
|
1259
|
+
(
|
|
1260
|
+
this.connectionOptions
|
|
1261
|
+
.target as CallableEntityState
|
|
1262
|
+
).addSuccessCaller(
|
|
1263
|
+
newInstance,
|
|
1264
|
+
changeSet,
|
|
1265
|
+
// To recalculate its scope automatically
|
|
1266
|
+
true
|
|
1267
|
+
);
|
|
1268
|
+
} else if (
|
|
1269
|
+
this.connectionOptions?.nodeType ===
|
|
1270
|
+
ConnectionNodeType.PropertyIn &&
|
|
1271
|
+
!!this.connectionOptions?.target
|
|
1272
|
+
) {
|
|
1273
|
+
newInstance.addValueReader(
|
|
1274
|
+
this.connectionOptions
|
|
1275
|
+
.target as ValueReadingEntityState,
|
|
1276
|
+
changeSet
|
|
1277
|
+
);
|
|
1278
|
+
} else if (
|
|
1279
|
+
this.connectionOptions?.nodeType ===
|
|
1280
|
+
ConnectionNodeType.ErrorCaller &&
|
|
1281
|
+
!!this.connectionOptions?.source
|
|
1282
|
+
) {
|
|
1283
|
+
newInstance.addErrorCaller(
|
|
1284
|
+
this.connectionOptions
|
|
1285
|
+
.source as PassThroughCallableEntityState,
|
|
1286
|
+
changeSet,
|
|
1287
|
+
// To recalculate its scope automatically
|
|
1288
|
+
true
|
|
1289
|
+
);
|
|
1290
|
+
(
|
|
1291
|
+
this.connectionOptions
|
|
1292
|
+
.source as PassThroughCallableEntityState
|
|
1293
|
+
).addErrorCall(newInstance, changeSet, true);
|
|
1294
|
+
} else if (
|
|
1295
|
+
this.connectionOptions?.nodeType ===
|
|
1296
|
+
ConnectionNodeType.SuccessCaller &&
|
|
1297
|
+
!!this.connectionOptions?.source
|
|
1298
|
+
) {
|
|
1299
|
+
newInstance.addSuccessCaller(
|
|
1300
|
+
this.connectionOptions
|
|
1301
|
+
.source as PassThroughCallableEntityState,
|
|
1302
|
+
changeSet,
|
|
1303
|
+
// To recalculate its scope automatically
|
|
1304
|
+
true
|
|
1305
|
+
);
|
|
1306
|
+
(
|
|
1307
|
+
this.connectionOptions
|
|
1308
|
+
.source as PassThroughCallableEntityState
|
|
1309
|
+
).addSuccessCall(newInstance, changeSet);
|
|
1310
|
+
} else if (
|
|
1311
|
+
this.connectionOptions?.nodeType ===
|
|
1312
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
1313
|
+
!!this.connectionOptions?.source
|
|
1314
|
+
) {
|
|
1315
|
+
newInstance.addEntryCaller(
|
|
1316
|
+
this.connectionOptions
|
|
1317
|
+
.source as EntryPointEntityState,
|
|
1318
|
+
changeSet,
|
|
1319
|
+
// To recalculate its scope automatically
|
|
1320
|
+
true
|
|
1321
|
+
);
|
|
1322
|
+
(
|
|
1323
|
+
this.connectionOptions
|
|
1324
|
+
.source as EntryPointEntityState
|
|
1325
|
+
).addCall(newInstance, changeSet);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
EditorService.navigate(
|
|
1329
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1330
|
+
);
|
|
1331
|
+
|
|
1332
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1333
|
+
newInstance,
|
|
1334
|
+
changeSet
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
case EntityType.GlobalEvent: {
|
|
1340
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1341
|
+
new ChangeSet(
|
|
1342
|
+
this.project.logic,
|
|
1343
|
+
ProjectState.sessionAuthor,
|
|
1344
|
+
new Date().toISOString(),
|
|
1345
|
+
this.project.logic,
|
|
1346
|
+
false,
|
|
1347
|
+
StateMutationAction.CreateNewGlobalEvent
|
|
1348
|
+
)
|
|
1349
|
+
);
|
|
1350
|
+
|
|
1351
|
+
const newEntityTransfer =
|
|
1352
|
+
GlobalEventState.new(changeSet);
|
|
1353
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1354
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1355
|
+
newEntityTransfer.parent =
|
|
1356
|
+
this.project.logic.toReference();
|
|
1357
|
+
|
|
1358
|
+
// Global events must always point to an base built-in action-descriptor implementation
|
|
1359
|
+
// The menu disabled creating new global events when all the available ones have been implemented
|
|
1360
|
+
// So here we pick the first action-descriptor for global events that hasn't been implemented yet
|
|
1361
|
+
const actionDescriptor =
|
|
1362
|
+
this.project.logic.globalEventActionDescriptors.find(
|
|
1363
|
+
(actionDescriptor) =>
|
|
1364
|
+
!this.project.logic.events.find(
|
|
1365
|
+
(event) =>
|
|
1366
|
+
event.implements?.id ===
|
|
1367
|
+
actionDescriptor.id
|
|
1368
|
+
)
|
|
1369
|
+
);
|
|
1370
|
+
|
|
1371
|
+
if (!actionDescriptor) {
|
|
1372
|
+
Logger.error(
|
|
1373
|
+
'Cannot create a new global event because all the available action descriptors have been implemented'
|
|
1374
|
+
);
|
|
1375
|
+
popupNotification({
|
|
1376
|
+
text: 'Cannot create a new global event because all the available global event types have been implemented',
|
|
1377
|
+
color: 'error'
|
|
1378
|
+
});
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
newEntityTransfer.implements =
|
|
1383
|
+
actionDescriptor.toJSON() as IActionDescriptorTransfer;
|
|
1384
|
+
newEntityTransfer.name =
|
|
1385
|
+
actionDescriptor.name as GlobalEventNames;
|
|
1386
|
+
|
|
1387
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1388
|
+
newEntityTransfer,
|
|
1389
|
+
this.project.logic
|
|
1390
|
+
) as GlobalEventState;
|
|
1391
|
+
|
|
1392
|
+
newInstance.hydrateAncestors();
|
|
1393
|
+
newInstance.addSelfToProject(changeSet);
|
|
1394
|
+
|
|
1395
|
+
changeSet.add(
|
|
1396
|
+
newInstance,
|
|
1397
|
+
ChangeSetEntityChangeType.Added
|
|
1398
|
+
);
|
|
1399
|
+
|
|
1400
|
+
if (
|
|
1401
|
+
this.connectionOptions?.nodeType ===
|
|
1402
|
+
ConnectionNodeType.CalledBy &&
|
|
1403
|
+
!!this.connectionOptions?.target
|
|
1404
|
+
) {
|
|
1405
|
+
newInstance.addCall(
|
|
1406
|
+
this.connectionOptions
|
|
1407
|
+
.target as CallableEntityState,
|
|
1408
|
+
changeSet
|
|
1409
|
+
);
|
|
1410
|
+
(
|
|
1411
|
+
this.connectionOptions
|
|
1412
|
+
.target as CallableEntityState
|
|
1413
|
+
).addEntryCaller(
|
|
1414
|
+
newInstance,
|
|
1415
|
+
changeSet,
|
|
1416
|
+
// To recalculate its scope automatically
|
|
1417
|
+
true
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1422
|
+
|
|
1423
|
+
EditorService.navigate(
|
|
1424
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1425
|
+
);
|
|
1426
|
+
|
|
1427
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1428
|
+
newInstance,
|
|
1429
|
+
changeSet
|
|
1430
|
+
);
|
|
1431
|
+
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
case EntityType.Loop: {
|
|
1435
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1436
|
+
new ChangeSet(
|
|
1437
|
+
this.project.logic,
|
|
1438
|
+
ProjectState.sessionAuthor,
|
|
1439
|
+
new Date().toISOString(),
|
|
1440
|
+
this.project.logic,
|
|
1441
|
+
false,
|
|
1442
|
+
StateMutationAction.CreateNewLoop
|
|
1443
|
+
)
|
|
1444
|
+
);
|
|
1445
|
+
|
|
1446
|
+
const newEntityTransfer = LoopState.new(changeSet);
|
|
1447
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1448
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1449
|
+
newEntityTransfer.parent = (
|
|
1450
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
1451
|
+
this.project.logic,
|
|
1452
|
+
this.props.connectedSource,
|
|
1453
|
+
this.props.connectedTarget
|
|
1454
|
+
) as EntryPointEntityState
|
|
1455
|
+
).toReference();
|
|
1456
|
+
|
|
1457
|
+
// We select the first loop declaration available for now
|
|
1458
|
+
// The user can change it later
|
|
1459
|
+
const actionDescriptor =
|
|
1460
|
+
this.project.logic.loopDeclarations[0];
|
|
1461
|
+
|
|
1462
|
+
newEntityTransfer.declaration =
|
|
1463
|
+
actionDescriptor.toJSON() as IActionDescriptorTransfer;
|
|
1464
|
+
|
|
1465
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1466
|
+
newEntityTransfer,
|
|
1467
|
+
this.project.logic
|
|
1468
|
+
) as LoopState;
|
|
1469
|
+
|
|
1470
|
+
newInstance.hydrateAncestors();
|
|
1471
|
+
newInstance.addSelfToProject(changeSet);
|
|
1472
|
+
|
|
1473
|
+
changeSet.add(
|
|
1474
|
+
newInstance,
|
|
1475
|
+
ChangeSetEntityChangeType.Added
|
|
1476
|
+
);
|
|
1477
|
+
|
|
1478
|
+
if (
|
|
1479
|
+
this.connectionOptions?.nodeType ===
|
|
1480
|
+
ConnectionNodeType.CalledBy &&
|
|
1481
|
+
!!this.connectionOptions?.target
|
|
1482
|
+
) {
|
|
1483
|
+
newInstance.addSuccessCall(
|
|
1484
|
+
this.connectionOptions
|
|
1485
|
+
.target as CallableEntityState,
|
|
1486
|
+
changeSet,
|
|
1487
|
+
// To recalculate its scope automatically
|
|
1488
|
+
true
|
|
1489
|
+
);
|
|
1490
|
+
(
|
|
1491
|
+
this.connectionOptions
|
|
1492
|
+
.target as CallableEntityState
|
|
1493
|
+
).addSuccessCaller(
|
|
1494
|
+
newInstance,
|
|
1495
|
+
changeSet,
|
|
1496
|
+
// To recalculate its scope automatically
|
|
1497
|
+
true
|
|
1498
|
+
);
|
|
1499
|
+
} else if (
|
|
1500
|
+
this.connectionOptions?.nodeType ===
|
|
1501
|
+
ConnectionNodeType.ErrorCaller &&
|
|
1502
|
+
!!this.connectionOptions?.source
|
|
1503
|
+
) {
|
|
1504
|
+
newInstance.addErrorCaller(
|
|
1505
|
+
this.connectionOptions
|
|
1506
|
+
.source as PassThroughCallableEntityState,
|
|
1507
|
+
changeSet,
|
|
1508
|
+
// To recalculate its scope automatically
|
|
1509
|
+
true
|
|
1510
|
+
);
|
|
1511
|
+
(
|
|
1512
|
+
this.connectionOptions
|
|
1513
|
+
.source as PassThroughCallableEntityState
|
|
1514
|
+
).addErrorCall(newInstance, changeSet);
|
|
1515
|
+
} else if (
|
|
1516
|
+
this.connectionOptions?.nodeType ===
|
|
1517
|
+
ConnectionNodeType.SuccessCaller &&
|
|
1518
|
+
!!this.connectionOptions?.source
|
|
1519
|
+
) {
|
|
1520
|
+
newInstance.addSuccessCaller(
|
|
1521
|
+
this.connectionOptions
|
|
1522
|
+
.source as PassThroughCallableEntityState,
|
|
1523
|
+
changeSet,
|
|
1524
|
+
// To recalculate its scope automatically
|
|
1525
|
+
true
|
|
1526
|
+
);
|
|
1527
|
+
(
|
|
1528
|
+
this.connectionOptions
|
|
1529
|
+
.source as PassThroughCallableEntityState
|
|
1530
|
+
).addSuccessCall(newInstance, changeSet);
|
|
1531
|
+
} else if (
|
|
1532
|
+
this.connectionOptions?.nodeType ===
|
|
1533
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
1534
|
+
!!this.connectionOptions?.source
|
|
1535
|
+
) {
|
|
1536
|
+
newInstance.addEntryCaller(
|
|
1537
|
+
this.connectionOptions
|
|
1538
|
+
.source as EntryPointEntityState,
|
|
1539
|
+
changeSet,
|
|
1540
|
+
// To recalculate its scope automatically
|
|
1541
|
+
true
|
|
1542
|
+
);
|
|
1543
|
+
(
|
|
1544
|
+
this.connectionOptions
|
|
1545
|
+
.source as EntryPointEntityState
|
|
1546
|
+
).addCall(newInstance, changeSet);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1550
|
+
|
|
1551
|
+
EditorService.navigate(
|
|
1552
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1553
|
+
);
|
|
1554
|
+
|
|
1555
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1556
|
+
newInstance,
|
|
1557
|
+
changeSet
|
|
1558
|
+
);
|
|
1559
|
+
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
case EntityType.Search: {
|
|
1563
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1564
|
+
new ChangeSet(
|
|
1565
|
+
this.project.logic,
|
|
1566
|
+
ProjectState.sessionAuthor,
|
|
1567
|
+
new Date().toISOString(),
|
|
1568
|
+
this.project.logic,
|
|
1569
|
+
false,
|
|
1570
|
+
StateMutationAction.CreateNewSearch
|
|
1571
|
+
)
|
|
1572
|
+
);
|
|
1573
|
+
|
|
1574
|
+
const newEntityTransfer = SearchState.new(changeSet);
|
|
1575
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1576
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1577
|
+
|
|
1578
|
+
newEntityTransfer.name = findNextAvailableName(
|
|
1579
|
+
'Search',
|
|
1580
|
+
this.project.logic.getSearches()
|
|
1581
|
+
);
|
|
1582
|
+
|
|
1583
|
+
newEntityTransfer.parent = (
|
|
1584
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
1585
|
+
this.project.logic,
|
|
1586
|
+
this.props.connectedSource,
|
|
1587
|
+
this.props.connectedTarget
|
|
1588
|
+
) as EntryPointEntityState
|
|
1589
|
+
).toReference();
|
|
1590
|
+
|
|
1591
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1592
|
+
newEntityTransfer,
|
|
1593
|
+
this.project.logic
|
|
1594
|
+
) as SearchState;
|
|
1595
|
+
|
|
1596
|
+
newInstance.hydrateAncestors();
|
|
1597
|
+
newInstance.addSelfToProject(changeSet);
|
|
1598
|
+
|
|
1599
|
+
changeSet.add(
|
|
1600
|
+
newInstance,
|
|
1601
|
+
ChangeSetEntityChangeType.Added
|
|
1602
|
+
);
|
|
1603
|
+
|
|
1604
|
+
if (
|
|
1605
|
+
this.connectionOptions?.nodeType ===
|
|
1606
|
+
ConnectionNodeType.CalledBy &&
|
|
1607
|
+
!!this.connectionOptions?.target
|
|
1608
|
+
) {
|
|
1609
|
+
newInstance.addSuccessCall(
|
|
1610
|
+
this.connectionOptions
|
|
1611
|
+
.target as CallableEntityState,
|
|
1612
|
+
changeSet,
|
|
1613
|
+
// To recalculate its scope automatically
|
|
1614
|
+
true
|
|
1615
|
+
);
|
|
1616
|
+
(
|
|
1617
|
+
this.connectionOptions
|
|
1618
|
+
.target as CallableEntityState
|
|
1619
|
+
).addSuccessCaller(
|
|
1620
|
+
newInstance,
|
|
1621
|
+
changeSet,
|
|
1622
|
+
// To recalculate its scope automatically
|
|
1623
|
+
true
|
|
1624
|
+
);
|
|
1625
|
+
} else if (
|
|
1626
|
+
this.connectionOptions?.nodeType ===
|
|
1627
|
+
ConnectionNodeType.ErrorCaller &&
|
|
1628
|
+
!!this.connectionOptions?.source
|
|
1629
|
+
) {
|
|
1630
|
+
newInstance.addErrorCaller(
|
|
1631
|
+
this.connectionOptions
|
|
1632
|
+
.source as PassThroughCallableEntityState,
|
|
1633
|
+
changeSet,
|
|
1634
|
+
// To recalculate its scope automatically
|
|
1635
|
+
true
|
|
1636
|
+
);
|
|
1637
|
+
(
|
|
1638
|
+
this.connectionOptions
|
|
1639
|
+
.source as PassThroughCallableEntityState
|
|
1640
|
+
).addErrorCall(newInstance, changeSet);
|
|
1641
|
+
} else if (
|
|
1642
|
+
this.connectionOptions?.nodeType ===
|
|
1643
|
+
ConnectionNodeType.SuccessCaller &&
|
|
1644
|
+
!!this.connectionOptions?.source
|
|
1645
|
+
) {
|
|
1646
|
+
newInstance.addSuccessCaller(
|
|
1647
|
+
this.connectionOptions
|
|
1648
|
+
.source as PassThroughCallableEntityState,
|
|
1649
|
+
changeSet,
|
|
1650
|
+
// To recalculate its scope automatically
|
|
1651
|
+
true
|
|
1652
|
+
);
|
|
1653
|
+
(
|
|
1654
|
+
this.connectionOptions
|
|
1655
|
+
.source as PassThroughCallableEntityState
|
|
1656
|
+
).addSuccessCall(newInstance, changeSet);
|
|
1657
|
+
} else if (
|
|
1658
|
+
this.connectionOptions?.nodeType ===
|
|
1659
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
1660
|
+
!!this.connectionOptions?.source
|
|
1661
|
+
) {
|
|
1662
|
+
newInstance.addEntryCaller(
|
|
1663
|
+
this.connectionOptions
|
|
1664
|
+
.source as EntryPointEntityState,
|
|
1665
|
+
changeSet,
|
|
1666
|
+
// To recalculate its scope automatically
|
|
1667
|
+
true
|
|
1668
|
+
);
|
|
1669
|
+
(
|
|
1670
|
+
this.connectionOptions
|
|
1671
|
+
.source as EntryPointEntityState
|
|
1672
|
+
).addCall(newInstance, changeSet);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1676
|
+
|
|
1677
|
+
EditorService.navigate(
|
|
1678
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1679
|
+
);
|
|
1680
|
+
|
|
1681
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1682
|
+
newInstance,
|
|
1683
|
+
changeSet
|
|
1684
|
+
);
|
|
1685
|
+
|
|
1686
|
+
break;
|
|
1687
|
+
}
|
|
1688
|
+
case EntityType.Operation: {
|
|
1689
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1690
|
+
new ChangeSet(
|
|
1691
|
+
this.project.logic,
|
|
1692
|
+
ProjectState.sessionAuthor,
|
|
1693
|
+
new Date().toISOString(),
|
|
1694
|
+
this.project.logic,
|
|
1695
|
+
false,
|
|
1696
|
+
StateMutationAction.CreateNewOperation
|
|
1697
|
+
)
|
|
1698
|
+
);
|
|
1699
|
+
|
|
1700
|
+
const newEntityTransfer = OperationState.new(changeSet);
|
|
1701
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1702
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1703
|
+
newEntityTransfer.parent = (
|
|
1704
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
1705
|
+
this.project.logic,
|
|
1706
|
+
this.props.connectedSource,
|
|
1707
|
+
this.props.connectedTarget
|
|
1708
|
+
) as EntryPointEntityState
|
|
1709
|
+
).toReference();
|
|
1710
|
+
|
|
1711
|
+
// We select the first operation declaration available for now
|
|
1712
|
+
// The user can change it later
|
|
1713
|
+
const actionDescriptor =
|
|
1714
|
+
this.project.logic.operationDeclarations[0];
|
|
1715
|
+
|
|
1716
|
+
newEntityTransfer.declaration =
|
|
1717
|
+
actionDescriptor.toJSON() as IActionDescriptorTransfer;
|
|
1718
|
+
|
|
1719
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1720
|
+
newEntityTransfer,
|
|
1721
|
+
this.project.logic
|
|
1722
|
+
) as OperationState;
|
|
1723
|
+
|
|
1724
|
+
newInstance.hydrateAncestors();
|
|
1725
|
+
newInstance.addSelfToProject(changeSet);
|
|
1726
|
+
|
|
1727
|
+
changeSet.add(
|
|
1728
|
+
newInstance,
|
|
1729
|
+
ChangeSetEntityChangeType.Added
|
|
1730
|
+
);
|
|
1731
|
+
|
|
1732
|
+
if (
|
|
1733
|
+
this.connectionOptions?.nodeType ===
|
|
1734
|
+
ConnectionNodeType.CalledBy &&
|
|
1735
|
+
!!this.connectionOptions?.target
|
|
1736
|
+
) {
|
|
1737
|
+
newInstance.addSuccessCall(
|
|
1738
|
+
this.connectionOptions
|
|
1739
|
+
.target as CallableEntityState,
|
|
1740
|
+
changeSet,
|
|
1741
|
+
// To recalculate its scope automatically
|
|
1742
|
+
true
|
|
1743
|
+
);
|
|
1744
|
+
(
|
|
1745
|
+
this.connectionOptions
|
|
1746
|
+
.target as CallableEntityState
|
|
1747
|
+
).addSuccessCaller(
|
|
1748
|
+
newInstance,
|
|
1749
|
+
changeSet,
|
|
1750
|
+
// To recalculate its scope automatically
|
|
1751
|
+
true
|
|
1752
|
+
);
|
|
1753
|
+
} else if (
|
|
1754
|
+
this.connectionOptions?.nodeType ===
|
|
1755
|
+
ConnectionNodeType.ErrorCaller &&
|
|
1756
|
+
!!this.connectionOptions?.source
|
|
1757
|
+
) {
|
|
1758
|
+
newInstance.addErrorCaller(
|
|
1759
|
+
this.connectionOptions
|
|
1760
|
+
.source as PassThroughCallableEntityState,
|
|
1761
|
+
changeSet,
|
|
1762
|
+
// To recalculate its scope automatically
|
|
1763
|
+
true
|
|
1764
|
+
);
|
|
1765
|
+
(
|
|
1766
|
+
this.connectionOptions
|
|
1767
|
+
.source as PassThroughCallableEntityState
|
|
1768
|
+
).addErrorCall(newInstance, changeSet);
|
|
1769
|
+
} else if (
|
|
1770
|
+
this.connectionOptions?.nodeType ===
|
|
1771
|
+
ConnectionNodeType.SuccessCaller &&
|
|
1772
|
+
!!this.connectionOptions?.source
|
|
1773
|
+
) {
|
|
1774
|
+
newInstance.addSuccessCaller(
|
|
1775
|
+
this.connectionOptions
|
|
1776
|
+
.source as PassThroughCallableEntityState,
|
|
1777
|
+
changeSet,
|
|
1778
|
+
// To recalculate its scope automatically
|
|
1779
|
+
true
|
|
1780
|
+
);
|
|
1781
|
+
(
|
|
1782
|
+
this.connectionOptions
|
|
1783
|
+
.source as PassThroughCallableEntityState
|
|
1784
|
+
).addSuccessCall(newInstance, changeSet);
|
|
1785
|
+
} else if (
|
|
1786
|
+
this.connectionOptions?.nodeType ===
|
|
1787
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
1788
|
+
!!this.connectionOptions?.source
|
|
1789
|
+
) {
|
|
1790
|
+
newInstance.addEntryCaller(
|
|
1791
|
+
this.connectionOptions
|
|
1792
|
+
.source as EntryPointEntityState,
|
|
1793
|
+
changeSet,
|
|
1794
|
+
// To recalculate its scope automatically
|
|
1795
|
+
true
|
|
1796
|
+
);
|
|
1797
|
+
(
|
|
1798
|
+
this.connectionOptions
|
|
1799
|
+
.source as EntryPointEntityState
|
|
1800
|
+
).addCall(newInstance, changeSet);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1804
|
+
|
|
1805
|
+
EditorService.navigate(
|
|
1806
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1807
|
+
);
|
|
1808
|
+
|
|
1809
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1810
|
+
newInstance,
|
|
1811
|
+
changeSet
|
|
1812
|
+
);
|
|
1813
|
+
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
case EntityType.FunctionCall: {
|
|
1817
|
+
// We select the first operation declaration available for now
|
|
1818
|
+
// The user can change it later
|
|
1819
|
+
const functionDeclaration =
|
|
1820
|
+
this.project.logic.functions[0];
|
|
1821
|
+
|
|
1822
|
+
if (!functionDeclaration) {
|
|
1823
|
+
popupNotification({
|
|
1824
|
+
text: 'Cannot create a new trigger execution because there are no triggers',
|
|
1825
|
+
color: 'error'
|
|
1826
|
+
});
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1831
|
+
new ChangeSet(
|
|
1832
|
+
this.project.logic,
|
|
1833
|
+
ProjectState.sessionAuthor,
|
|
1834
|
+
new Date().toISOString(),
|
|
1835
|
+
this.project.logic,
|
|
1836
|
+
false,
|
|
1837
|
+
StateMutationAction.CreateNewFuncCall
|
|
1838
|
+
)
|
|
1839
|
+
);
|
|
1840
|
+
|
|
1841
|
+
const newEntityTransfer =
|
|
1842
|
+
FunctionCallState.new(changeSet);
|
|
1843
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1844
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1845
|
+
newEntityTransfer.parent = (
|
|
1846
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
1847
|
+
this.project.logic,
|
|
1848
|
+
this.props.connectedSource,
|
|
1849
|
+
this.props.connectedTarget
|
|
1850
|
+
) as EntryPointEntityState
|
|
1851
|
+
).toReference();
|
|
1852
|
+
|
|
1853
|
+
newEntityTransfer.declaration =
|
|
1854
|
+
functionDeclaration.toJSON() as IFunctionDeclarationTransfer;
|
|
1855
|
+
|
|
1856
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1857
|
+
newEntityTransfer,
|
|
1858
|
+
this.project.logic
|
|
1859
|
+
) as FunctionCallState;
|
|
1860
|
+
|
|
1861
|
+
newInstance.hydrateAncestors();
|
|
1862
|
+
newInstance.addSelfToProject(changeSet);
|
|
1863
|
+
|
|
1864
|
+
changeSet.add(
|
|
1865
|
+
newInstance,
|
|
1866
|
+
ChangeSetEntityChangeType.Added
|
|
1867
|
+
);
|
|
1868
|
+
|
|
1869
|
+
if (
|
|
1870
|
+
this.connectionOptions?.nodeType ===
|
|
1871
|
+
ConnectionNodeType.CalledBy &&
|
|
1872
|
+
!!this.connectionOptions?.target
|
|
1873
|
+
) {
|
|
1874
|
+
newInstance.addSuccessCall(
|
|
1875
|
+
this.connectionOptions
|
|
1876
|
+
.target as CallableEntityState,
|
|
1877
|
+
changeSet,
|
|
1878
|
+
// To recalculate its scope automatically
|
|
1879
|
+
true
|
|
1880
|
+
);
|
|
1881
|
+
(
|
|
1882
|
+
this.connectionOptions
|
|
1883
|
+
.target as CallableEntityState
|
|
1884
|
+
).addSuccessCaller(
|
|
1885
|
+
newInstance,
|
|
1886
|
+
changeSet,
|
|
1887
|
+
// To recalculate its scope automatically
|
|
1888
|
+
true
|
|
1889
|
+
);
|
|
1890
|
+
} else if (
|
|
1891
|
+
this.connectionOptions?.nodeType ===
|
|
1892
|
+
ConnectionNodeType.ErrorCaller &&
|
|
1893
|
+
!!this.connectionOptions?.source
|
|
1894
|
+
) {
|
|
1895
|
+
newInstance.addErrorCaller(
|
|
1896
|
+
this.connectionOptions
|
|
1897
|
+
.source as PassThroughCallableEntityState,
|
|
1898
|
+
changeSet,
|
|
1899
|
+
// To recalculate its scope automatically
|
|
1900
|
+
true
|
|
1901
|
+
);
|
|
1902
|
+
(
|
|
1903
|
+
this.connectionOptions
|
|
1904
|
+
.source as PassThroughCallableEntityState
|
|
1905
|
+
).addErrorCall(newInstance, changeSet);
|
|
1906
|
+
} else if (
|
|
1907
|
+
this.connectionOptions?.nodeType ===
|
|
1908
|
+
ConnectionNodeType.SuccessCaller &&
|
|
1909
|
+
!!this.connectionOptions?.source
|
|
1910
|
+
) {
|
|
1911
|
+
newInstance.addSuccessCaller(
|
|
1912
|
+
this.connectionOptions
|
|
1913
|
+
.source as PassThroughCallableEntityState,
|
|
1914
|
+
changeSet,
|
|
1915
|
+
// To recalculate its scope automatically
|
|
1916
|
+
true
|
|
1917
|
+
);
|
|
1918
|
+
(
|
|
1919
|
+
this.connectionOptions
|
|
1920
|
+
.source as PassThroughCallableEntityState
|
|
1921
|
+
).addSuccessCall(newInstance, changeSet);
|
|
1922
|
+
} else if (
|
|
1923
|
+
this.connectionOptions?.nodeType ===
|
|
1924
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
1925
|
+
!!this.connectionOptions?.source
|
|
1926
|
+
) {
|
|
1927
|
+
newInstance.addEntryCaller(
|
|
1928
|
+
this.connectionOptions
|
|
1929
|
+
.source as EntryPointEntityState,
|
|
1930
|
+
changeSet,
|
|
1931
|
+
// To recalculate its scope automatically
|
|
1932
|
+
true
|
|
1933
|
+
);
|
|
1934
|
+
(
|
|
1935
|
+
this.connectionOptions
|
|
1936
|
+
.source as EntryPointEntityState
|
|
1937
|
+
).addCall(newInstance, changeSet);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
1941
|
+
|
|
1942
|
+
EditorService.navigate(
|
|
1943
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
1944
|
+
);
|
|
1945
|
+
|
|
1946
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
1947
|
+
newInstance,
|
|
1948
|
+
changeSet
|
|
1949
|
+
);
|
|
1950
|
+
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
case EntityType.Condition: {
|
|
1954
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
1955
|
+
new ChangeSet(
|
|
1956
|
+
this.project.logic,
|
|
1957
|
+
ProjectState.sessionAuthor,
|
|
1958
|
+
new Date().toISOString(),
|
|
1959
|
+
this.project.logic,
|
|
1960
|
+
false,
|
|
1961
|
+
StateMutationAction.CreateNewCondition
|
|
1962
|
+
)
|
|
1963
|
+
);
|
|
1964
|
+
|
|
1965
|
+
const newEntityTransfer = ConditionState.new(changeSet);
|
|
1966
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
1967
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
1968
|
+
newEntityTransfer.parent = (
|
|
1969
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
1970
|
+
this.project.logic,
|
|
1971
|
+
this.props.connectedSource,
|
|
1972
|
+
this.props.connectedTarget
|
|
1973
|
+
) as EntryPointEntityState
|
|
1974
|
+
).toReference();
|
|
1975
|
+
|
|
1976
|
+
// We select the first condition declaration available for now
|
|
1977
|
+
// The user can change it later
|
|
1978
|
+
const actionDescriptor =
|
|
1979
|
+
this.project.logic.conditionDeclarations[0];
|
|
1980
|
+
|
|
1981
|
+
newEntityTransfer.declaration =
|
|
1982
|
+
actionDescriptor.toJSON() as IActionDescriptorTransfer;
|
|
1983
|
+
|
|
1984
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
1985
|
+
newEntityTransfer,
|
|
1986
|
+
this.project.logic
|
|
1987
|
+
) as ConditionState;
|
|
1988
|
+
|
|
1989
|
+
newInstance.hydrateAncestors();
|
|
1990
|
+
newInstance.addSelfToProject(changeSet);
|
|
1991
|
+
|
|
1992
|
+
changeSet.add(
|
|
1993
|
+
newInstance,
|
|
1994
|
+
ChangeSetEntityChangeType.Added
|
|
1995
|
+
);
|
|
1996
|
+
|
|
1997
|
+
if (
|
|
1998
|
+
this.connectionOptions?.nodeType ===
|
|
1999
|
+
ConnectionNodeType.CalledBy &&
|
|
2000
|
+
!!this.connectionOptions?.target
|
|
2001
|
+
) {
|
|
2002
|
+
newInstance.addSuccessCall(
|
|
2003
|
+
this.connectionOptions
|
|
2004
|
+
.target as CallableEntityState,
|
|
2005
|
+
changeSet,
|
|
2006
|
+
// To recalculate its scope automatically
|
|
2007
|
+
true
|
|
2008
|
+
);
|
|
2009
|
+
(
|
|
2010
|
+
this.connectionOptions
|
|
2011
|
+
.target as CallableEntityState
|
|
2012
|
+
).addSuccessCaller(
|
|
2013
|
+
newInstance,
|
|
2014
|
+
changeSet,
|
|
2015
|
+
// To recalculate its scope automatically
|
|
2016
|
+
true
|
|
2017
|
+
);
|
|
2018
|
+
} else if (
|
|
2019
|
+
this.connectionOptions?.nodeType ===
|
|
2020
|
+
ConnectionNodeType.ErrorCaller &&
|
|
2021
|
+
!!this.connectionOptions?.source
|
|
2022
|
+
) {
|
|
2023
|
+
newInstance.addErrorCaller(
|
|
2024
|
+
this.connectionOptions
|
|
2025
|
+
.source as PassThroughCallableEntityState,
|
|
2026
|
+
changeSet,
|
|
2027
|
+
// To recalculate its scope automatically
|
|
2028
|
+
true
|
|
2029
|
+
);
|
|
2030
|
+
(
|
|
2031
|
+
this.connectionOptions
|
|
2032
|
+
.source as PassThroughCallableEntityState
|
|
2033
|
+
).addErrorCall(newInstance, changeSet);
|
|
2034
|
+
} else if (
|
|
2035
|
+
this.connectionOptions?.nodeType ===
|
|
2036
|
+
ConnectionNodeType.SuccessCaller &&
|
|
2037
|
+
!!this.connectionOptions?.source
|
|
2038
|
+
) {
|
|
2039
|
+
newInstance.addSuccessCaller(
|
|
2040
|
+
this.connectionOptions
|
|
2041
|
+
.source as PassThroughCallableEntityState,
|
|
2042
|
+
changeSet,
|
|
2043
|
+
// To recalculate its scope automatically
|
|
2044
|
+
true
|
|
2045
|
+
);
|
|
2046
|
+
(
|
|
2047
|
+
this.connectionOptions
|
|
2048
|
+
.source as PassThroughCallableEntityState
|
|
2049
|
+
).addSuccessCall(newInstance, changeSet);
|
|
2050
|
+
} else if (
|
|
2051
|
+
this.connectionOptions?.nodeType ===
|
|
2052
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
2053
|
+
!!this.connectionOptions?.source
|
|
2054
|
+
) {
|
|
2055
|
+
newInstance.addEntryCaller(
|
|
2056
|
+
this.connectionOptions
|
|
2057
|
+
.source as EntryPointEntityState,
|
|
2058
|
+
changeSet,
|
|
2059
|
+
// To recalculate its scope automatically
|
|
2060
|
+
true
|
|
2061
|
+
);
|
|
2062
|
+
(
|
|
2063
|
+
this.connectionOptions
|
|
2064
|
+
.source as EntryPointEntityState
|
|
2065
|
+
).addCall(newInstance, changeSet);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
2069
|
+
|
|
2070
|
+
EditorService.navigate(
|
|
2071
|
+
`${this.project.editorBasePath}/entity/${entityType}/${newInstance.id}`
|
|
2072
|
+
);
|
|
2073
|
+
|
|
2074
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2075
|
+
newInstance,
|
|
2076
|
+
changeSet
|
|
2077
|
+
);
|
|
2078
|
+
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
case EntityType.ReturnStatement: {
|
|
2082
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2083
|
+
new ChangeSet(
|
|
2084
|
+
this.project.logic,
|
|
2085
|
+
ProjectState.sessionAuthor,
|
|
2086
|
+
new Date().toISOString(),
|
|
2087
|
+
this.project.logic,
|
|
2088
|
+
false,
|
|
2089
|
+
StateMutationAction.CreateNewReturnStmt
|
|
2090
|
+
)
|
|
2091
|
+
);
|
|
2092
|
+
|
|
2093
|
+
const newEntityTransfer =
|
|
2094
|
+
ReturnStatementState.new(changeSet);
|
|
2095
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
2096
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
2097
|
+
newEntityTransfer.parent = (
|
|
2098
|
+
getFirstNonLoopScopeOwner(
|
|
2099
|
+
this.connectionOptions
|
|
2100
|
+
?.source as EntryPointEntityState,
|
|
2101
|
+
this.project.logic
|
|
2102
|
+
) as EntryPointEntityState
|
|
2103
|
+
).toReference();
|
|
2104
|
+
|
|
2105
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
2106
|
+
newEntityTransfer,
|
|
2107
|
+
this.project.logic
|
|
2108
|
+
) as ReturnStatementState;
|
|
2109
|
+
|
|
2110
|
+
newInstance.hydrateAncestors();
|
|
2111
|
+
newInstance.addSelfToProject(changeSet);
|
|
2112
|
+
|
|
2113
|
+
changeSet.add(
|
|
2114
|
+
newInstance,
|
|
2115
|
+
ChangeSetEntityChangeType.Added
|
|
2116
|
+
);
|
|
2117
|
+
|
|
2118
|
+
if (
|
|
2119
|
+
this.connectionOptions?.nodeType ===
|
|
2120
|
+
ConnectionNodeType.ErrorCaller &&
|
|
2121
|
+
!!this.connectionOptions?.source
|
|
2122
|
+
) {
|
|
2123
|
+
newInstance.addErrorCaller(
|
|
2124
|
+
this.connectionOptions
|
|
2125
|
+
.source as PassThroughCallableEntityState,
|
|
2126
|
+
changeSet
|
|
2127
|
+
);
|
|
2128
|
+
(
|
|
2129
|
+
this.connectionOptions
|
|
2130
|
+
.source as PassThroughCallableEntityState
|
|
2131
|
+
).addErrorCall(newInstance, changeSet);
|
|
2132
|
+
} else if (
|
|
2133
|
+
this.connectionOptions?.nodeType ===
|
|
2134
|
+
ConnectionNodeType.SuccessCaller &&
|
|
2135
|
+
!!this.connectionOptions?.source
|
|
2136
|
+
) {
|
|
2137
|
+
newInstance.addSuccessCaller(
|
|
2138
|
+
this.connectionOptions
|
|
2139
|
+
.source as PassThroughCallableEntityState,
|
|
2140
|
+
changeSet
|
|
2141
|
+
);
|
|
2142
|
+
(
|
|
2143
|
+
this.connectionOptions
|
|
2144
|
+
.source as PassThroughCallableEntityState
|
|
2145
|
+
).addSuccessCall(newInstance, changeSet);
|
|
2146
|
+
} else if (
|
|
2147
|
+
this.connectionOptions?.nodeType ===
|
|
2148
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
2149
|
+
!!this.connectionOptions?.source
|
|
2150
|
+
) {
|
|
2151
|
+
newInstance.addEntryCaller(
|
|
2152
|
+
this.connectionOptions
|
|
2153
|
+
.source as EntryPointEntityState,
|
|
2154
|
+
changeSet
|
|
2155
|
+
);
|
|
2156
|
+
(
|
|
2157
|
+
this.connectionOptions
|
|
2158
|
+
.source as EntryPointEntityState
|
|
2159
|
+
).addCall(newInstance, changeSet);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
2163
|
+
|
|
2164
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2165
|
+
newInstance,
|
|
2166
|
+
changeSet
|
|
2167
|
+
);
|
|
2168
|
+
|
|
2169
|
+
break;
|
|
2170
|
+
}
|
|
2171
|
+
case EntityType.BreakStatement: {
|
|
2172
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2173
|
+
new ChangeSet(
|
|
2174
|
+
this.project.logic,
|
|
2175
|
+
ProjectState.sessionAuthor,
|
|
2176
|
+
new Date().toISOString(),
|
|
2177
|
+
this.project.logic,
|
|
2178
|
+
false,
|
|
2179
|
+
StateMutationAction.CreateNewBreakStmt
|
|
2180
|
+
)
|
|
2181
|
+
);
|
|
2182
|
+
|
|
2183
|
+
const newEntityTransfer =
|
|
2184
|
+
BreakStatementState.new(changeSet);
|
|
2185
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
2186
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
2187
|
+
newEntityTransfer.parent = (
|
|
2188
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
2189
|
+
this.project.logic,
|
|
2190
|
+
this.props.connectedSource,
|
|
2191
|
+
this.props.connectedTarget
|
|
2192
|
+
) as LoopState
|
|
2193
|
+
).toReference();
|
|
2194
|
+
|
|
2195
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
2196
|
+
newEntityTransfer,
|
|
2197
|
+
this.project.logic
|
|
2198
|
+
) as BreakStatementState;
|
|
2199
|
+
|
|
2200
|
+
newInstance.hydrateAncestors();
|
|
2201
|
+
newInstance.addSelfToProject(changeSet);
|
|
2202
|
+
|
|
2203
|
+
changeSet.add(
|
|
2204
|
+
newInstance,
|
|
2205
|
+
ChangeSetEntityChangeType.Added
|
|
2206
|
+
);
|
|
2207
|
+
|
|
2208
|
+
if (
|
|
2209
|
+
this.connectionOptions?.nodeType ===
|
|
2210
|
+
ConnectionNodeType.ErrorCaller &&
|
|
2211
|
+
!!this.connectionOptions?.source
|
|
2212
|
+
) {
|
|
2213
|
+
newInstance.addErrorCaller(
|
|
2214
|
+
this.connectionOptions
|
|
2215
|
+
.source as PassThroughCallableEntityState,
|
|
2216
|
+
changeSet,
|
|
2217
|
+
// To recalculate its scope automatically
|
|
2218
|
+
true
|
|
2219
|
+
);
|
|
2220
|
+
(
|
|
2221
|
+
this.connectionOptions
|
|
2222
|
+
.source as PassThroughCallableEntityState
|
|
2223
|
+
).addErrorCall(newInstance, changeSet);
|
|
2224
|
+
} else if (
|
|
2225
|
+
this.connectionOptions?.nodeType ===
|
|
2226
|
+
ConnectionNodeType.SuccessCaller &&
|
|
2227
|
+
!!this.connectionOptions?.source
|
|
2228
|
+
) {
|
|
2229
|
+
newInstance.addSuccessCaller(
|
|
2230
|
+
this.connectionOptions
|
|
2231
|
+
.source as PassThroughCallableEntityState,
|
|
2232
|
+
changeSet,
|
|
2233
|
+
// To recalculate its scope automatically
|
|
2234
|
+
true
|
|
2235
|
+
);
|
|
2236
|
+
(
|
|
2237
|
+
this.connectionOptions
|
|
2238
|
+
.source as PassThroughCallableEntityState
|
|
2239
|
+
).addSuccessCall(newInstance, changeSet);
|
|
2240
|
+
} else if (
|
|
2241
|
+
this.connectionOptions?.nodeType ===
|
|
2242
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
2243
|
+
!!this.connectionOptions?.source
|
|
2244
|
+
) {
|
|
2245
|
+
newInstance.addEntryCaller(
|
|
2246
|
+
this.connectionOptions
|
|
2247
|
+
.source as EntryPointEntityState,
|
|
2248
|
+
changeSet,
|
|
2249
|
+
// To recalculate its scope automatically
|
|
2250
|
+
true
|
|
2251
|
+
);
|
|
2252
|
+
(
|
|
2253
|
+
this.connectionOptions
|
|
2254
|
+
.source as EntryPointEntityState
|
|
2255
|
+
).addCall(newInstance, changeSet);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
2259
|
+
|
|
2260
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2261
|
+
newInstance,
|
|
2262
|
+
changeSet
|
|
2263
|
+
);
|
|
2264
|
+
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
case EntityType.ContinueStatement: {
|
|
2268
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2269
|
+
new ChangeSet(
|
|
2270
|
+
this.project.logic,
|
|
2271
|
+
ProjectState.sessionAuthor,
|
|
2272
|
+
new Date().toISOString(),
|
|
2273
|
+
this.project.logic,
|
|
2274
|
+
false,
|
|
2275
|
+
StateMutationAction.CreateNewContinueStmt
|
|
2276
|
+
)
|
|
2277
|
+
);
|
|
2278
|
+
|
|
2279
|
+
const newEntityTransfer =
|
|
2280
|
+
ContinueStatementState.new(changeSet);
|
|
2281
|
+
newEntityTransfer.x = this.coordinates.x;
|
|
2282
|
+
newEntityTransfer.y = this.coordinates.y;
|
|
2283
|
+
newEntityTransfer.parent = (
|
|
2284
|
+
resolveNewParentFromConnectionsScopeOwner(
|
|
2285
|
+
this.project.logic,
|
|
2286
|
+
this.props.connectedSource,
|
|
2287
|
+
this.props.connectedTarget
|
|
2288
|
+
) as LoopState
|
|
2289
|
+
).toReference();
|
|
2290
|
+
|
|
2291
|
+
const newInstance = createStateFromTypeAndSubscribe(
|
|
2292
|
+
newEntityTransfer,
|
|
2293
|
+
this.project.logic
|
|
2294
|
+
) as ContinueStatementState;
|
|
2295
|
+
|
|
2296
|
+
newInstance.hydrateAncestors();
|
|
2297
|
+
newInstance.addSelfToProject(changeSet);
|
|
2298
|
+
|
|
2299
|
+
changeSet.add(
|
|
2300
|
+
newInstance,
|
|
2301
|
+
ChangeSetEntityChangeType.Added
|
|
2302
|
+
);
|
|
2303
|
+
|
|
2304
|
+
if (
|
|
2305
|
+
this.connectionOptions?.nodeType ===
|
|
2306
|
+
ConnectionNodeType.ErrorCaller &&
|
|
2307
|
+
!!this.connectionOptions?.source
|
|
2308
|
+
) {
|
|
2309
|
+
newInstance.addErrorCaller(
|
|
2310
|
+
this.connectionOptions
|
|
2311
|
+
.source as PassThroughCallableEntityState,
|
|
2312
|
+
changeSet,
|
|
2313
|
+
// To recalculate its scope automatically
|
|
2314
|
+
true
|
|
2315
|
+
);
|
|
2316
|
+
(
|
|
2317
|
+
this.connectionOptions
|
|
2318
|
+
.source as PassThroughCallableEntityState
|
|
2319
|
+
).addErrorCall(newInstance, changeSet);
|
|
2320
|
+
} else if (
|
|
2321
|
+
this.connectionOptions?.nodeType ===
|
|
2322
|
+
ConnectionNodeType.SuccessCaller &&
|
|
2323
|
+
!!this.connectionOptions?.source
|
|
2324
|
+
) {
|
|
2325
|
+
newInstance.addSuccessCaller(
|
|
2326
|
+
this.connectionOptions
|
|
2327
|
+
.source as PassThroughCallableEntityState,
|
|
2328
|
+
changeSet,
|
|
2329
|
+
// To recalculate its scope automatically
|
|
2330
|
+
true
|
|
2331
|
+
);
|
|
2332
|
+
(
|
|
2333
|
+
this.connectionOptions
|
|
2334
|
+
.source as PassThroughCallableEntityState
|
|
2335
|
+
).addSuccessCall(newInstance, changeSet);
|
|
2336
|
+
} else if (
|
|
2337
|
+
this.connectionOptions?.nodeType ===
|
|
2338
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
2339
|
+
!!this.connectionOptions?.source
|
|
2340
|
+
) {
|
|
2341
|
+
newInstance.addEntryCaller(
|
|
2342
|
+
this.connectionOptions
|
|
2343
|
+
.source as EntryPointEntityState,
|
|
2344
|
+
changeSet,
|
|
2345
|
+
// To recalculate its scope automatically
|
|
2346
|
+
true
|
|
2347
|
+
);
|
|
2348
|
+
(
|
|
2349
|
+
this.connectionOptions
|
|
2350
|
+
.source as EntryPointEntityState
|
|
2351
|
+
).addCall(newInstance, changeSet);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
newInstance.afterAllChildrenInitialized(changeSet);
|
|
2355
|
+
|
|
2356
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2357
|
+
newInstance,
|
|
2358
|
+
changeSet
|
|
2359
|
+
);
|
|
2360
|
+
|
|
2361
|
+
break;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
// Close menu
|
|
2366
|
+
this.project.hideEntityCreationMenu();
|
|
2367
|
+
},
|
|
2368
|
+
onCreateFromSpecificEntity: async (from, event) => {
|
|
2369
|
+
const currentTime = new Date().toISOString();
|
|
2370
|
+
|
|
2371
|
+
// Based on the entity type, navigate the user to the correct entity creation dialog
|
|
2372
|
+
switch (from.type) {
|
|
2373
|
+
// case EntityType.DefinitionEntity: {
|
|
2374
|
+
// const changeSet = this.project.logic.addChangeSet(
|
|
2375
|
+
// new ChangeSet(
|
|
2376
|
+
// this.project.logic,
|
|
2377
|
+
// ProjectState.sessionAuthor,
|
|
2378
|
+
// currentTime,
|
|
2379
|
+
// this.project.logic
|
|
2380
|
+
// false,
|
|
2381
|
+
// StateMutationAction.ExtendExistingDefWithNew,
|
|
2382
|
+
// )
|
|
2383
|
+
// );
|
|
2384
|
+
|
|
2385
|
+
// EditorService.navigate(
|
|
2386
|
+
// `${this.project.editorBasePath}/entity/${from}/new?${
|
|
2387
|
+
// from.abstract ? 'implements' : 'extends'
|
|
2388
|
+
// }=${from.id}`
|
|
2389
|
+
// );
|
|
2390
|
+
// break;
|
|
2391
|
+
// }
|
|
2392
|
+
case EntityType.BuiltInBaseEntity: {
|
|
2393
|
+
let actionName =
|
|
2394
|
+
StateMutationAction.ImplementBuiltInFunctionalityAsDef;
|
|
2395
|
+
|
|
2396
|
+
if (from.name === BaseEntityNames.HTTP_ENDPOINT) {
|
|
2397
|
+
actionName =
|
|
2398
|
+
StateMutationAction.ImplementNewHTTPEndpoint;
|
|
2399
|
+
} else if (from.name === BaseEntityNames.CRON_JOB) {
|
|
2400
|
+
actionName =
|
|
2401
|
+
StateMutationAction.ImplementNewScheduledTrigger;
|
|
2402
|
+
} else if (
|
|
2403
|
+
from.name === BaseEntityNames.PERSISTED_ENTITY
|
|
2404
|
+
) {
|
|
2405
|
+
actionName =
|
|
2406
|
+
StateMutationAction.ImplementNewPersistedEntity;
|
|
2407
|
+
} else if (
|
|
2408
|
+
from.name === BaseEntityNames.SQL_ROW_TRANSFORMER
|
|
2409
|
+
) {
|
|
2410
|
+
actionName =
|
|
2411
|
+
StateMutationAction.AddedNewRowTransformer;
|
|
2412
|
+
} else if (
|
|
2413
|
+
from.name ===
|
|
2414
|
+
BaseEntityNames.SQL_SSL_CONNECTION_CONFIG
|
|
2415
|
+
) {
|
|
2416
|
+
actionName =
|
|
2417
|
+
StateMutationAction.AddedNewSSLConnectionConfig;
|
|
2418
|
+
} else if (
|
|
2419
|
+
from.name ===
|
|
2420
|
+
BaseEntityNames.SQL_ROOT_CONNECTION_CONFIG
|
|
2421
|
+
) {
|
|
2422
|
+
actionName =
|
|
2423
|
+
StateMutationAction.AddedSQLConnectionConfig;
|
|
2424
|
+
} else if (
|
|
2425
|
+
from.name ===
|
|
2426
|
+
BaseEntityNames.EXTERNAL_INTEGRATION_CONNECTION
|
|
2427
|
+
) {
|
|
2428
|
+
actionName =
|
|
2429
|
+
StateMutationAction.AddedNewExternalAccountConnection;
|
|
2430
|
+
} else if (
|
|
2431
|
+
from.name === BaseEntityNames.GOOGLE_AUTH_CONNECTION
|
|
2432
|
+
) {
|
|
2433
|
+
actionName =
|
|
2434
|
+
StateMutationAction.AddedGoogleConnection;
|
|
2435
|
+
} else if (
|
|
2436
|
+
from.name === BaseEntityNames.SLACK_AUTH_CONNECTION
|
|
2437
|
+
) {
|
|
2438
|
+
actionName =
|
|
2439
|
+
StateMutationAction.AddedSlackConnection;
|
|
2440
|
+
} else if (
|
|
2441
|
+
from.name ===
|
|
2442
|
+
BaseEntityNames.GOOGLE_DRIVE_AUTH_CONNECTION
|
|
2443
|
+
) {
|
|
2444
|
+
actionName =
|
|
2445
|
+
StateMutationAction.AddedGoogleDriveConnection;
|
|
2446
|
+
} else if (
|
|
2447
|
+
from.name ===
|
|
2448
|
+
BaseEntityNames.GOOGLE_SHEET_AUTH_CONNECTION
|
|
2449
|
+
) {
|
|
2450
|
+
actionName =
|
|
2451
|
+
StateMutationAction.AddedGoogleSheetsConnection;
|
|
2452
|
+
} else if (
|
|
2453
|
+
from.name ===
|
|
2454
|
+
BaseEntityNames.GOOGLE_SLIDES_AUTH_CONNECTION
|
|
2455
|
+
) {
|
|
2456
|
+
actionName =
|
|
2457
|
+
StateMutationAction.AddedGoogleSlidesConnection;
|
|
2458
|
+
} else if (
|
|
2459
|
+
from.name ===
|
|
2460
|
+
BaseEntityNames.GOOGLE_MAIL_AUTH_CONNECTION
|
|
2461
|
+
) {
|
|
2462
|
+
actionName =
|
|
2463
|
+
StateMutationAction.AddedGoogleMailConnection;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2467
|
+
new ChangeSet(
|
|
2468
|
+
this.project.logic,
|
|
2469
|
+
ProjectState.sessionAuthor,
|
|
2470
|
+
currentTime,
|
|
2471
|
+
this.project.logic,
|
|
2472
|
+
false,
|
|
2473
|
+
actionName
|
|
2474
|
+
)
|
|
2475
|
+
);
|
|
2476
|
+
|
|
2477
|
+
// Create a new function call of this function declaration at this coordinates
|
|
2478
|
+
const newDefinition =
|
|
2479
|
+
createDefinitionEntityFromBuiltInBaseEntity(
|
|
2480
|
+
from,
|
|
2481
|
+
this.connectionOptions,
|
|
2482
|
+
this.project.logic,
|
|
2483
|
+
changeSet
|
|
2484
|
+
);
|
|
2485
|
+
|
|
2486
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2487
|
+
newDefinition,
|
|
2488
|
+
changeSet
|
|
2489
|
+
);
|
|
2490
|
+
break;
|
|
2491
|
+
}
|
|
2492
|
+
case EntityType.FunctionDeclaration: {
|
|
2493
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2494
|
+
new ChangeSet(
|
|
2495
|
+
this.project.logic,
|
|
2496
|
+
ProjectState.sessionAuthor,
|
|
2497
|
+
currentTime,
|
|
2498
|
+
this.project.logic,
|
|
2499
|
+
false,
|
|
2500
|
+
StateMutationAction.CreateNewFuncCall
|
|
2501
|
+
)
|
|
2502
|
+
);
|
|
2503
|
+
|
|
2504
|
+
// Create a new function call of this function declaration at this coordinates
|
|
2505
|
+
const newCall =
|
|
2506
|
+
createFunctionCallFromFunctionDeclaration(
|
|
2507
|
+
from,
|
|
2508
|
+
this.connectionOptions,
|
|
2509
|
+
this.project.logic,
|
|
2510
|
+
changeSet
|
|
2511
|
+
);
|
|
2512
|
+
|
|
2513
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2514
|
+
newCall,
|
|
2515
|
+
changeSet
|
|
2516
|
+
);
|
|
2517
|
+
break;
|
|
2518
|
+
}
|
|
2519
|
+
case EntityType.VariableDeclaration: {
|
|
2520
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2521
|
+
new ChangeSet(
|
|
2522
|
+
this.project.logic,
|
|
2523
|
+
ProjectState.sessionAuthor,
|
|
2524
|
+
currentTime,
|
|
2525
|
+
this.project.logic,
|
|
2526
|
+
false,
|
|
2527
|
+
StateMutationAction.CreateNewVarInst
|
|
2528
|
+
)
|
|
2529
|
+
);
|
|
2530
|
+
|
|
2531
|
+
const newVariableInstance =
|
|
2532
|
+
createVariableInstanceFromDeclaration(
|
|
2533
|
+
from,
|
|
2534
|
+
this.connectionOptions,
|
|
2535
|
+
this.project.logic,
|
|
2536
|
+
changeSet
|
|
2537
|
+
);
|
|
2538
|
+
|
|
2539
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2540
|
+
newVariableInstance,
|
|
2541
|
+
changeSet
|
|
2542
|
+
);
|
|
2543
|
+
break;
|
|
2544
|
+
}
|
|
2545
|
+
case EntityType.InternalCall: {
|
|
2546
|
+
const changeSet = this.project.logic.addChangeSet(
|
|
2547
|
+
new ChangeSet(
|
|
2548
|
+
this.project.logic,
|
|
2549
|
+
ProjectState.sessionAuthor,
|
|
2550
|
+
currentTime,
|
|
2551
|
+
this.project.logic,
|
|
2552
|
+
false,
|
|
2553
|
+
StateMutationAction.CreateNewInternalCall
|
|
2554
|
+
)
|
|
2555
|
+
);
|
|
2556
|
+
|
|
2557
|
+
const declaration = getDeclaration(from.parent);
|
|
2558
|
+
|
|
2559
|
+
// We create a new variable instance of the variable declaration that owns this internal call
|
|
2560
|
+
// At this coordinates
|
|
2561
|
+
// We then connect the new internal call to the connected source and target
|
|
2562
|
+
// Then add the full variable instance to the canvas
|
|
2563
|
+
|
|
2564
|
+
const newVariableInstance =
|
|
2565
|
+
createVariableInstanceFromDeclaration(
|
|
2566
|
+
declaration,
|
|
2567
|
+
null,
|
|
2568
|
+
this.project.logic,
|
|
2569
|
+
changeSet
|
|
2570
|
+
);
|
|
2571
|
+
|
|
2572
|
+
const counterPartCall =
|
|
2573
|
+
newVariableInstance.internalCalls.find(
|
|
2574
|
+
(internalCall) =>
|
|
2575
|
+
internalCall.declaration.id ===
|
|
2576
|
+
from.declaration.id
|
|
2577
|
+
) as InternalCallState;
|
|
2578
|
+
|
|
2579
|
+
// Connect to caller
|
|
2580
|
+
if (
|
|
2581
|
+
this.connectionOptions?.nodeType ===
|
|
2582
|
+
ConnectionNodeType.ErrorCaller &&
|
|
2583
|
+
!!this.connectionOptions?.source
|
|
2584
|
+
) {
|
|
2585
|
+
counterPartCall.addErrorCaller(
|
|
2586
|
+
this.connectionOptions
|
|
2587
|
+
.source as PassThroughCallableEntityState,
|
|
2588
|
+
changeSet,
|
|
2589
|
+
// To recalculate its scope automatically
|
|
2590
|
+
true
|
|
2591
|
+
);
|
|
2592
|
+
(
|
|
2593
|
+
this.connectionOptions
|
|
2594
|
+
.source as PassThroughCallableEntityState
|
|
2595
|
+
).addErrorCall(counterPartCall, changeSet);
|
|
2596
|
+
} else if (
|
|
2597
|
+
this.connectionOptions?.nodeType ===
|
|
2598
|
+
ConnectionNodeType.SuccessCaller &&
|
|
2599
|
+
!!this.connectionOptions?.source
|
|
2600
|
+
) {
|
|
2601
|
+
counterPartCall.addSuccessCaller(
|
|
2602
|
+
this.connectionOptions
|
|
2603
|
+
.source as PassThroughCallableEntityState,
|
|
2604
|
+
changeSet,
|
|
2605
|
+
// To recalculate its scope automatically
|
|
2606
|
+
true
|
|
2607
|
+
);
|
|
2608
|
+
(
|
|
2609
|
+
this.connectionOptions
|
|
2610
|
+
.source as PassThroughCallableEntityState
|
|
2611
|
+
).addSuccessCall(counterPartCall, changeSet);
|
|
2612
|
+
} else if (
|
|
2613
|
+
this.connectionOptions?.nodeType ===
|
|
2614
|
+
ConnectionNodeType.EntryPointCaller &&
|
|
2615
|
+
!!this.connectionOptions?.source
|
|
2616
|
+
) {
|
|
2617
|
+
counterPartCall.addEntryCaller(
|
|
2618
|
+
this.connectionOptions
|
|
2619
|
+
.source as EntryPointEntityState,
|
|
2620
|
+
changeSet,
|
|
2621
|
+
// To recalculate its scope automatically
|
|
2622
|
+
true
|
|
2623
|
+
);
|
|
2624
|
+
(
|
|
2625
|
+
this.connectionOptions
|
|
2626
|
+
.source as EntryPointEntityState
|
|
2627
|
+
).addCall(counterPartCall, changeSet);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
let counterPartEntity: ExecutableEntityState | null =
|
|
2631
|
+
null;
|
|
2632
|
+
|
|
2633
|
+
if (
|
|
2634
|
+
[
|
|
2635
|
+
ConnectionNodeType.ErrorCaller,
|
|
2636
|
+
ConnectionNodeType.SuccessCaller,
|
|
2637
|
+
ConnectionNodeType.EntryPointCaller
|
|
2638
|
+
].includes(this.connectionOptions?.nodeType)
|
|
2639
|
+
) {
|
|
2640
|
+
counterPartEntity = this.connectionOptions
|
|
2641
|
+
.source as ExecutableEntityState;
|
|
2642
|
+
} else if (
|
|
2643
|
+
this.connectionOptions?.nodeType ===
|
|
2644
|
+
ConnectionNodeType.CalledBy
|
|
2645
|
+
) {
|
|
2646
|
+
counterPartEntity = this.connectionOptions
|
|
2647
|
+
.target as ExecutableEntityState;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
const connectedEntityScopeOwner = !!counterPartEntity
|
|
2651
|
+
? getScopeOwner(
|
|
2652
|
+
counterPartEntity,
|
|
2653
|
+
this.project.logic
|
|
2654
|
+
)
|
|
2655
|
+
: this.project.logic;
|
|
2656
|
+
|
|
2657
|
+
newVariableInstance.setParent(
|
|
2658
|
+
connectedEntityScopeOwner,
|
|
2659
|
+
changeSet
|
|
2660
|
+
);
|
|
2661
|
+
|
|
2662
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2663
|
+
newVariableInstance,
|
|
2664
|
+
changeSet
|
|
2665
|
+
);
|
|
2666
|
+
break;
|
|
2667
|
+
}
|
|
2668
|
+
case EntityType.ActionDescriptor: {
|
|
2669
|
+
const type =
|
|
2670
|
+
mapActionDescriptorToTypeItRepresents(from);
|
|
2671
|
+
|
|
2672
|
+
switch (type) {
|
|
2673
|
+
case EntityType.GlobalEvent: {
|
|
2674
|
+
let actionName =
|
|
2675
|
+
StateMutationAction.CreateNewGlobalEvent;
|
|
2676
|
+
|
|
2677
|
+
if (
|
|
2678
|
+
from.name ===
|
|
2679
|
+
GlobalEventNames.PROJECT_PUBLICATION_COMPLETED
|
|
2680
|
+
) {
|
|
2681
|
+
actionName =
|
|
2682
|
+
StateMutationAction.CreateNewProjectPublicationCompletedEvent;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
const changeSet =
|
|
2686
|
+
this.project.logic.addChangeSet(
|
|
2687
|
+
new ChangeSet(
|
|
2688
|
+
this.project.logic,
|
|
2689
|
+
ProjectState.sessionAuthor,
|
|
2690
|
+
currentTime,
|
|
2691
|
+
this.project.logic,
|
|
2692
|
+
false,
|
|
2693
|
+
actionName
|
|
2694
|
+
)
|
|
2695
|
+
);
|
|
2696
|
+
|
|
2697
|
+
const newGlobalEvent =
|
|
2698
|
+
createGlobalEventFromActionDescriptor(
|
|
2699
|
+
from,
|
|
2700
|
+
this.connectionOptions,
|
|
2701
|
+
this.project.logic,
|
|
2702
|
+
changeSet
|
|
2703
|
+
);
|
|
2704
|
+
|
|
2705
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2706
|
+
newGlobalEvent,
|
|
2707
|
+
changeSet
|
|
2708
|
+
);
|
|
2709
|
+
break;
|
|
2710
|
+
}
|
|
2711
|
+
case EntityType.Loop: {
|
|
2712
|
+
let actionName =
|
|
2713
|
+
StateMutationAction.CreateNewLoop;
|
|
2714
|
+
|
|
2715
|
+
if (
|
|
2716
|
+
from.id ===
|
|
2717
|
+
BUILT_IN_BASE_ENTITY_IDS.loop[
|
|
2718
|
+
'counted-loop'
|
|
2719
|
+
]?.id
|
|
2720
|
+
) {
|
|
2721
|
+
actionName =
|
|
2722
|
+
StateMutationAction.CreateNewCountedLoop;
|
|
2723
|
+
} else if (
|
|
2724
|
+
from.id ===
|
|
2725
|
+
BUILT_IN_BASE_ENTITY_IDS.loop['list-loop']
|
|
2726
|
+
?.id
|
|
2727
|
+
) {
|
|
2728
|
+
actionName =
|
|
2729
|
+
StateMutationAction.CreateNewListLoop;
|
|
2730
|
+
} else if (
|
|
2731
|
+
from.id ===
|
|
2732
|
+
BUILT_IN_BASE_ENTITY_IDS.loop?.[
|
|
2733
|
+
'manual-flow-loop'
|
|
2734
|
+
]?.id
|
|
2735
|
+
) {
|
|
2736
|
+
actionName =
|
|
2737
|
+
StateMutationAction.CreateNewManualFlowLoop;
|
|
2738
|
+
} else if (
|
|
2739
|
+
from.id ===
|
|
2740
|
+
BUILT_IN_BASE_ENTITY_IDS.loop?.[
|
|
2741
|
+
'object-keys-loop'
|
|
2742
|
+
]?.id
|
|
2743
|
+
) {
|
|
2744
|
+
actionName =
|
|
2745
|
+
StateMutationAction.CreateNewObjectKeysLoop;
|
|
2746
|
+
} else if (
|
|
2747
|
+
from.id ===
|
|
2748
|
+
BUILT_IN_BASE_ENTITY_IDS.loop?.[
|
|
2749
|
+
'object-values-loop'
|
|
2750
|
+
]?.id
|
|
2751
|
+
) {
|
|
2752
|
+
actionName =
|
|
2753
|
+
StateMutationAction.CreateNewObjectValuesLoop;
|
|
2754
|
+
} else if (
|
|
2755
|
+
from.id ===
|
|
2756
|
+
BUILT_IN_BASE_ENTITY_IDS.loop?.[
|
|
2757
|
+
'string-loop'
|
|
2758
|
+
]?.id
|
|
2759
|
+
) {
|
|
2760
|
+
actionName =
|
|
2761
|
+
StateMutationAction.CreateNewStringLoop;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
const changeSet =
|
|
2765
|
+
this.project.logic.addChangeSet(
|
|
2766
|
+
new ChangeSet(
|
|
2767
|
+
this.project.logic,
|
|
2768
|
+
ProjectState.sessionAuthor,
|
|
2769
|
+
currentTime,
|
|
2770
|
+
this.project.logic,
|
|
2771
|
+
false,
|
|
2772
|
+
actionName
|
|
2773
|
+
)
|
|
2774
|
+
);
|
|
2775
|
+
|
|
2776
|
+
const newLoop = createLoopFromActionDescriptor(
|
|
2777
|
+
from,
|
|
2778
|
+
this.connectionOptions,
|
|
2779
|
+
this.project.logic,
|
|
2780
|
+
changeSet
|
|
2781
|
+
);
|
|
2782
|
+
|
|
2783
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2784
|
+
newLoop,
|
|
2785
|
+
changeSet
|
|
2786
|
+
);
|
|
2787
|
+
break;
|
|
2788
|
+
}
|
|
2789
|
+
case EntityType.Condition: {
|
|
2790
|
+
let actionName =
|
|
2791
|
+
StateMutationAction.CreateNewCondition;
|
|
2792
|
+
|
|
2793
|
+
if (
|
|
2794
|
+
from.id ===
|
|
2795
|
+
BUILT_IN_BASE_ENTITY_IDS.condition[
|
|
2796
|
+
'condition-boolean-is-false'
|
|
2797
|
+
]?.id
|
|
2798
|
+
) {
|
|
2799
|
+
actionName =
|
|
2800
|
+
StateMutationAction.CreateNewIsFalseCondition;
|
|
2801
|
+
} else if (
|
|
2802
|
+
from.id ===
|
|
2803
|
+
BUILT_IN_BASE_ENTITY_IDS.condition[
|
|
2804
|
+
'condition-boolean-is-true'
|
|
2805
|
+
]?.id
|
|
2806
|
+
) {
|
|
2807
|
+
actionName =
|
|
2808
|
+
StateMutationAction.CreateNewIsTrueCondition;
|
|
2809
|
+
} else if (
|
|
2810
|
+
from.id ===
|
|
2811
|
+
BUILT_IN_BASE_ENTITY_IDS.condition[
|
|
2812
|
+
'condition-group-and'
|
|
2813
|
+
]?.id
|
|
2814
|
+
) {
|
|
2815
|
+
actionName =
|
|
2816
|
+
StateMutationAction.CreateNewAndCondition;
|
|
2817
|
+
} else if (
|
|
2818
|
+
from.id ===
|
|
2819
|
+
BUILT_IN_BASE_ENTITY_IDS.condition[
|
|
2820
|
+
'condition-group-or'
|
|
2821
|
+
]?.id
|
|
2822
|
+
) {
|
|
2823
|
+
actionName =
|
|
2824
|
+
StateMutationAction.CreateNewOrCondition;
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
const changeSet =
|
|
2828
|
+
this.project.logic.addChangeSet(
|
|
2829
|
+
new ChangeSet(
|
|
2830
|
+
this.project.logic,
|
|
2831
|
+
ProjectState.sessionAuthor,
|
|
2832
|
+
currentTime,
|
|
2833
|
+
this.project.logic,
|
|
2834
|
+
false,
|
|
2835
|
+
actionName
|
|
2836
|
+
)
|
|
2837
|
+
);
|
|
2838
|
+
|
|
2839
|
+
const newCondition =
|
|
2840
|
+
createConditionFromActionDescriptor(
|
|
2841
|
+
from,
|
|
2842
|
+
this.connectionOptions,
|
|
2843
|
+
this.project.logic,
|
|
2844
|
+
changeSet
|
|
2845
|
+
);
|
|
2846
|
+
|
|
2847
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2848
|
+
newCondition,
|
|
2849
|
+
changeSet
|
|
2850
|
+
);
|
|
2851
|
+
break;
|
|
2852
|
+
}
|
|
2853
|
+
case EntityType.Operation: {
|
|
2854
|
+
let actionName =
|
|
2855
|
+
StateMutationAction.CreateNewOperation;
|
|
2856
|
+
|
|
2857
|
+
try {
|
|
2858
|
+
const readableName = resolveEntityName(
|
|
2859
|
+
from,
|
|
2860
|
+
this.project.logic
|
|
2861
|
+
);
|
|
2862
|
+
|
|
2863
|
+
const kebabCaseName =
|
|
2864
|
+
toKebabCase(readableName);
|
|
2865
|
+
|
|
2866
|
+
actionName =
|
|
2867
|
+
`create-new-${kebabCaseName}-operation` as StateMutationAction;
|
|
2868
|
+
} catch (error) {
|
|
2869
|
+
// Do nothing
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
const changeSet =
|
|
2873
|
+
this.project.logic.addChangeSet(
|
|
2874
|
+
new ChangeSet(
|
|
2875
|
+
this.project.logic,
|
|
2876
|
+
ProjectState.sessionAuthor,
|
|
2877
|
+
currentTime,
|
|
2878
|
+
this.project.logic,
|
|
2879
|
+
false,
|
|
2880
|
+
actionName
|
|
2881
|
+
)
|
|
2882
|
+
);
|
|
2883
|
+
|
|
2884
|
+
const newOperation =
|
|
2885
|
+
createOperationFromActionDescriptor(
|
|
2886
|
+
from,
|
|
2887
|
+
this.connectionOptions,
|
|
2888
|
+
this.project.logic,
|
|
2889
|
+
changeSet
|
|
2890
|
+
);
|
|
2891
|
+
|
|
2892
|
+
await this.addNewEntitiesToCanvasFromRootEntity(
|
|
2893
|
+
newOperation,
|
|
2894
|
+
changeSet
|
|
2895
|
+
);
|
|
2896
|
+
break;
|
|
2897
|
+
}
|
|
2898
|
+
default: {
|
|
2899
|
+
Logger.error(
|
|
2900
|
+
`Cannot create entity from action descriptor of type ${type}`
|
|
2901
|
+
);
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
// Close menu
|
|
2908
|
+
this.project.hideEntityCreationMenu();
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2911
|
+
|
|
2912
|
+
if (!!document.contains(this.canvasObject.element)) {
|
|
2913
|
+
if (!this.node) {
|
|
2914
|
+
this.node = createRoot('#' + this.canvasObject.id);
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
await this.node.render(this.component, resolvedProps, null, {
|
|
2918
|
+
onError: (error) => {
|
|
2919
|
+
Logger.log('Error handler worked: ', error);
|
|
2920
|
+
this.project.events.emit('canvas-react-error', error);
|
|
2921
|
+
}
|
|
2922
|
+
});
|
|
2923
|
+
|
|
2924
|
+
// Recalculate canvas connections
|
|
2925
|
+
this.canvasObject.updateConnections();
|
|
2926
|
+
|
|
2927
|
+
if (this.project.canvas?.disabled) {
|
|
2928
|
+
this.project.disableAllConnections(this.canvasObject);
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
return this;
|
|
2933
|
+
}
|
|
2934
|
+
}
|