Remove unpublished wc-admin-settings package and update getSetting usage (https://github.com/woocommerce/woocommerce-admin/pull/8057)

* Remove use of wc-admin-settings from packages

* Move getSetting to getAdminSetting and remove wc-admin-settings package

* Add changelog

* Update package.json and remove last use of wc-admin-settings
This commit is contained in:
louwie17 2022-01-06 08:53:30 -04:00 committed by GitHub
parent 0c028b4a87
commit 3998f88597
102 changed files with 390 additions and 479 deletions

View File

@ -5,6 +5,8 @@ module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
settings: {
'import/resolver': 'typescript',
// List of modules that are externals in our webpack config.
'import/core-modules': [ '@woocommerce/settings', 'lodash', 'react' ],
react: {
pragma: 'createElement',
},

View File

@ -0,0 +1,4 @@
Significance: minor
Type: Dev
Remove wc-admin-settings package and rename getSetting to getAdminSetting. #8057

View File

@ -6,7 +6,7 @@ import { lazy, useState } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { uniqueId, find } from 'lodash';
import { Icon, help as helpIcon, external } from '@wordpress/icons';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink, getSetting } from '@woocommerce/settings';
import { H, Section } from '@woocommerce/components';
import {
ONBOARDING_STORE_NAME,

View File

@ -6,12 +6,12 @@ import {
USER_STORE_NAME,
QUERY_DEFAULTS,
} from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { getUnreadNotesCount } from '~/inbox-panel/utils';
import { getAdminSetting } from '~/utils/admin-settings';
const UNREAD_NOTES_QUERY = {
page: 1,
@ -55,5 +55,5 @@ export function isNotesPanelVisible( select ) {
}
export function getLowStockCount() {
return getSetting( 'lowStockCount', 0 );
return getAdminSetting( 'lowStockCount', 0 );
}

View File

@ -4,13 +4,13 @@
import { render } from '@testing-library/react';
import { numberFormat } from '@woocommerce/number';
import CurrencyFactory from '@woocommerce/currency';
import { CURRENCY } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { Leaderboard } from '../';
import mockData from '../data/top-selling-products-mock-data';
import { CURRENCY } from '~/utils/admin-settings';
const { formatAmount, formatDecimal } = CurrencyFactory( CURRENCY );

View File

@ -7,7 +7,6 @@ import PropTypes from 'prop-types';
import { omitBy, isUndefined, snakeCase } from 'lodash';
import { withSelect, withDispatch } from '@wordpress/data';
import { ReportFilters as Filters } from '@woocommerce/components';
import { LOCALE } from '@woocommerce/wc-admin-settings';
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
import {
getCurrentDates,
@ -21,6 +20,7 @@ import { recordEvent } from '@woocommerce/tracks';
*/
import { CurrencyContext } from '../../../lib/currency-context';
import { STORE_KEY as CES_STORE_KEY } from '../../../customer-effort-score-tracks/data/constants';
import { LOCALE } from '~/utils/admin-settings';
class ReportFilters extends Component {
constructor() {

View File

@ -7,7 +7,6 @@ import { map } from 'lodash';
import { Date, Link } from '@woocommerce/components';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { formatValue } from '@woocommerce/number';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { defaultTableDateFormat } from '@woocommerce/date';
/**
@ -15,6 +14,7 @@ import { defaultTableDateFormat } from '@woocommerce/date';
*/
import ReportTable from '../../components/report-table';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
class CouponsReportTable extends Component {
constructor() {
@ -66,7 +66,10 @@ class CouponsReportTable extends Component {
getRowsContent( coupons ) {
const { query } = this.props;
const persistedQuery = getPersistedQuery( query );
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
const dateFormat = getAdminSetting(
'dateFormat',
defaultTableDateFormat
);
const {
formatAmount,
formatDecimal: getCurrencyFormatDecimal,

View File

@ -4,10 +4,9 @@
import { __, _x } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { applyFilters } from '@wordpress/hooks';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { NAMESPACE } from '@woocommerce/data';
const { countries } = getSetting( 'dataEndpoints', { countries: {} } );
const { countries } = getAdminSetting( 'dataEndpoints', { countries: {} } );
/**
* Internal dependencies
@ -16,6 +15,7 @@ import {
getCustomerLabels,
getRequestByIdString,
} from '../../../lib/async-requests';
import { getAdminSetting } from '~/utils/admin-settings';
const CUSTOMERS_REPORT_FILTERS_FILTER =
'woocommerce_admin_customers_report_filters';

View File

@ -6,7 +6,7 @@ import { Component, Fragment } from '@wordpress/element';
import { Tooltip } from '@wordpress/components';
import { Date, Link } from '@woocommerce/components';
import { formatValue } from '@woocommerce/number';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { defaultTableDateFormat } from '@woocommerce/date';
/**
@ -14,8 +14,9 @@ import { defaultTableDateFormat } from '@woocommerce/date';
*/
import ReportTable from '../../components/report-table';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
const { countries } = getSetting( 'dataEndpoints', { countries: {} } );
const { countries } = getAdminSetting( 'dataEndpoints', { countries: {} } );
class CustomersReportTable extends Component {
constructor() {
@ -109,7 +110,10 @@ class CustomersReportTable extends Component {
}
getRowsContent( customers ) {
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
const dateFormat = getAdminSetting(
'dateFormat',
defaultTableDateFormat
);
const {
formatAmount,
formatDecimal: getCurrencyFormatDecimal,

View File

@ -9,7 +9,7 @@ import moment from 'moment';
import { Date, Link } from '@woocommerce/components';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { formatValue } from '@woocommerce/number';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
import { getCurrentDates, defaultTableDateFormat } from '@woocommerce/date';
@ -18,6 +18,7 @@ import { getCurrentDates, defaultTableDateFormat } from '@woocommerce/date';
*/
import ReportTable from '../../components/report-table';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
class DownloadsReportTable extends Component {
constructor() {
@ -67,7 +68,10 @@ class DownloadsReportTable extends Component {
getRowsContent( downloads ) {
const { query } = this.props;
const persistedQuery = getPersistedQuery( query );
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
const dateFormat = getAdminSetting(
'dateFormat',
defaultTableDateFormat
);
return map( downloads, ( download ) => {
const {

View File

@ -3,15 +3,12 @@
*/
import { __ } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { lazy } from '@wordpress/element';
const manageStock = getSetting( 'manageStock', 'no' );
const REPORTS_FILTER = 'woocommerce_admin_reports_list';
/**
* Internal dependencies
*/
import { getAdminSetting } from '~/utils/admin-settings';
const RevenueReport = lazy( () =>
import( /* webpackChunkName: "analytics-report-revenue" */ './revenue' )
);
@ -47,6 +44,9 @@ const CustomersReport = lazy( () =>
import( /* webpackChunkName: "analytics-report-customers" */ './customers' )
);
const manageStock = getAdminSetting( 'manageStock', 'no' );
const REPORTS_FILTER = 'woocommerce_admin_reports_list';
export default () => {
const reports = [
{

View File

@ -3,7 +3,6 @@
*/
import { __, _x } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
import { ORDER_STATUSES } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
@ -14,6 +13,7 @@ import {
getTaxRateLabels,
getVariationLabels,
} from '../../../lib/async-requests';
import { ORDER_STATUSES } from '~/utils/admin-settings';
const ORDERS_REPORT_CHARTS_FILTER = 'woocommerce_admin_orders_report_charts';
const ORDERS_REPORT_FILTERS_FILTER = 'woocommerce_admin_orders_report_filters';

View File

@ -6,7 +6,6 @@ import { Component, Fragment } from '@wordpress/element';
import { map } from 'lodash';
import { Date, Link, OrderStatus, ViewMoreList } from '@woocommerce/components';
import { formatValue } from '@woocommerce/number';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { defaultTableDateFormat } from '@woocommerce/date';
@ -14,6 +13,7 @@ import { defaultTableDateFormat } from '@woocommerce/date';
* Internal dependencies
*/
import ReportTable from '../../components/report-table';
import { getAdminSetting } from '~/utils/admin-settings';
import { CurrencyContext } from '../../../lib/currency-context';
import './style.scss';
@ -108,7 +108,10 @@ class OrdersReportTable extends Component {
getRowsContent( tableData ) {
const { query } = this.props;
const persistedQuery = getPersistedQuery( query );
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
const dateFormat = getAdminSetting(
'dateFormat',
defaultTableDateFormat
);
const { render: renderCurrency, getCurrencyConfig } = this.context;
return map( tableData, ( row ) => {
@ -176,7 +179,10 @@ class OrdersReportTable extends Component {
<OrderStatus
className="woocommerce-orders-table__status"
order={ { status } }
orderStatusMap={ getSetting( 'orderStatuses', {} ) }
orderStatusMap={ getAdminSetting(
'orderStatuses',
{}
) }
/>
),
value: status,

View File

@ -10,7 +10,7 @@ import { map } from 'lodash';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { Link, Tag } from '@woocommerce/components';
import { formatValue } from '@woocommerce/number';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { ITEMS_STORE_NAME } from '@woocommerce/data';
/**
@ -20,10 +20,12 @@ import CategoryBreacrumbs from '../categories/breadcrumbs';
import { isLowStock } from './utils';
import ReportTable from '../../components/report-table';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
const manageStock = getSetting( 'manageStock', 'no' );
const stockStatuses = getSetting( 'stockStatuses', {} );
const manageStock = getAdminSetting( 'manageStock', 'no' );
const stockStatuses = getAdminSetting( 'stockStatuses', {} );
class ProductsReportTable extends Component {
constructor() {

View File

@ -9,7 +9,6 @@ import { compose } from '@wordpress/compose';
import { get, memoize } from 'lodash';
import { Date, Link } from '@woocommerce/components';
import { formatValue } from '@woocommerce/number';
import { getSetting } from '@woocommerce/wc-admin-settings';
import {
getReportTableQuery,
REPORTS_STORE_NAME,
@ -27,6 +26,7 @@ import { stringify } from 'qs';
* Internal dependencies
*/
import ReportTable from '../../components/report-table';
import { getAdminSetting } from '~/utils/admin-settings';
import { CurrencyContext } from '../../../lib/currency-context';
const EMPTY_ARRAY = [];
@ -121,7 +121,10 @@ class RevenueReportTable extends Component {
}
getRowsContent( data = [] ) {
const dateFormat = getSetting( 'dateFormat', defaultTableDateFormat );
const dateFormat = getAdminSetting(
'dateFormat',
defaultTableDateFormat
);
const {
formatAmount,
render: renderCurrency,

View File

@ -7,7 +7,7 @@ import { decodeEntities } from '@wordpress/html-entities';
import { Link } from '@woocommerce/components';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { formatValue } from '@woocommerce/number';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
@ -15,8 +15,9 @@ import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import ReportTable from '../../components/report-table';
import { isLowStock } from './utils';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
const stockStatuses = getSetting( 'stockStatuses', {} );
const stockStatuses = getAdminSetting( 'stockStatuses', {} );
class StockReportTable extends Component {
constructor() {

View File

@ -7,7 +7,7 @@ import { map } from 'lodash';
import { Link } from '@woocommerce/components';
import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
import { formatValue } from '@woocommerce/number';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
@ -16,9 +16,10 @@ import ReportTable from '../../components/report-table';
import { isLowStock } from '../products/utils';
import { CurrencyContext } from '../../../lib/currency-context';
import { getVariationName } from '../../../lib/async-requests';
import { getAdminSetting } from '~/utils/admin-settings';
const manageStock = getSetting( 'manageStock', 'no' );
const stockStatuses = getSetting( 'stockStatuses', {} );
const manageStock = getAdminSetting( 'manageStock', 'no' );
const stockStatuses = getAdminSetting( 'stockStatuses', {} );
const getFullVariationName = ( rowData ) =>
getVariationName( rowData.extended_info || {} );

View File

@ -4,12 +4,12 @@
import { __, sprintf } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
import interpolateComponents from 'interpolate-components';
import { getSetting, ORDER_STATUSES } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import DefaultDate from './default-date';
import { getAdminSetting, ORDER_STATUSES } from '~/utils/admin-settings';
const SETTINGS_FILTER = 'woocommerce_admin_analytics_settings';
export const DEFAULT_ACTIONABLE_STATUSES = [ 'processing', 'on-hold' ];
@ -37,7 +37,10 @@ const filteredOrderStatuses = Object.keys( ORDER_STATUSES )
};
} );
const unregisteredOrderStatuses = getSetting( 'unregisteredOrderStatuses', {} );
const unregisteredOrderStatuses = getAdminSetting(
'unregisteredOrderStatuses',
{}
);
const orderStatusOptions = [
{

View File

@ -8,7 +8,6 @@ import { Button, Modal } from '@wordpress/components';
import { find } from 'lodash';
import { decodeEntities } from '@wordpress/html-entities';
import { withSelect } from '@wordpress/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { List } from '@woocommerce/components';
import { ONBOARDING_STORE_NAME, PLUGINS_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
@ -19,6 +18,7 @@ import { recordEvent } from '@woocommerce/tracks';
import { getProductIdsForCart } from '../utils';
import sanitizeHTML from '../../lib/sanitize-html';
import { getInAppPurchaseUrl } from '../../lib/in-app-purchase';
import { getAdminSetting } from '~/utils/admin-settings';
class CartModal extends Component {
constructor( props ) {
@ -81,7 +81,7 @@ class CartModal extends Component {
renderProducts() {
const { productIds, productTypes } = this.props;
const { themes = [] } = getSetting( 'onboarding', {} );
const { themes = [] } = getAdminSetting( 'onboarding', {} );
const listItems = [];
productIds.forEach( ( productId ) => {

View File

@ -5,10 +5,14 @@ import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { escapeRegExp } from 'lodash';
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { SelectControl, TextControl } from '@woocommerce/components';
const { countries } = getSetting( 'dataEndpoints', { countries: {} } );
/**
* Internal dependencies
*/
import { getAdminSetting } from '~/utils/admin-settings';
const { countries } = getAdminSetting( 'dataEndpoints', { countries: {} } );
/**
* Form validation.
*

View File

@ -10,7 +10,7 @@ import {
getNewPath,
getPersistedQuery,
} from '@woocommerce/navigation';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { Text } from '@woocommerce/experimental';
/**

View File

@ -14,13 +14,13 @@ import {
SectionHeader,
} from '@woocommerce/components';
import { useUserPreferences, ITEMS_STORE_NAME } from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
*/
import Leaderboard from '../../analytics/components/leaderboard';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
const renderLeaderboardToggles = ( {
@ -175,9 +175,12 @@ Leaderboards.propTypes = {
export default compose(
withSelect( ( select ) => {
const { getItems, getItemsError } = select( ITEMS_STORE_NAME );
const { leaderboards: allLeaderboards } = getSetting( 'dataEndpoints', {
leaderboards: [],
} );
const { leaderboards: allLeaderboards } = getAdminSetting(
'dataEndpoints',
{
leaderboards: [],
}
);
return {
allLeaderboards,

View File

@ -5,7 +5,6 @@ import { __ } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { getPersistedQuery } from '@woocommerce/navigation';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { withSelect } from '@wordpress/data';
import { SETTINGS_STORE_NAME } from '@woocommerce/data';
import {
@ -26,10 +25,14 @@ import { recordEvent } from '@woocommerce/tracks';
import './style.scss';
import { CurrencyContext } from '../../lib/currency-context';
import { getIndicatorData, getIndicatorValues } from './utils';
import { getAdminSetting } from '~/utils/admin-settings';
const { performanceIndicators: indicators } = getSetting( 'dataEndpoints', {
performanceIndicators: [],
} );
const { performanceIndicators: indicators } = getAdminSetting(
'dataEndpoints',
{
performanceIndicators: [],
}
);
class StorePerformance extends Component {
renderMenu() {

View File

@ -11,7 +11,7 @@ import {
} from '@woocommerce/data';
import { getNewPath } from '@woocommerce/navigation';
import { calculateDelta, formatValue } from '@woocommerce/number';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
function getReportUrl( href, persistedQuery, primaryItem ) {
if ( ! href ) {

View File

@ -3,7 +3,11 @@
*/
import { decodeEntities } from '@wordpress/html-entities';
import { without } from 'lodash';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { getAdminSetting } from '~/utils/admin-settings';
/**
* Gets the country code from a country:state value string.
@ -23,7 +27,7 @@ export function getCountryCode( countryState ) {
export function getCurrencyRegion( countryState ) {
let region = getCountryCode( countryState );
const euCountries = without(
getSetting( 'onboarding', { euCountries: [] } ).euCountries,
getAdminSetting( 'onboarding', { euCountries: [] } ).euCountries,
'GB'
);
if ( euCountries.includes( region ) ) {
@ -143,7 +147,7 @@ export function getProductList(
}
} );
const onboarding = getSetting( 'onboarding', {} );
const onboarding = getAdminSetting( 'onboarding', {} );
let theme = null;
if ( onboarding && onboarding.themes ) {
theme = onboarding.themes.find(

View File

@ -5,7 +5,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { useEffect, useLayoutEffect, useRef } from '@wordpress/element';
import classnames from 'classnames';
import { decodeEntities } from '@wordpress/html-entities';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { getSetting } from '@woocommerce/settings';
import { Text, useSlot } from '@woocommerce/experimental';
/**

View File

@ -1,5 +1,5 @@
jest.mock( '@woocommerce/wc-admin-settings', () => ( {
...jest.requireActual( '@woocommerce/wc-admin-settings' ),
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting() {
return 'Fake Site Title';
},

View File

@ -10,7 +10,6 @@ import {
PanelRow,
__experimentalText as Text,
} from '@wordpress/components';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { ONBOARDING_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { useEffect } from '@wordpress/element';
@ -28,17 +27,21 @@ import {
import { getAllPanels } from './panels';
import { getUnapprovedReviews } from './reviews/utils';
import { getUrlParams } from '../../utils';
import { getAdminSetting } from '~/utils/admin-settings';
export const ActivityPanel = () => {
const panelsData = useSelect( ( select ) => {
const totalOrderCount = getSetting( 'orderCount', 0 );
const totalOrderCount = getAdminSetting( 'orderCount', 0 );
const orderStatuses = getOrderStatuses( select );
const reviewsEnabled = getSetting( 'reviewsEnabled', 'no' );
const reviewsEnabled = getAdminSetting( 'reviewsEnabled', 'no' );
const countUnreadOrders = getUnreadOrders( select, orderStatuses );
const manageStock = getSetting( 'manageStock', 'no' );
const manageStock = getAdminSetting( 'manageStock', 'no' );
const countLowStockProducts = getLowStockCount( select );
const countUnapprovedReviews = getUnapprovedReviews( select );
const publishedProductCount = getSetting( 'publishedProductCount', 0 );
const publishedProductCount = getAdminSetting(
'publishedProductCount',
0
);
const taskList = select( ONBOARDING_STORE_NAME ).getTaskList( 'setup' );
return {

View File

@ -15,7 +15,7 @@ import {
Section,
} from '@woocommerce/components';
import { getNewPath } from '@woocommerce/navigation';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { ITEMS_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
@ -26,6 +26,7 @@ import {
ActivityCard,
ActivityCardPlaceholder,
} from '~/activity-panel/activity-card';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
function recordOrderEvent( eventName ) {
@ -188,7 +189,7 @@ function renderOrders( orders ) {
>
<OrderStatus
order={ order }
orderStatusMap={ getSetting( 'orderStatuses', {} ) }
orderStatusMap={ getAdminSetting( 'orderStatuses', {} ) }
/>
</ActivityCard>
);

View File

@ -18,7 +18,7 @@ import {
ProductImage,
Section,
} from '@woocommerce/components';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { get, isNull } from 'lodash';
import { REVIEWS_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';

View File

@ -8,7 +8,6 @@ import { Component, Fragment } from '@wordpress/element';
import { ESCAPE } from '@wordpress/keycodes';
import { get } from 'lodash';
import { Link, ProductImage } from '@woocommerce/components';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { recordEvent } from '@woocommerce/tracks';
import moment from 'moment';
@ -16,6 +15,7 @@ import moment from 'moment';
* Internal dependencies
*/
import { ActivityCard } from '~/activity-panel/activity-card';
import { getAdminSetting } from '~/utils/admin-settings';
export class ProductStockCard extends Component {
constructor( props ) {
@ -194,7 +194,10 @@ export class ProductStockCard extends Component {
render() {
const { product } = this.props;
const { edited, editing } = this.state;
const notifyLowStockAmount = getSetting( 'notifyLowStockAmount', 0 );
const notifyLowStockAmount = getAdminSetting(
'notifyLowStockAmount',
0
);
const lowStockAmount = Number.isFinite( product.low_stock_amount )
? product.low_stock_amount
: notifyLowStockAmount;

View File

@ -4,7 +4,6 @@
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { identity } from 'lodash';
import { getSetting } from '@woocommerce/wc-admin-settings';
import {
ONBOARDING_STORE_NAME,
withOnboardingHydration,
@ -16,6 +15,7 @@ import type { History } from 'history';
* Internal dependencies
*/
import Layout from './layout';
import { getAdminSetting } from '~/utils/admin-settings';
type HomescreenProps = ReturnType< typeof withSelectHandler > & {
hasFinishedResolution: boolean;
@ -39,7 +39,7 @@ const Homescreen = ( {
return <Layout query={ query } />;
};
const onboardingData = getSetting( 'onboarding', {} );
const onboardingData = getAdminSetting( 'onboarding', {} );
const withSelectHandler = ( select: WCDataSelector ) => {
const { getProfileItems, hasFinishedResolution } = select(

View File

@ -13,7 +13,6 @@ import {
Link,
} from '@woocommerce/components';
import { useUserPreferences, PLUGINS_STORE_NAME } from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { getNewPath } from '@woocommerce/navigation';
import { recordEvent } from '@woocommerce/tracks';
import { Text } from '@woocommerce/experimental';
@ -26,8 +25,9 @@ import './style.scss';
import { DEFAULT_STATS, DEFAULT_HIDDEN_STATS } from './defaults';
import StatsList from './stats-list';
import { InstallJetpackCTA } from './install-jetpack-cta';
import { getAdminSetting } from '~/utils/admin-settings';
const { performanceIndicators = [] } = getSetting( 'dataEndpoints', {
const { performanceIndicators = [] } = getAdminSetting( 'dataEndpoints', {
performanceIndicators: [],
} );

View File

@ -11,7 +11,7 @@ import {
} from '@woocommerce/data';
import { H } from '@woocommerce/components';
import { recordEvent } from '@woocommerce/tracks';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies

View File

@ -7,12 +7,12 @@ import {
withCurrentUserHydration,
withSettingsHydration,
} from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import './stylesheets/_index.scss';
import { getAdminSetting } from '~/utils/admin-settings';
import { PageLayout, EmbedLayout, PrimaryLayout as NoticeArea } from './layout';
import { CustomerEffortScoreTracksContainer } from './customer-effort-score-tracks';
import { EmbeddedBodyLayout } from './embedded-body-layout';
@ -24,7 +24,7 @@ __webpack_public_path__ = global.wcAdminAssets.path;
const appRoot = document.getElementById( 'root' );
const embeddedRoot = document.getElementById( 'woocommerce-embedded-root' );
const settingsGroup = 'wc_admin';
const hydrateUser = getSetting( 'currentUserData' );
const hydrateUser = getAdminSetting( 'currentUserData' );
if ( appRoot ) {
let HydratedPageLayout = withSettingsHydration(

View File

@ -13,7 +13,6 @@ import {
getQueryExcludedScreens,
getScreenFromPath,
} from '@woocommerce/navigation';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { Spinner } from '@woocommerce/components';
/**
@ -21,6 +20,7 @@ import { Spinner } from '@woocommerce/components';
*/
import getReports from '../analytics/report/get-reports';
import { isWCAdmin } from '../dashboard/utils';
import { getAdminSetting } from '~/utils/admin-settings';
import { NoMatch } from './NoMatch';
const AnalyticsReport = lazy( () =>
@ -55,7 +55,7 @@ export const PAGES_FILTER = 'woocommerce_admin_pages_list';
export const getPages = () => {
const pages = [];
const initialBreadcrumbs = [
[ '', getSetting( 'woocommerceTranslation' ) ],
[ '', getAdminSetting( 'woocommerceTranslation' ) ],
];
pages.push( {
@ -179,7 +179,7 @@ export const getPages = () => {
path: '/settings/:page',
breadcrumbs: ( { match } ) => {
// @todo This might need to be refactored to retreive groups via data store.
const settingsPages = getSetting( 'settingsPages' );
const settingsPages = getAdminSetting( 'settingsPages' );
const page = settingsPages[ match.params.page ];
if ( ! page ) {
return [];

View File

@ -10,7 +10,6 @@ import PropTypes from 'prop-types';
import { get, isFunction, identity } from 'lodash';
import { parse } from 'qs';
import { getHistory, getQuery } from '@woocommerce/navigation';
import { getSetting } from '@woocommerce/wc-admin-settings';
import {
PLUGINS_STORE_NAME,
useUser,
@ -29,6 +28,7 @@ import { Controller, getPages } from './controller';
import { Header } from '../header';
import Notices from './notices';
import TransientNotices from './transient-notices';
import { getAdminSetting } from '~/utils/admin-settings';
import '~/activity-panel';
import '~/mobile-banner';
import './navigation';
@ -205,10 +205,10 @@ _Layout.propTypes = {
} ).isRequired,
};
const dataEndpoints = getSetting( 'dataEndpoints' );
const dataEndpoints = getAdminSetting( 'dataEndpoints' );
const Layout = compose(
withPluginsHydration( {
...getSetting( 'plugins', {} ),
...getAdminSetting( 'plugins', {} ),
jetpackStatus:
( dataEndpoints && dataEndpoints.jetpackStatus ) || false,
} ),
@ -264,7 +264,7 @@ const _PageLayout = () => {
export const PageLayout = compose(
window.wcSettings.admin
? withOptionsHydration( {
...getSetting( 'preloadOptions', {} ),
...getAdminSetting( 'preloadOptions', {} ),
} )
: identity
)( _PageLayout );
@ -272,16 +272,16 @@ export const PageLayout = compose(
const _EmbedLayout = () => (
<Layout
page={ {
breadcrumbs: getSetting( 'embedBreadcrumbs', [] ),
breadcrumbs: getAdminSetting( 'embedBreadcrumbs', [] ),
} }
isEmbedded
/>
);
export const EmbedLayout = compose(
getSetting( 'preloadOptions' )
getAdminSetting( 'preloadOptions' )
? withOptionsHydration( {
...getSetting( 'preloadOptions' ),
...getAdminSetting( 'preloadOptions' ),
} )
: identity
)( _EmbedLayout );

View File

@ -17,7 +17,6 @@ import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import moment from 'moment';
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { NOTES_STORE_NAME, QUERY_DEFAULTS } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { Text } from '@woocommerce/experimental';
@ -27,6 +26,7 @@ import { Text } from '@woocommerce/experimental';
*/
import sanitizeHTML from '../../lib/sanitize-html';
import StoreAlertsPlaceholder from './placeholder';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
@ -182,7 +182,7 @@ export class StoreAlerts extends Component {
render() {
const alerts = this.getAlerts();
const preloadAlertCount = getSetting( 'alertCount', 0, ( count ) =>
const preloadAlertCount = getAdminSetting( 'alertCount', 0, ( count ) =>
parseInt( count, 10 )
);

View File

@ -2,12 +2,12 @@
* External dependencies
*/
import { render, fireEvent } from '@testing-library/react';
import { setSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { StoreAlerts } from '../';
import { setAdminSetting } from '~/utils/admin-settings';
const alerts = [
{
@ -39,7 +39,7 @@ describe( 'StoreAlerts', () => {
} );
it( 'should show the placeholder when loading and preloaded alerts exist', () => {
setSetting( 'alertCount', 2 );
setAdminSetting( 'alertCount', 2 );
const { container } = render(
<StoreAlerts isLoading alerts={ alerts } />
);

View File

@ -6,12 +6,12 @@ import apiFetch from '@wordpress/api-fetch';
import { identity } from 'lodash';
import { getIdsFromQuery } from '@woocommerce/navigation';
import { NAMESPACE } from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { getTaxCode } from '../../analytics/report/taxes/utils';
import { getAdminSetting } from '~/utils/admin-settings';
/**
* Get a function that accepts ids as they are found in url parameter and
@ -96,7 +96,10 @@ export const getTaxRateLabels = getRequestByIdString(
* @return {string} - formatted variation name
*/
export function getVariationName( { attributes, name } ) {
const separator = getSetting( 'variationTitleAttributesSeparator', ' - ' );
const separator = getAdminSetting(
'variationTitleAttributesSeparator',
' - '
);
if ( name && name.indexOf( separator ) > -1 ) {
return name;

View File

@ -4,7 +4,10 @@
import { createContext } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';
import CurrencyFactory from '@woocommerce/currency';
import { CURRENCY } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { CURRENCY } from '~/utils/admin-settings';
const appCurrency = CurrencyFactory( CURRENCY );

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { addQueryArgs } from '@wordpress/url';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { getSetting } from '@woocommerce/settings';
/**
* Returns an in-app-purchase URL.

View File

@ -2,7 +2,6 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
@ -10,10 +9,11 @@ import { getSetting } from '@woocommerce/wc-admin-settings';
import './style.scss';
import RecommendedExtensions from '../components/recommended-extensions';
import KnowledgeBase from '../components/knowledge-base';
import { getAdminSetting } from '~/utils/admin-settings';
import '../data';
const CouponsOverview = () => {
const allowMarketplaceSuggestions = getSetting(
const allowMarketplaceSuggestions = getAdminSetting(
'allowMarketplaceSuggestions',
false
);

View File

@ -1,15 +1,15 @@
/**
* External dependencies
*/
import { getSetting } from '@woocommerce/wc-admin-settings';
import { without } from 'lodash';
/**
* Internal dependencies
*/
import TYPES from './action-types';
import { getAdminSetting } from '~/utils/admin-settings';
const { installedExtensions } = getSetting( 'marketing', {} );
const { installedExtensions } = getAdminSetting( 'marketing', {} );
const DEFAULT_STATE = {
installedPlugins: installedExtensions,

View File

@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { getSetting } from '@woocommerce/wc-admin-settings';
import { withOptionsHydration } from '@woocommerce/data';
/**
@ -12,10 +11,11 @@ import InstalledExtensions from './installed-extensions';
import RecommendedExtensions from '../components/recommended-extensions';
import KnowledgeBase from '../components/knowledge-base';
import WelcomeCard from './welcome-card';
import { getAdminSetting } from '~/utils/admin-settings';
import '../data';
const MarketingOverview = () => {
const allowMarketplaceSuggestions = getSetting(
const allowMarketplaceSuggestions = getAdminSetting(
'allowMarketplaceSuggestions',
false
);
@ -33,5 +33,5 @@ const MarketingOverview = () => {
};
export default withOptionsHydration( {
...getSetting( 'preloadOptions', {} ),
...getAdminSetting( 'preloadOptions', {} ),
} )( MarketingOverview );

View File

@ -12,7 +12,7 @@ import { createElement } from '@wordpress/element';
import { WelcomeCard } from '../index.js';
jest.mock( '@woocommerce/tracks' );
jest.mock( '@woocommerce/wc-admin-settings' );
jest.mock( '@woocommerce/settings' );
describe( 'WelcomeCard hide button', () => {
it( 'should record an event when clicked', () => {

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { act, render, waitFor } from '@testing-library/react';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { getHistory } from '@woocommerce/navigation';
import { useSelect } from '@wordpress/data';
import userEvent from '@testing-library/user-event';

View File

@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { decodeEntities } from '@wordpress/html-entities';
import { Icon, wordpress } from '@wordpress/icons';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { getSetting } from '@woocommerce/settings';
import { useSelect } from '@wordpress/data';
import { useEffect, useState } from '@wordpress/element';
import classnames from 'classnames';

View File

@ -11,8 +11,8 @@ import Header from '../';
global.window.wcNavigation = {};
jest.mock( '@woocommerce/wc-admin-settings', () => ( {
...jest.requireActual( '@woocommerce/wc-admin-settings' ),
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn( ( setting ) => {
const settings = {
homeUrl: 'https://fake-site-url.com',

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
type MenuId = 'primary' | 'favorites' | 'plugins' | 'secondary';

View File

@ -16,7 +16,7 @@ import {
} from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import ExternalIcon from 'gridicons/dist/external';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies

View File

@ -4,7 +4,7 @@
import { render, fireEvent, waitFor } from '@testing-library/react';
import { useSelect, useDispatch } from '@wordpress/data';
import { recordEvent } from '@woocommerce/tracks';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
@ -51,7 +51,7 @@ jest.mock(
} )
);
jest.mock( '@woocommerce/wc-admin-settings', () => ( {
jest.mock( '@woocommerce/settings', () => ( {
getAdminLink: jest
.fn()
.mockImplementation( ( link: string ) => 'https://test.ca/' + link ),

View File

@ -21,7 +21,7 @@ import {
QUERY_DEFAULTS,
} from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
@ -32,6 +32,7 @@ import ProductTypes from './steps/product-types';
import ProfileWizardHeader from './header';
import StoreDetails from './steps/store-details';
import Theme from './steps/theme';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
const STEPS_FILTER = 'woocommerce_admin_profile_wizard_steps';
@ -318,10 +319,11 @@ export default compose(
updateProfileItems,
};
} ),
getSetting( 'plugins' )
getAdminSetting( 'plugins' )
? withPluginsHydration( {
...getSetting( 'plugins' ),
jetpackStatus: getSetting( 'dataEndpoints', {} ).jetpackStatus,
...getAdminSetting( 'plugins' ),
jetpackStatus: getAdminSetting( 'dataEndpoints', {} )
.jetpackStatus,
} )
: identity
)( ProfileWizard );

View File

@ -13,7 +13,6 @@ import {
import { compose } from '@wordpress/compose';
import { filter, find, findIndex, get } from 'lodash';
import { withDispatch, withSelect } from '@wordpress/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { ONBOARDING_STORE_NAME, SETTINGS_STORE_NAME } from '@woocommerce/data';
import { TextControl } from '@woocommerce/components';
import { recordEvent } from '@woocommerce/tracks';
@ -23,8 +22,9 @@ import { Text } from '@woocommerce/experimental';
* Internal dependencies
*/
import { getCurrencyRegion } from '../../dashboard/utils';
import { getAdminSetting } from '~/utils/admin-settings';
const onboarding = getSetting( 'onboarding', {} );
const onboarding = getAdminSetting( 'onboarding', {} );
class Industry extends Component {
constructor( props ) {

View File

@ -16,7 +16,6 @@ import { Component, useRef } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { Form, TextControl } from '@woocommerce/components';
import { getSetting } from '@woocommerce/wc-admin-settings';
import {
ONBOARDING_STORE_NAME,
OPTIONS_STORE_NAME,
@ -36,6 +35,7 @@ import {
} from '../../../dashboard/components/settings/general/store-address';
import UsageModal from '../usage-modal';
import { CurrencyContext } from '../../../lib/currency-context';
import { getAdminSetting } from '~/utils/admin-settings';
import './style.scss';
// FlexItem is not available until WP version 5.5. This code is safe to remove
@ -77,7 +77,7 @@ class StoreDetails extends Component {
const Currency = this.context;
const country = getCountryCode( countryState );
const { currencySymbols = {}, localeInfo = {} } = getSetting(
const { currencySymbols = {}, localeInfo = {} } = getAdminSetting(
'onboarding',
{}
);

View File

@ -17,7 +17,6 @@ import {
} from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { H } from '@woocommerce/components';
import { getSetting, setSetting } from '@woocommerce/wc-admin-settings';
import { ONBOARDING_STORE_NAME } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';
import { Text } from '@woocommerce/experimental';
@ -29,6 +28,7 @@ import './style.scss';
import ThemeUploader from './uploader';
import ThemePreview from './preview';
import { getPriceValue } from '../../../dashboard/utils';
import { getAdminSetting, setAdminSetting } from '~/utils/admin-settings';
class Theme extends Component {
constructor() {
@ -84,7 +84,7 @@ class Theme extends Component {
onChoose( theme, location = '' ) {
const { updateProfileItems } = this.props;
const { is_installed: isInstalled, price, slug } = theme;
const { activeTheme = '' } = getSetting( 'onboarding', {} );
const { activeTheme = '' } = getAdminSetting( 'onboarding', {} );
this.setState( { chosen: slug } );
recordEvent( 'storeprofiler_store_theme_choose', {
@ -147,8 +147,8 @@ class Theme extends Component {
response.name
)
);
setSetting( 'onboarding', {
...getSetting( 'onboarding', {} ),
setAdminSetting( 'onboarding', {
...getAdminSetting( 'onboarding', {} ),
activeTheme: response.slug,
} );
updateProfileItems( { theme: slug } );
@ -177,7 +177,7 @@ class Theme extends Component {
}
skipStep() {
const { activeTheme = '' } = getSetting( 'onboarding', {} );
const { activeTheme = '' } = getAdminSetting( 'onboarding', {} );
recordEvent( 'storeprofiler_store_theme_skip_step', { activeTheme } );
this.props.goToNextStep();
}
@ -191,7 +191,7 @@ class Theme extends Component {
title,
} = theme;
const { chosen } = this.state;
const { activeTheme = '' } = getSetting( 'onboarding', {} );
const { activeTheme = '' } = getAdminSetting( 'onboarding', {} );
return (
<Card className="woocommerce-profile-wizard__theme" key={ slug }>
@ -267,7 +267,7 @@ class Theme extends Component {
getThemeStatus( theme ) {
const { is_installed: isInstalled, price, slug } = theme;
const { activeTheme = '' } = getSetting( 'onboarding', {} );
const { activeTheme = '' } = getAdminSetting( 'onboarding', {} );
if ( activeTheme === slug ) {
return __( 'Currently active theme', 'woocommerce-admin' );
@ -285,7 +285,7 @@ class Theme extends Component {
}
doesActiveThemeSupportWooCommerce() {
const { activeTheme = '' } = getSetting( 'onboarding', {} );
const { activeTheme = '' } = getAdminSetting( 'onboarding', {} );
const allThemes = this.getThemes();
const currentTheme = allThemes.find(
( theme ) => theme.slug === activeTheme
@ -306,7 +306,7 @@ class Theme extends Component {
getThemes( activeTab = 'all' ) {
const { uploadedThemes } = this.state;
const { activeTheme = '', themes = [] } = getSetting(
const { activeTheme = '', themes = [] } = getAdminSetting(
'onboarding',
{}
);

View File

@ -6,18 +6,20 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { Button, ExternalLink } from '@wordpress/components';
import { Pill } from '@woocommerce/components';
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
*/
import './woocommerce-services-item.scss';
import WooIcon from './woo-icon.svg';
import { getAdminSetting } from '../utils/admin-settings';
const WooCommerceServicesItem: React.FC< {
pluginsBeingSetup: Array< string >;
onSetupClick: ( slugs: string[] ) => PromiseLike< void >;
} > = ( { onSetupClick, pluginsBeingSetup } ) => {
const wcAdminAssetUrl = getSetting( 'wcAdminAssetUrl', '' );
const wcAdminAssetUrl = getAdminSetting( 'wcAdminAssetUrl', '' );
const { createSuccessNotice } = useDispatch( 'core/notices' );
const isSiteConnectedToJetpack = useSelect( ( select ) =>

View File

@ -14,7 +14,6 @@ import {
payment,
pencil,
} from '@wordpress/icons';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { recordEvent } from '@woocommerce/tracks';
import { Text } from '@woocommerce/experimental';
@ -24,6 +23,7 @@ import { Text } from '@woocommerce/experimental';
import './style.scss';
import { QuickLinkCategory } from './quick-link-category';
import { QuickLink } from './quick-link';
import { getAdminSetting } from '~/utils/admin-settings';
export function getItemsByCategory( shopUrl ) {
return [
@ -156,7 +156,7 @@ export const generateExtensionLinks = ( links ) => {
};
export const StoreManagementLinks = () => {
const shopUrl = getSetting( 'shopUrl' );
const shopUrl = getAdminSetting( 'shopUrl' );
const extensionQuickLinks = generateExtensionLinks(
applyFilters( 'woocommerce_admin_homescreen_quicklinks', [] )

View File

@ -3,8 +3,8 @@ jest.mock( '@woocommerce/tracks', () => ( {
recordEvent: jest.fn(),
} ) );
jest.mock( '@woocommerce/wc-admin-settings', () => ( {
...jest.requireActual( '@woocommerce/wc-admin-settings' ),
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn( () => 'https://fake-site-url.com' ),
} ) );

View File

@ -3,7 +3,7 @@
*/
import { __, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { recordEvent } from '@woocommerce/tracks';
import { Text } from '@woocommerce/experimental';
import { Pill } from '@woocommerce/components';

View File

@ -3,7 +3,6 @@
*/
import { __, sprintf } from '@wordpress/i18n';
import { Card, CardBody } from '@wordpress/components';
import { enqueueScript } from '@woocommerce/wc-admin-settings';
import {
OPTIONS_STORE_NAME,
PAYMENT_GATEWAYS_STORE_NAME,
@ -20,6 +19,7 @@ import { useSlot } from '@woocommerce/experimental';
* Internal dependencies
*/
import { createNoticesFromResponse } from '~/lib/notices';
import { enqueueScript } from '~/utils/enqueue-script';
import { Configure } from './Configure';
import './Setup.scss';

View File

@ -2,12 +2,12 @@
* External dependencies
*/
import { act, render } from '@testing-library/react';
import { enqueueScript } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import { Setup } from '../';
import { enqueueScript } from '~/utils/enqueue-script';
jest.mock( '@woocommerce/components', () => {
const originalModule = jest.requireActual( '@woocommerce/components' );
@ -19,7 +19,8 @@ jest.mock( '@woocommerce/components', () => {
};
} );
jest.mock( '@woocommerce/wc-admin-settings' );
jest.mock( '@woocommerce/settings' );
jest.mock( '~/utils/enqueue-script' );
const mockGateway = {
id: 'mock-gateway',

View File

@ -12,7 +12,7 @@ import {
PLUGINS_STORE_NAME,
SETTINGS_STORE_NAME,
} from '@woocommerce/data';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { recordEvent } from '@woocommerce/tracks';
/**

View File

@ -19,7 +19,7 @@ import {
} from '@woocommerce/data';
import { useSelect } from '@wordpress/data';
import { List, Pill } from '@woocommerce/components';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { recordEvent } from '@woocommerce/tracks';
import { registerPlugin } from '@wordpress/plugins';
import { WooOnboardingTask } from '@woocommerce/onboarding';

View File

@ -10,7 +10,7 @@ import { difference, filter } from 'lodash';
import interpolateComponents from 'interpolate-components';
import { withDispatch, withSelect } from '@wordpress/data';
import { Link, Stepper, Plugins } from '@woocommerce/components';
import { getAdminLink, getSetting } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { getHistory, getNewPath } from '@woocommerce/navigation';
import {
SETTINGS_STORE_NAME,
@ -29,6 +29,7 @@ import { getCountryCode } from '../../../dashboard/utils';
import StoreLocation from '../steps/location';
import ShippingRates from './rates';
import { createNoticesFromResponse } from '../../../lib/notices';
import { getAdminSetting } from '~/utils/admin-settings';
import './shipping.scss';
export class Shipping extends Component {
@ -367,7 +368,7 @@ const ShippingWrapper = compose(
settings.woocommerce_default_country
);
const { countries = [] } = getSetting( 'dataEndpoints', {} );
const { countries = [] } = getAdminSetting( 'dataEndpoints', {} );
const country = countryCode
? countries.find( ( c ) => c.code === countryCode )
: null;

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import interpolateComponents from 'interpolate-components';
import { recordEvent } from '@woocommerce/tracks';

View File

@ -4,7 +4,7 @@
import { __ } from '@wordpress/i18n';
import { Card, CardBody, Spinner } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import {
ONBOARDING_STORE_NAME,
OPTIONS_STORE_NAME,

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { WPDataSelectors } from '@woocommerce/data';
/**

View File

@ -2,29 +2,20 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { getSetting } from '@woocommerce/settings';
// Remove mutable data from settings object to prevent access. Data stores should be used instead.
const mutableSources = [ 'wcAdminSettings', 'preloadSettings' ];
const settings = typeof wcSettings === 'object' ? wcSettings : {};
const SOURCE = Object.keys( settings ).reduce( ( source, key ) => {
if ( ! mutableSources.includes( key ) ) {
source[ key ] = settings[ key ];
}
return source;
}, {} );
Object.keys( settings.admin || {} ).forEach( ( key ) => {
if ( ! mutableSources.includes( key ) ) {
SOURCE[ key ] = settings.admin[ key ];
}
} );
export const ADMIN_URL = SOURCE.adminUrl;
export const COUNTRIES = SOURCE.countries;
export const CURRENCY = SOURCE.currency;
export const LOCALE = SOURCE.locale;
export const ORDER_STATUSES = SOURCE.orderStatuses;
export const SITE_TITLE = SOURCE.siteTitle;
export const WC_ASSET_URL = SOURCE.wcAssetUrl;
const adminSettings = getSetting( 'admin', {} );
const ADMIN_SETTINGS_SOURCE = Object.keys( adminSettings ).reduce(
( source, key ) => {
if ( ! mutableSources.includes( key ) ) {
source[ key ] = adminSettings[ key ];
}
return source;
},
{}
);
/**
* Retrieves a setting value from the setting state.
@ -42,16 +33,30 @@ export const WC_ASSET_URL = SOURCE.wcAssetUrl;
* @return {*} The value present in the settings state for the given
* name.
*/
export function getSetting( name, fallback = false, filter = ( val ) => val ) {
export function getAdminSetting(
name,
fallback = false,
filter = ( val ) => val
) {
if ( mutableSources.includes( name ) ) {
throw new Error(
__( 'Mutable settings should be accessed via data store.' )
);
}
const value = SOURCE.hasOwnProperty( name ) ? SOURCE[ name ] : fallback;
const value = ADMIN_SETTINGS_SOURCE.hasOwnProperty( name )
? ADMIN_SETTINGS_SOURCE[ name ]
: fallback;
return filter( value, fallback );
}
export const ADMIN_URL = getSetting( 'adminUrl' );
export const COUNTRIES = getSetting( 'countries' );
export const CURRENCY = getSetting( 'currency' );
export const LOCALE = getSetting( 'locale' );
export const SITE_TITLE = getSetting( 'siteTitle' );
export const WC_ASSET_URL = getSetting( 'wcAssetUrl' );
export const ORDER_STATUSES = getAdminSetting( 'orderStatuses' );
/**
* Sets a value to a property on the settings state.
*
@ -67,44 +72,11 @@ export function getSetting( name, fallback = false, filter = ( val ) => val ) {
* to sanitize the setting (eg.
* ensure it's a number)
*/
export function setSetting( name, value, filter = ( val ) => val ) {
export function setAdminSetting( name, value, filter = ( val ) => val ) {
if ( mutableSources.includes( name ) ) {
throw new Error(
__( 'Mutable settings should be mutated via data store.' )
);
}
SOURCE[ name ] = filter( value );
}
/**
* Returns a string with the site's wp-admin URL appended. JS version of `admin_url`.
*
* @param {string} path Relative path.
* @return {string} Full admin URL.
*/
export function getAdminLink( path ) {
return ( ADMIN_URL || '' ) + path;
}
/**
* Adds a script to the page if it has not already been loaded. JS version of `wp_enqueue_script`.
*
* @param {Object} script WP_Script
* @param {string} script.handle Script handle.
* @param {string} script.src Script URL.
*/
export function enqueueScript( script ) {
return new Promise( ( resolve, reject ) => {
if ( document.querySelector( `#${ script.handle }-js` ) ) {
resolve();
}
const domElement = document.createElement( 'script' );
domElement.src = script.src;
domElement.id = `${ script.handle }-js`;
domElement.async = true;
domElement.onload = resolve;
domElement.onerror = reject;
document.body.appendChild( domElement );
} );
ADMIN_SETTINGS_SOURCE[ name ] = filter( value );
}

View File

@ -0,0 +1,22 @@
/**
* Adds a script to the page if it has not already been loaded. JS version of `wp_enqueue_script`.
*
* @param {Object} script WP_Script
* @param {string} script.handle Script handle.
* @param {string} script.src Script URL.
*/
export function enqueueScript( script ) {
return new Promise( ( resolve, reject ) => {
if ( document.querySelector( `#${ script.handle }-js` ) ) {
resolve();
}
const domElement = document.createElement( 'script' );
domElement.src = script.src;
domElement.id = `${ script.handle }-js`;
domElement.async = true;
domElement.onload = resolve;
domElement.onerror = reject;
document.body.appendChild( domElement );
} );
}

View File

@ -4,7 +4,7 @@
import { dispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import domReady from '@wordpress/dom-ready';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
import { queueRecordEvent } from '@woocommerce/tracks';
/**

View File

@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import domReady from '@wordpress/dom-ready';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
domReady( () => {
const actionButtons = document.querySelector( '.wc-actions' );

View File

@ -4,7 +4,7 @@
import { __ } from '@wordpress/i18n';
import { dispatch } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Displays a notice after product creation.

View File

@ -4,7 +4,7 @@
import { __ } from '@wordpress/i18n';
import { dispatch } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { getAdminLink } from '@woocommerce/settings';
/**
* Returns a promise and resolves when the loader overlay no longer exists.

View File

@ -3,12 +3,12 @@
*/
import { render } from '@wordpress/element';
import { withPluginsHydration } from '@woocommerce/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
*/
import ShippingBanner from './shipping-banner';
import { getAdminSetting } from '~/utils/admin-settings';
const metaBox = document.getElementById( 'wc-admin-shipping-banner-root' );
const args =
@ -16,7 +16,7 @@ const args =
// Render the header.
const HydratedShippingBanner = withPluginsHydration( {
...getSetting( 'plugins' ),
jetpackStatus: getSetting( 'dataEndpoints', {} ).jetpackStatus,
...getAdminSetting( 'plugins' ),
jetpackStatus: getAdminSetting( 'dataEndpoints', {} ).jetpackStatus,
} )( ShippingBanner );
render( <HydratedShippingBanner itemsCount={ args.items } />, metaBox );

View File

@ -10,7 +10,6 @@ import PropTypes from 'prop-types';
import { get, isArray } from 'lodash';
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
import { withDispatch, withSelect } from '@wordpress/data';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { recordEvent } from '@woocommerce/tracks';
/**
@ -20,8 +19,9 @@ import '../style.scss';
import DismissModal from '../dismiss-modal';
import SetupNotice, { setupErrorTypes } from '../setup-notice';
import { getWcsAssets, acceptWcsTos } from '../wcs-api';
import { getAdminSetting } from '~/utils/admin-settings';
const wcAdminAssetUrl = getSetting( 'wcAdminAssetUrl', '' );
const wcAdminAssetUrl = getAdminSetting( 'wcAdminAssetUrl', '' );
const wcsPluginSlug = 'woocommerce-services';
export class ShippingBanner extends Component {

View File

@ -17,7 +17,6 @@ jest.mock( '../../wcs-api.js' );
acceptWcsTos.mockReturnValue( Promise.resolve() );
jest.mock( '@woocommerce/tracks' );
jest.mock( '@woocommerce/wc-admin-settings' );
const wcsPluginSlug = 'woocommerce-services';

View File

@ -86,10 +86,6 @@ const webpackConfig = {
__dirname,
'../../../node_modules/@wordpress/components/src'
),
'@woocommerce/wc-admin-settings': path.resolve(
__dirname,
'../../../client/wc-admin-settings/index.js'
),
},
},
plugins: [

View File

@ -9420,16 +9420,6 @@
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz",
"integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw=="
},
"@types/yauzl": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz",
"integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==",
"dev": true,
"optional": true,
"requires": {
"@types/node": "*"
}
},
"@typescript-eslint/eslint-plugin": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.22.1.tgz",
@ -13086,13 +13076,6 @@
"debug": "4.3.1"
}
},
"@woocommerce/wc-admin-settings": {
"version": "file:packages/wc-admin-settings",
"dev": true,
"requires": {
"@wordpress/i18n": "3.17.0"
}
},
"@wordpress/a11y": {
"version": "2.15.3",
"resolved": "https://registry.npmjs.org/@wordpress/a11y/-/a11y-2.15.3.tgz",
@ -15659,6 +15642,18 @@
"debug": "^4.1.1",
"get-stream": "^5.1.0",
"yauzl": "^2.10.0"
},
"dependencies": {
"@types/yauzl": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz",
"integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==",
"dev": true,
"optional": true,
"requires": {
"@types/node": "*"
}
}
}
},
"file-entry-cache": {
@ -16830,6 +16825,36 @@
"tar-fs": "^2.0.0",
"unbzip2-stream": "^1.3.3",
"ws": "^7.2.3"
},
"dependencies": {
"chownr": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
"dev": true
},
"tar-fs": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
"dev": true,
"requires": {
"chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
"tar-stream": "^2.1.4"
}
},
"unbzip2-stream": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
"integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==",
"dev": true,
"requires": {
"buffer": "^5.2.1",
"through": "^2.3.8"
}
}
}
},
"read-pkg": {
@ -42424,18 +42449,6 @@
}
}
},
"tar-fs": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
"dev": true,
"requires": {
"chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
"tar-stream": "^2.1.4"
}
},
"tar-stream": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
@ -43346,16 +43359,6 @@
"which-boxed-primitive": "^1.0.2"
}
},
"unbzip2-stream": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
"integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==",
"dev": true,
"requires": {
"buffer": "^5.2.1",
"through": "^2.3.8"
}
},
"unc-path-regex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",

View File

@ -185,7 +185,6 @@
"@woocommerce/onboarding": "file:packages/onboarding",
"@woocommerce/style-build": "file:packages/style-build",
"@woocommerce/tracks": "file:packages/tracks",
"@woocommerce/wc-admin-settings": "file:packages/wc-admin-settings",
"@wordpress/babel-plugin-makepot": "2.1.3",
"@wordpress/babel-preset-default": "^6.2.0",
"@wordpress/browserslist-config": "4.0.1",

View File

@ -4,6 +4,7 @@
- Fix select-control component label/value alignment. #8045
- Fix clicking the error message opens the dropdown. #8094
- Fix misaligned "Rows per page" dropdown. #8113
- Remove dev dependency `@woocommerce/wc-admin-settings`. #8057
# 8.1.1

View File

@ -76,7 +76,6 @@
"@testing-library/react": "11.2.7",
"@testing-library/user-event": "13.2.1",
"@woocommerce/style-build": "file:../style-build",
"@woocommerce/wc-admin-settings": "file:../wc-admin-settings",
"@wordpress/scripts": "12.6.1",
"concurrently": "5.3.0"
},

View File

@ -2,7 +2,7 @@
* External dependencies
*/
import { AdvancedFilters } from '@woocommerce/components';
import { CURRENCY } from '@woocommerce/wc-admin-settings';
import { getSetting } from '@woocommerce/settings';
const ORDER_STATUSES = {
cancelled: 'Cancelled',
@ -15,7 +15,7 @@ const ORDER_STATUSES = {
};
const siteLocale = 'en_US';
const currency = getSetting( 'currency' );
const path = new URL( document.location ).searchParams.get( 'path' );
const query = {
component: 'advanced-filters',
@ -181,7 +181,7 @@ export const Basic = () => (
query={ query }
filterTitle="Orders"
config={ advancedFilters }
currency={ CURRENCY }
currency={ currency }
/>
);

View File

@ -7,7 +7,6 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { AdvancedFilters } from '@woocommerce/components';
import { CURRENCY } from '@woocommerce/wc-admin-settings';
import { createElement } from '@wordpress/element';
const ORDER_STATUSES = {
@ -20,6 +19,16 @@ const ORDER_STATUSES = {
refunded: 'Refunded',
};
const CURRENCY = {
code: 'USD',
decimalSeparator: '.',
precision: 2,
priceFormat: '%1$s%2$s',
symbol: '$',
symbolPosition: 'left',
thousandSeparator: ',',
};
const advancedFiltersConfig = {
title: 'Orders Match {{select /}} Filters',
filters: {

View File

@ -2,7 +2,6 @@
* External dependencies
*/
import { render } from '@testing-library/react';
import { setSetting } from '@woocommerce/wc-admin-settings';
import { createElement } from '@wordpress/element';
/**
@ -74,15 +73,10 @@ describe( 'ProductImage', () => {
} );
test( 'should render a placeholder image if no product images are found', () => {
setSetting(
'wcAssetUrl',
'https://woocommerce.com/wp-content/plugins/woocommerce/assets/'
);
const product = {
name: 'Test Product',
};
const { container } = render( <ProductImage product={ product } /> );
expect( container ).toMatchSnapshot();
setSetting( 'wcAssetUrl', '' );
} );
} );

View File

@ -4,6 +4,7 @@
- Add backwards compability for old function format. #7688
- Add console warning for inbox note contents exceeding 320 characters and add dompurify dependency. #7869
- Fix race condition in data package's options module. #7947
- Remove dev dependency `@woocommerce/wc-admin-settings`. #8057
# 1.4.0

View File

@ -38,9 +38,6 @@
"qs": "6.9.6",
"rememo": "^3.0.0"
},
"devDependencies": {
"@woocommerce/wc-admin-settings": "file:../wc-admin-settings"
},
"publishConfig": {
"access": "public"
},

View File

@ -2,11 +2,6 @@
* @jest-environment node
*/
/**
* External dependencies
*/
import { getAdminLink } from '@woocommerce/wc-admin-settings';
jest.mock( '@wordpress/data-controls', () => ( {
apiFetch: jest.fn(),
} ) );
@ -39,6 +34,10 @@ global.window = {
} as Location,
} as Window & typeof globalThis;
function getAdminLink( path: string ) {
return path;
}
describe( 'installJetPackAndConnect', () => {
beforeEach( () => {
jest.clearAllMocks();

View File

@ -1,3 +1,7 @@
# Unreleased
- Remove dev dependency `@woocommerce/wc-admin-settings`. #8057
# 3.1.0
- Fix commonjs module build, allow package to be built in isolation. #7286

View File

@ -26,9 +26,6 @@
"moment": "2.29.1",
"qs": "6.9.6"
},
"devDependencies": {
"@woocommerce/wc-admin-settings": "file:../wc-admin-settings"
},
"peerDependencies": {
"lodash": "^4.17.0"
},

View File

@ -2,7 +2,6 @@
* External dependencies
*/
import moment from 'moment';
import { getSetting } from '@woocommerce/wc-admin-settings';
/**
* Internal dependencies
@ -719,7 +718,10 @@ describe( 'getRangeLabel', () => {
} );
describe( 'loadLocaleData', () => {
const originalLocale = getSetting( 'locale' );
const originalLocale = {
siteLocale: 'en_US',
userLocale: 'en_US',
};
beforeEach( () => {
// Reset to default settings
loadLocaleData( originalLocale );

View File

@ -6,6 +6,10 @@ const path = require( 'path' );
module.exports = {
moduleNameMapper: {
tinymce: path.resolve( __dirname, 'build/mocks/tinymce' ),
'@woocommerce/settings': path.resolve(
__dirname,
'build/mocks/woocommerce-settings'
),
'~/(.*)': path.resolve( __dirname, '../../client/$1' ),
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': path.resolve(
__dirname,

View File

@ -0,0 +1,11 @@
module.exports = {
getSetting: ( key, backup ) => {
return global.wcSettings[ key ] || backup;
},
getAdminLink: ( path ) => {
if ( global.wcSettings && global.wcSettings.adminUrl ) {
return global.wcSettings.adminUrl + path;
}
return path;
},
};

View File

@ -54,43 +54,45 @@ global.wcSettings = {
userLocale: 'en_US',
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
},
orderStatuses: {
pending: 'Pending payment',
processing: 'Processing',
'on-hold': 'On hold',
completed: 'Completed',
cancelled: 'Cancelled',
refunded: 'Refunded',
failed: 'Failed',
},
wcAdminSettings: {
woocommerce_actionable_order_statuses: [],
woocommerce_excluded_report_order_statuses: [],
},
dataEndpoints: {
countries: [],
performanceIndicators: [
{
chart: 'total_sales',
label: 'Total sales',
stat: 'revenue/total_sales',
},
{
chart: 'net_revenue',
label: 'Net sales',
stat: 'revenue/net_revenue',
},
{
chart: 'orders_count',
label: 'Orders',
stat: 'orders/orders_count',
},
{
chart: 'items_sold',
label: 'Items sold',
stat: 'products/items_sold',
},
],
admin: {
orderStatuses: {
pending: 'Pending payment',
processing: 'Processing',
'on-hold': 'On hold',
completed: 'Completed',
cancelled: 'Cancelled',
refunded: 'Refunded',
failed: 'Failed',
},
wcAdminSettings: {
woocommerce_actionable_order_statuses: [],
woocommerce_excluded_report_order_statuses: [],
},
dataEndpoints: {
countries: [],
performanceIndicators: [
{
chart: 'total_sales',
label: 'Total sales',
stat: 'revenue/total_sales',
},
{
chart: 'net_revenue',
label: 'Net sales',
stat: 'revenue/net_revenue',
},
{
chart: 'orders_count',
label: 'Orders',
stat: 'orders/orders_count',
},
{
chart: 'items_sold',
label: 'Items sold',
stat: 'products/items_sold',
},
],
},
},
};

View File

@ -1 +0,0 @@
package-lock=false

View File

@ -1,119 +0,0 @@
{
"name": "@woocommerce/wc-admin-settings",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/runtime": {
"version": "7.15.3",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.3.tgz",
"integrity": "sha512-OvwMLqNXkCXSz1kSm58sEsNuhqOx/fKpnUnKnFB5v8uDda5bLNEHNgKPvhDN6IU0LDcnHQ90LlJ0Q6jnyBSIBA==",
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"@tannin/compile": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@tannin/compile/-/compile-1.1.0.tgz",
"integrity": "sha512-n8m9eNDfoNZoxdvWiTfW/hSPhehzLJ3zW7f8E7oT6mCROoMNWCB4TYtv041+2FMAxweiE0j7i1jubQU4MEC/Gg==",
"requires": {
"@tannin/evaluate": "^1.2.0",
"@tannin/postfix": "^1.1.0"
}
},
"@tannin/evaluate": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@tannin/evaluate/-/evaluate-1.2.0.tgz",
"integrity": "sha512-3ioXvNowbO/wSrxsDG5DKIMxC81P0QrQTYai8zFNY+umuoHWRPbQ/TuuDEOju9E+jQDXmj6yI5GyejNuh8I+eg=="
},
"@tannin/plural-forms": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@tannin/plural-forms/-/plural-forms-1.1.0.tgz",
"integrity": "sha512-xl9R2mDZO/qiHam1AgMnAES6IKIg7OBhcXqy6eDsRCdXuxAFPcjrej9HMjyCLE0DJ/8cHf0i5OQTstuBRhpbHw==",
"requires": {
"@tannin/compile": "^1.1.0"
}
},
"@tannin/postfix": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@tannin/postfix/-/postfix-1.1.0.tgz",
"integrity": "sha512-oocsqY7g0cR+Gur5jRQLSrX2OtpMLMse1I10JQBm8CdGMrDkh1Mg2gjsiquMHRtBs4Qwu5wgEp5GgIYHk4SNPw=="
},
"@wordpress/i18n": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-3.17.0.tgz",
"integrity": "sha512-CTZ0oezI6BT5GlmiE4X0fzRY6i7bNsX6hxiROkGlpREY6q4s1pnwhM8ggLIaP18Bvkb/HDkUEENDrv3iwM/LIQ==",
"requires": {
"@babel/runtime": "^7.12.5",
"gettext-parser": "^1.3.1",
"lodash": "^4.17.19",
"memize": "^1.1.0",
"sprintf-js": "^1.1.1",
"tannin": "^1.2.0"
}
},
"encoding": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"requires": {
"iconv-lite": "^0.6.2"
}
},
"gettext-parser": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz",
"integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==",
"requires": {
"encoding": "^0.1.12",
"safe-buffer": "^5.1.1"
}
},
"iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
},
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"memize": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/memize/-/memize-1.1.0.tgz",
"integrity": "sha512-K4FcPETOMTwe7KL2LK0orMhpOmWD2wRGwWWpbZy0fyArwsyIKR8YJVz8+efBAh3BO4zPqlSICu4vsLTRRqtFAg=="
},
"regenerator-runtime": {
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA=="
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sprintf-js": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz",
"integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug=="
},
"tannin": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/tannin/-/tannin-1.2.0.tgz",
"integrity": "sha512-U7GgX/RcSeUETbV7gYgoz8PD7Ni4y95pgIP/Z6ayI3CfhSujwKEBlGFTCRN+Aqnuyf4AN2yHL+L8x+TCGjb9uA==",
"requires": {
"@tannin/plural-forms": "^1.1.0"
}
}
}
}

View File

@ -1,31 +0,0 @@
{
"name": "@woocommerce/wc-admin-settings",
"version": "1.1.0",
"description": "Wrapper around the wcSettings object - used for development.",
"author": "Automattic",
"license": "GPL-2.0-or-later",
"homepage": "https://github.com/woocommerce/woocommerce-admin/tree/main/packages/wc-admin-settings/README.md",
"repository": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"directory": "packages/wc-admin-settings"
},
"bugs": {
"url": "https://github.com/woocommerce/woocommerce-admin/issues"
},
"files": [
"index.js"
],
"main": "build/index.js",
"module": "build-module/index.js",
"private": true,
"dependencies": {
"@wordpress/i18n": "3.17.0"
},
"scripts": {
"clean": "npx rimraf tsconfig.tsbuildinfo build build-*",
"build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"prepack": "npm run clean && npm run build",
"start": "tsc --build --watch"
}
}

View File

@ -1,7 +0,0 @@
{
"extends": "../tsconfig-cjs",
"compilerOptions": {
"outDir": "build",
"declaration": true
}
}

View File

@ -1,8 +0,0 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "build-module",
"declaration": true
}
}

Some files were not shown because too many files have changed in this diff Show More