Skip to content

Commit

Permalink
esmodules: Update lib/url/support (Automattic#21510)
Browse files Browse the repository at this point in the history
* esmodules: Update lib/url/support

@see: https://github.com/Automattic/wp-calypso/milestone/224

Previously we were exporting a default object of multiple methods and
importing those through the non-spec-compliant Babel destructuring
import statements.

This patch makes those methods proper named exports in the work of
turning off CommonJS compilation.

* please eslint
  • Loading branch information
dmsnell authored Jan 16, 2018
1 parent 817a8d6 commit 9801f80
Show file tree
Hide file tree
Showing 57 changed files with 292 additions and 306 deletions.
4 changes: 2 additions & 2 deletions client/account-recovery/lost-password-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { identity, noop } from 'lodash';
/**
* Internal dependencies
*/
import support from 'lib/url/support';
import { ACCOUNT_RECOVERY } from 'lib/url/support';
import Card from 'components/card';
import FormButton from 'components/button';
import FormLabel from 'components/forms/form-label';
Expand Down Expand Up @@ -73,7 +73,7 @@ export class LostPasswordFormComponent extends Component {
<p>
{ translate(
'Want more help? We have a full {{link}}guide to resetting your password{{/link}}.',
{ components: { link: <a href={ support.ACCOUNT_RECOVERY } /> } }
{ components: { link: <a href={ ACCOUNT_RECOVERY } /> } }
) }
</p>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { identity } from 'lodash';
/**
* Internal dependencies
*/
import support from 'lib/url/support';
import { ACCOUNT_RECOVERY } from 'lib/url/support';
import Card from 'components/card';
import Button from 'components/button';
import FormLabel from 'components/forms/form-label';
Expand Down Expand Up @@ -52,7 +52,7 @@ export class TransactionIdFormComponent extends Component {
{
components: {
strong: <strong />,
helpLink: <a href={ support.ACCOUNT_RECOVERY } />,
helpLink: <a href={ ACCOUNT_RECOVERY } />,
},
}
) }
Expand All @@ -66,7 +66,7 @@ export class TransactionIdFormComponent extends Component {
'{{helpLink}}Need help to find your transaction id?{{/helpLink}}',
{
components: {
helpLink: <a href={ support.ACCOUNT_RECOVERY } />,
helpLink: <a href={ ACCOUNT_RECOVERY } />,
},
}
) }
Expand Down
10 changes: 3 additions & 7 deletions client/blocks/credit-card-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import notices from 'notices';
import { validateCardDetails } from 'lib/credit-card-details';
import ValidationErrorList from 'notices/validation-error-list';
import wpcomFactory from 'lib/wp';
import support from 'lib/url/support';
import { AUTO_RENEWAL, MANAGE_PURCHASES } from 'lib/url/support';

const wpcom = wpcomFactory.undocumented();

Expand Down Expand Up @@ -289,14 +289,10 @@ const CreditCardForm = createReactClass( {
<a href="//wordpress.com/tos/" target="_blank" rel="noopener noreferrer" />
),
autoRenewalSupportPage: (
<a href={ support.AUTO_RENEWAL } target="_blank" rel="noopener noreferrer" />
<a href={ AUTO_RENEWAL } target="_blank" rel="noopener noreferrer" />
),
managePurchasesSupportPage: (
<a
href={ support.MANAGE_PURCHASES }
target="_blank"
rel="noopener noreferrer"
/>
<a href={ MANAGE_PURCHASES } target="_blank" rel="noopener noreferrer" />
),
},
}
Expand Down
6 changes: 3 additions & 3 deletions client/components/domains/transfer-domain-step/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { composeAnalytics, recordGoogleEvent, recordTracksEvent } from 'state/an
import { getSelectedSite } from 'state/ui/selectors';
import FormTextInputWithAffixes from 'components/forms/form-text-input-with-affixes';
import TransferDomainPrecheck from './transfer-domain-precheck';
import support from 'lib/url/support';
import { INCOMING_DOMAIN_TRANSFER, MAP_EXISTING_DOMAIN } from 'lib/url/support';
import HeaderCake from 'components/header-cake';
import Button from 'components/button';

