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

#8565: Delete and Unpublish buttons in backoffice content edit #8566

Open
wants to merge 13 commits into
base: 1.10.x
Choose a base branch
from

Conversation

AndreaPiovanelli
Copy link
Contributor

@AndreaPiovanelli AndreaPiovanelli commented Jun 10, 2022

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.

@@ -352,6 +352,18 @@ public class AdminController : ContentControllerBase, IUpdateModel {
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem));
}

[HttpPost, ActionName("Edit")]
Copy link
Member

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?

Copy link
Contributor Author

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()) {
Copy link
Member

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.

Copy link
Contributor Author

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>
Copy link
Member

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

@AndreaPiovanelli
Copy link
Contributor Author

@sebastienros fixed as requested.

@AndreaPiovanelli
Copy link
Contributor Author

Modified the code following Sebastien's remarks.

@BenedekFarkas BenedekFarkas linked an issue Apr 16, 2024 that may be closed by this pull request
Copy link
Member

@BenedekFarkas BenedekFarkas left a 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:

  1. BlogPost, Page, etc., when Draftable is enabled (default configuration) - too much space
    image
  2. BlogPost, when Draftable is disabled - spacing missing:
    image

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

<fieldset class="unpublish-button">
<button type="submit" name="submit.Unpublish" value="submit.Unpublish">@T("Unpublish")</button>
</fieldset>
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

if (widgetPart.Id > 0)
results.Add(ContentShape("Widget_DeleteButton",
deleteButton => deleteButton));
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) {
Copy link
Member

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.

Suggested change
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) {
if (widgetPart.Id > 0) {

Comment on lines 3 to 5
@using Orchard.Utility.Extensions;

@if (Authorizer.Authorize(Permissions.PublishContent, (IContent)Model.ContentItem) && ((IContent)Model.ContentItem).IsPublished()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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)) {

Comment on lines +26 to +28
if (part.ContentItem.IsPublished()) {
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton));
}
Copy link
Member

@BenedekFarkas BenedekFarkas Apr 16, 2024

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?

Suggested change
if (part.ContentItem.IsPublished()) {
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton));
}
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton));

Copy link
Contributor

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.

@BenedekFarkas BenedekFarkas changed the title Delete and Unpublish buttons in backoffice content edit #8565: Delete and Unpublish buttons in backoffice content edit Apr 18, 2024
@MatteoPiovanelli-Laser
Copy link
Contributor

rebased on 1.10.x and applied some of @BenedekFarkas suggestions

@BenedekFarkas
Copy link
Member

Sorry for replying just now, I'll be able to review later towards the end of September (after Harvest).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unpublish and Delete buttons in backoffice content edit page
5 participants