diff --git a/changelog/update-9971-simplify-localization-csv-export b/changelog/update-9971-simplify-localization-csv-export
new file mode 100644
index 00000000000..dac5219b344
--- /dev/null
+++ b/changelog/update-9971-simplify-localization-csv-export
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Simplify localization of CSV exports to use global site language settings from WP Admin
diff --git a/client/components/csv-export-modal/index.tsx b/client/components/csv-export-modal/index.tsx
deleted file mode 100644
index 2cddf0908ab..00000000000
--- a/client/components/csv-export-modal/index.tsx
+++ /dev/null
@@ -1,227 +0,0 @@
-/** @format */
-/**
- * External dependencies
- */
-import React, { useState } from 'react';
-import { __ } from '@wordpress/i18n';
-import {
- Button,
- SelectControl,
- CheckboxControl,
- ExternalLink,
-} from '@wordpress/components';
-import interpolateComponents from '@automattic/interpolate-components';
-import { useDispatch } from '@wordpress/data';
-import DomainsIcon from 'gridicons/dist/domains';
-
-/**
- * Internal dependencies
- */
-import { ReportingExportLanguageHook } from 'wcpay/settings/reporting-settings/interfaces';
-import { useReportingExportLanguage, useSettings } from 'wcpay/data';
-import ConfirmationModal from 'wcpay/components/confirmation-modal';
-import { getAdminUrl, getExportLanguageOptions } from 'wcpay/utils';
-import './styles.scss';
-
-interface CSVExportModalProps {
- totalItems: number;
- exportType: 'transactions' | 'deposits' | 'disputes';
- onClose: () => void;
- onSubmit: ( language: string ) => void;
-}
-
-interface SettingsHook {
- isSaving: boolean;
- isLoading: boolean;
- saveSettings: () => void;
-}
-
-const CVSExportModal: React.FunctionComponent< CSVExportModalProps > = ( {
- totalItems,
- exportType,
- onClose,
- onSubmit,
-} ) => {
- const { updateOptions } = useDispatch( 'wc/admin/options' );
- const { saveSettings } = useSettings() as SettingsHook;
-
- const [
- exportLanguage,
- updateExportLanguage,
- ] = useReportingExportLanguage() as ReportingExportLanguageHook;
-
- const [ modalLanguage, setModalLanguage ] = useState( exportLanguage );
- const [ modalRemember, setModalRemember ] = useState( true );
-
- const onDownload = async () => {
- onSubmit( modalLanguage );
-
- // If the Remember checkbox is checked, dismiss the modal.
- if ( modalRemember ) {
- await updateOptions( {
- wcpay_reporting_export_modal_dismissed: modalRemember,
- } );
-
- updateExportLanguage( modalLanguage );
- saveSettings();
-
- wcpaySettings.reporting.exportModalDismissed = true;
- }
- };
-
- const buttonContent = (
- <>
-
-
- >
- );
-
- const getModalTitle = ( type: string ): string => {
- switch ( type ) {
- case 'transactions':
- return __(
- 'Export transactions report',
- 'woocommerce-payments'
- );
- case 'deposits':
- return __( 'Export deposits report', 'woocommerce-payments' );
- case 'disputes':
- return __( 'Export disputes report', 'woocommerce-payments' );
- default:
- return __( 'Export report', 'woocommerce-payments' );
- }
- };
-
- const getExportNumberText = ( type: string ): string => {
- switch ( type ) {
- case 'transactions':
- return __(
- 'Exporting {{total/}} transactions…',
- 'woocommerce-payments'
- );
- case 'deposits':
- return __(
- 'Exporting {{total/}} deposits…',
- 'woocommerce-payments'
- );
- case 'disputes':
- return __(
- 'Exporting {{total/}} disputes…',
- 'woocommerce-payments'
- );
- default:
- return __(
- 'Exporting {{total/}} rows…',
- 'woocommerce-payments'
- );
- }
- };
-
- const getExportLabel = ( type: string ): string => {
- switch ( type ) {
- case 'transactions':
- return __(
- 'Export transactions report in',
- 'woocommerce-payments'
- );
- case 'deposits':
- return __(
- 'Export deposits report in',
- 'woocommerce-payments'
- );
- case 'disputes':
- return __(
- 'Export disputes report in',
- 'woocommerce-payments'
- );
- default:
- return __( 'Export report in', 'woocommerce-payments' );
- }
- };
-
- const handleExportLanguageChange = ( language: string ) => {
- setModalLanguage( language );
- };
-
- const handleExportLanguageRememberChange = ( value: boolean ) => {
- setModalRemember( value );
- };
-
- return (
- {
- return false;
- } }
- >
-
- { interpolateComponents( {
- mixedString: getExportNumberText( exportType ),
- components: {
- total: { totalItems },
- },
- } ) }
-
-
-
-
Settings
-
-
-
-
-
- { getExportLabel( exportType ) }
-
-
-
-
-
-
-
-
-
- ),
- },
- } ) }
- checked={ modalRemember }
- onChange={ handleExportLanguageRememberChange }
- data-testid="export-modal-remember"
- />
-
-
-
- );
-};
-
-export default CVSExportModal;
diff --git a/client/components/csv-export-modal/styles.scss b/client/components/csv-export-modal/styles.scss
deleted file mode 100644
index 600a6d2a18a..00000000000
--- a/client/components/csv-export-modal/styles.scss
+++ /dev/null
@@ -1,51 +0,0 @@
-.reporting-export-modal {
- .components-modal__header {
- border-bottom: 1px solid #dcdcde !important;
- }
-
- .wcpay-confirmation-modal__footer {
- .is-secondary {
- box-shadow: none;
- }
- }
-
- &__items-number {
- border-bottom: 1px solid #dcdcde;
- padding: 15px 0;
- }
-
- &__settings {
- @include breakpoint( '>660px' ) {
- min-width: 500px;
- }
-
- &--language {
- display: flex;
- flex-wrap: wrap;
- }
-
- &--language-label {
- flex: 1 1 200px;
- display: flex;
-
- .domains-icon {
- width: 16px;
- margin: 7px 0;
- }
-
- .export-label {
- padding: 10px 0 0 8px;
- }
- }
-
- &--language-select {
- flex: 1 1 200px;
- }
-
- &--remember {
- p {
- padding-top: 0 !important;
- }
- }
- }
-}
diff --git a/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap b/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap
deleted file mode 100644
index 251b5f8438f..00000000000
--- a/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap
+++ /dev/null
@@ -1,7 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`RefundModal it renders correctly 1`] = `
-
-`;
diff --git a/client/components/csv-export-modal/test/index.test.tsx b/client/components/csv-export-modal/test/index.test.tsx
deleted file mode 100644
index 731abf9f136..00000000000
--- a/client/components/csv-export-modal/test/index.test.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-/** @format */
-
-/**
- * External dependencies
- */
-import React from 'react';
-import { render } from '@testing-library/react';
-
-/**
- * Internal dependencies
- */
-import CVSExportModal from '..';
-import { useReportingExportLanguage, useSettings } from 'wcpay/data';
-
-declare const global: {
- wcpaySettings: {
- locale: {
- code: string;
- native_name: string;
- };
- };
-};
-
-jest.mock( '@wordpress/data', () => ( {
- useDispatch: jest.fn( () => ( { updateOptions: jest.fn() } ) ),
-} ) );
-
-jest.mock( 'wcpay/data', () => ( {
- useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ),
- useSettings: jest.fn(),
-} ) );
-
-const mockUseSettings = useSettings as jest.MockedFunction<
- typeof useSettings
->;
-
-const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction<
- typeof useReportingExportLanguage
->;
-
-describe( 'RefundModal', () => {
- beforeEach( () => {
- mockUseReportingExportLanguage.mockReturnValue( [ 'en', jest.fn() ] );
-
- mockUseSettings.mockReturnValue( {
- isLoading: false,
- isDirty: false,
- isSaving: false,
- saveSettings: ( a ) => a,
- } );
-
- global.wcpaySettings = {
- locale: {
- code: 'es_ES',
- native_name: 'Spanish',
- },
- };
- } );
-
- test( 'it renders correctly', () => {
- const { container: modal } = render(
-
- );
-
- expect( modal ).toMatchSnapshot();
- } );
-} );
diff --git a/client/data/settings/actions.js b/client/data/settings/actions.js
index 6a2e315657c..93fb135fc7a 100644
--- a/client/data/settings/actions.js
+++ b/client/data/settings/actions.js
@@ -204,12 +204,6 @@ export function updateDepositScheduleMonthlyAnchor(
} );
}
-export function updateExportLanguage( language ) {
- return updateSettingsValues( {
- reporting_export_language: language,
- } );
-}
-
export function* saveSettings() {
let error = null;
try {
diff --git a/client/data/settings/hooks.js b/client/data/settings/hooks.js
index 873cc22a1ea..659249b9a62 100644
--- a/client/data/settings/hooks.js
+++ b/client/data/settings/hooks.js
@@ -265,16 +265,6 @@ export const useDepositScheduleMonthlyAnchor = () => {
return [ depositScheduleMonthlyAnchor, updateDepositScheduleMonthlyAnchor ];
};
-export const useReportingExportLanguage = () => {
- const { updateExportLanguage } = useDispatch( STORE_NAME );
-
- const exportLanguage = useSelect( ( select ) =>
- select( STORE_NAME ).getExportLanguage()
- );
-
- return [ exportLanguage, updateExportLanguage ];
-};
-
export const useDepositDelayDays = () =>
useSelect( ( select ) => select( STORE_NAME ).getDepositDelayDays(), [] );
diff --git a/client/data/settings/selectors.js b/client/data/settings/selectors.js
index 16cd1b4ec55..f36f402527a 100644
--- a/client/data/settings/selectors.js
+++ b/client/data/settings/selectors.js
@@ -121,10 +121,6 @@ export const getDepositScheduleInterval = ( state ) => {
return getSettings( state ).deposit_schedule_interval || '';
};
-export const getExportLanguage = ( state ) => {
- return getSettings( state ).reporting_export_language || '';
-};
-
export const getDepositScheduleWeeklyAnchor = ( state ) => {
return getSettings( state ).deposit_schedule_weekly_anchor || '';
};
diff --git a/client/deposits/list/index.tsx b/client/deposits/list/index.tsx
index 52194cb184f..00280b029f2 100644
--- a/client/deposits/list/index.tsx
+++ b/client/deposits/list/index.tsx
@@ -23,7 +23,6 @@ import { parseInt } from 'lodash';
*/
import type { DepositsTableHeader } from 'wcpay/types/deposits';
import { useDeposits, useDepositsSummary } from 'wcpay/data';
-import { useReportingExportLanguage } from 'data/index';
import { displayType, depositStatusLabels } from '../strings';
import {
formatExplicitCurrency,
@@ -37,13 +36,6 @@ import DownloadButton from 'components/download-button';
import { getDepositsCSV } from 'wcpay/data/deposits/resolvers';
import { applyThousandSeparator } from '../../utils/index.js';
import DepositStatusChip from 'components/deposit-status-chip';
-import {
- isExportModalDismissed,
- getExportLanguage,
- isDefaultSiteLanguage,
-} from 'utils';
-import CSVExportModal from 'components/csv-export-modal';
-import { ReportingExportLanguageHook } from 'wcpay/settings/reporting-settings/interfaces';
import './style.scss';
import { formatDateTimeFromString } from 'wcpay/utils/date-time';
@@ -104,10 +96,6 @@ const getColumns = ( sortByDate?: boolean ): DepositsTableHeader[] => [
];
export const DepositsList = (): JSX.Element => {
- const [
- exportLanguage,
- ] = useReportingExportLanguage() as ReportingExportLanguageHook;
-
const [ isDownloading, setIsDownloading ] = useState( false );
const { createNotice } = useDispatch( 'core/notices' );
const { deposits, isLoading } = useDeposits( getQuery() );
@@ -115,8 +103,6 @@ export const DepositsList = (): JSX.Element => {
getQuery()
);
- const [ isCSVExportModalOpen, setCSVExportModalOpen ] = useState( false );
-
const sortByDate = ! getQuery().orderby || 'date' === getQuery().orderby;
const columns = useMemo( () => getColumns( sortByDate ), [ sortByDate ] );
const totalRows = depositsSummary.count || 0;
@@ -220,12 +206,9 @@ export const DepositsList = (): JSX.Element => {
const downloadable = !! rows.length;
- const endpointExport = async ( language: string ) => {
- // We destructure page and path to get the right params.
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { page, path, ...params } = getQuery();
+ const endpointExport = async () => {
const userEmail = wcpaySettings.currentUserEmail;
- const locale = getExportLanguage( language, exportLanguage );
+ const locale = wcpaySettings.locale.code;
const {
date_before: dateBefore,
@@ -313,11 +296,7 @@ export const DepositsList = (): JSX.Element => {
const downloadType = totalRows > rows.length ? 'endpoint' : 'browser';
if ( 'endpoint' === downloadType ) {
- if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) {
- setCSVExportModalOpen( true );
- } else {
- endpointExport( '' );
- }
+ endpointExport();
} else {
const params = getQuery();
@@ -353,16 +332,6 @@ export const DepositsList = (): JSX.Element => {
setIsDownloading( false );
};
- const closeModal = () => {
- setCSVExportModalOpen( false );
- };
-
- const exportDeposits = ( language: string ) => {
- endpointExport( language );
-
- closeModal();
- };
-
return (
@@ -387,16 +356,6 @@ export const DepositsList = (): JSX.Element => {
),
] }
/>
- { ! isDefaultSiteLanguage() &&
- ! isExportModalDismissed() &&
- isCSVExportModalOpen && (
-
- ) }
);
};
diff --git a/client/deposits/list/test/index.tsx b/client/deposits/list/test/index.tsx
index ee2077da8f9..e29c5aa1994 100644
--- a/client/deposits/list/test/index.tsx
+++ b/client/deposits/list/test/index.tsx
@@ -14,11 +14,7 @@ import os from 'os';
* Internal dependencies
*/
import { DepositsList } from '../';
-import {
- useDeposits,
- useDepositsSummary,
- useReportingExportLanguage,
-} from 'wcpay/data';
+import { useDeposits, useDepositsSummary } from 'wcpay/data';
import { getUnformattedAmount } from 'wcpay/utils/test-utils';
import {
CachedDeposit,
@@ -30,7 +26,6 @@ import React from 'react';
jest.mock( 'wcpay/data', () => ( {
useDeposits: jest.fn(),
useDepositsSummary: jest.fn(),
- useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ),
} ) );
jest.mock( '@woocommerce/csv-export', () => {
@@ -85,8 +80,8 @@ declare const global: {
connect: {
country: string;
};
- reporting?: {
- exportModalDismissed: boolean;
+ locale: {
+ code: string;
};
dateFormat: string;
};
@@ -122,10 +117,6 @@ const mockDownloadCSVFile = downloadCSVFile as jest.MockedFunction<
typeof downloadCSVFile
>;
-const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction<
- typeof useReportingExportLanguage
->;
-
describe( 'Deposits list', () => {
beforeEach( () => {
jest.clearAllMocks();
@@ -133,8 +124,6 @@ describe( 'Deposits list', () => {
// the query string is preserved across tests, so we need to reset it
updateQueryString( {}, '/', {} );
- mockUseReportingExportLanguage.mockReturnValue( [ 'en', jest.fn() ] );
-
global.wcpaySettings = {
zeroDecimalCurrencies: [],
connect: {
@@ -151,8 +140,8 @@ describe( 'Deposits list', () => {
precision: 2,
},
},
- reporting: {
- exportModalDismissed: true,
+ locale: {
+ code: 'en',
},
dateFormat: 'M j Y',
};
diff --git a/client/disputes/index.tsx b/client/disputes/index.tsx
index ad5e8258d7f..81a9436b325 100644
--- a/client/disputes/index.tsx
+++ b/client/disputes/index.tsx
@@ -23,11 +23,7 @@ import NoticeOutlineIcon from 'gridicons/dist/notice-outline';
/**
* Internal dependencies.
*/
-import {
- useDisputes,
- useDisputesSummary,
- useReportingExportLanguage,
-} from 'data/index';
+import { useDisputes, useDisputesSummary } from 'data/index';
import OrderLink from 'components/order-link';
import DisputeStatusChip from 'components/dispute-status-chip';
import ClickableCell from 'components/clickable-cell';
@@ -45,16 +41,9 @@ import DownloadButton from 'components/download-button';
import disputeStatusMapping from 'components/dispute-status-chip/mappings';
import { CachedDispute, DisputesTableHeader } from 'wcpay/types/disputes';
import { getDisputesCSV } from 'wcpay/data/disputes/resolvers';
-import {
- applyThousandSeparator,
- isExportModalDismissed,
- getExportLanguage,
- isDefaultSiteLanguage,
-} from 'wcpay/utils';
+import { applyThousandSeparator } from 'wcpay/utils';
import { useSettings } from 'wcpay/data';
import { isAwaitingResponse } from 'wcpay/disputes/utils';
-import CSVExportModal from 'components/csv-export-modal';
-import { ReportingExportLanguageHook } from 'wcpay/settings/reporting-settings/interfaces';
import DateFormatNotice from 'wcpay/components/date-format-notice';
import './style.scss';
import { formatDateTimeFromString } from 'wcpay/utils/date-time';
@@ -218,12 +207,6 @@ export const DisputesList = (): JSX.Element => {
getQuery()
);
- const [ isCSVExportModalOpen, setCSVExportModalOpen ] = useState( false );
-
- const [
- exportLanguage,
- ] = useReportingExportLanguage() as ReportingExportLanguageHook;
-
const headers = getHeaders( getQuery().orderby );
const totalRows = disputesSummary.count || 0;
@@ -358,13 +341,13 @@ export const DisputesList = (): JSX.Element => {
const downloadable = !! rows.length;
- const endpointExport = async ( language: string ) => {
+ const endpointExport = async () => {
// We destructure page and path to get the right params.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { page, path, ...params } = getQuery();
const userEmail = wcpaySettings.currentUserEmail;
- const locale = getExportLanguage( language, exportLanguage );
+ const locale = wcpaySettings.locale.code;
const {
date_before: dateBefore,
date_after: dateAfter,
@@ -451,11 +434,7 @@ export const DisputesList = (): JSX.Element => {
const downloadType = totalRows > rows.length ? 'endpoint' : 'browser';
if ( 'endpoint' === downloadType ) {
- if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) {
- setCSVExportModalOpen( true );
- } else {
- endpointExport( '' );
- }
+ endpointExport();
} else {
const csvColumns = [
{
@@ -543,16 +522,6 @@ export const DisputesList = (): JSX.Element => {
disputesSummary.currencies ||
( isCurrencyFiltered ? [ getQuery().store_currency_is ?? '' ] : [] );
- const closeModal = () => {
- setCSVExportModalOpen( false );
- };
-
- const exportDisputes = ( language: string ) => {
- endpointExport( language );
-
- closeModal();
- };
-
return (
@@ -579,16 +548,6 @@ export const DisputesList = (): JSX.Element => {
),
] }
/>
- { ! isDefaultSiteLanguage() &&
- ! isExportModalDismissed() &&
- isCSVExportModalOpen && (
-
- ) }
);
};
diff --git a/client/disputes/test/index.tsx b/client/disputes/test/index.tsx
index 37bbd2e93af..70fdcd326cc 100644
--- a/client/disputes/test/index.tsx
+++ b/client/disputes/test/index.tsx
@@ -11,12 +11,7 @@ import os from 'os';
* Internal dependencies
*/
import DisputesList from '..';
-import {
- useDisputes,
- useDisputesSummary,
- useReportingExportLanguage,
- useSettings,
-} from 'data/index';
+import { useDisputes, useDisputesSummary, useSettings } from 'data/index';
import { getUnformattedAmount } from 'wcpay/utils/test-utils';
import React from 'react';
import {
@@ -55,7 +50,6 @@ jest.mock( '@wordpress/data', () => ( {
jest.mock( 'data/index', () => ( {
useDisputes: jest.fn(),
useDisputesSummary: jest.fn(),
- useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ),
useSettings: jest.fn(),
} ) );
@@ -77,10 +71,6 @@ const mockUseSettings = useSettings as jest.MockedFunction<
typeof useSettings
>;
-const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction<
- typeof useReportingExportLanguage
->;
-
declare const global: {
wcpaySettings: {
zeroDecimalCurrencies: string[];
@@ -98,8 +88,8 @@ declare const global: {
precision: number;
};
};
- reporting?: {
- exportModalDismissed: boolean;
+ locale: {
+ code: string;
};
dateFormat?: string;
timeFormat?: string;
@@ -173,8 +163,6 @@ describe( 'Disputes list', () => {
new Date( '2019-11-07T12:33:37.000Z' ).getTime()
);
- mockUseReportingExportLanguage.mockReturnValue( [ 'en', jest.fn() ] );
-
mockUseSettings.mockReturnValue( {
isLoading: false,
isSaving: false,
@@ -198,8 +186,8 @@ describe( 'Disputes list', () => {
precision: 2,
},
},
- reporting: {
- exportModalDismissed: true,
+ locale: {
+ code: 'en',
},
dateFormat: 'Y-m-d',
timeFormat: 'g:iA',
diff --git a/client/globals.d.ts b/client/globals.d.ts
index 8b91ee4b05f..d7b22d130eb 100644
--- a/client/globals.d.ts
+++ b/client/globals.d.ts
@@ -124,9 +124,6 @@ declare global {
isNextDepositNoticeDismissed: boolean;
isInstantDepositNoticeDismissed: boolean;
isDateFormatNoticeDismissed: boolean;
- reporting: {
- exportModalDismissed?: boolean;
- };
locale: {
code: string;
english_name: string;
diff --git a/client/settings/reporting-settings/components/export-language/index.tsx b/client/settings/reporting-settings/components/export-language/index.tsx
deleted file mode 100644
index 950d43f5584..00000000000
--- a/client/settings/reporting-settings/components/export-language/index.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * External dependencies
- */
-import React from 'react';
-import { __ } from '@wordpress/i18n';
-import { addQueryArgs } from '@wordpress/url';
-import { SelectControl, ExternalLink } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import interpolateComponents from '@automattic/interpolate-components';
-import { ReportingExportLanguageHook } from '../../interfaces';
-import { useReportingExportLanguage } from 'wcpay/data';
-import { getExportLanguageOptions } from 'wcpay/utils';
-
-const ExportLanguage: React.FC = () => {
- const [
- exportLanguage,
- updateExportLanguage,
- ] = useReportingExportLanguage() as ReportingExportLanguageHook;
-
- const handleExportLanguageChange = ( language: string ) => {
- updateExportLanguage( language );
- };
-
- return (
-
-
-
- { interpolateComponents( {
- mixedString: __(
- 'You can change your global site language preferences in {{learnMoreLink}}General Settings{{/learnMoreLink}}.',
- 'woocommerce-payments'
- ),
- components: {
- learnMoreLink: (
- // eslint-disable-next-line max-len
-
- ),
- },
- } ) }
-
-
- );
-};
-
-export default ExportLanguage;
diff --git a/client/settings/reporting-settings/components/index.ts b/client/settings/reporting-settings/components/index.ts
deleted file mode 100644
index 3c3360bd22a..00000000000
--- a/client/settings/reporting-settings/components/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Internal dependencies
- */
-import ExportLanguage from './export-language';
-
-export { ExportLanguage };
diff --git a/client/settings/reporting-settings/index.tsx b/client/settings/reporting-settings/index.tsx
deleted file mode 100644
index 9e2ee4a0178..00000000000
--- a/client/settings/reporting-settings/index.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * External dependencies
- */
-import React from 'react';
-import { __ } from '@wordpress/i18n';
-import { Card } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import CardBody from '../card-body';
-import { ExportLanguage } from './components';
-import './style.scss';
-
-const Reporting: React.FC = () => {
- return (
- <>
-
-
-
-
- { __(
- 'Report exporting default language',
- 'woocommerce-payments'
- ) }
-
-
-
-
-
- >
- );
-};
-
-export default Reporting;
diff --git a/client/settings/reporting-settings/interfaces.ts b/client/settings/reporting-settings/interfaces.ts
deleted file mode 100644
index 22f37cb1e7b..00000000000
--- a/client/settings/reporting-settings/interfaces.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export type ReportingExportLanguageHook = [
- string,
- ( language: string ) => void
-];
diff --git a/client/settings/reporting-settings/style.scss b/client/settings/reporting-settings/style.scss
deleted file mode 100644
index 354c2530e61..00000000000
--- a/client/settings/reporting-settings/style.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-.reporting-settings {
- &__text--help-text {
- font-size: 12px;
- color: #757575;
- margin: 0;
- display: inline-block;
- }
-
- .reporting-export-language {
- flex-wrap: wrap;
- margin-bottom: 0;
- .components-select-control {
- padding-right: 16px;
- margin-bottom: 0;
- }
- }
-}
diff --git a/client/settings/reporting-settings/test/__snapshots__/index.test.js.snap b/client/settings/reporting-settings/test/__snapshots__/index.test.js.snap
deleted file mode 100644
index aef73119cb9..00000000000
--- a/client/settings/reporting-settings/test/__snapshots__/index.test.js.snap
+++ /dev/null
@@ -1,151 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Reporting Settings should render correctly 1`] = `
-
-
-
-
-
-
- Report exporting default language
-
-
-
-
-
-
-
-
-
-`;
diff --git a/client/settings/reporting-settings/test/index.test.js b/client/settings/reporting-settings/test/index.test.js
deleted file mode 100644
index ef0a2437145..00000000000
--- a/client/settings/reporting-settings/test/index.test.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * External dependencies
- */
-import { render, screen, within } from '@testing-library/react';
-
-/**
- * Internal dependencies
- */
-import Reporting from '..';
-import { useReportingExportLanguage } from 'wcpay/data';
-
-jest.mock( '@wordpress/data' );
-
-jest.mock( 'wcpay/data', () => ( {
- useReportingExportLanguage: jest.fn(),
-} ) );
-
-describe( 'Reporting Settings', () => {
- beforeEach( () => {
- useReportingExportLanguage.mockReturnValue( [ 'en_US', jest.fn() ] );
-
- global.wcpaySettings = {
- locale: {
- code: 'es_ES',
- native_name: 'Spanish',
- },
- };
- } );
-
- it( 'should render correctly', () => {
- const { container } = render( );
- expect( container ).toMatchSnapshot();
-
- expect(
- screen.getByText( /Report exporting default language/ )
- ).toBeInTheDocument();
- expect(
- screen.getByText(
- /You can change your global site language preferences/
- )
- ).toBeInTheDocument();
- } );
-
- it( 'renders the language select', () => {
- render( );
-
- const languageSelect = screen.getByLabelText( /Language/ );
- expect( languageSelect ).toHaveValue( 'en_US' );
-
- within( languageSelect ).getByRole( 'option', { name: /English/ } );
- within( languageSelect ).getByRole( 'option', {
- name: /Site Language - Spanish/,
- } );
- } );
-} );
diff --git a/client/settings/settings-manager/index.js b/client/settings/settings-manager/index.js
index fc238c706b2..3da257c9074 100644
--- a/client/settings/settings-manager/index.js
+++ b/client/settings/settings-manager/index.js
@@ -14,7 +14,6 @@ import AdvancedSettings from '../advanced-settings';
import ExpressCheckout from '../express-checkout';
import SettingsSection from '../settings-section';
import GeneralSettings from '../general-settings';
-import ReportingSettings from '../reporting-settings';
import SettingsLayout from '../settings-layout';
import SaveSettingsSection from '../save-settings-section';
import Transactions from '../transactions';
@@ -29,7 +28,6 @@ import {
useSettings,
} from '../../data';
import FraudProtection from '../fraud-protection';
-import { isDefaultSiteLanguage } from 'wcpay/utils';
import DuplicatedPaymentMethodsContext from './duplicated-payment-methods-context';
const ExpressCheckoutDescription = () => (
@@ -124,20 +122,6 @@ const FraudProtectionDescription = () => {
);
};
-const ReportingDescription = () => {
- return (
- <>
- { __( 'Reporting', 'woocommerce-payments' ) }
-
- { __(
- 'Adjust your report exporting language preferences.',
- 'woocommerce-payments'
- ) }
-
- >
- );
-};
-
const AdvancedDescription = () => {
return (
<>
@@ -260,18 +244,6 @@ const SettingsManager = () => {
- { ! isDefaultSiteLanguage() && (
-
-
-
-
-
-
-
- ) }
getColumns(
@@ -599,13 +581,13 @@ export const TransactionsList = (
const downloadable = !! rows.length;
- const endpointExport = async ( language: string ) => {
+ const endpointExport = async () => {
// We destructure page and path to get the right params.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { page, path, ...params } = getQuery();
const userEmail = wcpaySettings.currentUserEmail;
- const locale = getExportLanguage( language, exportLanguage );
+ const locale = wcpaySettings.locale.code;
const {
date_after: dateAfter,
date_before: dateBefore,
@@ -722,11 +704,7 @@ export const TransactionsList = (
} );
if ( 'endpoint' === downloadType ) {
- if ( ! isDefaultSiteLanguage() && ! isExportModalDismissed() ) {
- setCSVExportModalOpen( true );
- } else {
- endpointExport( '' );
- }
+ endpointExport();
} else {
const columnsToDisplayInCsv = columnsToDisplay.map( ( column ) => {
if ( column.labelInCsv ) {
@@ -810,16 +788,6 @@ export const TransactionsList = (
}
}
- const closeModal = () => {
- setCSVExportModalOpen( false );
- };
-
- const exportTransactions = ( language: string ) => {
- endpointExport( language );
-
- closeModal();
- };
-
const showFilters = ! props.depositId;
const storeCurrencies =
transactionsSummary.store_currencies ||
@@ -870,17 +838,6 @@ export const TransactionsList = (
),
] }
/>
-
- { ! isDefaultSiteLanguage() &&
- ! isExportModalDismissed() &&
- isCSVExportModalOpen && (
-
- ) }
);
};
diff --git a/client/transactions/list/test/index.tsx b/client/transactions/list/test/index.tsx
index 66db0268a34..ce8ff812523 100644
--- a/client/transactions/list/test/index.tsx
+++ b/client/transactions/list/test/index.tsx
@@ -18,11 +18,7 @@ import os from 'os';
* Internal dependencies
*/
import { TransactionsList } from '../';
-import {
- useTransactions,
- useTransactionsSummary,
- useReportingExportLanguage,
-} from 'data/index';
+import { useTransactions, useTransactionsSummary } from 'data/index';
import type { Transaction } from 'data/transactions/hooks';
jest.mock( '@woocommerce/csv-export', () => {
@@ -55,7 +51,6 @@ jest.mock( '@wordpress/data', () => ( {
jest.mock( 'data/index', () => ( {
useTransactions: jest.fn(),
useTransactionsSummary: jest.fn(),
- useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ),
} ) );
// Mock dateI18n
@@ -81,10 +76,6 @@ const mockUseTransactionsSummary = useTransactionsSummary as jest.MockedFunction
typeof useTransactionsSummary
>;
-const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction<
- typeof useReportingExportLanguage
->;
-
declare const global: {
wcpaySettings: {
isSubscriptionsActive: boolean;
@@ -106,8 +97,8 @@ declare const global: {
precision: number;
};
};
- reporting?: {
- exportModalDismissed: boolean;
+ locale: {
+ code: string;
};
};
};
@@ -227,8 +218,6 @@ describe( 'Transactions list', () => {
// the query string is preserved across tests, so we need to reset it
updateQueryString( {}, '/', {} );
- mockUseReportingExportLanguage.mockReturnValue( [ 'en', jest.fn() ] );
-
global.wcpaySettings = {
featureFlags: {
customSearch: true,
@@ -249,8 +238,8 @@ describe( 'Transactions list', () => {
precision: 2,
},
},
- reporting: {
- exportModalDismissed: true,
+ locale: {
+ code: 'en',
},
};
window.wcpaySettings.dateFormat = 'M j, Y';
diff --git a/client/transactions/test/index.tsx b/client/transactions/test/index.tsx
index 9eae004fd90..1a979376127 100644
--- a/client/transactions/test/index.tsx
+++ b/client/transactions/test/index.tsx
@@ -18,7 +18,6 @@ import {
useSettings,
useTransactions,
useTransactionsSummary,
- useReportingExportLanguage,
} from 'data/index';
jest.mock( '@wordpress/api-fetch', () => jest.fn() );
@@ -46,7 +45,6 @@ jest.mock( 'data/index', () => ( {
useManualCapture: jest.fn(),
useSettings: jest.fn(),
useAuthorizationsSummary: jest.fn(),
- useReportingExportLanguage: jest.fn( () => [ 'en', jest.fn() ] ),
} ) );
const mockUseTransactions = useTransactions as jest.MockedFunction<
@@ -73,10 +71,6 @@ const mockUseFraudOutcomeTransactionsSummary = useFraudOutcomeTransactionsSummar
typeof useFraudOutcomeTransactionsSummary
>;
-const mockUseReportingExportLanguage = useReportingExportLanguage as jest.MockedFunction<
- typeof useReportingExportLanguage
->;
-
declare const global: {
wcpaySettings: {
featureFlags: {
@@ -97,8 +91,6 @@ describe( 'TransactionsPage', () => {
beforeEach( () => {
jest.clearAllMocks();
- mockUseReportingExportLanguage.mockReturnValue( [ 'en', jest.fn() ] );
-
// the query string is preserved across tests, so we need to reset it
updateQueryString( {}, '/', {} );
diff --git a/client/utils/index.js b/client/utils/index.js
index c642c1034e1..99f7f96f3e5 100644
--- a/client/utils/index.js
+++ b/client/utils/index.js
@@ -7,7 +7,6 @@ import moment from 'moment';
import { dateI18n } from '@wordpress/date';
import { NAMESPACE } from 'wcpay/data/constants';
import { numberFormat } from '@woocommerce/number';
-import { __ } from '@wordpress/i18n';
/**
* Returns whether a value is an object.
@@ -237,80 +236,6 @@ export const applyThousandSeparator = ( trxCount ) => {
return formattedNumber( trxCount );
};
-/**
- * Returns true if Export Modal is dismissed, false otherwise.
- *
- * @return {boolean} True if dismissed, false otherwise.
- */
-export const isExportModalDismissed = () => {
- if ( typeof wcpaySettings === 'undefined' ) {
- return true;
- }
-
- return wcpaySettings?.reporting?.exportModalDismissed ?? false;
-};
-
-/**
- * Returns true if Export Modal is dismissed, false otherwise.
- *
- * @return {boolean} True if dismissed, false otherwise.
- */
-
-export const isDefaultSiteLanguage = () => {
- if ( typeof wcpaySettings === 'undefined' ) {
- return true;
- }
-
- return wcpaySettings.locale?.code === 'en_US';
-};
-
-/**
- * Returns the language code for CSV exports.
- *
- * @param {string} language Selected language code.
- * @param {string} storedLanguage Stored language code.
- *
- * @return {string} Language code.
- */
-export const getExportLanguage = ( language, storedLanguage ) => {
- let siteLanguage = 'en_US';
-
- // If the default site language is en_US, skip
- if ( isDefaultSiteLanguage() ) {
- return siteLanguage;
- }
-
- if ( typeof wcpaySettings !== 'undefined' ) {
- siteLanguage = wcpaySettings?.locale?.code ?? siteLanguage;
- }
-
- // In case the default export setting is not present, use the site locale.
- const defaultLanguage = storedLanguage ?? siteLanguage;
-
- // When modal is dismissed use the default language locale.
- return language !== '' ? language : defaultLanguage;
-};
-
-/**
- * Returns the language options for CSV exports language selector.
- *
- * @return {Array} Language options.
- */
-export const getExportLanguageOptions = () => {
- return [
- {
- label: __( 'English (United States)', 'woocommerce-payments' ),
- value: 'en_US',
- },
- {
- label:
- __( 'Site Language - ', 'woocommerce-payments' ) +
- wcpaySettings.locale.native_name,
- value: wcpaySettings.locale.code,
- },
- ];
-};
-
/**
* Given an object, remove all properties with null or undefined values.
*
diff --git a/includes/admin/class-wc-payments-admin.php b/includes/admin/class-wc-payments-admin.php
index 392dec5c611..531fa432fb8 100644
--- a/includes/admin/class-wc-payments-admin.php
+++ b/includes/admin/class-wc-payments-admin.php
@@ -974,9 +974,6 @@ private function get_js_settings(): array {
'isNextDepositNoticeDismissed' => WC_Payments_Features::is_next_deposit_notice_dismissed(),
'isInstantDepositNoticeDismissed' => get_option( 'wcpay_instant_deposit_notice_dismissed', false ),
'isDateFormatNoticeDismissed' => get_option( 'wcpay_date_format_notice_dismissed', false ),
- 'reporting' => [
- 'exportModalDismissed' => get_option( 'wcpay_reporting_export_modal_dismissed', false ),
- ],
'dismissedDuplicateNotices' => get_option( 'wcpay_duplicate_payment_method_notices_dismissed', [] ),
'locale' => WC_Payments_Utils::get_language_data( get_locale() ),
'isOverviewSurveySubmitted' => get_option( 'wcpay_survey_payment_overview_submitted', false ),