Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Replace old task list option calls with data store selectors #7820

Merged
merged 15 commits into from
Nov 15, 2021
Merged

Conversation

joshuatf
Copy link
Contributor

@joshuatf joshuatf commented Oct 19, 2021

Fixes #7751

Replaces old deprecated option calls with data store selectors.

Detailed test instructions:

For all use cases

  • Add a plugin like Google Listings and Ads so that the extended task list can be tested
  • Make sure the extended tasks aren't complete
  • Make sure the task list is not hidden

Abbreviated components

  1. Navigate to a WCA page besides the homepage
  2. Click "Inbox" in the header
  3. Check that the the correct count of extended item todos is shown in the abbreviated notifications

Finish setup

  1. Navigate to any WCA page besides the homepage
  2. Check that clicking "Finish Setup" in the header navigates to the homescreen without console errors

Help highlight

  1. Delete help_panel_highlight_shown from your user meta table
  2. Start a task more than once
  3. Make sure the help tip is shown if it's not a completed task

Purchase undo dismiss

  1. Select a purchaseable product type during the profile wizard
  2. Dismiss the purchase task on the homescreen
  3. Navigate back to the profile wizard
  4. Add another purchaseable product
  5. Make sure the purchase task is no longer dismissed

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Nice work on this @joshuatf, it's nice to get rid of so many of the getOption calls :)
I just noticed a couple small things during testing and left a couple suggestions, looking good though!!

Check that the the correct count of extended item todos is shown in the abbreviated notifications

This tested well, but only on WC Admin pages, not the orders page for example, but I guess that is a plugin's problem (given this was already the case with Google listings and ads).

Also the Store Setup would show briefly while the task lists are being loaded, I left a comment in the file as well, I think this might also be a current issue (given the options are async), but would be a minimal change and nice to add to this PR.

Check that clicking "Finish Setup" in the header navigates to the homescreen without console errors

I didn't errors, but did get these warnings:
Screen Shot 2021-10-22 at 9 59 46 AM

isResolving( 'getOption', [ 'woocommerce_task_list_hidden' ] ),
setupTaskListComplete:
getOption( 'woocommerce_task_list_complete' ) === 'yes',
requestingTaskListOptions: isResolving( 'getTaskLists' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make use of this condition for the Finish setup panel as well (on line 263). Given the Finish Setup shows up when the task lists haven't been loaded yet.

( list ) => list.id === 'setup' && list.isComplete
),
isTaskListHidden: taskLists.find(
( list ) => list.id === 'setup' && list.isHidden
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be worth creating selectors for the above two - getTaskIsComplete & getTaskIsHidden or something similar, then we could move this logic to the data store.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea. Added getTaskList and getTask. I think these allow a bit more flexibility and it's still trivial to call getTaskList( 'setup' ).isComplete.

`/wc-admin/onboarding/tasks/${ id }/unhide`
);
expect( response.statusCode ).toEqual( 200 );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, having the API available will make E2E tests a bit easier 😄

@@ -143,6 +143,19 @@ public function register_routes() {
)
);

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[a-z0-9_\-]+)/unhide',
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of calling this unhide should we call it show instead?

@@ -59,15 +59,15 @@ public static function update_deprecated_options( $value, $old_value, $option )
if ( ! $task_list ) {
return;
}
$update = 'yes' === $value ? $task_list->hide() : $task_list->show();
$update = 'yes' === $value ? $task_list->hide() : $task_list->unhide();
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess my previous comment suggested to use show, was there a particular reason you decided to change it to unhide?

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 felt show was a bit ambiguous in meaning. It sounds like it will either render the task list, redirect to the task list, or not hide it anymore (what we actually do). Whereas unhide I can only see one meaning.

I don't have a strong opinion on this though, so if you feel show is better, I'm happy to revert.

@louwie17 louwie17 added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed status: needs review labels Oct 22, 2021
@joshuatf
Copy link
Contributor Author

Thanks for the feedback, @louwie17!

I wasn't able to reproduce those console warnings. Is that also on main or only this branch?

I addressed all your feedback with the exception of the show/hide change. I left some comments on why I updated this, but I don't have very strong feelings on this so I'm happy to revert if you feel it makes more sense as show.

@joshuatf joshuatf added status: needs review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Oct 28, 2021

export function* getTask() {
yield resolveSelect( STORE_NAME, 'getTaskLists' );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that's a clever way!

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

@joshuatf just noticed one issue in the home screen layout.

isTaskListHidden: Boolean( taskLists.length )
? ! taskLists.find( ( list ) => list.id === 'setup' ).isVisible
: null,
isTaskListHidden: taskList?.isVisible,
Copy link
Contributor

Choose a reason for hiding this comment

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

@joshuatf this should be isHidden right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! It actually is supposed to be isVisible but the references to isTaskListHidden needed to be updated.

I think it's better to check visibility in this case since that's really the dependency we're checking and we know the data has been fully loaded if this value is true.

Updated in b957d70.

@louwie17 louwie17 added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed status: needs review labels Nov 1, 2021
@joshuatf joshuatf added status: needs review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Nov 12, 2021
@joshuatf
Copy link
Contributor Author

Thanks for the review, @louwie17! Rebased and fixed the visibility based on your comment. This is ready for another review.

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @joshuatf, I am fine with the isTaskListVisible rename, although this will also need to be updated in the panels.js file as mentioned in the comment below.

isTaskListHidden: Boolean( taskLists.length )
? ! taskLists.find( ( list ) => list.id === 'setup' ).isVisible
: null,
isTaskListVisible: taskList?.isVisible,
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing the isTaskListHidden prop here, will also require a change in the getAllPanels function here:


None of the panels are showing up at the moment.

@louwie17 louwie17 added needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. and removed status: needs review labels Nov 15, 2021
@joshuatf
Copy link
Contributor Author

Great catch, @louwie17! I completely missed the panelData being passed to the child.

Reverted back to checking for hidden task list so that we don't prematurely show the wrong panels. The usage of the task list in this controller has a check for undefined so it should still be okay.

@joshuatf joshuatf added status: needs review and removed needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. labels Nov 15, 2021
Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

All seems good now, thanks for the updates @joshuatf 👍 :shipit:

@joshuatf joshuatf merged commit e9d94f6 into main Nov 15, 2021
@joshuatf joshuatf deleted the update/7751 branch November 15, 2021 20:57
ObliviousHarmony pushed a commit to woocommerce/woocommerce that referenced this pull request Mar 18, 2022
…erce/woocommerce-admin#7820)

* Add endpoint to unhide task list

* Rename show method to unhide

* Replace requests for hidden task list options

* Replace unhide task list requests

* Replace task list complete checks

* Replace dismiss option requests

* Remove complete task option check

* Fix up panel buttons

* Update finished setup to wait for task list resolution

* Create selector for getting a single task list

* Add selector for single task

* Fix task list panel visibility

* Add changelog entry

* Fix empty product types in profiler data

* Revert to checking for hidden task list
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up old usage of task list options
2 participants