Skip to content

Commit

Permalink
Disconnect Site: add follow-up screen transition
Browse files Browse the repository at this point in the history
Refactor rendering code such that it cleans the Main component
after selecting a survey option, creating a new Card for
the follow-up question or action.

This commit renames functions in `disconnect-survey.jsx` to improve readability.
  • Loading branch information
AnnaMag committed Oct 1, 2017
1 parent 07a41b0 commit 8ab75bd
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions client/my-sites/site-settings/disconnect-site/disconnect-survey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,31 @@ import { isJetpackSite } from 'state/sites/selectors';
class DisconnectSurvey extends Component {
state = {
reasonSelected: 'onlyNeedFree',
compactButtons: false,
renderFull: false,
renderInitial: true,
};

renderFull() {
renderFollowUp() {
// placeholder
return <div>{ ' follow-up QA' }</div>;
return <Card className="disconnect-site__question">{ 'follow-up' }</Card>;
}

logReason = option => {
logSelection = option => {
this.setState( {
reasonSelected: option.value,
renderFull: true,
renderInitial: false,
} );
};

getOptions() {
const { site } = this.props;
const { translate, site } = this.props;

const options = [
{ value: 'tooHard', label: 'It was too hard to configure Jetpack' },
{ value: 'didNotInclude', label: 'This plan didn’t include what I needed' },
{ value: 'tooHard', label: translate( 'It was too hard to configure Jetpack' ) },
{ value: 'didNotInclude', label: translate( 'This plan didn’t include what I needed' ) },
];

if ( ! isFreeJetpackPlan( site.plan ) ) {
options.push( { value: 'onlyNeedFree', label: 'This plan is too expensive' } );
options.push( { value: 'onlyNeedFree', label: translate( 'This plan is too expensive' ) } );
}
return options;
}
Expand All @@ -52,17 +51,16 @@ class DisconnectSurvey extends Component {
const questions = [];
for ( let i = 0; i < options.length; i++ ) {
questions.push(
<CompactCard href="#" onClick={ this.logReason } className="disconnect-site__survey-one">
<CompactCard href="#" onClick={ this.logSelection } className="disconnect-site__survey-one">
{ options[ i ].label }
</CompactCard>
);
}
return questions;
}

render() {
renderEntryQuestion() {
const { translate, siteSlug } = this.props;
const { reasonSelected, renderFull } = this.state;

const textShareWhy = translate(
'Would you mind sharing why you want to disconnect %(siteName)s from WordPress.com ',
Expand All @@ -71,15 +69,21 @@ class DisconnectSurvey extends Component {
args: { siteName: siteSlug },
}
);

const options = this.getOptions();
const surveyQuestionsOne = this.getSurveyQuestions( options );

return (
<div className="disconnect-site__survey main">
<div>
<Card className="disconnect-site__question">{ textShareWhy }</Card>
{ surveyQuestionsOne }
{ renderFull ? this.renderFull( reasonSelected ) : null }
</div>
);
}

render() {
const { reasonSelected, renderInitial } = this.state;
return (
<div className="disconnect-site__survey main">
{ renderInitial ? this.renderEntryQuestion() : this.renderFollowUp( reasonSelected ) }
</div>
);
}
Expand Down

0 comments on commit 8ab75bd

Please sign in to comment.