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

Conversation

@samueljseay
Copy link
Contributor

@samueljseay samueljseay commented Jul 22, 2020

Fixes #4592

This adds the functionality to support a store setup tab displayed in ActivityPanel. The tab currently just redirects to the home page, rather than implementing the nice-to-haves of displaying the task list in the panel. The reason for this, is that I found it would require significant refactoring of the task list to support this currently.

As part of this I have also refactored rendering of tabs inside into 2 new functional components: <Tabs> and <Tab>. The reason for this is to decompose large untestable components, test them and by virtue of being decomposed they will also be more reusable in future. Ideally would have been refactored to a functional component as well, but it would have been too large a task.

The logic for showing the setup progress tab is something I'd be keen to have checked. At the moment it only displays if:

  • You're not on the home screen
  • You haven't completed the setup task list
  • You're not working on one of the setup tasks

Accessibility

Screenshots

Screenshot 2020-07-23 at 10 40 43 AM

Detailed test instructions:

Test the ActivityPanel refactor

Because there has been some refactoring of the ActivityPanel in general it would be really great to smoke test its general functionality such as:

  • click outside close the menu
  • switching between different panels (note the animations still work)
  • view page at mobile size and check the mobile menu toggle still works.

Test the Setup Progress tab

Testing the setup progress tab will require having a site with some setup tasks not completed.

  • Visit the home screen and confirm its not shown there.
  • Go to a setup task and confirm its not shown there
  • Go to other menu items in WooCommerce and confirm its shown there.
  • Click the tab. You should be taken back to the home screen

This allows the click outside functionality to work.
It was simpler to maintain a separate list of visible tabs for
situations where we display the setup progress tab.

It was a nice to have to display the task list, but I had some
issues with that, which will require some refactoring of those
components and I've decided to avoid doing that here.

For now we support the most basic functionality which is routing
to the home page where the setup task list exists.
}

closePanel() {
this.setState( ( state ) => ( {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

one thing that was happening a lot before was that ActivityPanel was setting state to be a completely different shaped object in various scenarios. This lead to a lot of confusion about what state was at any given time. I've changed this to always keep state the same shape.

case 'inbox':
return <InboxPanel />;
case 'orders':
const { hasUnreadOrders } = this.props;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a good idea to declare variables inside case's since they'll clash if you reuse them in separate cases.

height: 18px;

// custom progress icon, requires specific coloring
&.setup-progress {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setup progress is different from all the other icons, its a 2 toned SVG rather than all the other tab icons which are dashicons.

@samueljseay samueljseay requested a review from a team July 22, 2020 22:52
@samueljseay samueljseay added [Status] Needs Review focus: activity panel Issues about activity/task panels on the home screen. labels Jul 22, 2020
{
name: 'setup',
title: __( 'Store Setup', 'woocommerce-admin' ),
icon: <SetupProgress />,
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool ✨


import { Tab } from '../';

const renderTab = () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

😍 thanks for the tests!

Copy link
Contributor

Choose a reason for hiding this comment

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

Love all these tests 💯

orientation="horizontal"
className="woocommerce-layout__activity-panel-tabs"
>
{ tabs &&
Copy link
Contributor

Choose a reason for hiding this comment

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

With this refactor, we could now have a filter right here for the tabs. Given the uncertain future of the activity panels though, my vote is to not add it quite yet - but still really cool that your changes have allowed for a good spot to add it in.

};

describe( 'Activity Panel Tabs', () => {
it( 'correctly tracks the selected tab', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice test here!

@samueljseay
Copy link
Contributor Author

samueljseay commented Jul 30, 2020

@timmyc You're right no need for the lock. I have reverted that.

// Ensure that if the user is trying to get to the task list they can see it even if
// it was dismissed.
updateOptions( { woocommerce_task_list_hidden: 'no' } );
getHistory().push( getAdminLink( 'admin.php?page=wc-admin' ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

The url comes out to this:

http://tangaroa.test/wp-admin/http://tangaroa.test/wp-admin/http://tangaroa.test/wp-admin/admin.php?page=wc-admin

getAdminLink is for external links. Sorry about this not being documented anywhere! This will look more like

getHistory().push( getNewPath( {}, `/profiler`, {} ) );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops! Thanks, I'll fix that

Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Really awesome to have this feature, @samueljseay! Great work on this PR; left a couple quick questions, but testing well for me.


import { Tab } from '../';

const renderTab = () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Love all these tests 💯

@psealock psealock 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 Aug 5, 2020
@samueljseay
Copy link
Contributor Author

@joshuatf @psealock

thanks for the feedback! I believe I've implemented all your suggested changes.

@samueljseay samueljseay 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 Aug 5, 2020
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Testing really well! Thanks for the updates here, Sam! LGTM 🚢

@timmyc
Copy link
Contributor

timmyc commented Aug 5, 2020

@samueljseay pinged you on the original issue that the design changed a bit here, but let's land this and we can take care of those revisions in a follow-up. Solid work!!!

@samueljseay samueljseay merged commit a8b326d into main Aug 5, 2020
@samueljseay samueljseay deleted the add/4592 branch August 5, 2020 22:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

focus: activity panel Issues about activity/task panels on the home screen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task list - add a shortcut back to store setup

5 participants