Skip to content

Commit

Permalink
Checklist: rollout to other goal types.
Browse files Browse the repository at this point in the history
  • Loading branch information
taggon committed Aug 17, 2018
1 parent f58ddd9 commit da7957a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
5 changes: 3 additions & 2 deletions client/my-sites/checklist/checklist-show/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getSelectedSiteId } from 'state/ui/selectors';
import getSiteChecklist from 'state/selectors/get-site-checklist';
import { getSiteSlug } from 'state/sites/selectors';
import QuerySiteChecklist from 'components/data/query-site-checklist';
import { launchTask, tasks } from '../onboardingChecklist';
import { launchTask, getTasks } from '../onboardingChecklist';
import { loadTrackingTool, recordTracksEvent } from 'state/analytics/actions';
import { createNotice } from 'state/notices/actions';
import { requestGuidedTour } from 'state/ui/guided-tours/actions';
Expand Down Expand Up @@ -56,7 +56,7 @@ class ChecklistShow extends PureComponent {
};

render() {
const { siteId, taskStatuses } = this.props;
const { siteId, taskStatuses, tasks } = this.props;

return (
<Fragment>
Expand Down Expand Up @@ -90,6 +90,7 @@ const mapStateToProps = state => {
siteId,
siteSlug: getSiteSlug( state, siteId ),
taskStatuses: get( getSiteChecklist( state, siteId ), [ 'tasks' ] ),
tasks: getTasks( state, siteId ),
};
};

Expand Down
13 changes: 13 additions & 0 deletions client/my-sites/checklist/onboardingChecklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import page from 'page';
import { isDesktop } from 'lib/viewport';
import { translate } from 'i18n-calypso';
import { getSiteOption } from 'state/sites/selectors';

export const tasks = [
{
Expand Down Expand Up @@ -109,6 +110,18 @@ export const tasks = [
},
];

export function getTasks( state, siteId ) {
const designType = getSiteOption( state, siteId, 'design_type' );

if ( designType === 'blog' ) {
return tasks;
}

return tasks.filter( task => {
return task.id !== 'avatar_uploaded' && task.id !== 'post_published';
} );
}

export function launchTask( { task, location, requestTour, siteSlug, track } ) {
const checklist_name = 'new_blog';
const url = task.url && task.url.replace( '$siteSlug', siteSlug );
Expand Down
4 changes: 2 additions & 2 deletions client/my-sites/checkout/checkout/checkout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ export class Checkout extends React.Component {
const siteDesignType = get( selectedSite, 'options.design_type' );
const hasGoogleAppsInCart = cartItems.hasGoogleApps( cart );

// The onboarding checklist currently supports the blog type only.
if ( hasGoogleAppsInCart && domainReceiptId && 'blog' === siteDesignType ) {
// The onboarding checklist does not support the store type.
if ( hasGoogleAppsInCart && domainReceiptId && 'store' !== siteDesignType ) {
return `/checklist/${ selectedSiteSlug }?d=gsuite`;
}

Expand Down
16 changes: 9 additions & 7 deletions client/my-sites/stats/checklist-banner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import Gauge from 'components/gauge';
import ProgressBar from 'components/progress-bar';
import QuerySiteChecklist from 'components/data/query-site-checklist';
import getSiteChecklist from 'state/selectors/get-site-checklist';
import { getSite, getSiteSlug } from 'state/sites/selectors';
import { launchTask, tasks } from 'my-sites/checklist/onboardingChecklist';
import { getSiteOption, getSiteSlug } from 'state/sites/selectors';
import { launchTask, getTasks as getOnboardingTasks } from 'my-sites/checklist/onboardingChecklist';
import ChecklistShowShare from 'my-sites/checklist/share';
import { recordTracksEvent } from 'state/analytics/actions';
import { requestGuidedTour } from 'state/ui/guided-tours/actions';
Expand Down Expand Up @@ -71,7 +71,7 @@ export class ChecklistBanner extends Component {

getTask() {
const task = find(
tasks,
this.props.tasks,
( { id, completed } ) => ! completed && ! get( this.props.taskStatuses, [ id, 'completed' ] )
);
return (
Expand All @@ -96,7 +96,7 @@ export class ChecklistBanner extends Component {
return false;
}

if ( this.props.siteDesignType !== 'blog' ) {
if ( this.props.siteDesignType === 'store' ) {
return false;
}

Expand Down Expand Up @@ -128,7 +128,7 @@ export class ChecklistBanner extends Component {
}

render() {
const { siteId, taskStatuses, translate } = this.props;
const { siteId, taskStatuses, translate, tasks } = this.props;
const total = tasks.length;
const completed = reduce(
tasks,
Expand Down Expand Up @@ -194,14 +194,16 @@ export class ChecklistBanner extends Component {
}

const mapStateToProps = ( state, { siteId } ) => {
const taskStatuses = get( getSiteChecklist( state, siteId ), [ 'tasks' ] );
const siteSlug = getSiteSlug( state, siteId );
const siteDesignType = get( getSite( state, siteId ), [ 'options', 'design_type' ] );
const taskStatuses = get( getSiteChecklist( state, siteId ), [ 'tasks' ] );
const siteDesignType = getSiteOption( state, siteId, 'design_type' );
const tasks = getOnboardingTasks( state, siteId );

return {
siteDesignType,
siteSlug,
taskStatuses,
tasks,
};
};

Expand Down
4 changes: 2 additions & 2 deletions client/signup/processing-screen/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ export class SignupProcessingScreen extends Component {

return (
config.isEnabled( 'onboarding-checklist' ) &&
'blog' === designType &&
[ 'personal', 'premium', 'business' ].indexOf( this.props.flowName ) === -1
'store' !== designType &&
[ 'main', 'desktop', 'subdomain' ].indexOf( this.props.flowName ) !== -1
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function isEligibleForCheckoutToChecklist( state, siteId, cart )
}

return (
'blog' === designType &&
'store' !== designType &&
isNewSite( state, siteId ) &&
cartItems.hasPlan( cart ) &&
! some( cartItems.getAll( cart ), isDotcomBusinessPlan )
Expand Down

0 comments on commit da7957a

Please sign in to comment.