diff --git a/components/x-gift-article/__tests__/x-gift-article.test.jsx b/components/x-gift-article/__tests__/x-gift-article.test.jsx index da88a3ac7..57c491708 100644 --- a/components/x-gift-article/__tests__/x-gift-article.test.jsx +++ b/components/x-gift-article/__tests__/x-gift-article.test.jsx @@ -1,8 +1,9 @@ -const fetchMock = require('fetch-mock') -const { h } = require('@financial-times/x-engine') -const { mount } = require('@financial-times/x-test-utils/enzyme') +import fetchMock from 'fetch-mock' +import { h } from '@financial-times/x-engine' +import { mount } from '@financial-times/x-test-utils/enzyme' +import { ShareArticleModal } from '../dist/GiftArticle.cjs' -const { GiftArticle } = require('../dist/GiftArticle.cjs.js') +jest.mock('@financial-times/o-share', () => jest.fn()) const articleId = 'article id' const articleUrl = 'https://www.ft.com/content/blahblahblah' @@ -10,13 +11,14 @@ const articleUrlRedeemed = 'https://gift-url-redeemed' const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` const baseArgs = { - title: 'Title', + title: 'Share this article:', isFreeArticle: false, article: { - title: 'Article Title Blah Blah Blah', id: articleId, - url: articleUrl + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' }, + id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` } @@ -27,70 +29,55 @@ describe('x-gift-article', () => { actions = {} fetchMock - .get('/article/gift-credits', { + .get('path:/article/gift-credits', { allowance: 20, consumedCredits: 5, remainingCredits: 15, renewalDate: '2018-08-01T00:00:00Z' }) - .get(`/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { shortenedUrl: 'https://shortened-gift-url' }) - .get(`/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { shortenedUrl: 'https://shortened-non-gift-url' }) - .get(`/article/gift-link/${encodeURIComponent(articleId)}`, { + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, remainingAllowance: 1 }) - .get('https://enterprise-sharing-api.ft.com/v1/users/me/allowance', { + .get('path:/v1/users/me/allowance', { limit: 120, hasCredits: true, - firstTimeUser: true + firstTimeUser: false }) - .post('https://enterprise-sharing-api.ft.com/v1/shares', { + .post('path:/v1/shares', { url: articleUrlRedeemed, redeemLimit: 120 }) + .post('path:/v1/copy-annotations', { + annotationsCopyResult: [] + }) }) afterEach(() => { fetchMock.reset() }) - it('displays the correct title', async () => { + it('displays the article title', async () => { const args = { - ...baseArgs, - title: 'A given test title' + ...baseArgs } - const subject = mount() - - expect(subject.find('h2').text()).toEqual('A given test title') - }) + args.article.title = 'A given test article title' - it('displays the mobile share links when showMobileShareLinks is true', async () => { - const args = { - ...baseArgs, - showMobileShareLinks: true - } - const subject = mount() + const subject = mount() - expect(subject.find('div.x-gift-article-mobile-share-buttons').length).toEqual(1) - }) - - it('does not display the mobile share links when showMobileShareLinks is false', async () => { - const args = { - ...baseArgs, - showMobileShareLinks: false - } - const subject = mount() - - expect(subject.find('div.x-gift-article-mobile-share-buttons').length).toEqual(0) + expect(subject.find('h2').text()).toEqual('A given test article title') }) it('should call correct endpoints on activate', async () => { - mount( Object.assign(actions, a)} />) + mount( Object.assign(actions, a)} />) await actions.activate() @@ -100,126 +87,106 @@ describe('x-gift-article', () => { expect(fetchMock.called('/article/gift-credits')).toBe(true) }) - it('should call showGiftUrlSection and show correct html element', async () => { - const subject = mount( Object.assign(actions, a)} />) + it('should call shortenNonGiftUrl and display correct url', async () => { + const subject = mount( Object.assign(actions, a)} />) - await actions.activate() + await actions.showNonGiftUrlSection() + await actions.shortenNonGiftUrl() - expect(actions.showGiftUrlSection).toBeDefined() - await actions.showGiftUrlSection() subject.update() - expect(subject.find('div[data-section-id="giftLink"]')).toHaveLength(1) + const input = subject.find('input#share-link') + expect(input.prop('value')).toEqual('https://shortened-non-gift-url') }) - it('should call showEnterpriseUrlSection and show correct html element', async () => { - const subject = mount( Object.assign(actions, a)} />) + it('should call createGiftUrl and display correct url', async () => { + const subject = mount( Object.assign(actions, a)} />) - await actions.activate() + await actions.createGiftUrl() - expect(actions.showEnterpriseUrlSection).toBeDefined() - await actions.showEnterpriseUrlSection() subject.update() - expect(subject.find('div[data-section-id="enterpriseLink"]')).toHaveLength(1) - }) - - it('enterpriseLink radio button is not shown for non-enterprise users', async () => { - const args = { - ...baseArgs, - enterpriseApiBaseUrl: undefined - } - - const subject = mount( Object.assign(actions, a)} />) + const input = subject.find('input#share-link') - expect(subject.find('input#enterpriseLink')).toHaveLength(0) - expect(subject.find('input#giftLink')).toHaveLength(1) - expect(subject.find('input#nonGiftLink')).toHaveLength(1) + expect(input.prop('value')).toEqual('https://shortened-gift-url') }) - it('should call showNonGiftUrlSection and show correct html element', async () => { - const subject = mount( Object.assign(actions, a)} />) - await actions.activate() - - expect(actions.showNonGiftUrlSection).toBeDefined() - await actions.showNonGiftUrlSection() + it('should call createEnterpriseUrl and display correct url', async () => { + const subject = mount( Object.assign(actions, a)} />) + expect(actions.createEnterpriseUrl).toBeDefined() + await actions.createEnterpriseUrl() subject.update() - expect(subject.find('div[data-section-id="nonGiftLink"]')).toHaveLength(1) + const input = subject.find('input#share-link') + expect(input.prop('value')).toEqual('https://gift-url-redeemed') }) - it('should call createGiftUrl and display correct url', async () => { - const subject = mount( Object.assign(actions, a)} />) - expect(actions.createGiftUrl).toBeDefined() - await actions.createGiftUrl() + it('when credits are available, an alert is not shown', async () => { + const subject = mount( Object.assign(actions, a)} />) + + await actions.activate() subject.update() - const input = subject.find('input#share-link') - expect(input.prop('value')).toEqual('https://shortened-gift-url') + expect(subject.find('#no-credit-alert')).not.toExist() }) - it('should call createEnterpriseUrl and display correct url', async () => { - const subject = mount( Object.assign(actions, a)} />) - expect(actions.createEnterpriseUrl).toBeDefined() - await actions.createEnterpriseUrl() + it('when no credits are available, an alert is shown', async () => { + fetchMock + .get( + 'path:/article/gift-credits', + { + allowance: 20, + consumedCredits: 20, + remainingCredits: 0, + renewalDate: '2018-08-01T00:00:00Z' + }, + { overwriteRoutes: true } + ) + .get( + 'path:/v1/users/me/allowance', + { + limit: 120, + hasCredits: false, + firstTimeUser: false + }, + { overwriteRoutes: true } + ) + + const subject = mount( Object.assign(actions, a)} />) + + await actions.activate() subject.update() - const input = subject.find('input#share-link') - expect(input.prop('value')).toEqual('https://gift-url-redeemed') + expect(subject.find('#no-credit-alert')).toExist() }) - it('when no gift-credits are available, a message is shown', async () => { - fetchMock.get( - '/article/gift-credits', - { - allowance: 20, - consumedCredits: 20, - remainingCredits: 0, - renewalDate: '2018-08-01T00:00:00Z' - }, - { overwriteRoutes: true } - ) + it('displays the social share buttons', async () => { + const subject = mount( Object.assign(actions, a)} />) - const subject = mount( Object.assign(actions, a)} />) await actions.activate() - expect(actions.showGiftUrlSection).toBeDefined() - await actions.showGiftUrlSection() + await actions.shortenNonGiftUrl() + subject.update() - expect(subject.find('input#share-link')).toHaveLength(0) - expect( - subject.find('div.x-gift-article-message').text().includes('You’ve used all your gift article credits') - ).toBe(true) + expect(subject.find('#social-share-buttons')).toExist() }) - it('when no enterprise credits are available, a message is shown', async () => { - fetchMock.get( - `https://enterprise-sharing-api.ft.com/v1/users/me/allowance`, - { - limit: 120, - hasCredits: false, - firstTimeUser: false - }, - { overwriteRoutes: true } - ) + it('should display the free article message when isFreeArticle is true', async () => { + const args = { + ...baseArgs, + isFreeArticle: true + } + const subject = mount( Object.assign(actions, a)} />) - const subject = mount( Object.assign(actions, a)} />) await actions.activate() - expect(actions.showEnterpriseUrlSection).toBeDefined() - await actions.showEnterpriseUrlSection() subject.update() - expect(subject.find('input#share-link')).toHaveLength(0) - expect( - subject - .find('div.x-gift-article-message') - .text() - .includes('Your organisation has run out of share credits') - ).toBe(true) + expect(subject.find('#free-article-alert')).toExist() + expect(subject.find('#share-with-non-subscribers-checkbox')).not.toExist() }) }) diff --git a/components/x-gift-article/package.json b/components/x-gift-article/package.json index c11a579d0..3200a5458 100644 --- a/components/x-gift-article/package.json +++ b/components/x-gift-article/package.json @@ -5,7 +5,7 @@ "main": "dist/GiftArticle.cjs.js", "browser": "dist/GiftArticle.es5.js", "module": "dist/GiftArticle.esm.js", - "style": "src/GiftArticle.scss", + "style": "src/main.scss", "scripts": { "build": "node rollup.js", "start": "node rollup.js --watch", @@ -23,10 +23,10 @@ }, "devDependencies": { "@financial-times/o-buttons": "^7.2.2", - "@financial-times/o-forms": "^9.2.3", + "@financial-times/o-forms": "^9.11.0", "@financial-times/o-labels": "^6.2.2", "@financial-times/o-loading": "^5.2.1", - "@financial-times/o-message": "^5.2.1", + "@financial-times/o-message": "^5.4.2", "@financial-times/o-normalise": "^3.2.2", "@financial-times/o-typography": "^7.4.1", "@financial-times/x-rollup": "file:../../packages/x-rollup", @@ -44,11 +44,12 @@ "@financial-times/o-banner": "^4.4.9", "@financial-times/o-buttons": "^7.2.2", "@financial-times/o-colors": "^6.6.0", - "@financial-times/o-forms": "^9.2.3", + "@financial-times/o-forms": "^9.11.0", "@financial-times/o-labels": "^6.2.2", "@financial-times/o-loading": "^5.2.1", - "@financial-times/o-message": "^5.2.1", + "@financial-times/o-message": "^5.4.2", "@financial-times/o-normalise": "^3.2.2", + "@financial-times/o-share": "^9.0.2", "@financial-times/o-typography": "^7.4.1" } } diff --git a/components/x-gift-article/readme.md b/components/x-gift-article/readme.md index 66d837a28..c304ba5c1 100644 --- a/components/x-gift-article/readme.md +++ b/components/x-gift-article/readme.md @@ -75,7 +75,6 @@ Property | Type | Required | Note --------------------------|---------|----------|---- `isFreeArticle` | Boolean | yes | Only non gift form is displayed when this value is `true`. `article` | Object | yes | Must contain `id`, `title` and `url` properties -`showMobileShareLinks` | Boolean | no | For ft.com on mobile sharing. `nativeShare` | Boolean | no | This is a property for App to display Native Sharing. `apiProtocol` | String | no | The protocol to use when making requests to the gift article and URL shortening services. Ignored if `apiDomain` is not set. `apiDomain` | String | no | The domain to use when making requests to the gift article and URL shortening services. diff --git a/components/x-gift-article/src/CopyConfirmation.jsx b/components/x-gift-article/src/CopyConfirmation.jsx index 39e5bd2cd..d759a57c6 100644 --- a/components/x-gift-article/src/CopyConfirmation.jsx +++ b/components/x-gift-article/src/CopyConfirmation.jsx @@ -1,14 +1,18 @@ import { h } from '@financial-times/x-engine' -export default ({ hideCopyConfirmation }) => ( +export default ({ hideCopyConfirmation, isArticleSharingUxUpdates }) => ( - The link has been copied to your clipboard + {isArticleSharingUxUpdates ? ( + Link copied to clipboard. + ) : ( + Link copied to clipboard. + )} diff --git a/components/x-gift-article/src/Form.jsx b/components/x-gift-article/src/Form.jsx index 48f908b2d..c514dff40 100644 --- a/components/x-gift-article/src/Form.jsx +++ b/components/x-gift-article/src/Form.jsx @@ -29,7 +29,7 @@ export default (props) => ( shareType={props.shareType} hasHighlights={props.hasHighlights} includeHighlights={props.includeHighlights} - includeHighlightsHandler={props.actions.includeHighlightsHandler} + setIncludeHighlights={props.actions.setIncludeHighlights} isGiftUrlCreated={props.isGiftUrlCreated} saveHighlightsHandler={props.actions.saveHighlightsHandler} showHighlightsRecipientMessage={props.showHighlightsRecipientMessage} @@ -60,6 +60,6 @@ export default (props) => ( )} - {props.showMobileShareLinks && } + ) diff --git a/components/x-gift-article/src/GiftArticle.jsx b/components/x-gift-article/src/GiftArticle.jsx index afd065cd1..04ebe095f 100644 --- a/components/x-gift-article/src/GiftArticle.jsx +++ b/components/x-gift-article/src/GiftArticle.jsx @@ -2,7 +2,6 @@ import { h } from '@financial-times/x-engine' import { withActions } from '@financial-times/x-interaction' import Loading from './Loading' -import Form from './Form' import ApiClient from './lib/api' import EnterpriseApiClient from './lib/enterpriseApi' @@ -10,6 +9,8 @@ import { copyToClipboard, createMailtoUrl } from './lib/share-link-actions' import tracking from './lib/tracking' import * as updaters from './lib/updaters' import { ShareType } from './lib/constants' +import ShareArticleDialog from './v2/ShareArticleDialog' +import Form from './Form' const isCopySupported = typeof document !== 'undefined' && document.queryCommandSupported && document.queryCommandSupported('copy') @@ -32,19 +33,15 @@ const withGiftFormActions = withActions( }, showNonGiftUrlSection() { - return async (state) => { - const update = updaters.showNonGiftUrlSection(state) - - if (!state.isNonGiftUrlShortened) { - const { url, isShortened } = await api.getShorterUrl(state.urls.nonGift) + return updaters.showNonGiftUrlSection + }, - if (isShortened) { - Object.assign(update, updaters.setShortenedNonGiftUrl(url)(state)) - } - } + showAdvancedSharingOptions() { + return updaters.showAdvancedSharingOptions + }, - return update - } + hideAdvancedSharingOptions() { + return updaters.hideAdvancedSharingOptions }, async createGiftUrl() { @@ -60,6 +57,23 @@ const withGiftFormActions = withActions( } }, + async shortenNonGiftUrl() { + return async (state) => { + if (state.isNonGiftUrlShortened) { + state.showFreeArticleAlert = false + return state + } + const { url, isShortened } = await api.getShorterUrl(state.urls.nonGift) + tracking.createNonGiftLink(url, state.urls.nonGift) + + if (isShortened) { + return updaters.setShortenedNonGiftUrl(url)(state) + } else { + return updaters.setErrorState(true) + } + } + }, + async createEnterpriseUrl() { return async (state) => { const { redemptionUrl, redemptionLimit } = await enterpriseApi.getESUrl( @@ -161,15 +175,17 @@ const withGiftFormActions = withActions( if (initialProps.isFreeArticle) { const { url, isShortened } = await api.getShorterUrl(state.urls.nonGift) - - if (isShortened) { - updaters.setShortenedNonGiftUrl(url)(state) - } - return { + const freeArticleState = { invalidResponseFromApi: true, enterpriseEnabled: enabled, ...enterpriseState } + + if (isShortened) { + Object.assign(freeArticleState, updaters.setShortenedNonGiftUrl(url)(state)) + freeArticleState.showFreeArticleAlert = true + } + return freeArticleState } else { const { giftCredits, monthlyAllowance, nextRenewalDate } = await api.getGiftArticleAllowance() @@ -177,7 +193,7 @@ const withGiftFormActions = withActions( if (giftCredits > 0 || giftCredits === 0) { return { ...updaters.setAllowance(giftCredits, monthlyAllowance, nextRenewalDate), - shareType: enabled && hasCredits ? ShareType.enterprise : ShareType.gift, + shareType: ShareType.nonGift, enterpriseEnabled: enabled, ...enterpriseState } @@ -191,9 +207,8 @@ const withGiftFormActions = withActions( } } }, - includeHighlightsHandler() { + setIncludeHighlights(includeHighlights) { return (state) => { - const includeHighlights = !state.includeHighlights state.includeHighlights = includeHighlights return { includeHighlights } } @@ -231,7 +246,7 @@ const withGiftFormActions = withActions( }, (props) => { const initialState = { - title: 'Share this article', + title: 'Share this article:', giftCredits: undefined, monthlyAllowance: undefined, showCopyButton: isCopySupported, @@ -239,6 +254,7 @@ const withGiftFormActions = withActions( isGiftUrlShortened: false, isNonGiftUrlShortened: false, includeHighlights: false, + showAdvancedSharingOptions: false, hasHighlights: false, showHighlightsRecipientMessage: new URL(location.href).searchParams.has('highlights'), showHighlightsSuccessMessage: false, @@ -257,22 +273,21 @@ const withGiftFormActions = withActions( nonGift: createMailtoUrl(props.article.title, `${props.article.url}?shareType=nongift`) }, - mobileShareLinks: props.showMobileShareLinks - ? { - facebook: `http://www.facebook.com/sharer.php?u=${encodeURIComponent( - props.article.url - )}&t=${encodeURIComponent(props.article.title)}`, - twitter: `https://twitter.com/intent/tweet?url=${encodeURIComponent( - props.article.url - )}&text=${encodeURIComponent(props.article.title)}&via=financialtimes`, - linkedin: `http://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent( - props.article.url - )}&title=${encodeURIComponent(props.article.title)}&source=Financial+Times`, - whatsapp: `whatsapp://send?text=${encodeURIComponent( - props.article.title - )}%20-%20${encodeURIComponent(props.article.url)}` - } - : undefined + mobileShareLinks: { + facebook: `http://www.facebook.com/sharer.php?u=${encodeURIComponent( + props.article.url + )}&t=${encodeURIComponent(props.article.title)}`, + twitter: `https://twitter.com/intent/tweet?url=${encodeURIComponent( + props.article.url + )}&text=${encodeURIComponent(props.article.title)}&via=financialtimes`, + linkedin: `http://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent( + props.article.url + )}&title=${encodeURIComponent(props.article.title)}&source=Financial+Times`, + whatsapp: `whatsapp://send?text=${encodeURIComponent(props.article.title)}%20-%20${encodeURIComponent( + props.article.url + )}` + }, + showFreeArticleAlert: false } const expandedProps = Object.assign({}, props, initialState) @@ -288,6 +303,12 @@ const BaseGiftArticle = (props) => { return props.isLoading ? : } +const BaseShareArticleModal = (props) => { + return +} + const GiftArticle = withGiftFormActions(BaseGiftArticle) -export { GiftArticle } +const ShareArticleModal = withGiftFormActions(BaseShareArticleModal) + +export { GiftArticle, ShareArticleModal } diff --git a/components/x-gift-article/src/HighlightCheckbox.jsx b/components/x-gift-article/src/HighlightCheckbox.jsx index 7eb09563a..b25b1db5f 100644 --- a/components/x-gift-article/src/HighlightCheckbox.jsx +++ b/components/x-gift-article/src/HighlightCheckbox.jsx @@ -1,6 +1,6 @@ import { h } from '@financial-times/x-engine' -export default ({ includeHighlightsHandler, includeHighlights, isGiftUrlCreated }) => { +export default ({ setIncludeHighlights, includeHighlights, isGiftUrlCreated }) => { return ( @@ -10,7 +10,7 @@ export default ({ includeHighlightsHandler, includeHighlights, isGiftUrlCreated name="includeHighlights" value={includeHighlights} checked={includeHighlights} - onChange={includeHighlightsHandler} + onChange={(event) => setIncludeHighlights(event.target.checked)} disabled={isGiftUrlCreated} data-trackable="make-highlights-visible" /> diff --git a/components/x-gift-article/src/HighlightSection.jsx b/components/x-gift-article/src/HighlightSection.jsx index 3b7bb3e8b..30392e495 100644 --- a/components/x-gift-article/src/HighlightSection.jsx +++ b/components/x-gift-article/src/HighlightSection.jsx @@ -10,7 +10,7 @@ const USER_ANNOTATIONS_API = `https://enterprise-user-annotations-api.ft.com/v1` export default ({ shareType, includeHighlights, - includeHighlightsHandler, + setIncludeHighlights, isGiftUrlCreated, hasHighlights, saveHighlightsHandler, @@ -56,7 +56,7 @@ export default ({ {showHighlightsCheckbox ? ( ) : null} diff --git a/components/x-gift-article/src/lib/tracking.js b/components/x-gift-article/src/lib/tracking.js index a1e6a0267..0f3248116 100644 --- a/components/x-gift-article/src/lib/tracking.js +++ b/components/x-gift-article/src/lib/tracking.js @@ -25,6 +25,15 @@ module.exports = { link }), + createNonGiftLink: (link, longUrl) => + dispatchEvent({ + category: 'gift-link', + action: 'create', + linkType: 'nonGiftLink', + link, + longUrl + }), + initEnterpriseSharing: (status) => dispatchEvent({ category: 'gift-link', diff --git a/components/x-gift-article/src/lib/updaters.js b/components/x-gift-article/src/lib/updaters.js index 44a64e21b..bf7fdff75 100644 --- a/components/x-gift-article/src/lib/updaters.js +++ b/components/x-gift-article/src/lib/updaters.js @@ -46,6 +46,15 @@ export const showNonGiftUrlSection = (props) => ({ invalidResponseFromApi: false }) +export const showAdvancedSharingOptions = () => ({ + showAdvancedSharingOptions: true +}) + +export const hideAdvancedSharingOptions = (props) => ({ + ...showNonGiftUrlSection(props), + showAdvancedSharingOptions: false +}) + export const setGiftUrl = (url, redemptionLimit, isShortened, isEnterprise = false) => (props) => { diff --git a/components/x-gift-article/src/main.scss b/components/x-gift-article/src/main.scss new file mode 100644 index 000000000..fac9c48a9 --- /dev/null +++ b/components/x-gift-article/src/main.scss @@ -0,0 +1,2 @@ +@import "GiftArticle.scss"; +@import "./v2/ShareArticleDialog.scss"; diff --git a/components/x-gift-article/src/v2/AdvancedSharingBanner.jsx b/components/x-gift-article/src/v2/AdvancedSharingBanner.jsx new file mode 100644 index 000000000..875b5b556 --- /dev/null +++ b/components/x-gift-article/src/v2/AdvancedSharingBanner.jsx @@ -0,0 +1,10 @@ +import { h } from '@financial-times/x-engine' +export const AdvancedSharingBanner = ({ enterpriseEnabled, enterpriseRequestAccess }) => { + // show banner only if user is b2b and has advanced sharing enabled + return enterpriseEnabled && !enterpriseRequestAccess ? ( + + + Advanced Sharing + + ) : null +} diff --git a/components/x-gift-article/src/v2/AdvancedSharingOptions.jsx b/components/x-gift-article/src/v2/AdvancedSharingOptions.jsx new file mode 100644 index 000000000..33eca9764 --- /dev/null +++ b/components/x-gift-article/src/v2/AdvancedSharingOptions.jsx @@ -0,0 +1,91 @@ +import { h } from '@financial-times/x-engine' +import { ShareType } from '../lib/constants' +import { NoCreditAlert } from './NoCreditAlert' +import { ReceivedHighlightsAlert } from './ReceivedHighlightsAlert' + +export const AdvancedSharingOptions = (props) => { + const { + shareType, + actions, + showHighlightsCheckbox, + includeHighlights, + enterpriseHasCredits, + giftCredits, + showHighlightsRecipientMessage + } = props + const onValueChange = (event) => { + if (event.target.value === ShareType.enterprise) { + actions.showEnterpriseUrlSection(event) + } else if (event.target.value === ShareType.gift) { + actions.showGiftUrlSection(event) + actions.setIncludeHighlights(false) + } + } + + const includeHighlightsHandler = (event) => { + actions.setIncludeHighlights(event.target.checked) + } + + return ( + + + + + + + Multiple people + + + + One person + + + + + {(!giftCredits || !enterpriseHasCredits) && ( + + One of the non-subscriber choices is not available because you’ve run out of credits. Please use the + other option. + + )} + {showHighlightsRecipientMessage && } + {showHighlightsCheckbox && ( + + + + Include highlights + + + )} + + ) +} diff --git a/components/x-gift-article/src/v2/CreateLinkButton.jsx b/components/x-gift-article/src/v2/CreateLinkButton.jsx new file mode 100644 index 000000000..27218c025 --- /dev/null +++ b/components/x-gift-article/src/v2/CreateLinkButton.jsx @@ -0,0 +1,32 @@ +import { h } from '@financial-times/x-engine' +import { ShareType } from '../lib/constants' +import oShare from '@financial-times/o-share/main' + +export const CreateLinkButton = ({ shareType, actions, enterpriseEnabled }) => { + const createLinkHandler = async () => { + switch (shareType) { + case ShareType.gift: + await actions.createGiftUrl() + break + case ShareType.nonGift: + await actions.shortenNonGiftUrl() + break + case ShareType.enterprise: + await actions.createEnterpriseUrl() + break + default: + } + new oShare(document.querySelector('#social-share-buttons')) + } + return ( + + Create link + + ) +} diff --git a/components/x-gift-article/src/v2/Footer.jsx b/components/x-gift-article/src/v2/Footer.jsx new file mode 100644 index 000000000..0e4b1001a --- /dev/null +++ b/components/x-gift-article/src/v2/Footer.jsx @@ -0,0 +1,10 @@ +import { h } from '@financial-times/x-engine' +import { FooterMessage } from './FooterMessage' + +export const Footer = (props) => { + return ( + + ) +} diff --git a/components/x-gift-article/src/v2/FooterMessage.jsx b/components/x-gift-article/src/v2/FooterMessage.jsx new file mode 100644 index 000000000..ef89ee540 --- /dev/null +++ b/components/x-gift-article/src/v2/FooterMessage.jsx @@ -0,0 +1,107 @@ +import { h } from '@financial-times/x-engine' +import { ShareType } from '../lib/constants' + +export const FooterMessage = ({ + shareType, + isGiftUrlCreated, + redemptionLimit, + enterpriseLimit, + giftCredits, + isNonGiftUrlShortened, + enterpriseEnabled, + enterpriseRequestAccess, + includeHighlights, + isFreeArticle, + showFreeArticleAlert +}) => { + // if the share link button has not been clicked yet + if (!(isGiftUrlCreated || isNonGiftUrlShortened)) { + // when the user is b2b and has advanced sharing enabled + if (enterpriseEnabled && !enterpriseRequestAccess) { + return ( + + + Tell me more about Advanced Sharing + + + ) + } + + return enterpriseEnabled ? ( // when the user is b2b + + Send to multiple people with{' '} + + Advanced Sharing + + + ) : null // when the user is b2c + } + + // when the share link has been created + + if (isFreeArticle) { + return !showFreeArticleAlert ? ( + + Anyone will be able to see the full article using this link. + + ) : null + } + + if (shareType === ShareType.gift) { + const redemptionLimitUnit = redemptionLimit === 1 ? 'time' : 'times' + const creditUnit = giftCredits === 1 ? 'credit' : 'credits' + const redemptionLimitMessage = `Link can be viewed ${redemptionLimit} ${redemptionLimitUnit} and is valid for 90 days.` + const creditsMessage = `You still have ${giftCredits} ${creditUnit} left this month.` + + return ( + + {redemptionLimitMessage} + {creditsMessage} + + ) + } + + if (shareType === ShareType.nonGift) { + return ( + + Only FT subscribers will be able to see the full article using this link. + + ) + } + + if (shareType === ShareType.enterprise) { + const advancedSharingLimitUnit = enterpriseLimit === 1 ? 'time' : 'times' + const advancedSharingLimitMessage = `Link can be viewed ${enterpriseLimit} ${advancedSharingLimitUnit}. ${ + includeHighlights ? 'Your highlights will be visible to recipients.' : '' + }` + + return ( + + {advancedSharingLimitMessage} + + We’ve added this link to your list.{' '} + + See all shared links + + + + ) + } + + return null +} diff --git a/components/x-gift-article/src/v2/FreeArticleAlert.jsx b/components/x-gift-article/src/v2/FreeArticleAlert.jsx new file mode 100644 index 000000000..2a5b68d6a --- /dev/null +++ b/components/x-gift-article/src/v2/FreeArticleAlert.jsx @@ -0,0 +1,21 @@ +import { h } from '@financial-times/x-engine' + +export const FreeArticleAlert = () => { + return ( + + + + + This is one of our free articles + + Even non-subscribers can read it, without using up your sharing credits. + + + + + ) +} diff --git a/components/x-gift-article/src/v2/GiftLinkSection.jsx b/components/x-gift-article/src/v2/GiftLinkSection.jsx new file mode 100644 index 000000000..1a8f0bfe0 --- /dev/null +++ b/components/x-gift-article/src/v2/GiftLinkSection.jsx @@ -0,0 +1,26 @@ +import { h } from '@financial-times/x-engine' +import { SharedLinkTypeSelector } from './SharedLinkTypeSelector' +import { ShareType } from '../lib/constants' +import { UrlSection } from './UrlSection' +import { CreateLinkButton } from './CreateLinkButton' +import { FreeArticleAlert } from './FreeArticleAlert' + +export const GiftLinkSection = (props) => { + const { isGiftUrlCreated, shareType, isNonGiftUrlShortened, showFreeArticleAlert } = props + + // when the gift url is created or the non-gift url is shortened, show the url section + if ( + isGiftUrlCreated || + (shareType === ShareType.nonGift && isNonGiftUrlShortened && !showFreeArticleAlert) + ) { + return + } + + return ( + + {showFreeArticleAlert && } + {!showFreeArticleAlert && } + + + ) +} diff --git a/components/x-gift-article/src/v2/Header.jsx b/components/x-gift-article/src/v2/Header.jsx new file mode 100644 index 000000000..783dcd403 --- /dev/null +++ b/components/x-gift-article/src/v2/Header.jsx @@ -0,0 +1,31 @@ +import { h } from '@financial-times/x-engine' +import { ShareType } from '../lib/constants' + +export const Header = ({ + title, + article, + isGiftUrlCreated, + shareType, + isNonGiftUrlShortened, + showFreeArticleAlert +}) => { + // when a gift link is created or shortened, the title is "Sharing link" + if ( + isGiftUrlCreated || + (shareType === ShareType.nonGift && isNonGiftUrlShortened && !showFreeArticleAlert) + ) { + return ( + + Sharing link + + ) + } + + // when a gift link is not created, the title should be "Share this article:" + return ( + + {title} + {article.title} + + ) +} diff --git a/components/x-gift-article/src/v2/NoCreditAlert.jsx b/components/x-gift-article/src/v2/NoCreditAlert.jsx new file mode 100644 index 000000000..803e86650 --- /dev/null +++ b/components/x-gift-article/src/v2/NoCreditAlert.jsx @@ -0,0 +1,17 @@ +import { h } from '@financial-times/x-engine' + +export const NoCreditAlert = ({ children }) => { + return ( + + + + {children} + + + + ) +} diff --git a/components/x-gift-article/src/v2/ReceivedHighlightsAlert.jsx b/components/x-gift-article/src/v2/ReceivedHighlightsAlert.jsx new file mode 100644 index 000000000..bd45aa5b7 --- /dev/null +++ b/components/x-gift-article/src/v2/ReceivedHighlightsAlert.jsx @@ -0,0 +1,44 @@ +import { h } from '@financial-times/x-engine' +import HighlightsApiClient from '../lib/highlightsApi' + +export const ReceivedHighlightsAlert = ({ actions }) => { + const handleSaveAnnotations = async (event) => { + event.preventDefault() + const url = new URL(location.href) + const params = new URLSearchParams(url.search) + const highlightsToken = params.get('highlights') + const highlightsAPIClient = new HighlightsApiClient('https://enterprise-user-annotations-api.ft.com/v1') + const { annotationsCopyResult } = await highlightsAPIClient.copySharedHighlights(highlightsToken) + + if (annotationsCopyResult) { + actions.saveHighlightsHandler() + } + } + + return ( + + + + + If you wish to share the article with the highlights, you need to{' '} + {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} + + save the highlights + {' '} + first. + + + + + + ) +} diff --git a/components/x-gift-article/src/v2/ShareArticleDialog.jsx b/components/x-gift-article/src/v2/ShareArticleDialog.jsx new file mode 100644 index 000000000..9c5309b72 --- /dev/null +++ b/components/x-gift-article/src/v2/ShareArticleDialog.jsx @@ -0,0 +1,19 @@ +import { h } from '@financial-times/x-engine' +import { Header } from './Header' +import { GiftLinkSection } from './GiftLinkSection' +import { Footer } from './Footer' +import { AdvancedSharingBanner } from './AdvancedSharingBanner' + +export default (props) => { + return ( + + + + + + + + + + ) +} diff --git a/components/x-gift-article/src/v2/ShareArticleDialog.scss b/components/x-gift-article/src/v2/ShareArticleDialog.scss new file mode 100644 index 000000000..fa191b6fa --- /dev/null +++ b/components/x-gift-article/src/v2/ShareArticleDialog.scss @@ -0,0 +1,183 @@ +@import '../lib/variables'; +@import '@financial-times/o-normalise/main'; +@import '@financial-times/o-typography/main'; +@import '@financial-times/o-buttons/main'; +@import '@financial-times/o-forms/main'; +@import '@financial-times/o-message/main'; +@import '@financial-times/o-share/main'; +@import '@financial-times/o-icons/main'; + +@include oNormalise(); +@include oTypography(); + +@include oButtons($opts: ( + 'sizes': ('big'), + 'types': ('primary'), + 'themes': ('professional', 'b2c'), +)); + +@include oForms( + $opts: ( + 'elements': ( + 'text', + 'radio-round', + 'checkbox' + ), + 'features': ( + 'inline', + 'disabled', + 'suffix' + ), + 'themes': ( + 'professional' + ) + ) +); + +@include oMessage($opts: ( + 'types': ('action', 'alert'), + 'states': ('error', 'success', 'neutral'), + 'layouts': ('inner') +)); + +@include oMessageAddState( + $name: 'received-highlights', + $opts: ( + 'foreground-color': 'slate', + 'background-color': whitesmoke, + 'icon': 'info', + ), $types: ('action', 'alert')); + +@include oShare($opts: ( + 'icons': ('twitter', 'facebook', 'linkedin', 'mail', 'whatsapp') +)); + +@include oIcons($opts: ( + 'icons': ('mail') +)); + +.share-article-dialog__wrapper { + @include oNormaliseBoxSizing(); + border-radius: oSpacingByName('s1'); + background: oColorsByName('white'); + box-shadow: 2px 2px 8px rgba(15, 10, 46, 0.09); + width: oSpacingByName('s8') * 11; // 32 * 11 = 352px + margin: 0; +} + +.share-article-dialog__banner-strip { + background: oColorsByName('slate'); + height: oSpacingByName('s2'); + width: 100%; + border-radius: oSpacingByName('s1') oSpacingByName('s1') 0 0; +} + +.share-article-dialog__banner-title { + @include oTypographySans($scale: 0, $weight: 'medium'); + color: oColorsMix($color: 'black', $percentage: 70); + text-transform: uppercase; + padding-left: oSpacingByName('s4'); + padding-right: oSpacingByName('s4'); + margin: oSpacingByName('s2') 0 0; + line-height: 24px; + letter-spacing: 1px; +} + +.share-article-dialog__main { + padding: oSpacingByName('s4'); +} + +.share-article-dialog__header-share-article-title { + @include oTypographySans($scale: -1, $weight: 'medium'); + color: oColorsByName('black'); + margin-top: oSpacingByName('s1'); + margin-bottom: oSpacingByName('s1'); +} + +.share-article-dialog__header-article-title { + @include oTypographyDisplay($scale: 3, $weight: 'medium'); + color: oColorsByName('black'); + margin-top: oSpacingByName('s2'); + margin-bottom: oSpacingByName('s2'); + margin-right: oSpacingByName('s1'); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.share-article-dialog__header-share-link-title { + @include oTypographySans($scale: 0, $weight: 'semibold'); +} + +.share-article-dialog__non-subscriber-checkbox { + :last-child { + margin-bottom: 0; + } +} + +.share-article-dialog__create-link-button { + width: 100%; +} + +.share-article-dialog__footer { + :first-child { + margin-top: oSpacingByName('s6'); + } + + :last-child { + margin-bottom: 0; + } +} + +.share-article-dialog__footer-message { + @include oTypographySans($scale: 0, $weight: 'regular'); + color: oColorsByName('ft-grey'); + margin-bottom: 0; +} + +.share-article-dialog__footer-message-shared-link { + @include oTypographySans($scale: -1, $weight: 'regular'); + color: oColorsMix($color: 'black', $percentage: 60); +} + +.share-article-dialog__copy-confirmation-alert { + margin-top: oSpacingByName('s2'); + width: 100%; +} + +.share-article-dialog__advanced-sharing-options { + margin-left: oSpacingByName('s8') + 5; + margin-bottom: oSpacingByName('s4'); +} + +.share-article-dialog__include-highlights { + margin-bottom: oSpacingByName('s1'); +} + +.share-article-dialog__share-via-socials-title { + @include oTypographySans($scale: 0, $weight: 'semibold'); + color: oColorsByName('ft-grey'); + margin-bottom: oSpacingByName('s3'); + margin-top: oSpacingByName('s3'); +} + +.share-article-dialog__share-via-socials-wrapper { + display: flex; + gap: oSpacingByName('s3'); +} + +.share-article-dialog__icon--email:hover { + background-color: oColorsByName('slate'); + border-color: oColorsByName('slate'); + svg { + fill: oColorsByName('white'); + } +} + +.share-article-dialog__alert { + margin-top: oSpacingByName('s4'); + margin-bottom: oSpacingByName('s4'); + strong { + @include oTypographySans($weight: 'medium'); + } +} diff --git a/components/x-gift-article/src/v2/SharedLinkTypeSelector.jsx b/components/x-gift-article/src/v2/SharedLinkTypeSelector.jsx new file mode 100644 index 000000000..eee3fa96b --- /dev/null +++ b/components/x-gift-article/src/v2/SharedLinkTypeSelector.jsx @@ -0,0 +1,81 @@ +import { h } from '@financial-times/x-engine' +import { AdvancedSharingOptions } from './AdvancedSharingOptions' +import { ShareType } from '../lib/constants' +import { NoCreditAlert } from './NoCreditAlert' + +export const SharedLinkTypeSelector = (props) => { + const { + shareType, + actions, + enterpriseEnabled, + enterpriseRequestAccess, + showAdvancedSharingOptions, + enterpriseHasCredits, + giftCredits + } = props + const advancedSharingEnabled = enterpriseEnabled && !enterpriseRequestAccess + const canShareWithNonSubscribers = giftCredits > 0 || enterpriseHasCredits + + const handleChange = (event) => { + if (advancedSharingEnabled) { + if (event.target.checked) { + enterpriseHasCredits ? actions.showEnterpriseUrlSection(event) : actions.showGiftUrlSection(event) + actions.showAdvancedSharingOptions() + } else { + actions.hideAdvancedSharingOptions(event) + actions.setIncludeHighlights(false) + } + return + } + + if (event.target.checked) { + // if the checkbox is checked, the user wants to share the article with non-subscribers + actions.showGiftUrlSection(event) + } else { + // if the checkbox is unchecked, the user wants to share the article with subscribers only + actions.showNonGiftUrlSection(event) + } + } + + return ( + + + + + Give access to non-subscribers + + + {!canShareWithNonSubscribers && ( + + You’ve run out of sharing credits, which you need to share articles with FT non-subscribers. Use + another option or{' '} + + contact support + + . + + )} + {showAdvancedSharingOptions && } + + ) +} diff --git a/components/x-gift-article/src/v2/SocialShareButtons.jsx b/components/x-gift-article/src/v2/SocialShareButtons.jsx new file mode 100644 index 000000000..c60ca966b --- /dev/null +++ b/components/x-gift-article/src/v2/SocialShareButtons.jsx @@ -0,0 +1,112 @@ +import { h } from '@financial-times/x-engine' +import { ShareType } from '../lib/constants' + +export const SocialShareButtons = ({ + actions, + mailtoUrl, + mobileShareLinks, + shareType, + enterpriseEnabled +}) => { + const onClickHandler = (event) => { + switch (shareType) { + case ShareType.gift: + actions.emailGiftUrl(event) + break + case ShareType.enterprise: + actions.emailEnterpriseUrl(event) + break + case ShareType.nonGift: + actions.emailNonGiftUrl(event) + break + default: + } + } + + return ( + + Or share via + + + + + + + + + + Share on Twitter + + + + + + + + + + Share on Facebook + + + + + + + + + + Share on LinkedIn + + + + + + + + + + Share on Whatsapp + + + + + + + + + + Share via Email + + + + + + ) +} diff --git a/components/x-gift-article/src/v2/UrlSection.jsx b/components/x-gift-article/src/v2/UrlSection.jsx new file mode 100644 index 000000000..b4ea1e0d8 --- /dev/null +++ b/components/x-gift-article/src/v2/UrlSection.jsx @@ -0,0 +1,59 @@ +import { h } from '@financial-times/x-engine' +import CopyConfirmation from '../CopyConfirmation' +import { ShareType } from '../lib/constants' +import { SocialShareButtons } from './SocialShareButtons' + +export const UrlSection = (props) => { + const { + urlType, + url, + actions, + isArticleSharingUxUpdates, + shareType, + showCopyConfirmation, + enterpriseEnabled + } = props + + const copyLinkHandler = (event) => { + switch (shareType) { + case ShareType.gift: + actions.copyGiftUrl(event) + break + case ShareType.enterprise: + actions.copyEnterpriseUrl(event) + break + case ShareType.nonGift: + actions.copyNonGiftUrl(event) + break + default: + } + } + + return ( + + + + + Copy Link + + {showCopyConfirmation && ( + + )} + + + + ) +} diff --git a/components/x-gift-article/storybook/index.jsx b/components/x-gift-article/storybook/index.jsx index d317f3931..9d233020f 100644 --- a/components/x-gift-article/storybook/index.jsx +++ b/components/x-gift-article/storybook/index.jsx @@ -1,9 +1,9 @@ -import { GiftArticle } from '../src/GiftArticle' +import { GiftArticle, ShareArticleModal } from '../src/GiftArticle' import fetchMock from 'fetch-mock' import React from 'react' import BuildService from '../../../.storybook/build-service' -import '../src/GiftArticle.scss' +import '../src/main.scss' const dependencies = { 'o-fonts': '^5.3.0' @@ -160,3 +160,152 @@ export const ErrorResponse = (args) => { ErrorResponse.storyName = 'Error response' ErrorResponse.args = require('./error-response').args + +export const ShareArticleModalB2B = (args) => { + require('./share-article-modal').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2B.storyName = 'Share article modal (B2B)' +ShareArticleModalB2B.args = require('./share-article-modal').args + +export const ShareArticleModalB2C = (args) => { + require('./share-article-modal-b2c').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2C.storyName = 'Share article modal (B2C)' +ShareArticleModalB2C.args = require('./share-article-modal-b2c').args + +export const ShareArticleModalWithAdvanceSharing = (args) => { + require('./share-article-modal-with-advanced-sharing').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalWithAdvanceSharing.storyName = 'Share article modal (B2B with Advanced Sharing)' +ShareArticleModalWithAdvanceSharing.args = require('./share-article-modal-with-advanced-sharing').args + +export const ShareArticleModalB2CNoCredits = (args) => { + require('./share-article-modal-b2c-no-credits').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2CNoCredits.storyName = 'Share article modal (B2C no credits)' +ShareArticleModalB2CNoCredits.args = require('./share-article-modal-b2c-no-credits').args + +export const ShareArticleModalB2BNoCredits = (args) => { + require('./share-article-modal-no-credits').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2BNoCredits.storyName = 'Share article modal (B2B no credits)' +ShareArticleModalB2BNoCredits.args = require('./share-article-modal-no-credits').args + +export const ShareArticleModalWithAdvancedSharingNoGiftCredits = (args) => { + require('./share-article-modal-with-advanced-sharing-no-gift-credits').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalWithAdvancedSharingNoGiftCredits.storyName = 'Share article modal (AS no gift credits)' +ShareArticleModalWithAdvancedSharingNoGiftCredits.args = + require('./share-article-modal-with-advanced-sharing-no-gift-credits').args + +export const ShareArticleModalWithAdvancedSharingNoEnterpriseCredits = (args) => { + require('./share-article-modal-with-advanced-sharing-no-enterprise-credits').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalWithAdvancedSharingNoEnterpriseCredits.storyName = + 'Share article modal (AS no enterprise credits)' +ShareArticleModalWithAdvancedSharingNoEnterpriseCredits.args = + require('./share-article-modal-with-advanced-sharing-no-enterprise-credits').args + +export const ShareArticleModalWithAdvancedSharingSaveHighlightsMessage = (args) => { + require('./share-article-modal-with-advanced-sharing-save-highlights-message').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalWithAdvancedSharingSaveHighlightsMessage.storyName = + 'Share article modal (AS save highlights message)' +ShareArticleModalWithAdvancedSharingSaveHighlightsMessage.args = + require('./share-article-modal-with-advanced-sharing-save-highlights-message').args + +export const ShareArticleModalB2BFreeArticle = (args) => { + require('./share-article-modal-b2b-free-article').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2BFreeArticle.storyName = 'Share article modal (B2B free article)' +ShareArticleModalB2BFreeArticle.args = require('./share-article-modal-b2b-free-article').args + +export const ShareArticleModalB2CFreeArticle = (args) => { + require('./share-article-modal-b2c-free-article').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalB2CFreeArticle.storyName = 'Share article modal (B2C free article)' +ShareArticleModalB2CFreeArticle.args = require('./share-article-modal-b2c-free-article').args + +export const ShareArticleModalWithAdvancedSharingFreeArticle = (args) => { + require('./share-article-modal-with-advanced-sharing-free-article').fetchMock(fetchMock) + return ( + + {dependencies && } + actions?.activate()} /> + + ) +} + +ShareArticleModalWithAdvancedSharingFreeArticle.storyName = 'Share article modal (AS free article)' +ShareArticleModalWithAdvancedSharingFreeArticle.args = + require('./share-article-modal-with-advanced-sharing-free-article').args diff --git a/components/x-gift-article/storybook/share-article-modal-b2b-free-article.js b/components/x-gift-article/storybook/share-article-modal-b2b-free-article.js new file mode 100644 index 000000000..934df0eee --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-b2b-free-article.js @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: true, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 403) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-b2c-free-article.jsx b/components/x-gift-article/storybook/share-article-modal-b2c-free-article.jsx new file mode 100644 index 000000000..2a1c01645 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-b2c-free-article.jsx @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: true, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 404) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-b2c-no-credits.jsx b/components/x-gift-article/storybook/share-article-modal-b2c-no-credits.jsx new file mode 100644 index 000000000..69b925ae3 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-b2c-no-credits.jsx @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 20, + remainingCredits: 0, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 404) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-b2c.jsx b/components/x-gift-article/storybook/share-article-modal-b2c.jsx new file mode 100644 index 000000000..c6f43821b --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-b2c.jsx @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 404) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-no-credits.jsx b/components/x-gift-article/storybook/share-article-modal-no-credits.jsx new file mode 100644 index 000000000..acea711e1 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-no-credits.jsx @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 20, + remainingCredits: 0, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 403) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-free-article.jsx b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-free-article.jsx new file mode 100644 index 000000000..ff155f303 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-free-article.jsx @@ -0,0 +1,47 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: true, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', { + limit: 120, + hasCredits: true, + firstTimeUser: false + }) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-enterprise-credits.jsx b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-enterprise-credits.jsx new file mode 100644 index 000000000..1768062b9 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-enterprise-credits.jsx @@ -0,0 +1,47 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', { + limit: 120, + hasCredits: false, + firstTimeUser: false + }) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-gift-credits.jsx b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-gift-credits.jsx new file mode 100644 index 000000000..efb41df85 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-no-gift-credits.jsx @@ -0,0 +1,47 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 20, + remainingCredits: 0, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', { + limit: 120, + hasCredits: true, + firstTimeUser: false + }) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-save-highlights-message.jsx b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-save-highlights-message.jsx new file mode 100644 index 000000000..ccc4672b0 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing-save-highlights-message.jsx @@ -0,0 +1,52 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com`, + showHighlightsCheckbox: false, + showHighlightsRecipientMessage: true +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', { + limit: 120, + hasCredits: true, + firstTimeUser: false + }) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) + .post('path:/v1/copy-annotations', { + annotationsCopyResult: [] + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing.jsx b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing.jsx new file mode 100644 index 000000000..563f0b5a9 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal-with-advanced-sharing.jsx @@ -0,0 +1,47 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', { + limit: 120, + hasCredits: true, + firstTimeUser: false + }) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/share-article-modal.js b/components/x-gift-article/storybook/share-article-modal.js new file mode 100644 index 000000000..adece1177 --- /dev/null +++ b/components/x-gift-article/storybook/share-article-modal.js @@ -0,0 +1,43 @@ +const articleId = 'e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrl = 'https://www.ft.com/content/e4b5ade3-01d1-4db8-b197-257051656684' +const articleUrlRedeemed = 'https://enterprise-sharing.ft.com/gift-url-redeemed' +const nonGiftArticleUrl = `${articleUrl}?shareType=nongift` + +exports.args = { + title: 'Share this article:', + isFreeArticle: false, + article: { + id: articleId, + url: articleUrl, + title: 'Equinor and Daimler Truck cut Russia ties as Volvo and JLR halt car deliveries' + }, + id: 'base-gift-article-static-id', + enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` +} + +exports.fetchMock = (fetchMock) => { + fetchMock + .restore() + .get('path:/article/gift-credits', { + allowance: 20, + consumedCredits: 5, + remainingCredits: 15, + renewalDate: '2018-08-01T00:00:00Z' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(articleUrlRedeemed)}`, { + shortenedUrl: 'https://shortened-gift-url' + }) + .get(`path:/article/shorten-url/${encodeURIComponent(nonGiftArticleUrl)}`, { + shortenedUrl: 'https://shortened-non-gift-url' + }) + .get(`path:/article/gift-link/${encodeURIComponent(articleId)}`, { + redemptionUrl: articleUrlRedeemed, + redemptionLimit: 3, + remainingAllowance: 1 + }) + .get('path:/v1/users/me/allowance', 403) + .post('path:/v1/shares', { + url: articleUrlRedeemed, + redeemLimit: 120 + }) +} diff --git a/components/x-gift-article/storybook/with-enterprise-first-time-user.js b/components/x-gift-article/storybook/with-enterprise-first-time-user.js index 5c5d5eff4..3d5716e2e 100644 --- a/components/x-gift-article/storybook/with-enterprise-first-time-user.js +++ b/components/x-gift-article/storybook/with-enterprise-first-time-user.js @@ -11,7 +11,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` } diff --git a/components/x-gift-article/storybook/with-enterprise-no-credits.js b/components/x-gift-article/storybook/with-enterprise-no-credits.js index aee6190c3..2042bda72 100644 --- a/components/x-gift-article/storybook/with-enterprise-no-credits.js +++ b/components/x-gift-article/storybook/with-enterprise-no-credits.js @@ -11,7 +11,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` } diff --git a/components/x-gift-article/storybook/with-enterprise-request-access.js b/components/x-gift-article/storybook/with-enterprise-request-access.js index 3c7deb3f8..5de6b3bc0 100644 --- a/components/x-gift-article/storybook/with-enterprise-request-access.js +++ b/components/x-gift-article/storybook/with-enterprise-request-access.js @@ -11,7 +11,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` } diff --git a/components/x-gift-article/storybook/with-enterprise-sharing-link.js b/components/x-gift-article/storybook/with-enterprise-sharing-link.js index 1c5caa4fe..de2a24b52 100644 --- a/components/x-gift-article/storybook/with-enterprise-sharing-link.js +++ b/components/x-gift-article/storybook/with-enterprise-sharing-link.js @@ -12,7 +12,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com`, shareType: 'enterprise' diff --git a/components/x-gift-article/storybook/with-enterprise.js b/components/x-gift-article/storybook/with-enterprise.js index d24bf8c32..a22dc84da 100644 --- a/components/x-gift-article/storybook/with-enterprise.js +++ b/components/x-gift-article/storybook/with-enterprise.js @@ -11,7 +11,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com`, hasHighlights: true diff --git a/components/x-gift-article/storybook/with-gift-credits.js b/components/x-gift-article/storybook/with-gift-credits.js index c611eb591..c8bc4ffb3 100644 --- a/components/x-gift-article/storybook/with-gift-credits.js +++ b/components/x-gift-article/storybook/with-gift-credits.js @@ -11,7 +11,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id', enterpriseApiBaseUrl: `https://enterprise-sharing-api.ft.com` } diff --git a/components/x-gift-article/storybook/with-gift-link.js b/components/x-gift-article/storybook/with-gift-link.js index 1c8ad313f..f419dae2e 100644 --- a/components/x-gift-article/storybook/with-gift-link.js +++ b/components/x-gift-article/storybook/with-gift-link.js @@ -12,7 +12,6 @@ exports.args = { url: articleUrl, title: 'Title Title Title Title' }, - showMobileShareLinks: true, id: 'base-gift-article-static-id' } diff --git a/jest.config.js b/jest.config.js index ae5c47186..70cb55399 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,7 +6,8 @@ module.exports = { '^.+\\.jsx?$': './packages/x-babel-config/jest' }, moduleNameMapper: { - '^[./a-zA-Z0-9$_-]+\\.scss$': '/__mocks__/styleMock.js' + '^[./a-zA-Z0-9$_-]+\\.scss$': '/__mocks__/styleMock.js', + '@financial-times/o-share': '/node_modules/@financial-times/o-share/main.js' }, modulePathIgnorePatterns: ['/e2e/'] } diff --git a/package-lock.json b/package-lock.json index 738e9d8ae..65b90fe41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -119,10 +119,10 @@ }, "devDependencies": { "@financial-times/o-buttons": "^7.2.2", - "@financial-times/o-forms": "^9.2.3", + "@financial-times/o-forms": "^9.11.0", "@financial-times/o-labels": "^6.2.2", "@financial-times/o-loading": "^5.2.1", - "@financial-times/o-message": "^5.2.1", + "@financial-times/o-message": "^5.4.2", "@financial-times/o-normalise": "^3.2.2", "@financial-times/o-typography": "^7.4.1", "@financial-times/x-rollup": "file:../../packages/x-rollup", @@ -137,11 +137,12 @@ "@financial-times/o-banner": "^4.4.9", "@financial-times/o-buttons": "^7.2.2", "@financial-times/o-colors": "^6.6.0", - "@financial-times/o-forms": "^9.2.3", + "@financial-times/o-forms": "^9.11.0", "@financial-times/o-labels": "^6.2.2", "@financial-times/o-loading": "^5.2.1", - "@financial-times/o-message": "^5.2.1", + "@financial-times/o-message": "^5.4.2", "@financial-times/o-normalise": "^3.2.2", + "@financial-times/o-share": "^9.0.2", "@financial-times/o-typography": "^7.4.1" } }, @@ -2644,9 +2645,10 @@ } }, "node_modules/@financial-times/o-forms": { - "version": "9.6.0", + "version": "9.11.0", + "resolved": "https://registry.npmjs.org/@financial-times/o-forms/-/o-forms-9.11.0.tgz", + "integrity": "sha512-YIwLCRY5t9GIhysto4ztxSc6THnVPSxmfVEQtTTST4bdQ5ksxhWq/XNh+IaK/imfDUcb6edlYtuTEisY1acwyg==", "dev": true, - "license": "MIT", "dependencies": { "@types/lodash.uniqueid": "^4.0.7", "lodash.uniqueid": "^4.0.1" @@ -2658,13 +2660,14 @@ "@financial-times/math": "^1.0.0", "@financial-times/o-brand": "^4.1.0", "@financial-times/o-buttons": "^7.2.0", - "@financial-times/o-colors": "^6.4.1", + "@financial-times/o-colors": "^6.5.0", "@financial-times/o-grid": "^6.0.0", "@financial-times/o-icons": "^7.0.0", "@financial-times/o-loading": "^5.0.0", "@financial-times/o-normalise": "^3.3.0", "@financial-times/o-spacing": "^3.0.0", - "@financial-times/o-typography": "^7.0.1" + "@financial-times/o-typography": "^7.0.1", + "@financial-times/o-utils": "^2.2.0" } }, "node_modules/@financial-times/o-grid": { @@ -2717,17 +2720,18 @@ } }, "node_modules/@financial-times/o-message": { - "version": "5.4.1", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/@financial-times/o-message/-/o-message-5.4.2.tgz", + "integrity": "sha512-hj1Tabdb10zbp2Gu2FxkhAu4kciOkKc9X8XFpWpwSwfgHFgSA1RpWKnBpJfqowUWgbabo9XFmR8i2yeZCcs4GA==", "dev": true, - "license": "MIT", "engines": { "npm": "^7 || ^8" }, "peerDependencies": { "@financial-times/math": "^1.0.0", "@financial-times/o-brand": "^4.1.0", - "@financial-times/o-buttons": "^7.0.0", - "@financial-times/o-colors": "^6.0.1", + "@financial-times/o-buttons": "^7.8.0", + "@financial-times/o-colors": "^6.5.0", "@financial-times/o-grid": "^6.0.0", "@financial-times/o-icons": "^7.0.1", "@financial-times/o-spacing": "^3.0.0", @@ -2770,8 +2774,9 @@ } }, "node_modules/@financial-times/o-share": { - "version": "9.0.1", - "license": "MIT", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@financial-times/o-share/-/o-share-9.0.2.tgz", + "integrity": "sha512-kHWYScT1PelJOuVBpWxAynjrCTd25GxmhVDc/Q53c9ZxkfT3z/VNezj+IvGFgls7N9m9fm08PZE2vz3z/8Xlvg==", "peer": true, "dependencies": { "ftdomdelegate": "^4.0.6" @@ -2782,7 +2787,7 @@ "peerDependencies": { "@financial-times/math": "^1.0.0", "@financial-times/o-brand": "^4.1.0", - "@financial-times/o-colors": "^6.0.1", + "@financial-times/o-colors": "^6.5.0", "@financial-times/o-grid": "^6.0.0", "@financial-times/o-normalise": "^3.3.0", "@financial-times/o-spacing": "^3.0.0", @@ -2887,9 +2892,9 @@ } }, "node_modules/@financial-times/o-utils": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@financial-times/o-utils/-/o-utils-2.1.1.tgz", - "integrity": "sha512-kZQfGjVI0A8axO3aPs8AIGStxG+jGX0FKZgjBTQAx+4Dud6vloVGJpSix+/Q7ym5rewjhDLsFVECM18Lvswbhw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@financial-times/o-utils/-/o-utils-2.2.0.tgz", + "integrity": "sha512-fCm8428H6GOpNhpwNXDKCe5Gx9GPyrwgFg26UsAfVCVmyjOMFCp2TxJECP6Y+NaXJqx6ZYU4lhARxSiL2HO+5A==", "dev": true, "peer": true, "engines": { @@ -28639,7 +28644,9 @@ "requires": {} }, "@financial-times/o-forms": { - "version": "9.6.0", + "version": "9.11.0", + "resolved": "https://registry.npmjs.org/@financial-times/o-forms/-/o-forms-9.11.0.tgz", + "integrity": "sha512-YIwLCRY5t9GIhysto4ztxSc6THnVPSxmfVEQtTTST4bdQ5ksxhWq/XNh+IaK/imfDUcb6edlYtuTEisY1acwyg==", "dev": true, "requires": { "@types/lodash.uniqueid": "^4.0.7", @@ -28665,7 +28672,9 @@ "requires": {} }, "@financial-times/o-message": { - "version": "5.4.1", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/@financial-times/o-message/-/o-message-5.4.2.tgz", + "integrity": "sha512-hj1Tabdb10zbp2Gu2FxkhAu4kciOkKc9X8XFpWpwSwfgHFgSA1RpWKnBpJfqowUWgbabo9XFmR8i2yeZCcs4GA==", "dev": true, "requires": {} }, @@ -28685,7 +28694,9 @@ } }, "@financial-times/o-share": { - "version": "9.0.1", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@financial-times/o-share/-/o-share-9.0.2.tgz", + "integrity": "sha512-kHWYScT1PelJOuVBpWxAynjrCTd25GxmhVDc/Q53c9ZxkfT3z/VNezj+IvGFgls7N9m9fm08PZE2vz3z/8Xlvg==", "peer": true, "requires": { "ftdomdelegate": "^4.0.6" @@ -28734,9 +28745,9 @@ } }, "@financial-times/o-utils": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@financial-times/o-utils/-/o-utils-2.1.1.tgz", - "integrity": "sha512-kZQfGjVI0A8axO3aPs8AIGStxG+jGX0FKZgjBTQAx+4Dud6vloVGJpSix+/Q7ym5rewjhDLsFVECM18Lvswbhw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@financial-times/o-utils/-/o-utils-2.2.0.tgz", + "integrity": "sha512-fCm8428H6GOpNhpwNXDKCe5Gx9GPyrwgFg26UsAfVCVmyjOMFCp2TxJECP6Y+NaXJqx6ZYU4lhARxSiL2HO+5A==", "dev": true, "peer": true }, @@ -28809,10 +28820,10 @@ "version": "file:components/x-gift-article", "requires": { "@financial-times/o-buttons": "^7.2.2", - "@financial-times/o-forms": "^9.2.3", + "@financial-times/o-forms": "^9.11.0", "@financial-times/o-labels": "^6.2.2", "@financial-times/o-loading": "^5.2.1", - "@financial-times/o-message": "^5.2.1", + "@financial-times/o-message": "^5.4.2", "@financial-times/o-normalise": "^3.2.2", "@financial-times/o-typography": "^7.4.1", "@financial-times/x-engine": "file:../../packages/x-engine",
- The link has been copied to your clipboard + {isArticleSharingUxUpdates ? ( + Link copied to clipboard. + ) : ( + Link copied to clipboard. + )}
+ Send to multiple people with{' '} + + Advanced Sharing + +
+ Anyone will be able to see the full article using this link. +
{redemptionLimitMessage}
{creditsMessage}
+ Only FT subscribers will be able to see the full article using this link. +
{advancedSharingLimitMessage}
+ We’ve added this link to your list.{' '} + + See all shared links + +
+ This is one of our free articles + + Even non-subscribers can read it, without using up your sharing credits. +
{children}
+ If you wish to share the article with the highlights, you need to{' '} + {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} + + save the highlights + {' '} + first. +