diff --git a/client/additional-methods-setup/wizard/task-item.js b/client/additional-methods-setup/wizard/task-item.js index 943ac88760e..57975deeb22 100644 --- a/client/additional-methods-setup/wizard/task-item.js +++ b/client/additional-methods-setup/wizard/task-item.js @@ -11,7 +11,13 @@ import { Icon, check } from '@wordpress/icons'; import WizardTaskContext from './task/context'; import './task-item.scss'; -const WizardTaskItem = ( { children, title, index, className } ) => { +const WizardTaskItem = ( { + children, + title, + index, + className, + visibleDescription, +} ) => { const { isCompleted, isActive } = useContext( WizardTaskContext ); return ( @@ -39,6 +45,16 @@ const WizardTaskItem = ( { children, title, index, className } ) => { { title } + { visibleDescription && ! isActive && ( + + { visibleDescription } + + ) }
{ __( diff --git a/multi-currency/client/data/actions.js b/multi-currency/client/data/actions.js index d70f4aa93ef..0b822dde4cb 100644 --- a/multi-currency/client/data/actions.js +++ b/multi-currency/client/data/actions.js @@ -10,7 +10,7 @@ import { __ } from '@wordpress/i18n'; /** * Internal Dependencies */ -import { recordEvent } from 'multi-currency/interface/data'; +import { recordEvent } from 'multi-currency/interface/functions'; import TYPES from './action-types'; import { NAMESPACE, STORE_NAME } from './constants'; diff --git a/multi-currency/client/data/resolvers.js b/multi-currency/client/data/resolvers.js index b74f052f4e0..78168ad708a 100644 --- a/multi-currency/client/data/resolvers.js +++ b/multi-currency/client/data/resolvers.js @@ -34,7 +34,7 @@ export function* getCurrencies() { } /** - * Retrieve single currency sttings from the site's REST API. + * Retrieve single currency settings from the site's REST API. * * @param {string} currencyCode The currency code to fetch settings for. */ diff --git a/multi-currency/client/data/selectors.js b/multi-currency/client/data/selectors.js index 6c2a2b20f97..825a9271db0 100644 --- a/multi-currency/client/data/selectors.js +++ b/multi-currency/client/data/selectors.js @@ -13,7 +13,7 @@ const getMultiCurrencyState = ( state ) => { return {}; } - return state.multiCurrency || {}; + return state || {}; }; export const getCurrencies = ( state ) => { diff --git a/multi-currency/client/interface/components.js b/multi-currency/client/interface/components.js new file mode 100644 index 00000000000..bd930416fab --- /dev/null +++ b/multi-currency/client/interface/components.js @@ -0,0 +1,19 @@ +/** + * Dependencies from WooPayments to MCCY. + */ +// wcpay/additional-methods-setup/* +export { default as CollapsibleBody } from 'wcpay/additional-methods-setup/wizard/collapsible-body'; +export { default as Wizard } from 'wcpay/additional-methods-setup/wizard/wrapper'; +export { default as WizardTask } from 'wcpay/additional-methods-setup/wizard/task'; +export { default as WizardTaskItem } from 'wcpay/additional-methods-setup/wizard/task-item'; +export { default as WizardTaskList } from 'wcpay/additional-methods-setup/wizard/task-list'; +// wcpay/components/* +export { default as Page } from 'wcpay/components/page'; +export { default as Search } from 'wcpay/components/search'; +export { LoadableBlock } from 'wcpay/components/loadable'; + +/** + * Dependencies from MCCY to WooPayments. + */ +// multi-currency/setup +export { default as MultiCurrencySetupPage } from 'multi-currency/setup'; diff --git a/multi-currency/client/interface/data.js b/multi-currency/client/interface/data.js index ca48a6c70e8..af162ddd6ed 100644 --- a/multi-currency/client/interface/data.js +++ b/multi-currency/client/interface/data.js @@ -1,9 +1,10 @@ /** - * Importing 'tracks' from WooPayments and exporting. + * Dependencies from WooPayments to MCCY. */ -export { recordEvent } from 'wcpay/tracks'; +// wcpay/data +export { useSettings, useMultiCurrency } from 'wcpay/data'; /** - * Importing data from MCCY and exporting. + * Dependencies from MCCY to WooPayments. */ export { useCurrencies, useEnabledCurrencies } from 'multi-currency/data'; diff --git a/multi-currency/client/interface/functions.js b/multi-currency/client/interface/functions.js new file mode 100644 index 00000000000..edc8fc1a1ac --- /dev/null +++ b/multi-currency/client/interface/functions.js @@ -0,0 +1,9 @@ +/** + * Dependencies from WooPayments to MCCY. + */ +// wcpay/tracks +export { recordEvent } from 'wcpay/tracks'; +// wcpay/settings +export { default as WCPaySettingsContext } from 'wcpay/settings/wcpay-settings-context'; +// wcpay/additional-methods-setup/* +export { default as WizardTaskContext } from 'wcpay/additional-methods-setup/wizard/task/context'; diff --git a/client/multi-currency-setup/index.js b/multi-currency/client/setup/index.js similarity index 77% rename from client/multi-currency-setup/index.js rename to multi-currency/client/setup/index.js index 512ab078182..05e76eb67ce 100644 --- a/client/multi-currency-setup/index.js +++ b/multi-currency/client/setup/index.js @@ -3,9 +3,9 @@ /** * Internal dependencies */ -import Page from 'components/page'; import MultiCurrencySetup from './tasks/multi-currency-setup'; -import WCPaySettingsContext from '../settings/wcpay-settings-context'; +import { Page } from 'multi-currency/interface/components'; +import { WCPaySettingsContext } from 'multi-currency/interface/functions'; const MultiCurrencySetupPage = () => { const { isSetupCompleted } = window.wcpaySettings.multiCurrencySetup; diff --git a/client/multi-currency-setup/tasks/add-currencies-task/constants.js b/multi-currency/client/setup/tasks/add-currencies-task/constants.js similarity index 100% rename from client/multi-currency-setup/tasks/add-currencies-task/constants.js rename to multi-currency/client/setup/tasks/add-currencies-task/constants.js diff --git a/client/multi-currency-setup/tasks/add-currencies-task/index.js b/multi-currency/client/setup/tasks/add-currencies-task/index.js similarity index 93% rename from client/multi-currency-setup/tasks/add-currencies-task/index.js rename to multi-currency/client/setup/tasks/add-currencies-task/index.js index 1795edaa6a0..6fa8f100fcc 100644 --- a/client/multi-currency-setup/tasks/add-currencies-task/index.js +++ b/multi-currency/client/setup/tasks/add-currencies-task/index.js @@ -10,23 +10,26 @@ import _ from 'lodash'; /** * Internal dependencies */ -import WizardTaskContext from '../../../additional-methods-setup/wizard/task/context'; -import CollapsibleBody from '../../../additional-methods-setup/wizard/collapsible-body'; -import WizardTaskItem from '../../wizard/task-item'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; +import { + CollapsibleBody, + Search, + LoadableBlock, + WizardTaskItem, +} from 'multi-currency/interface/components'; import { useCurrencies, useAvailableCurrencies, useEnabledCurrencies, useDefaultCurrency, -} from 'wcpay/data'; +} from 'multi-currency/data'; // eslint-disable-next-line max-len -import EnabledCurrenciesModalCheckboxList from '../../../multi-currency/multi-currency-settings/enabled-currencies-list/modal-checkbox-list'; -import EnabledCurrenciesModalCheckbox from '../../../multi-currency/multi-currency-settings/enabled-currencies-list/modal-checkbox'; -import Search from 'components/search'; - -import { LoadableBlock } from '../../../components/loadable'; +// TODO: Migrate to 'multi-currency/settings/enabled-currencies-list/modal-checkbox-list'. +import EnabledCurrenciesModalCheckboxList from 'wcpay/multi-currency/multi-currency-settings/enabled-currencies-list/modal-checkbox-list'; +// TODO: Migrate to 'multi-currency/settings/enabled-currencies-list/modal-checkbox'. +import EnabledCurrenciesModalCheckbox from 'wcpay/multi-currency/multi-currency-settings/enabled-currencies-list/modal-checkbox'; import { recommendedCurrencyCodes, numberWords } from './constants'; import { diff --git a/client/multi-currency-setup/tasks/add-currencies-task/index.scss b/multi-currency/client/setup/tasks/add-currencies-task/index.scss similarity index 100% rename from client/multi-currency-setup/tasks/add-currencies-task/index.scss rename to multi-currency/client/setup/tasks/add-currencies-task/index.scss diff --git a/client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap b/multi-currency/client/setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap similarity index 100% rename from client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap rename to multi-currency/client/setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap diff --git a/client/multi-currency-setup/tasks/add-currencies-task/test/index.test.js b/multi-currency/client/setup/tasks/add-currencies-task/test/index.test.js similarity index 96% rename from client/multi-currency-setup/tasks/add-currencies-task/test/index.test.js rename to multi-currency/client/setup/tasks/add-currencies-task/test/index.test.js index f58beb09ced..49ca876bc9f 100644 --- a/client/multi-currency-setup/tasks/add-currencies-task/test/index.test.js +++ b/multi-currency/client/setup/tasks/add-currencies-task/test/index.test.js @@ -9,23 +9,29 @@ import { useSelect } from '@wordpress/data'; * Internal dependencies */ import AddCurrenciesTask from '..'; +import { useSettings } from 'multi-currency/interface/data'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; import { useCurrencies, useAvailableCurrencies, useDefaultCurrency, useEnabledCurrencies, - useSettings, -} from 'wcpay/data'; +} from 'multi-currency/data'; -import WizardTaskContext from '../../../../additional-methods-setup/wizard/task/context'; import { recommendedCurrencyCodes } from '../constants'; import { __ } from '@wordpress/i18n'; +// TODO: Remove this while we have a dependency on 'wcpay/multi-currency/preview-modal'. jest.mock( 'wcpay/data', () => ( { + useStoreSettings: jest.fn(), +} ) ); +jest.mock( 'multi-currency/data', () => ( { useCurrencies: jest.fn(), useAvailableCurrencies: jest.fn(), useDefaultCurrency: jest.fn(), useEnabledCurrencies: jest.fn(), +} ) ); +jest.mock( 'multi-currency/interface/data', () => ( { useSettings: jest.fn(), } ) ); diff --git a/client/multi-currency-setup/tasks/add-currencies-task/test/utils.test.js b/multi-currency/client/setup/tasks/add-currencies-task/test/utils.test.js similarity index 100% rename from client/multi-currency-setup/tasks/add-currencies-task/test/utils.test.js rename to multi-currency/client/setup/tasks/add-currencies-task/test/utils.test.js diff --git a/client/multi-currency-setup/tasks/add-currencies-task/utils.js b/multi-currency/client/setup/tasks/add-currencies-task/utils.js similarity index 100% rename from client/multi-currency-setup/tasks/add-currencies-task/utils.js rename to multi-currency/client/setup/tasks/add-currencies-task/utils.js diff --git a/client/multi-currency-setup/tasks/multi-currency-setup.js b/multi-currency/client/setup/tasks/multi-currency-setup.js similarity index 84% rename from client/multi-currency-setup/tasks/multi-currency-setup.js rename to multi-currency/client/setup/tasks/multi-currency-setup.js index 77263d9bf33..cbeb6387bda 100644 --- a/client/multi-currency-setup/tasks/multi-currency-setup.js +++ b/multi-currency/client/setup/tasks/multi-currency-setup.js @@ -7,9 +7,11 @@ import { Card, CardBody } from '@wordpress/components'; /** * Internal dependencies */ -import Wizard from '../../additional-methods-setup/wizard/wrapper'; -import WizardTask from '../../additional-methods-setup/wizard/task'; -import WizardTaskList from '../../additional-methods-setup/wizard/task-list'; +import { + Wizard, + WizardTask, + WizardTaskList, +} from 'multi-currency/interface/components'; import StoreSettingsTask from './store-settings-task'; import SetupCompleteTask from './setup-complete-task'; import AddCurrenciesTask from './add-currencies-task'; diff --git a/client/multi-currency-setup/tasks/multi-currency-setup.scss b/multi-currency/client/setup/tasks/multi-currency-setup.scss similarity index 100% rename from client/multi-currency-setup/tasks/multi-currency-setup.scss rename to multi-currency/client/setup/tasks/multi-currency-setup.scss diff --git a/client/multi-currency-setup/tasks/setup-complete-task/index.js b/multi-currency/client/setup/tasks/setup-complete-task/index.js similarity index 89% rename from client/multi-currency-setup/tasks/setup-complete-task/index.js rename to multi-currency/client/setup/tasks/setup-complete-task/index.js index e846498df0e..6c467ec3a08 100644 --- a/client/multi-currency-setup/tasks/setup-complete-task/index.js +++ b/multi-currency/client/setup/tasks/setup-complete-task/index.js @@ -10,13 +10,15 @@ import { useDispatch } from '@wordpress/data'; /** * Internal dependencies */ -import CollapsibleBody from '../../../additional-methods-setup/wizard/collapsible-body'; -import WizardTaskItem from '../../wizard/task-item'; -import WizardTaskContext from '../../../additional-methods-setup/wizard/task/context'; +import { + CollapsibleBody, + WizardTaskItem, +} from 'multi-currency/interface/components'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; import './index.scss'; -import { useDefaultCurrency } from 'wcpay/data'; +import { useDefaultCurrency } from 'multi-currency/data'; const SetupComplete = () => { const { isActive } = useContext( WizardTaskContext ); diff --git a/client/multi-currency-setup/tasks/setup-complete-task/index.scss b/multi-currency/client/setup/tasks/setup-complete-task/index.scss similarity index 100% rename from client/multi-currency-setup/tasks/setup-complete-task/index.scss rename to multi-currency/client/setup/tasks/setup-complete-task/index.scss diff --git a/client/multi-currency-setup/tasks/setup-complete-task/test/index.test.js b/multi-currency/client/setup/tasks/setup-complete-task/test/index.test.js similarity index 84% rename from client/multi-currency-setup/tasks/setup-complete-task/test/index.test.js rename to multi-currency/client/setup/tasks/setup-complete-task/test/index.test.js index 48c4ac16d7a..754e109f459 100644 --- a/client/multi-currency-setup/tasks/setup-complete-task/test/index.test.js +++ b/multi-currency/client/setup/tasks/setup-complete-task/test/index.test.js @@ -6,14 +6,18 @@ import { render } from '@testing-library/react'; /** * Internal dependencies */ -import WizardTaskContext from '../../../../additional-methods-setup/wizard/task/context'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; import SetupCompleteTask from '../../setup-complete-task'; jest.mock( '@wordpress/data', () => ( { useDispatch: jest.fn().mockReturnValue( { updateOptions: jest.fn() } ), } ) ); +// TODO: Remove this while we have a dependency on 'wcpay/multi-currency/preview-modal'. jest.mock( 'wcpay/data', () => ( { + useStoreSettings: jest.fn(), +} ) ); +jest.mock( 'multi-currency/data', () => ( { useDefaultCurrency: jest.fn().mockReturnValue( { code: 'USD', rate: 1, diff --git a/client/multi-currency-setup/tasks/store-settings-task/index.js b/multi-currency/client/setup/tasks/store-settings-task/index.js similarity index 92% rename from client/multi-currency-setup/tasks/store-settings-task/index.js rename to multi-currency/client/setup/tasks/store-settings-task/index.js index 7e20fc0f3e4..69f66da9882 100644 --- a/client/multi-currency-setup/tasks/store-settings-task/index.js +++ b/multi-currency/client/setup/tasks/store-settings-task/index.js @@ -9,13 +9,17 @@ import interpolateComponents from '@automattic/interpolate-components'; /** * Internal dependencies */ -import WizardTaskContext from '../../../additional-methods-setup/wizard/task/context'; -import CollapsibleBody from '../../../additional-methods-setup/wizard/collapsible-body'; -import WizardTaskItem from '../../wizard/task-item'; -import PreviewModal from '../../../multi-currency/preview-modal'; +import { + CollapsibleBody, + WizardTaskItem, +} from 'multi-currency/interface/components'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; +import { useSettings, useMultiCurrency } from 'multi-currency/interface/data'; +// TODO: Migrate to 'multi-currency/preview-modal'. +import PreviewModal from 'wcpay/multi-currency/preview-modal'; import './index.scss'; -import { useStoreSettings, useSettings, useMultiCurrency } from 'wcpay/data'; +import { useStoreSettings } from 'multi-currency/data'; const StoreSettingsTask = () => { const { storeSettings, submitStoreSettingsUpdate } = useStoreSettings(); diff --git a/client/multi-currency-setup/tasks/store-settings-task/index.scss b/multi-currency/client/setup/tasks/store-settings-task/index.scss similarity index 100% rename from client/multi-currency-setup/tasks/store-settings-task/index.scss rename to multi-currency/client/setup/tasks/store-settings-task/index.scss diff --git a/client/multi-currency-setup/tasks/store-settings-task/test/__snapshots__/index.test.js.snap b/multi-currency/client/setup/tasks/store-settings-task/test/__snapshots__/index.test.js.snap similarity index 100% rename from client/multi-currency-setup/tasks/store-settings-task/test/__snapshots__/index.test.js.snap rename to multi-currency/client/setup/tasks/store-settings-task/test/__snapshots__/index.test.js.snap diff --git a/client/multi-currency-setup/tasks/store-settings-task/test/index.test.js b/multi-currency/client/setup/tasks/store-settings-task/test/index.test.js similarity index 92% rename from client/multi-currency-setup/tasks/store-settings-task/test/index.test.js rename to multi-currency/client/setup/tasks/store-settings-task/test/index.test.js index e81b7b08f99..d80e8f8d12a 100644 --- a/client/multi-currency-setup/tasks/store-settings-task/test/index.test.js +++ b/multi-currency/client/setup/tasks/store-settings-task/test/index.test.js @@ -7,21 +7,21 @@ import { render, screen, fireEvent } from '@testing-library/react'; /** * Internal dependencies */ -import WizardTaskContext from '../../../../additional-methods-setup/wizard/task/context'; -import { - useCurrencies, - useStoreSettings, - useSettings, - useMultiCurrency, -} from 'wcpay/data'; +import { useCurrencies, useStoreSettings } from 'multi-currency/data'; +import { useSettings, useMultiCurrency } from 'multi-currency/interface/data'; +import { WizardTaskContext } from 'multi-currency/interface/functions'; import StoreSettingsTask from '..'; -jest.mock( 'wcpay/data', () => ( { +jest.mock( 'multi-currency/data', () => ( { useStoreSettings: jest.fn(), useCurrencies: jest.fn(), useSettings: jest.fn(), useMultiCurrency: jest.fn(), } ) ); +jest.mock( 'multi-currency/interface/data', () => ( { + useSettings: jest.fn(), + useMultiCurrency: jest.fn(), +} ) ); const changeableSettings = [ 'enable_storefront_switcher', diff --git a/client/multi-currency-setup/tasks/test/__snapshots__/multi-currency-setup.test.js.snap b/multi-currency/client/setup/tasks/test/__snapshots__/multi-currency-setup.test.js.snap similarity index 100% rename from client/multi-currency-setup/tasks/test/__snapshots__/multi-currency-setup.test.js.snap rename to multi-currency/client/setup/tasks/test/__snapshots__/multi-currency-setup.test.js.snap diff --git a/client/multi-currency-setup/tasks/test/multi-currency-setup.test.js b/multi-currency/client/setup/tasks/test/multi-currency-setup.test.js similarity index 100% rename from client/multi-currency-setup/tasks/test/multi-currency-setup.test.js rename to multi-currency/client/setup/tasks/test/multi-currency-setup.test.js diff --git a/client/multi-currency-setup/test/index.js b/multi-currency/client/setup/test/index.js similarity index 100% rename from client/multi-currency-setup/test/index.js rename to multi-currency/client/setup/test/index.js