Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#38341 closed defect (bug) (fixed)

Hide 'Empty Trash' button when trash is already empty

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: good-first-bug has-patch has-screenshots needs-unit-tests
Focuses: ui, administration Cc:

Description

Noticed while working on #37407.

Here's a screenshot:

https://cldup.com/TxxKy9pM0E.png

Attachments (11)

38341.diff (1.7 KB) - added by ivantedja 8 years ago.
38341-media.diff (689 bytes) - added by ivantedja 8 years ago.
38341-complete.diff (2.3 KB) - added by ivantedja 8 years ago.
trash.jpg (134.0 KB) - added by Presskopp 8 years ago.
38341.2.diff (2.0 KB) - added by Presskopp 8 years ago.
38341.3.diff (2.1 KB) - added by printsachen1 8 years ago.
38341.patch (2.2 KB) - added by Jaydeep Rami 8 years ago.
Attached patch from root
38341.4.diff (2.7 KB) - added by mathieuhays 8 years ago.
38341.5.diff (3.4 KB) - added by mathieuhays 8 years ago.
add php-unit test
38314.6.diff (3.5 KB) - added by cazm 8 years ago.
Fixing missing button when Spam is deleted and no trash
38341.6.diff (4.1 KB) - added by swissspidy 8 years ago.
Adds another test for the comments list table

Download all attachments as: .zip

Change History (31)

#1 @swissspidy
8 years ago

Note that you'll typically only see this right after emptying the trash. When the trash is already empty, there's not even a link to the trash.

@ivantedja
8 years ago

#2 follow-up: @ivantedja
8 years ago

Patch attached :)
It covers:

  • posts
  • pages
  • comments

I notice something, the code has "Empty Trash" button in "media" as well
But media always deleted permanently so "Empty Trash" for media is never shown up
Is it legacy code?

#3 @Presskopp
8 years ago

  • Keywords has-patch added; needs-patch removed

#4 @lukecavanagh
8 years ago

@ivantedja

Patch applies cleanly,

#5 in reply to: ↑ 2 @afercia
8 years ago

Replying to ivantedja:

But media always deleted permanently so "Empty Trash" for media is never shown up

There's a constant define( 'MEDIA_TRASH', true ) to enable trash for media.

#6 @ivantedja
8 years ago

Thanks @afercia ! Previously I only saw this info: https://en.support.wordpress.com/trash/#permanently-deleting-an-upload hence I thought there is no way to delete non-permanently

@lukecavanagh attached additional patch for "media"

#7 @swissspidy
8 years ago

  • Keywords needs-screenshots added
  • Milestone changed from Awaiting Review to Future Release

@ivantedja Thanks! Would you mind combining these two patches into 1? Makes it easier to test.

#8 @ivantedja
8 years ago

@swissspidy sure, has been attached :)

@Presskopp
8 years ago

#9 @Presskopp
8 years ago

  • Keywords needs-screenshots removed

Patch applies cleanly, screenshots attached, patch refreshed

Last edited 8 years ago by Presskopp (previous) (diff)

@Presskopp
8 years ago

#10 @swissspidy
8 years ago

  • Keywords has-screenshots added

#11 @lukecavanagh
8 years ago

Patch still applies cleanly and resolves the issue.

#12 @nonproftechie
8 years ago

  • Keywords needs-unit-tests added

#13 @swissspidy
8 years ago

  • Milestone changed from Future Release to 4.8

@printsachen1
8 years ago

#14 @printsachen1
8 years ago

The patch 38341.2.diff did not apply cleanly because it was not created from the project root directory. 38341.3.diff fixes this.

One other thing I noticed is that when restoring the last comment in the comments trash, the button remains since the page is not reloaded. This is only a minor issue, but may be something to consider.

#15 @swissspidy
8 years ago

Thanks @printsachen1 and good catch with the restore! I think it should be easy to make it work in that scenario, provided that the JS isn't that big of a mess.

@Jaydeep Rami
8 years ago

Attached patch from root

@mathieuhays
8 years ago

#16 @mathieuhays
8 years ago

I've just sent a new diff which hides the Empty Trash button for the use case mentioned by @printsachen1.

When testing I also noticed that when the Pages' trash is empty, there quite a lot of spacing due to the fact that there no button or filter anymore. Is it something that should fixed or is it expected to remain like that? Can be seen on the screenshot posted by @Presskopp.

@mathieuhays
8 years ago

add php-unit test

#17 @mathieuhays
8 years ago

I just pushed a new diff adding a simple PHP-Unit test.

@cazm
8 years ago

Fixing missing button when Spam is deleted and no trash

#18 @cazm
8 years ago

In certain conditions, when an item of Spam was "deleted perminently" and Trash = 0, the "empty spam" button disappeared, even when there was more than one item of spam still in the list.

#19 @swissspidy
8 years ago

One other thing I noticed is that when restoring the last comment in the comments trash, the button remains since the page is not reloaded. This is only a minor issue, but may be something to consider.

Good catch. I think it makes sense to address this in a new ticket.

@swissspidy
8 years ago

Adds another test for the comments list table

#20 @swissspidy
8 years ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 40297:

List Tables: Hide 'Empty Trash' and 'Empty Spam' buttons when view is already empty.

Props ivantedja, Presskopp, printsachen1, Jaydeep Rami, mathieuhays, cazm.
Fixes #38341.

Note: See TracTickets for help on using tickets.