Expand Down Expand Up @@ -132,7 +132,7 @@ class TransferDomainStep extends React.Component {
components: {
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER }
href={ INCOMING_DOMAIN_TRANSFER }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -179,7 +179,7 @@ class TransferDomainStep extends React.Component {
) }
<a
className="transfer-domain-step__map-help"
href={ support.MAP_EXISTING_DOMAIN }
href={ MAP_EXISTING_DOMAIN }
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import Notice from 'components/notice';
import { recordTracksEvent } from 'state/analytics/actions';
import FormattedHeader from 'components/formatted-header';
import { checkInboundTransferStatus } from 'lib/domains';
import support from 'lib/url/support';
import {
CALYPSO_CONTACT,
INCOMING_DOMAIN_TRANSFER_PREPARE_AUTH_CODE,
INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY,
INCOMING_DOMAIN_TRANSFER_PREPARE_UNLOCK,
} from 'lib/url/support';
import TransferRestrictionMessage from 'components/domains/transfer-domain-step/transfer-restriction-message';

class TransferDomainPrecheck extends React.PureComponent {
Expand Down Expand Up @@ -197,7 +202,7 @@ class TransferDomainPrecheck extends React.PureComponent {
br: <br />,
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_UNLOCK }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_UNLOCK }
rel="noopener noreferrer"
target="_blank"
/>
Expand All @@ -217,7 +222,7 @@ class TransferDomainPrecheck extends React.PureComponent {
components: {
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_UNLOCK }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_UNLOCK }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -288,7 +293,7 @@ class TransferDomainPrecheck extends React.PureComponent {
br: <br />,
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -318,7 +323,7 @@ class TransferDomainPrecheck extends React.PureComponent {
strong: <strong className="transfer-domain-step__admin-email" />,
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -347,7 +352,7 @@ class TransferDomainPrecheck extends React.PureComponent {
strong: <strong className="transfer-domain-step__admin-email" />,
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_PRIVACY }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -388,7 +393,7 @@ class TransferDomainPrecheck extends React.PureComponent {
components: {
a: (
<a
href={ support.INCOMING_DOMAIN_TRANSFER_PREPARE_AUTH_CODE }
href={ INCOMING_DOMAIN_TRANSFER_PREPARE_AUTH_CODE }
rel="noopener noreferrer"
target="_blank"
/>
Expand Down Expand Up @@ -445,13 +450,7 @@ class TransferDomainPrecheck extends React.PureComponent {
'Need help? {{a}}Get in touch with one of our Happiness Engineers{{/a}}.',
{
components: {
a: (
<a
href={ support.CALYPSO_CONTACT }
rel="noopener noreferrer"
target="_blank"
/>
),
a: <a href={ CALYPSO_CONTACT } rel="noopener noreferrer" target="_blank" />,
},
}
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import page from 'page';
import Button from 'components/button';
import Card from 'components/card';
import FormattedHeader from 'components/formatted-header';
import support from 'lib/url/support';
import { MAP_EXISTING_DOMAIN } from 'lib/url/support';
import paths from 'my-sites/domains/paths';

class TransferRestrictionMessage extends React.PureComponent {
Expand Down Expand Up @@ -62,7 +62,7 @@ class TransferRestrictionMessage extends React.PureComponent {
'{{a}}Learn how{{/a}}.',
{
components: {
a: <a href={ support.MAP_EXISTING_DOMAIN } rel="noopener noreferrer" target="_blank" />,
a: <a href={ MAP_EXISTING_DOMAIN } rel="noopener noreferrer" target="_blank" />,
},
}
);
Expand Down
15 changes: 10 additions & 5 deletions client/components/happiness-support/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { localize } from 'i18n-calypso';
*/
import Button from 'components/button';
import isHappychatAvailable from 'state/happychat/selectors/is-happychat-available';
import support from 'lib/url/support';
import {
CALYPSO_CONTACT,
JETPACK_CONTACT_SUPPORT,
JETPACK_SUPPORT,
SUPPORT_ROOT,
} from 'lib/url/support';
import HappychatButton from 'components/happychat/button';
import HappychatConnection from 'components/happychat/connection-connected';
import { recordTracksEvent } from 'state/analytics/actions';
Expand Down Expand Up @@ -86,11 +91,11 @@ export class HappinessSupport extends Component {
}

renderContactButton() {
let url = support.CALYPSO_CONTACT,
let url = CALYPSO_CONTACT,
target = '';

if ( this.props.isJetpack ) {
url = support.JETPACK_CONTACT_SUPPORT;
url = JETPACK_CONTACT_SUPPORT;
target = '_blank';
}

Expand Down Expand Up @@ -122,10 +127,10 @@ export class HappinessSupport extends Component {
}

renderSupportButton() {
let url = support.SUPPORT_ROOT;
let url = SUPPORT_ROOT;

if ( this.props.isJetpack ) {
url = support.JETPACK_SUPPORT;
url = JETPACK_SUPPORT;
}

return (
Expand Down
15 changes: 10 additions & 5 deletions client/components/happiness-support/test/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import { spy } from 'sinon';
import { HappinessSupport } from '..';
import HappychatButton from 'components/happychat/button';
import HappychatConnection from 'components/happychat/connection-connected';
import support from 'lib/url/support';
import {
CALYPSO_CONTACT,
JETPACK_CONTACT_SUPPORT,
JETPACK_SUPPORT,
SUPPORT_ROOT,
} from 'lib/url/support';

describe( 'HappinessSupport', () => {
let wrapper;
Expand Down Expand Up @@ -51,7 +56,7 @@ describe( 'HappinessSupport', () => {
<HappinessSupport translate={ translate } recordTracksEvent={ noop } isJetpack={ false } />
);
expect( wrapper.find( 'Button.happiness-support__support-button' ).props().href ).to.equal(
support.SUPPORT_ROOT
SUPPORT_ROOT
);
} );

Expand All @@ -64,7 +69,7 @@ describe( 'HappinessSupport', () => {
.find( 'Button' )
.last()
.prop( 'href' )
).to.equal( support.JETPACK_SUPPORT );
).to.equal( JETPACK_SUPPORT );
} );

test( 'should have is-placeholder className only if it is a placeholder', () => {
Expand Down Expand Up @@ -213,12 +218,12 @@ describe( 'HappinessSupport', () => {

test( 'should be rendered with link to CALYPSO_CONTACT if it is not for JetPack', () => {
wrapper = shallow( <HappinessSupport { ...props } /> );
expect( wrapper.find( selector ).prop( 'href' ) ).to.equal( support.CALYPSO_CONTACT );
expect( wrapper.find( selector ).prop( 'href' ) ).to.equal( CALYPSO_CONTACT );
} );

test( 'should be rendered with link to JETPACK_CONTACT_SUPPORT if it is for JetPack', () => {
wrapper = shallow( <HappinessSupport { ...props } isJetpack={ true } /> );
expect( wrapper.find( selector ).prop( 'href' ) ).to.equal( support.JETPACK_CONTACT_SUPPORT );
expect( wrapper.find( selector ).prop( 'href' ) ).to.equal( JETPACK_CONTACT_SUPPORT );
} );

test( 'should render translated content', () => {
Expand Down
17 changes: 9 additions & 8 deletions client/lib/domains/registration/availability-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { translate } from 'i18n-calypso';
* Internal dependencies
*/
import { getTld } from 'lib/domains';
import support from 'lib/url/support';
import {
CALYPSO_CONTACT,
INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS,
MAP_EXISTING_DOMAIN,
} from 'lib/url/support';
import { domainAvailability } from 'lib/domains/constants';
import {
domainManagementTransferToOtherSite,
Expand Down Expand Up @@ -92,7 +96,7 @@ function getAvailabilityNotice( domain, error, site ) {
args: { domain, site },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ support.CALYPSO_CONTACT } />,
a: <a rel="noopener noreferrer" href={ CALYPSO_CONTACT } />,
},
}
);
Expand All @@ -118,10 +122,7 @@ function getAvailabilityNotice( domain, error, site ) {
components: {
strong: <strong />,
a: (
<a
rel="noopener noreferrer"
href={ support.INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS }
/>
<a rel="noopener noreferrer" href={ INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS } />
),
},
}
Expand All @@ -136,7 +137,7 @@ function getAvailabilityNotice( domain, error, site ) {
args: { tld },
components: {
strong: <strong />,
a: <a rel="noopener noreferrer" href={ support.MAP_EXISTING_DOMAIN } />,
a: <a rel="noopener noreferrer" href={ MAP_EXISTING_DOMAIN } />,
},
}
);
Expand Down Expand Up @@ -183,7 +184,7 @@ function getAvailabilityNotice( domain, error, site ) {
href="http://wordpressfoundation.org/trademark-policy/"
/>
),
a2: <a href={ support.CALYPSO_CONTACT } />,
a2: <a href={ CALYPSO_CONTACT } />,
},
}
);
Expand Down
Loading

0 comments on commit 9801f80

Please sign in to comment.