Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unpublish workflow event #3079

Merged
merged 2 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@model ContentEventViewModel<ContentUnpublishedEvent>

<header>
<h4><i class="fa fa-bolt"></i>@Model.Activity.GetTitleOrDefault(() => T["Content Unpublished"])</h4>
</header>
<em>@(Model.ContentTypeFilter.Any() ? (object)string.Join(", ", Model.ContentTypeFilter.Select(x => x.DisplayName)) : T["Any content type"])</em>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@using OrchardCore.Contents.Workflows.ViewModels
@model ContentUnpublishedEventViewModel

<fieldset class="form-group" asp-validation-class-for="SelectedContentTypeNames">
<label asp-for="SelectedContentTypeNames">@T["Content Types"]</label>
@await Component.InvokeAsync("SelectContentTypes", new { selectedContentTypes = Model.SelectedContentTypeNames, htmlName = Html.NameFor(m => m.SelectedContentTypeNames) })
<span asp-validation-for="SelectedContentTypeNames"></span>
<span class="hint">@T["Select any content types to filter on."]</span>
</fieldset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h4 class="card-title"><i class="fa fa-bolt"></i>@T["Content Unpublished"]</h4>
<p>@T["Content is unpublished."]</p>
Original file line number Diff line number Diff line change
@@ -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<ContentUnpublishedEvent> localizer) : base(contentManager, scriptEvaluator, localizer)
{
}

public override string Name => nameof(ContentUnpublishedEvent);
}
}
Original file line number Diff line number Diff line change
@@ -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<ContentUnpublishedEvent, ContentUnpublishedEventViewModel>
{
public ContentUnpublishedEventDisplay(IContentDefinitionManager contentDefinitionManager) : base(contentDefinitionManager)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddActivity<ContentCreatedEvent, ContentCreatedEventDisplay>();
services.AddActivity<ContentDeletedEvent, ContentDeletedEventDisplay>();
services.AddActivity<ContentPublishedEvent, ContentPublishedEventDisplay>();
services.AddActivity<ContentUnpublishedEvent, ContentUnpublishedEventDisplay>();
services.AddActivity<ContentUpdatedEvent, ContentUpdatedEventDisplay>();
services.AddActivity<ContentVersionedEvent, ContentVersionedEventDisplay>();
services.AddActivity<DeleteContentTask, DeleteContentTaskDisplay>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using OrchardCore.Contents.Workflows.Activities;

namespace OrchardCore.Contents.Workflows.ViewModels
{
public class ContentUnpublishedEventViewModel : ContentEventViewModel<ContentUnpublishedEvent>
{
}
}
1 change: 1 addition & 0 deletions src/OrchardCore.Modules/OrchardCore.Workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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] |
Expand Down