OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Workflow module enhancement

Open hyzx86 opened this issue 1 year ago • 16 comments

Fixes #15496

  • [x] Adding versionId and audit information to workflow types.
  • [x] Adding versionId and audit information to workflow .
  • [x] Migrating older workflow types
  • [ ] Adjust workflow management page
  • [ ] Adjust workflow import logic

Fixes : #14276

  • [ ] Add title templates to the workflow, like TitlePart does
  • [ ] Add workflow instance title editor for workflow types
  • [ ] Adding display names to workflow types

Fixes: #12070

  • [x] Add ExecutedOnUtc field to workflow instances, which can be used for sorting

Fixes : #11608

  • [x] Adding audit information to workflow types, CreatedUtc,ModifiedUtc,ModifiedBy,CreatedBy

hyzx86 avatar May 13 '24 10:05 hyzx86

Please follow https://docs.orchardcore.net/en/latest/guides/contributing/contributing-code/#:~:text=If%20your%20PR%20addresses%20an%20issue%2C%20be%20sure%20to%20link%20them.%20This%20helps%20everyone%20find%20their%20way%20around%20contributions%2C%20and%20merging%20your%20PR%20will%20automatically%20close%20the%20issue%20too.

Piedone avatar May 14 '24 17:05 Piedone

Please follow https://docs.orchardcore.net/en/latest/guides/contributing/contributing-code/#:~:text=If%20your%20PR%20addresses%20an%20issue%2C%20be%20sure%20to%20link%20them.%20This%20helps%20everyone%20find%20their%20way%20around%20contributions%2C%20and%20merging%20your%20PR%20will%20automatically%20close%20the%20issue%20too.

I've already linked it in the first line of the PR description.😳

hyzx86 avatar May 14 '24 18:05 hyzx86

Not in a way explained in the docs :). You need to use something like Fixes #15496 to make this PR close that issue, and show up under the issue as its PR.

Piedone avatar May 14 '24 18:05 Piedone

Not in a way explained in the docs :). You need to use something like Fixes #15496 to make this PR close that issue, and show up under the issue as its PR.

oh, I see , thanks!

hyzx86 avatar May 14 '24 18:05 hyzx86

With these changes underway in workflows would it be a good time to upgrade the diagramming ui (js plumb) to a modern ui library ?. Eg panning and zooming would be useful.

giannik avatar May 15 '24 17:05 giannik

Could you please create a separate issue about that, with specific suggestions?

Piedone avatar May 15 '24 18:05 Piedone

With these changes underway in workflows would it be a good time to upgrade the diagramming ui (js plumb) to a modern ui library ?. Eg panning and zooming would be useful.

Yes currently it does get stuck here at UI editing, as currently every update to a workflow node triggers the saving of the entire process definition, i.e. every time a node is edited it generates a version, which makes no sense!

Prepare to refer to elsa-core for design ideas

hyzx86 avatar May 20 '24 06:05 hyzx86

Could you please create a separate issue about that, with specific suggestions?

No problem. I created an issue here https://github.com/OrchardCMS/OrchardCore/issues/16107

hyzx86 avatar May 20 '24 06:05 hyzx86

I would suggest to create more focused PRs so we can approve them individually in case one would block the others.

sebastienros avatar May 30 '24 17:05 sebastienros

I would suggest to create more focused PRs so we can approve them individually in case one would block the others.

The reason why we focus on one PR is that if we want to disassemble it, we will need a lot of table structure migration.

hyzx86 avatar May 30 '24 18:05 hyzx86

@hyzx86 do you plan to have this ready for review soon ? otherwise i would like to add a new pr for the workflow type display name and description.

giannik avatar May 31 '24 12:05 giannik

@hyzx86 do you plan to have this ready for review soon ? otherwise i would like to add a new pr for the workflow type display name and description.

Sorry, I'm busy with other projects and don't have time to sort out this PR at the moment , I probably won't be continuing this PR anytime soon!

Temporary closure

hyzx86 avatar May 31 '24 12:05 hyzx86

I'd potentially be interested in continuing the Audit Trail support, i.e. https://github.com/OrchardCMS/OrchardCore/issues/11608. I see @hyzx86 you ticked that in the PR description, but the corresponding code is not in the PR. Could you push it, please?

Piedone avatar Sep 23 '24 20:09 Piedone

This pull request has merge conflicts. Please resolve those before requesting a review.

github-actions[bot] avatar Sep 25 '24 03:09 github-actions[bot]

I'd potentially be interested in continuing the Audit Trail support, i.e. #11608. I see @hyzx86 you ticked that in the PR description, but the corresponding code is not in the PR. Could you push it, please?

