From dbd765a1080e7c290b15e2eddec266fc47121c32 Mon Sep 17 00:00:00 2001 From: David Ouwinga Date: Tue, 22 Jan 2019 10:41:50 -0500 Subject: [PATCH 1/2] Added unpublish workflow event --- .../ContentUnpublishedEvent.Fields.Design.cshtml | 6 ++++++ .../ContentUnpublishedEvent.Fields.Edit.cshtml | 9 +++++++++ ...ontentUnpublishedEvent.Fields.Thumbnail.cshtml | 2 ++ .../Activities/ContentUnpublishedEvent.cs | 15 +++++++++++++++ .../Drivers/ContentUnpublishedEventDisplay.cs | 13 +++++++++++++ .../Workflows/Handlers/ContentsHandler.cs | 5 +++++ .../OrchardCore.Contents/Workflows/Startup.cs | 1 + .../ContentUnpublishedEventViewModel.cs | 8 ++++++++ 8 files changed, 59 insertions(+) create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Design.cshtml create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Edit.cshtml create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Thumbnail.cshtml create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/ContentUnpublishedEvent.cs create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Drivers/ContentUnpublishedEventDisplay.cs create mode 100644 src/OrchardCore.Modules/OrchardCore.Contents/Workflows/ViewModels/ContentUnpublishedEventViewModel.cs diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Design.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Design.cshtml new file mode 100644 index 00000000000..137ea878b4a --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Design.cshtml @@ -0,0 +1,6 @@ +@model ContentEventViewModel + +
+

@Model.Activity.GetTitleOrDefault(() => T["Content Unpublished"])

+
+@(Model.ContentTypeFilter.Any() ? (object)string.Join(", ", Model.ContentTypeFilter.Select(x => x.DisplayName)) : T["Any content type"]) \ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Edit.cshtml new file mode 100644 index 00000000000..43b3b7dfec0 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Edit.cshtml @@ -0,0 +1,9 @@ +@using OrchardCore.Contents.Workflows.ViewModels +@model ContentUnpublishedEventViewModel + +
+ + @await Component.InvokeAsync("SelectContentTypes", new { selectedContentTypes = Model.SelectedContentTypeNames, htmlName = Html.NameFor(m => m.SelectedContentTypeNames) }) + + @T["Select any content types to filter on."] +
\ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Thumbnail.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Thumbnail.cshtml new file mode 100644 index 00000000000..09c96b10576 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Items/ContentUnpublishedEvent.Fields.Thumbnail.cshtml @@ -0,0 +1,2 @@ +

@T["Content Unpublished"]

+

@T["Content is unpublished."]

\ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/ContentUnpublishedEvent.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/ContentUnpublishedEvent.cs new file mode 100644 index 00000000000..877925605c1 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/ContentUnpublishedEvent.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.Localization; +using OrchardCore.ContentManagement; +using OrchardCore.Workflows.Services; + +namespace OrchardCore.Contents.Workflows.Activities +{ + public class ContentUnpublishedEvent : ContentEvent + { + public ContentUnpublishedEvent(IContentManager contentManager, IWorkflowScriptEvaluator scriptEvaluator, IStringLocalizer localizer) : base(contentManager, scriptEvaluator, localizer) + { + } + + public override string Name => nameof(ContentUnpublishedEvent); + } +} \ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Drivers/ContentUnpublishedEventDisplay.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Drivers/ContentUnpublishedEventDisplay.cs new file mode 100644 index 00000000000..92888cc1fdc --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Drivers/ContentUnpublishedEventDisplay.cs @@ -0,0 +1,13 @@ +using OrchardCore.ContentManagement.Metadata; +using OrchardCore.Contents.Workflows.Activities; +using OrchardCore.Contents.Workflows.ViewModels; + +namespace OrchardCore.Contents.Workflows.Drivers +{ + public class ContentUnpublishedEventDisplay : ContentEventDisplayDriver + { + public ContentUnpublishedEventDisplay(IContentDefinitionManager contentDefinitionManager) : base(contentDefinitionManager) + { + } + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Handlers/ContentsHandler.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Handlers/ContentsHandler.cs index 22947acb9b5..08b26f42189 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Handlers/ContentsHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Handlers/ContentsHandler.cs @@ -32,6 +32,11 @@ public override Task PublishedAsync(PublishContentContext context) return TriggerWorkflowEventAsync(nameof(ContentPublishedEvent), context.ContentItem); } + public override Task UnpublishedAsync(PublishContentContext context) + { + return TriggerWorkflowEventAsync(nameof(ContentUnpublishedEvent), context.ContentItem); + } + public override Task RemovedAsync(RemoveContentContext context) { return TriggerWorkflowEventAsync(nameof(ContentDeletedEvent), context.ContentItem); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Startup.cs index 668bbb50027..cc72357e4da 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Startup.cs @@ -17,6 +17,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddActivity(); services.AddActivity(); services.AddActivity(); + services.AddActivity(); services.AddActivity(); services.AddActivity(); services.AddActivity(); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/ViewModels/ContentUnpublishedEventViewModel.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/ViewModels/ContentUnpublishedEventViewModel.cs new file mode 100644 index 00000000000..cb308a2e45d --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/ViewModels/ContentUnpublishedEventViewModel.cs @@ -0,0 +1,8 @@ +using OrchardCore.Contents.Workflows.Activities; + +namespace OrchardCore.Contents.Workflows.ViewModels +{ + public class ContentUnpublishedEventViewModel : ContentEventViewModel + { + } +} From 14868abd271d39bce8cf6c9eac428d58201d0e65 Mon Sep 17 00:00:00 2001 From: David Ouwinga Date: Tue, 22 Jan 2019 10:58:03 -0500 Subject: [PATCH 2/2] Updated workflow documentation --- src/OrchardCore.Modules/OrchardCore.Workflows/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/README.md b/src/OrchardCore.Modules/OrchardCore.Workflows/README.md index 151034ed668..6b34947c9cf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/README.md +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/README.md @@ -219,6 +219,7 @@ The following activities are available with any default Orchard installation: | Content Created | Event | Executes when content is created. | [link] | | Content Deleted | Event | Executes when content is deleted. | [link] | | Content Published | Event | Executes when content is published. | [link] | +| Content Unpublished | Event | Executes when content is unpublished. | [link] | | Content Updated | Event | Executes when content is updated. | [link] | | Content Versioned| Event | Executes when content is versioned. | [link] | | Create Content | Task | Create a content item. | [link] |