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

Introduce 'View all' post type filter on pull screen #725

Merged
merged 3 commits into from
Mar 4, 2021

Conversation

elliott-stocks
Copy link
Contributor

Description of the Change

Introduce a 'View all' filter on the pull screen to allow users to view all post types by default instead of filtering manually. Also added a new column to the pull screen table to show which post type is currently in view - useful for when all are being displayed.

This handles one of the planned changes outlined in #392.

Alternate Designs

N/A

Benefits

Allows users to view all available post types on the pull screen without having to filter separately.

Possible Drawbacks

Verification Process

  1. Visit the pull screen and verify that "View all" is selected by default - all post types should be viewable
  2. Test filtering various post types
  3. Ensure correct post type is visible within the added "Post Type" column

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#392

Changelog Entry

@@ -258,7 +259,7 @@ public function column_date( $post ) {
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'name':
return $item['post_title'];
return $item->post_title;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at this, doesn't seem we even use this output, as the name column gets rendered in the _column_name callback function. Might be worth just removing this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dkotter Updated.

@@ -258,7 +259,7 @@ public function column_date( $post ) {
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'name':
return $item['post_title'];
return $item->post_title;
case 'url':
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is unrelated to any changes here but also doesn't seem we ever use a url column and if so, probably worth removing this case statement here as we're modifying other things in this UI

Copy link
Member

Choose a reason for hiding this comment

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

I agree that even some light cleanup is worthwhile while we're working on this section of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dkotter Updated.

@dkotter
Copy link
Collaborator

dkotter commented Feb 23, 2021

@elliott-stocks Overall looks good, left a few minor comments.

But there is an issue in regards to external connections. If you select all for the post type value (which is now the default) internal connections handle this fine but external connections break, because we now pass an array of post types and it expects a single post type.

As an example, here's one place that will throw a PHP error when all is selected and we try and pull from an external connection: https://github.com/10up/distributor/blob/develop/includes/classes/ExternalConnections/WordPressExternalConnection.php#L171

@elliott-stocks
Copy link
Contributor Author

@elliott-stocks Overall looks good, left a few minor comments.

But there is an issue in regards to external connections. If you select all for the post type value (which is now the default) internal connections handle this fine but external connections break, because we now pass an array of post types and it expects a single post type.

As an example, here's one place that will throw a PHP error when all is selected and we try and pull from an external connection: https://github.com/10up/distributor/blob/develop/includes/classes/ExternalConnections/WordPressExternalConnection.php#L171

Thanks, @dkotter !

Do we want to enable this for external connections? I think it works well for internal but not too sure about external - happy to disable the "view all" for external if you agree.

@dkotter
Copy link
Collaborator

dkotter commented Feb 26, 2021

Do we want to enable this for external connections?

I guess my expectation would be that this would work on both. It would be a little weird from a user perspective to lose options on that Pull screen if you switch connection types.

But that said, because of the way we handle running a query on an external connection, not sure there's a straight forward way to make this all work, at least without having to refactor that query portion. I guess in theory we could loop through the post types and run individual queries for each of those and then combine and reduce those results to the most recent. There are performance issues to consider there though, especially for sites that have lots of post types.

@jeffpaul jeffpaul added this to the 1.7.0 milestone Mar 1, 2021
@jeffpaul jeffpaul added the type:enhancement New feature or request. label Mar 1, 2021
@jeffpaul
Copy link
Member

jeffpaul commented Mar 1, 2021

@dkotter it could be worthwhile to add just for Internal Connections now and once we get through the larger work on #123 we could come back to enable this for External Connections then?

@dkotter
Copy link
Collaborator

dkotter commented Mar 1, 2021

@dkotter it could be worthwhile to add just for Internal Connections now and once we get through the larger work on #123 we could come back to enable this for External Connections then?

If we just want to add it for Internal Connections now, that's fine with me. I do have concerns both about the user expectations that both connection types would behave the same and it does make the code a little messier, as I think we would need to have conditionals in a few places to change behavior depending on the connection type.

But I'm happy to review any changes to this PR if we want to just apply this to Internal Connections for now.

@elliott-stocks
Copy link
Contributor Author

Thanks, both!

@dkotter I've pushed updates to address the default column logic and to limit the new filter to internal connections.

@jeffpaul jeffpaul modified the milestones: 1.7.0, 1.6.3 Mar 4, 2021
@jeffpaul jeffpaul merged commit 625efdb into develop Mar 4, 2021
@jeffpaul jeffpaul deleted the feature/pull-screen-view-all-filter branch March 4, 2021 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants