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

Checklists: Redux state, declarative structure #26216

Closed
wants to merge 12 commits into from

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Jul 20, 2018

Implementing ideas from #26015
Supersedes #26030
Closes #25958

This strikes a middle-ground of keeping array-of-objects that can be iterated over to produce a full checklist or a banner.

It also provides the option of building completely declarative checklists, which we do with the store checklist.

The props produced by connect are fewer and less likely to change.

Most importantly, we avoid merging declarative, structural information with state.

This will be helpful for future progress, such as #25935 and #25954

Todo:

  • ✅ Remove obsolete blocks
  • ✅ Remove obsolete helpers (mergeObjectIntoArrayById)
  • ✅ Fix classNames
  • ✅ Update devdocs
  • (postponed) Put launchTask somewhere better (Redux actions or middleware)
    This could be handled in a follow-up, everything works in this PR, this is additional cleanup.

Testing

Checklists may be used in 4 places. The functionality should remain unchanged for all of them:

Functionality:

  • Task counts
  • Task ordering (completed at the top)
  • Checklist collapsing
  • Clicking the event actions
  • Reporting of event completion

Checklists in use to test:

  • Checklist banners (simple sites at /stats/day/SITE) (@taggon / @fditrapani)
  • Jetpack checklist (Jetpack sites at /plans/my-plan/SITE) (@Automattic/luna)
  • Store checklist (Store installed, visit Store dashboard at /store/SITE) (@timmyc)
  • Devdocs https://calypso.live/devdocs/design/checklist?branch=update/checklist-separate-state-structure (@sirreal)
  • Devdocs playground (@sirreal):
    Drop the following in https://calypso.live/devdocs/playground?branch=update/checklist-separate-state-structure
    <Checklist inferCompletedCount>
    	<ChecklistTask
    		onClick={ () => console.log('Do this?') }
    		onDismiss={ () => console.log('Dismissing…') }
    		title="Reticulate splines"
    		buttonText="Reticulate!"
    		buttonPrimary
    		completedTitle="Splines are reticulated 👍"
    		description="Make sure that all the splines are reticulated."
    		duration="1 minute"
    		completed
    	/>
    	<ChecklistTask
    		onClick={ () => console.log('Do this?')  }
    		onDismiss={ () => console.log('Dismiss yak shaving.') }
    		title="Shave yaks!"
    		buttonText="Buzzzz"
    		buttonPrimary
    		completedTitle="Yaks shaved."
    		description="Make sure you shave the yaks so you can get on with your life."
    		duration="10,000 minutes"
    	/>
    </Checklist>

cc: @ockham @fditrapani

@matticbot
Copy link
Contributor

@fditrapani
Copy link
Contributor

From a code perspective, this stuff is a little over my head. Let me know how I might be able to test it out when it's ready.

@sirreal sirreal force-pushed the update/checklist-separate-state-structure branch from 3a413a7 to beb61d9 Compare July 20, 2018 21:41
* This should be a simpler dispatched action.
* Look at moving logic into middleware.
*/
void launchTask( {
Copy link
Member Author

Choose a reason for hiding this comment

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

This should go somewhere else and we'd just dispatch an action…

Copy link
Contributor

@ockham ockham Aug 3, 2018

Choose a reason for hiding this comment

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

Yeah, I think ideally, I'd love to decouple the tour from the checklist even more -- i.e. really just pass in an onClick handler function, and make the Task block ignorant about GT specific stuff such as tourSlug, tourUrl, etc.

Follow-up material tho.

Copy link
Contributor

@ockham ockham Aug 3, 2018

Choose a reason for hiding this comment

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

(Oh, which might mean we would possibly ditch the Task block and try to encapsulate that bound launchTask function elsewhere...)

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, scrolling down to the Task component, I realize this is the major distinction between the component and the block. I think I'd still even go as far as to possibly remove the block altogether if we can find a different way of encapsulating the launchTour function...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree with you here @ockham. I think this PR is a good balance of introducing the new, more declarative checklist components, and the Task block may well be a temporary measure.

My inclination is that this PR is in a sweet spot right now, it introduces the components and maintains a connected block that makes the state.checklist-connected Tasks trivial to declare.

Finding the right place to handle tour start from the task (and whether that's implemented where/how it should be, or if it should be rethought entirely) can be part of a follow up.

What are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, sounds good! I think what seems the most arbitrary to me is that coupling of Guided Tours internals to the checklist. Agree that this PR is a good step towards decoupling that 👍

@@ -40,6 +38,7 @@ export class ChecklistHeader extends PureComponent {
<ProgressBar compact total={ total } value={ completed } />
</div>
<div className="checklist__header-secondary">
{ /* eslint-disable-next-line jsx-a11y/label-has-for */ }
Copy link
Member Author

Choose a reason for hiding this comment

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

nesting and id are required, I'm not sure why. This file is moved but otherwise unchanged. Ignore rule.

@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Jul 20, 2018
@sirreal sirreal force-pushed the update/checklist-separate-state-structure branch from a7d4a2d to 2f8355f Compare July 20, 2018 22:10
@sirreal sirreal requested review from timmyc, ockham and taggon July 20, 2018 22:17
@sirreal
Copy link
Member Author

sirreal commented Jul 20, 2018

@fditrapani This is ready for some testing. I've added some instructions about where the Checklists can be found for testing and what should be expected (same behavior as staging/production). I'd appreciate any testing feedback you can provide, thanks!

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

I didn't do a full review of the code, but this is testing out perfectly for the usage in Store.

@ockham ockham force-pushed the update/checklist-separate-state-structure branch from 2f8355f to 1292d25 Compare August 3, 2018 20:13
buttonPrimary
completedTitle="Yaks shaved."
description="Make sure you shave the yaks so you can get on with your life."
duration="10,000 minutes"
Copy link
Contributor

Choose a reason for hiding this comment

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

🤣

@sirreal sirreal force-pushed the update/checklist-separate-state-structure branch from 1292d25 to f56f5cd Compare August 6, 2018 15:36
@sirreal sirreal requested review from fditrapani and a team August 6, 2018 16:56
@sirreal
Copy link
Member Author

sirreal commented Aug 6, 2018

I've pinged a few folks for some manual testing as a checklist in the PR description.

If folks will contribute some manual testing to a checklist in their domain, @Automattic/luna and @ockham should be able to handle code review.

Thanks!

@sirreal sirreal force-pushed the update/checklist-separate-state-structure branch from d1b2e6f to 1bc0cd9 Compare August 9, 2018 13:56
sirreal added a commit that referenced this pull request Aug 10, 2018
Adds Components from #26216
Uses components for WooCommerce Store checklist
Uses components for ChecklistShow
Removes blocks (discourage block usage)
sirreal added a commit that referenced this pull request Aug 13, 2018
Adds Components from #26216
Uses components for WooCommerce Store checklist
Uses components for ChecklistShow
Removes blocks (discourage block usage)
@sirreal
Copy link
Member Author

sirreal commented Aug 14, 2018

Closing in favor of #26618 and follow-up work.

@sirreal sirreal closed this Aug 14, 2018
sirreal added a commit that referenced this pull request Aug 15, 2018
Adds Components from #26216
Uses components for WooCommerce Store checklist
Uses components for ChecklistShow
Removes blocks (discourage block usage)
sirreal added a commit that referenced this pull request Aug 15, 2018
* Add and use Checklist components, remove blocks

Add components from #26216
Use components for WooCommerce Store checklist
Use components for ChecklistShow
Remove blocks
Update devdocs accordingly

* Separate state and structure in checklist banner
@sirreal sirreal deleted the update/checklist-separate-state-structure branch August 16, 2018 17:29
ockham pushed a commit that referenced this pull request Sep 10, 2018
This PR continues separation of state and declarative structure work outlined in #26216.

Inspired by suggestions from ockham, the Checklist is declared once in idiomatic React JSX, and can be rendered as a checklist of tasks or a banner (see `viewMode` prop).

* `ChecklistShow`, responsible only for rendering the WordPress.com checklist, has been removed.
* The array of task props in `onboardingChecklist` has been removed, and is now JSX in `WpcomChecklist`.
* `ChecklistBanner` has been removed and replaced by `<WpcomChecklist viewMode="banner" />`.
* `ChecklistMain` renders the `WpcomChecklist` and some surrounding UI. Clean up its usage of task status for calculating completion.
* Remove the `mergeObjectIntoArrayById` util which is no longer needed and related tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants