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

Removes all After the Deadline references from Jetpack #11772

Merged
merged 8 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions _inc/client/components/navigation-settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const NavigationSettings = createReactClass( {
{ this.props.hasAnyOfTheseModules( [
'masterbar',
'markdown',
'after-the-deadline',
'custom-content-types',
'post-by-email',
'infinite-scroll',
Expand Down Expand Up @@ -207,7 +206,7 @@ export const NavigationSettings = createReactClass( {
}
navItems = (
<NavTabs selectedText={ this.props.route.name }>
{ this.props.hasAnyOfTheseModules( [ 'after-the-deadline', 'post-by-email' ] ) && (
{ this.props.hasAnyOfTheseModules( [ 'post-by-email' ] ) && (
<NavItem
path="#writing"
onClick={ this.handleClickForTracking( 'writing' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe( 'NavigationSettings', () => {
siteAdminUrl: 'https://example.org/wp-admin/',
searchForTerm: () => {},
isLinked: true,
moduleList: { minileven: true, sitemaps: true, carousel: true, 'custom-content-types': true, 'verification-tools': true, markdown: true, 'infinite-scroll': true, 'gravatar-hovercards': true, sharedaddy: true, sso: true, 'related-posts': true, monitor: true, vaultpress: true, stats: true, masterbar: true, 'google-analytics': true, 'seo-tools': true, wordads: true, videopress: true, subscriptions: true, comments: true, 'post-by-email': true, 'after-the-deadline': true, photon: true, publicize: true, likes: true },
moduleList: { minileven: true, sitemaps: true, carousel: true, 'custom-content-types': true, 'verification-tools': true, markdown: true, 'infinite-scroll': true, 'gravatar-hovercards': true, sharedaddy: true, sso: true, 'related-posts': true, monitor: true, vaultpress: true, stats: true, masterbar: true, 'google-analytics': true, 'seo-tools': true, wordads: true, videopress: true, subscriptions: true, comments: true, 'post-by-email': true, photon: true, publicize: true, likes: true },
isPluginActive: () => true
};

Expand Down
10 changes: 2 additions & 8 deletions _inc/client/components/settings-group/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,15 @@ export const SettingsGroup = props => {
if (
module.module &&
! props.userCanManageModules &&
! includes( [ 'after-the-deadline', 'post-by-email', 'publicize' ], module.module )
! includes( [ 'post-by-email', 'publicize' ], module.module )
) {
return <span />;
}

const disableInDevMode = props.disableInDevMode && props.isUnavailableInDevMode( module.module );
let displayFadeBlock = disableInDevMode;

if (
( 'post-by-email' === module.module && ! props.isLinked ) ||
( 'after-the-deadline' === module.module &&
( ! props.userCanManageModules &&
props.userCanEditPosts &&
! props.isModuleActivated( 'after-the-deadline' ) ) )
) {
if ( 'post-by-email' === module.module && ! props.isLinked ) {
displayFadeBlock = true;
}

Expand Down
1 change: 0 additions & 1 deletion _inc/client/components/settings-group/test/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe( 'SettingsGroup', () => {
'photon'
],
allGroupsForNonAdmin = [
'after-the-deadline',
'post-by-email'
];

Expand Down
197 changes: 3 additions & 194 deletions _inc/client/writing/composing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,173 +4,19 @@
import React from 'react';
import { connect } from 'react-redux';
import { translate as __ } from 'i18n-calypso';
import CompactFormToggle from 'components/form/form-toggle/compact';
import FoldableCard from 'components/foldable-card';
import classNames from 'classnames';
import analytics from 'lib/analytics';

/**
* Internal dependencies
*/
import { FormFieldset, FormLegend } from 'components/forms';
import { FormFieldset } from 'components/forms';
import { isModuleFound as _isModuleFound } from 'state/search';
import { ModuleToggle } from 'components/module-toggle';
import { withModuleSettingsFormHelpers } from 'components/module-settings/with-module-settings-form-helpers';
import { getModule } from 'state/modules';
import TagsInput from 'components/tags-input';
import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';

export class Composing extends React.Component {
/**
* Get options for initial state.
*
* @return {Object} initialState {{
* onpublish: *,
* onupdate: *,
* guess_lang: *,
* Bias Language: *,
* Cliches: *,
* Complex Expression: *,
* Diacritical Marks: *,
* Double Negative: *,
* Hidden Verbs: *,
* Jargon Language: *,
* Passive voice: *,
* Phrases to Avoid: *,
* Redundant Expression: *
* }}
*/
state = {
onpublish: this.props.getOptionValue( 'onpublish', 'after-the-deadline' ),
onupdate: this.props.getOptionValue( 'onupdate', 'after-the-deadline' ),
guess_lang: this.props.getOptionValue( 'guess_lang', 'after-the-deadline' ),
'Bias Language': this.props.getOptionValue( 'Bias Language', 'after-the-deadline' ),
Cliches: this.props.getOptionValue( 'Cliches', 'after-the-deadline' ),
'Complex Expression': this.props.getOptionValue( 'Complex Expression', 'after-the-deadline' ),
'Diacritical Marks': this.props.getOptionValue( 'Diacritical Marks', 'after-the-deadline' ),
'Double Negative': this.props.getOptionValue( 'Double Negative', 'after-the-deadline' ),
'Hidden Verbs': this.props.getOptionValue( 'Hidden Verbs', 'after-the-deadline' ),
'Jargon Language': this.props.getOptionValue( 'Jargon Language', 'after-the-deadline' ),
'Passive voice': this.props.getOptionValue( 'Passive voice', 'after-the-deadline' ),
'Phrases to Avoid': this.props.getOptionValue( 'Phrases to Avoid', 'after-the-deadline' ),
'Redundant Expression': this.props.getOptionValue(
'Redundant Expression',
'after-the-deadline'
),
};

/**
* Update state so toggles are updated.
*
* @param {string} optionName slug of an option to be updated
*/
updateOptions = optionName => {
this.setState(
{
[ optionName ]: ! this.state[ optionName ],
},
this.props.updateFormStateModuleOption( 'after-the-deadline', optionName )
);
};

handleToggleChange = setting => {
return () => this.updateOptions( setting );
};

/**
* Render a toggle for a single option.
*
* @param {string} setting the slug for the option
* @param {string} label text label to be displayed with the toggle
* @returns {object} React element object
*/
getToggle = ( setting, label ) => {
return (
<CompactFormToggle
checked={ this.state[ setting ] }
disabled={
! this.props.getOptionValue( 'after-the-deadline' ) ||
this.props.isUnavailableInDevMode( 'after-the-deadline' ) ||
this.props.isSavingAnyOption( [ 'after-the-deadline', setting ] )
}
onChange={ this.handleToggleChange( setting ) }
>
<span className="jp-form-toggle-explanation">{ label }</span>
</CompactFormToggle>
);
};

getAtdSettings = () => {
const ignoredPhrases = this.props.getOptionValue( 'ignored_phrases' );
return (
<SettingsGroup
hasChild
disableInDevMode
module={ this.props.getModule( 'after-the-deadline' ) }
support={ {
text: __(
'Checks your content for correct grammar and spelling, ' +
'misused words, and style while you write.'
),
link: 'https://jetpack.com/support/spelling-and-grammar/',
} }
>
<FormFieldset>
<FormLegend> { __( 'Proofreading' ) } </FormLegend>
<span className="jp-form-setting-explanation">
{ __( 'Automatically proofread content when: ' ) }
</span>
{ this.getToggle( 'onpublish', __( 'A post or page is first published' ) ) }
{ this.getToggle( 'onupdate', __( 'A post or page is updated' ) ) }
</FormFieldset>
<FormFieldset>
<FormLegend> { __( 'Automatic Language Detection' ) }</FormLegend>
<span className="jp-form-setting-explanation">
{ __( 'The proofreader supports English, French, German, Portuguese and Spanish.' ) }
</span>
{ this.getToggle(
'guess_lang',
__( 'Use automatically detected language to proofread posts and pages' )
) }
</FormFieldset>
<FormFieldset>
<FormLegend> { __( 'English Options' ) } </FormLegend>
<span className="jp-form-setting-explanation">
{ __( 'Enable proofreading for the following grammar and style rules: ' ) }
</span>
{ this.getToggle( 'Bias Language', __( 'Bias Language' ) ) }
{ this.getToggle( 'Cliches', __( 'Clichés' ) ) }
{ this.getToggle( 'Complex Expression', __( 'Complex Phrases' ) ) }
{ this.getToggle( 'Diacritical Marks', __( 'Diacritical Marks' ) ) }
{ this.getToggle( 'Double Negative', __( 'Double Negatives' ) ) }
{ this.getToggle( 'Hidden Verbs', __( 'Hidden Verbs' ) ) }
{ this.getToggle( 'Jargon Language', __( 'Jargon' ) ) }
{ this.getToggle( 'Passive voice', __( 'Passive Voice' ) ) }
{ this.getToggle( 'Phrases to Avoid', __( 'Phrases to Avoid' ) ) }
{ this.getToggle( 'Redundant Expression', __( 'Redundant Phrases' ) ) }
</FormFieldset>
<FormFieldset>
<FormLegend>{ __( 'Ignored Phrases' ) }</FormLegend>
<TagsInput
name="ignored_phrases"
disabled={ ! this.props.getOptionValue( 'after-the-deadline' ) }
placeholder={ __( 'Add a phrase' ) }
value={
'undefined' !== typeof ignoredPhrases && '' !== ignoredPhrases
? ignoredPhrases.split( ',' )
: []
}
onChange={ this.props.onOptionChange }
/>
<span className="jp-form-setting-explanation">
{ __( 'Confirm each new phrase you add by pressing enter.' ) }
</span>
</FormFieldset>
</SettingsGroup>
);
};

/**
* If markdown module is inactive and this is toggling markdown for posts on, activate module.
* If markdown for comments is off and this is toggling markdown for posts off, deactivate module.
Expand All @@ -189,30 +35,21 @@ export class Composing extends React.Component {
);
};

trackOpenCard = () => {
analytics.tracks.recordJetpackClick( {
target: 'foldable-settings-open',
feature: 'atd',
} );
};

render() {
const foundCopyPost = this.props.isModuleFound( 'copy-post' ),
foundAtD = this.props.isModuleFound( 'after-the-deadline' ),
foundLatex = this.props.isModuleFound( 'latex' ),
foundMarkdown = this.props.isModuleFound( 'markdown' ),
foundShortcodes = this.props.isModuleFound( 'shortcodes' );

if ( ! foundCopyPost && ! foundLatex && ! foundMarkdown && ! foundAtD && ! foundShortcodes ) {
if ( ! foundCopyPost && ! foundLatex && ! foundMarkdown && ! foundShortcodes ) {
return null;
}

const markdown = this.props.module( 'markdown' ),
latex = this.props.module( 'latex' ),
atd = this.props.module( 'after-the-deadline' ),
copyPost = this.props.module( 'copy-post' ),
shortcodes = this.props.module( 'shortcodes' ),
unavailableInDevMode = this.props.isUnavailableInDevMode( 'after-the-deadline' ),

copyPostSettings = (
<SettingsGroup
module={ copyPost }
Expand Down Expand Up @@ -313,47 +150,19 @@ export class Composing extends React.Component {
</ModuleToggle>
</FormFieldset>
</SettingsGroup>
),
atdSettings = (
<FoldableCard
onOpen={ this.trackOpenCard }
className={ classNames( 'jp-foldable-card__main-settings', {
'jp-foldable-settings-disable': unavailableInDevMode,
} ) }
header={
this.props.userCanManageModules ? (
<ModuleToggle
slug="after-the-deadline"
compact
disabled={ unavailableInDevMode }
activated={ this.props.getOptionValue( 'after-the-deadline' ) }
toggling={ this.props.isSavingAnyOption( 'after-the-deadline' ) }
toggleModule={ this.props.toggleModuleNow }
>
<span className="jp-form-toggle-explanation">{ atd.description }</span>
</ModuleToggle>
) : (
<span className="jp-form-toggle-explanation">{ atd.description }</span>
)
}
>
{ this.getAtdSettings() }
</FoldableCard>
);

return (
<SettingsCard
{ ...this.props }
header={ __( 'Composing', { context: 'Settings header' } ) }
hideButton={ ! foundAtD }
module="composing"
saveDisabled={ this.props.isSavingAnyOption( 'ignored_phrases' ) }
>
{ foundCopyPost && copyPostSettings }
{ foundMarkdown && markdownSettings }
{ foundLatex && latexSettings }
{ foundShortcodes && shortcodeSettings }
{ foundAtD && atdSettings }
</SettingsCard>
);
}
Expand Down
5 changes: 1 addition & 4 deletions _inc/client/writing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class Writing extends React.Component {
'masterbar',
'markdown',
'shortcodes',
'after-the-deadline',
'custom-content-types',
'post-by-email',
'infinite-scroll',
Expand All @@ -66,9 +65,7 @@ export class Writing extends React.Component {
return null;
}

const showComposing =
this.props.userCanManageModules ||
( this.props.userCanEditPosts && this.props.isModuleActivated( 'after-the-deadline' ) ),
const showComposing = this.props.userCanManageModules || this.props.userCanEditPosts,
showPostByEmail =
this.props.userCanManageModules ||
( this.props.userCanEditPosts && this.props.isModuleActivated( 'post-by-email' ) );
Expand Down
Loading