-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#8565: Delete and Unpublish buttons in backoffice content edit #8566
base: 1.10.x
Are you sure you want to change the base?
#8565: Delete and Unpublish buttons in backoffice content edit #8566
Conversation
@@ -352,6 +352,18 @@ public class AdminController : ContentControllerBase, IUpdateModel { | |||
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem)); | |||
} | |||
|
|||
[HttpPost, ActionName("Edit")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this different that the other unpublish/delete actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added delete and unpublish actions referencing specific submits to the controller. There already were unpublish and delete actions (the ones called from the lists), so I called those inside the new actions, specific to the edit form.
results.Add(ContentShape("Content_PublishButton", publishButton => publishButton)); | ||
|
||
if (part.ContentItem.IsPublished()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put the show/hide logic in the view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed hide logic from the driver, was already implemented inside the shape too.
@@ -292,4 +289,4 @@ | |||
</PropertyGroup> | |||
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" /> | |||
</Target> | |||
</Project> | |||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove the EOLs
@sebastienros fixed as requested. |
Modified the code following Sebastien's remarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the consolidation for the delete button! Please merge from 1.10.x.
However I'm unsure about adding the Unpublish button in the editor - is that really necessary UX-wise? I feel like it get can get a bit too crowded in the action button row.
Some of the editors I checked have minor styling issues under different circumstances, but some of those might be independent of this PR:
@@ -138,6 +138,12 @@ public class BlogPostAdminController : Controller, IUpdateModel { | |||
}); | |||
} | |||
|
|||
[HttpPost, ActionName("Edit")] | |||
[Mvc.FormValueRequired("submit.Delete")] | |||
public ActionResult EditDeletePOST (int blogId, int postId, string returnUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public ActionResult EditDeletePOST (int blogId, int postId, string returnUrl) { | |
public ActionResult EditDeletePOST(int blogId, int postId, string returnUrl) { |
<fieldset class="delete-button"> | ||
<button type="submit" name="submit.Delete" value="submit.Delete" itemprop="RemoveUrl">@T("Delete")</button> | ||
</fieldset> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
<fieldset class="unpublish-button"> | ||
<button type="submit" name="submit.Unpublish" value="submit.Unpublish">@T("Unpublish")</button> | ||
</fieldset> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
if (widgetPart.Id > 0) | ||
results.Add(ContentShape("Widget_DeleteButton", | ||
deleteButton => deleteButton)); | ||
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being able to unpublish does/should not depend on Draftable.
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { | |
if (widgetPart.Id > 0) { |
@using Orchard.Utility.Extensions; | ||
|
||
@if (Authorizer.Authorize(Permissions.PublishContent, (IContent)Model.ContentItem) && ((IContent)Model.ContentItem).IsPublished()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@using Orchard.Utility.Extensions; | |
@if (Authorizer.Authorize(Permissions.PublishContent, (IContent)Model.ContentItem) && ((IContent)Model.ContentItem).IsPublished()) { | |
@{ | |
var contentItem = Model.ContentItem as IContent; | |
} | |
@if (contentItem.IsPublished() && Authorizer.Authorize(Permissions.PublishContent, contentItem)) { |
if (part.ContentItem.IsPublished()) { | ||
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: the previous comment - shouldn't be just this then, since the template already checks IsPublished
?
if (part.ContentItem.IsPublished()) { | |
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | |
} | |
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember right now. I'll check asap.
Managed unpublish and delete button for blogs and widgets.
Condition for delete button visibility now checks for contentItem.Id > 0 instead of IsNew() function
…hape and avoid its duplication or confusing management via Placement.info.
Added comments to clarify how new Unpublish and Delete actions work.
…d checked the content is published before showing the unpublish button.
e2d564e
to
18a7f37
Compare
rebased on 1.10.x and applied some of @BenedekFarkas suggestions |
Sorry for replying just now, I'll be able to review later towards the end of September (after Harvest). |
Fixes #8565
Added unpublish and delete buttons to backoffice content edit view.
Adapted Orchard.Blogs and Orchard.Widgets to be in line with the patch, adding a "unpublish-button" css class too (it is identical to "publish-button".
Regarding Orchard.Widgets, I removed previous delete button (Widget_DeleteButton shape, Widget.DeleteButton.cshtml) because it was now redundant and conflicted with the Core/Contents... button (not a terrible conflict, but both were displayed and editing the Placement.info turned to be a unreliable solution).
Modified / added actions to controllers when needed.