Some of the code is from my 1.8 implementation. My current implementation is not very good, if every time you save a node definition update it generates an audit message for the whole process, for this reason I have modified the WorkflowTypeStore so that it only generates a version when importing a process, and local modifications do not generate a version number, so that in the future the planned implementation of the SPA Workflow Designer will not have the problem of auditing the complete process every time you modify a node. This way, the SPA Workflow Designer, which is planned to be implemented in the future, will not have the problem of auditing the complete process every time a node is modified.

WorkflowTypeIndexProvider

using OrchardCore.Entities;
using OrchardCore.Workflows.Models;
using System;
using System.Linq;
using YesSql.Indexes;

namespace OrchardCore.Workflows.Indexes
{
    public class WorkflowTypeIndex : MapIndex
    {
        public long DocumentId { get; set; }
        public string WorkflowTypeId { get; set; }
        public string Name { get; set; }
        public bool IsEnabled { get; set; }
        public bool HasStart { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }
        public string WorkflowTypeVersionId { get; set; }
        public bool Latest { get; set; }
        public DateTime CreatedUtc { get; set; }
        public string CreatedBy { get; set; }
        public DateTime ModifiedUtc { get; set; }
        public string ModifiedBy { get; set; }
    }

    public class WorkflowTypeStartActivitiesIndex : MapIndex
    {
        public string WorkflowTypeId { get; set; }
        public string WorkflowTypeVersionId { get; set; }
        public string Name { get; set; }
        public bool IsEnabled { get; set; }
        public string StartActivityId { get; set; }
        public string StartActivityName { get; set; }
    }

    public class WorkflowTypeIndexProvider : IndexProvider<WorkflowType>
    {
        public override void Describe(DescribeContext<WorkflowType> context)
        {
            context.For<WorkflowTypeIndex>()
                .Map(workflowType =>
                {
                    var workflowTypeAudit = workflowType.As<WorkflowTypeVersionAudit>();
                    var index = new WorkflowTypeIndex
                    {
                        WorkflowTypeId = workflowType.WorkflowTypeId,
                        Name = workflowType.Name,
                        IsEnabled = workflowType.IsEnabled,
                        HasStart = workflowType.Activities.Any(x => x.IsStart),
                        DisplayName = workflowTypeAudit.DisplayName,
                        Description = workflowTypeAudit.Description,
                        WorkflowTypeVersionId = workflowTypeAudit.WorkflowTypeVersionId,
                        Latest = workflowTypeAudit.Latest,
                        CreatedUtc = workflowTypeAudit.CreatedUtc,
                        ModifiedUtc = workflowTypeAudit.ModifiedUtc,
                        ModifiedBy = workflowTypeAudit.ModifiedBy,
                        CreatedBy = workflowTypeAudit.CreatedBy
                    };
                    return index;
                }
                );

            context.For<WorkflowTypeStartActivitiesIndex>()
                .Map(workflowType =>
                {
                    var workflowTypeAudit = workflowType.As<WorkflowTypeVersionAudit>();

                    var startIndexies = workflowType.Activities.Where(x => x.IsStart).Select(x =>
                        new WorkflowTypeStartActivitiesIndex
                        {
                            WorkflowTypeVersionId = workflowTypeAudit.WorkflowTypeVersionId,
                            WorkflowTypeId = workflowType.WorkflowTypeId,
                            Name = workflowType.Name,
                            IsEnabled = workflowType.IsEnabled,
                            StartActivityId = x.ActivityId,
                            StartActivityName = x.Name
                        });
                    return startIndexies;
                }
                );
        }
    }
}

WorkflowTypeVersionAudit

using System;

namespace OrchardCore.Workflows.Indexes
{
    public class WorkflowTypeVersionAudit
    {
        public string WorkflowTypeVersionId { get; set; }
        public bool Latest { get; set; }
        public DateTime CreatedUtc { get; set; }
        public string CreatedBy { get; set; }
        public DateTime ModifiedUtc { get; set; }
        public string ModifiedBy { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }
    }
}

hyzx86 avatar Sep 25 '24 08:09 hyzx86

Thank you!

Piedone avatar Sep 25 '24 09:09 Piedone

@Piedone Have you been making any progress on this? If not maybe I'm able to help out!

wterpstra avatar Oct 31 '24 16:10 wterpstra

I haven't started it, so that would be great, thank you! To clarify, I only wanted Audit Trail support, i.e. https://github.com/OrchardCMS/OrchardCore/issues/11608. Is this something you'd continue?

Piedone avatar Oct 31 '24 19:10 Piedone

I think audit trail support only makes sense when you can see what actually changed, i.e. also implement some kind of versioning. What do you think?

wterpstra avatar Nov 02 '24 21:11 wterpstra

Since Audit Trail can record versions, that should be more or less given.

Piedone avatar Nov 02 '24 21:11 Piedone

It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up.

github-actions[bot] avatar Jan 02 '25 00:01 github-actions[bot]

Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it.

github-actions[bot] avatar Jan 17 '25 04:01 github-actions[bot]