diff --git a/client/my-sites/checkout/modal/index.tsx b/client/my-sites/checkout/modal/index.tsx index 3eec3142fb263..b7cbe967578eb 100644 --- a/client/my-sites/checkout/modal/index.tsx +++ b/client/my-sites/checkout/modal/index.tsx @@ -10,7 +10,7 @@ import { getRazorpayConfiguration, getStripeConfiguration } from 'calypso/lib/st import CalypsoShoppingCartProvider from 'calypso/my-sites/checkout/calypso-shopping-cart-provider'; import CheckoutMain from 'calypso/my-sites/checkout/src/components/checkout-main'; import { useSelector, useDispatch } from 'calypso/state'; -import getPreviousRoute from 'calypso/state/selectors/get-previous-route.js'; +import getPreviousRoute from 'calypso/state/selectors/get-previous-route'; import isAtomicSite from 'calypso/state/selectors/is-site-automated-transfer'; import { isJetpackSite } from 'calypso/state/sites/selectors'; import { setSelectedSiteId } from 'calypso/state/ui/actions'; diff --git a/client/reader/list-stream/empty.jsx b/client/reader/list-stream/empty.jsx deleted file mode 100644 index 736e3c8b23959..0000000000000 --- a/client/reader/list-stream/empty.jsx +++ /dev/null @@ -1,46 +0,0 @@ -import { localize } from 'i18n-calypso'; -import { Component } from 'react'; -import { connect } from 'react-redux'; -import EmptyContent from 'calypso/components/empty-content'; -import { recordAction, recordGaEvent } from 'calypso/reader/stats'; -import { recordReaderTracksEvent } from 'calypso/state/reader/analytics/actions'; - -class ListEmptyContent extends Component { - shouldComponentUpdate() { - return false; - } - - recordAction = () => { - recordAction( 'clicked_following_on_empty' ); - recordGaEvent( 'Clicked Following on EmptyContent' ); - this.props.recordReaderTracksEvent( 'calypso_reader_following_on_empty_list_stream_clicked' ); - }; - - render() { - /* eslint-disable wpcalypso/jsx-classname-namespace */ - const action = ( - - { this.props.translate( 'Back to Following' ) } - - ); - - return ( - - ); - /* eslint-enable wpcalypso/jsx-classname-namespace */ - } -} - -export default connect( null, { - recordReaderTracksEvent, -} )( localize( ListEmptyContent ) ); diff --git a/client/reader/list-stream/empty.tsx b/client/reader/list-stream/empty.tsx new file mode 100644 index 0000000000000..d32eb8fdb3dd3 --- /dev/null +++ b/client/reader/list-stream/empty.tsx @@ -0,0 +1,39 @@ +import { useTranslate } from 'i18n-calypso'; +import { useSelector } from 'react-redux'; +import EmptyContent from 'calypso/components/empty-content'; +import getPreviousRoute from 'calypso/state/selectors/get-previous-route'; + +export default function ListEmptyContent(): JSX.Element { + const translate = useTranslate(); + const previousRoute: string = useSelector( getPreviousRoute ); + + function previousRouteIsUserProfileLists(): boolean { + return /^\/read\/users\/[a-z0-9]+\/lists\??$/.test( previousRoute ); + } + + function getActionBtnLink(): string { + return previousRouteIsUserProfileLists() ? previousRoute : '/read'; + } + + function getActionBtnText(): string { + return previousRouteIsUserProfileLists() + ? translate( 'Back to User Profile' ) + : translate( 'Back to Following' ); + } + + const action = ( + + { getActionBtnText() } + + ); + + return ( + + ); +} diff --git a/client/state/selectors/get-previous-route.js b/client/state/selectors/get-previous-route.ts similarity index 75% rename from client/state/selectors/get-previous-route.js rename to client/state/selectors/get-previous-route.ts index 7c2d157d49921..48a94c2bd7d74 100644 --- a/client/state/selectors/get-previous-route.js +++ b/client/state/selectors/get-previous-route.ts @@ -1,20 +1,21 @@ import { stringify } from 'qs'; import getPreviousPath from 'calypso/state/selectors/get-previous-path'; import getPreviousQuery from 'calypso/state/selectors/get-previous-query'; +import { AppState } from 'calypso/types'; + /** * Gets the previous route set by a ROUTE_SET action - * @param {Object} state - global redux state + * @param {AppState} state - global redux state * @returns {string} previous route value */ - -export const getPreviousRoute = ( state ) => { +export default function getPreviousRoute( state: AppState ): string { const previousPath = getPreviousPath( state ); const previousQuery = getPreviousQuery( state ); let query = ''; + if ( previousQuery ) { query = '?' + stringify( previousQuery ); } - return previousPath + query; -}; -export default getPreviousRoute; + return previousPath + query; +} diff --git a/client/state/selectors/test/get-previous-route.js b/client/state/selectors/test/get-previous-route.ts similarity index 100% rename from client/state/selectors/test/get-previous-route.js rename to client/state/selectors/test/get-previous-route.ts