From 2a9793768a8aec3f7bbfe467cc86007df2bb4df9 Mon Sep 17 00:00:00 2001
From: herblinernexxbizz <125579511+herblinernexxbizz@users.noreply.github.com>
Date: Tue, 13 Jun 2023 10:25:42 +0200
Subject: [PATCH] make isReadonly editable on workflow model (#4130)
---
.../Elsa.Workflows.Core/Builders/WorkflowBuilder.cs | 5 ++++-
.../Contracts/IWorkflowBuilder.cs | 8 +++++++-
src/modules/Elsa.Workflows.Core/Models/Workflow.cs | 13 +++++++++++--
.../Mappers/WorkflowDefinitionMapper.cs | 6 ++++--
4 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs
index b3e78b665..d3b390dd4 100644
--- a/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs
+++ b/src/modules/Elsa.Workflows.Core/Builders/WorkflowBuilder.cs
@@ -38,6 +38,9 @@ public class WorkflowBuilder : IWorkflowBuilder
///
public string? Description { get; set; }
+ ///
+ public bool IsReadonly { get; set; }
+
///
public IActivity? Root { get; set; }
@@ -135,7 +138,7 @@ public class WorkflowBuilder : IWorkflowBuilder
var identity = new WorkflowIdentity(definitionId, Version, id);
var publication = WorkflowPublication.LatestAndPublished;
var workflowMetadata = new WorkflowMetadata(Name, Description);
- var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, Inputs, Outputs, Outcomes, CustomProperties);
+ var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, Inputs, Outputs, Outcomes, CustomProperties, IsReadonly);
// If a Result variable is defined, install it into the workflow so we can capture the output into it.
if (Result != null)
diff --git a/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs b/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs
index 71c8d9fd3..8280ad733 100644
--- a/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs
+++ b/src/modules/Elsa.Workflows.Core/Contracts/IWorkflowBuilder.cs
@@ -31,7 +31,13 @@ public interface IWorkflowBuilder
/// A description of the workflow.
///
string? Description { get; set; }
-
+
+
+ ///
+ /// WorkflowDefinition is readonly.
+ ///
+ bool IsReadonly { get; set; }
+
///
/// Options for the workflow being built.
///
diff --git a/src/modules/Elsa.Workflows.Core/Models/Workflow.cs b/src/modules/Elsa.Workflows.Core/Models/Workflow.cs
index a3cbd2ca6..93672d8d6 100644
--- a/src/modules/Elsa.Workflows.Core/Models/Workflow.cs
+++ b/src/modules/Elsa.Workflows.Core/Models/Workflow.cs
@@ -28,7 +28,8 @@ public class Workflow : Composite