Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Remove wc api 🎉 (#5075)
Browse files Browse the repository at this point in the history
* remove wc-api selects and constansts

* remove extendedItems dependence on wc-api

* remove wc-api

* PR feedback
  • Loading branch information
psealock authored Sep 3, 2020
1 parent 701de15 commit 7232d51
Show file tree
Hide file tree
Showing 42 changed files with 73 additions and 575 deletions.
2 changes: 1 addition & 1 deletion client/analytics/components/report-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { format as formatDate } from '@wordpress/date';
import { withSelect } from '@wordpress/data';
import { get, isEqual } from 'lodash';
import PropTypes from 'prop-types';
import { Chart } from '@woocommerce/components';
Expand All @@ -27,7 +28,6 @@ import {
*/
import { CurrencyContext } from '../../../lib/currency-context';
import ReportError from '../report-error';
import withSelect from '../../../wc-api/with-select';
import { getChartMode, getSelectedFilter } from './utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion client/analytics/components/report-summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import PropTypes from 'prop-types';
import { getNewPath } from '@woocommerce/navigation';
import {
Expand All @@ -20,7 +21,6 @@ import { recordEvent } from '@woocommerce/tracks';
* Internal dependencies
*/
import ReportError from '../report-error';
import withSelect from '../../../wc-api/with-select';
import { CurrencyContext } from '../../../lib/currency-context';

/**
Expand Down
11 changes: 7 additions & 4 deletions client/analytics/components/report-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { applyFilters } from '@wordpress/hooks';
import { Fragment, useRef, useState } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { focus } from '@wordpress/dom';
import { withDispatch } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';
import { get, noop, partial, uniq } from 'lodash';
import { __, sprintf } from '@wordpress/i18n';
import classnames from 'classnames';
Expand All @@ -29,6 +29,7 @@ import {
EXPORT_STORE_NAME,
SETTINGS_STORE_NAME,
useUserPreferences,
QUERY_DEFAULTS,
} from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';

Expand All @@ -37,8 +38,6 @@ import { recordEvent } from '@woocommerce/tracks';
*/
import DownloadIcon from './download-icon';
import ReportError from '../report-error';
import { QUERY_DEFAULTS } from '../../../wc-api/constants';
import withSelect from '../../../wc-api/with-select';
import { extendTableData } from './utils';
import './style.scss';

Expand Down Expand Up @@ -476,7 +475,7 @@ ReportTable.propTypes = {
*/
endpoint: PropTypes.string,
/**
* Name of the methods available via `select( 'wc-api' )` that will be used to
* Name of the methods available via `select` that will be used to
* load more data for table items. If omitted, no call will be made and only
* the data returned by the reports endpoint will be used.
*/
Expand All @@ -485,6 +484,10 @@ ReportTable.propTypes = {
isRequesting: PropTypes.string,
load: PropTypes.string,
} ),
/**
* Name of store on which extendItemsMethodNames can be found.
*/
extendedItemsStoreName: PropTypes.string,
/**
* A function that returns the headers object to build the table.
*/
Expand Down
8 changes: 6 additions & 2 deletions client/analytics/components/report-table/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import { first } from 'lodash';

export function extendTableData( select, props, queriedTableData ) {
const { extendItemsMethodNames, itemIdField } = props;
const {
extendItemsMethodNames,
extendedItemsStoreName,
itemIdField,
} = props;
const itemsData = queriedTableData.items.data;
if (
! Array.isArray( itemsData ) ||
Expand All @@ -19,7 +23,7 @@ export function extendTableData( select, props, queriedTableData ) {
[ extendItemsMethodNames.getError ]: getErrorMethod,
[ extendItemsMethodNames.isRequesting ]: isRequestingMethod,
[ extendItemsMethodNames.load ]: loadMethod,
} = select( 'wc-api' );
} = select( extendedItemsStoreName );
const extendQuery = {
include: itemsData.map( ( item ) => item[ itemIdField ] ).join( ',' ),
per_page: itemsData.length,
Expand Down
2 changes: 1 addition & 1 deletion client/analytics/report/customers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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: {} } );

Expand All @@ -15,7 +16,6 @@ import {
getCustomerLabels,
getRequestByIdString,
} from '../../../lib/async-requests';
import { NAMESPACE } from '../../../wc-api/constants';

const CUSTOMERS_REPORT_FILTERS_FILTER =
'woocommerce_admin_customers_report_filters';
Expand Down
4 changes: 2 additions & 2 deletions client/analytics/report/revenue/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { __, _n } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { format as formatDate } from '@wordpress/date';
import { withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { get } from 'lodash';
import { Date, Link } from '@woocommerce/components';
Expand All @@ -13,6 +14,7 @@ import {
getReportTableQuery,
REPORTS_STORE_NAME,
SETTINGS_STORE_NAME,
QUERY_DEFAULTS,
} from '@woocommerce/data';
import {
appendTimestamp,
Expand All @@ -23,9 +25,7 @@ import {
/**
* Internal dependencies
*/
import { QUERY_DEFAULTS } from '../../../wc-api/constants';
import ReportTable from '../../components/report-table';
import withSelect from '../../../wc-api/with-select';
import { CurrencyContext } from '../../../lib/currency-context';

class RevenueReportTable extends Component {
Expand Down
2 changes: 1 addition & 1 deletion client/analytics/report/taxes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/
import { __ } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
import { NAMESPACE } from '@woocommerce/data';

/**
* Internal dependencies
*/
import { getRequestByIdString } from '../../../lib/async-requests';
import { getTaxCode } from './utils';
import { NAMESPACE } from '../../../wc-api/constants';

const TAXES_REPORT_CHARTS_FILTER = 'woocommerce_admin_taxes_report_charts';
const TAXES_REPORT_FILTERS_FILTER = 'woocommerce_admin_taxes_report_filters';
Expand Down
2 changes: 1 addition & 1 deletion client/analytics/settings/historical-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
IMPORT_STORE_NAME,
NOTES_STORE_NAME,
QUERY_DEFAULTS,
SECOND,
} from '@woocommerce/data';
import { withDispatch, withSelect } from '@wordpress/data';
import { withSpokenMessages } from '@wordpress/components';
import { SECOND } from '@fresh-data/framework';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion client/dashboard/customizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { partial } from 'lodash';
import { Dropdown, Button, Icon } from '@wordpress/components';
import { applyFilters } from '@wordpress/hooks';
import { Icon as WPIcon, plusCircleFilled } from '@wordpress/icons';
import { withSelect } from '@wordpress/data';
import { H, Spinner } from '@woocommerce/components';
import {
SETTINGS_STORE_NAME,
Expand All @@ -28,7 +29,6 @@ import { recordEvent } from '@woocommerce/tracks';
import './style.scss';
import defaultSections from './default-sections';
import Section from './section';
import withSelect from '../wc-api/with-select';
import ReportFilters from '../analytics/components/report-filters';
import {
CurrencyContext,
Expand Down
2 changes: 1 addition & 1 deletion client/dashboard/store-performance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 {
EllipsisMenu,
Expand All @@ -22,7 +23,6 @@ import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
*/
import withSelect from '../../wc-api/with-select';
import './style.scss';
import { CurrencyContext } from '../../lib/currency-context';
import { getIndicatorData, getIndicatorValues } from './utils';
Expand Down
3 changes: 1 addition & 2 deletions client/header/activity-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import clickOutside from 'react-click-outside';
import { Component, lazy, Suspense } from '@wordpress/element';
import { Button } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withDispatch } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';
import { uniqueId, find } from 'lodash';
import PagesIcon from 'gridicons/dist/pages';
import CrossIcon from 'gridicons/dist/cross-small';
Expand All @@ -29,7 +29,6 @@ import {
getUnreadStock,
} from './unread-indicators';
import { isWCAdmin } from '../../dashboard/utils';
import withSelect from '../../wc-api/with-select';
import { Tabs } from './tabs';
import { SetupProgress } from './setup-progress';

Expand Down
9 changes: 6 additions & 3 deletions client/header/activity-panel/panels/inbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { __ } from '@wordpress/i18n';
import { Fragment, useEffect } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { EmptyContent, Section } from '@woocommerce/components';
import { NOTES_STORE_NAME, useUserPreferences } from '@woocommerce/data';
import {
NOTES_STORE_NAME,
useUserPreferences,
QUERY_DEFAULTS,
} from '@woocommerce/data';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -14,8 +19,6 @@ import { ActivityCard } from '../../activity-card';
import InboxNotePlaceholder from './placeholder';
import ActivityHeader from '../../activity-header';
import InboxNoteCard from './card';
import { QUERY_DEFAULTS } from '../../../../wc-api/constants';
import withSelect from '../../../../wc-api/with-select';
import { getUnreadNotesCount, hasValidNotes } from './utils';

const renderEmptyCard = () => (
Expand Down
5 changes: 2 additions & 3 deletions client/header/activity-panel/panels/reviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { __, sprintf } from '@wordpress/i18n';
import classnames from 'classnames';
import { Component, Fragment } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import Gridicon from 'gridicons';
import interpolateComponents from 'interpolate-components';
Expand All @@ -19,17 +20,15 @@ import {
Section,
} from '@woocommerce/components';
import { getAdminLink } from '@woocommerce/wc-admin-settings';
import { REVIEWS_STORE_NAME } from '@woocommerce/data';
import { REVIEWS_STORE_NAME, QUERY_DEFAULTS } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';

/**
* Internal dependencies
*/
import { ActivityCard, ActivityCardPlaceholder } from '../activity-card';
import ActivityHeader from '../activity-header';
import { QUERY_DEFAULTS } from '../../../wc-api/constants';
import sanitizeHTML from '../../../lib/sanitize-html';
import withSelect from '../../../wc-api/with-select';

class ReviewsPanel extends Component {
constructor() {
Expand Down
5 changes: 2 additions & 3 deletions client/homescreen/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useEffect,
} from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { withDispatch } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { NOTES_STORE_NAME, OPTIONS_STORE_NAME } from '@woocommerce/data';
Expand All @@ -24,7 +24,6 @@ import './style.scss';
import '../dashboard/style.scss';
import TaskListPlaceholder from '../task-list/placeholder';
import InboxPanel from '../header/activity-panel/panels/inbox';
import withWCApiSelect from '../wc-api/with-select';
import { WelcomeModal } from './welcome-modal';

const TaskList = lazy( () =>
Expand Down Expand Up @@ -161,7 +160,7 @@ Layout.propTypes = {
};

export default compose(
withWCApiSelect( ( select ) => {
withSelect( ( select ) => {
const { isNotesRequesting } = select( NOTES_STORE_NAME );
const { getOption, isResolving } = select( OPTIONS_STORE_NAME );

Expand Down
3 changes: 1 addition & 2 deletions client/homescreen/stats-overview/stats-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import { useContext } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { withSelect } from '@wordpress/data';
import classnames from 'classnames';

import {
SummaryNumber,
SummaryNumberPlaceholder,
Expand All @@ -15,7 +15,6 @@ import { recordEvent } from '@woocommerce/tracks';
/**
* Internal dependencies
*/
import withSelect from '../../wc-api/with-select';
import { CurrencyContext } from '../../lib/currency-context';
import {
getIndicatorData,
Expand Down
1 change: 0 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
*/
import './stylesheets/_index.scss';
import { PageLayout, EmbedLayout, PrimaryLayout as NoticeArea } from './layout';
import './wc-api/wp-data-store';

// Modify webpack pubilcPath at runtime based on location of WordPress Plugin.
// eslint-disable-next-line no-undef,camelcase
Expand Down
3 changes: 1 addition & 2 deletions client/layout/store-alerts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import moment from 'moment';
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
import { Card } from '@woocommerce/components';
import { getSetting } from '@woocommerce/wc-admin-settings';
import { NOTES_STORE_NAME } from '@woocommerce/data';
import { NOTES_STORE_NAME, QUERY_DEFAULTS } from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';

/**
* Internal dependencies
*/
import { QUERY_DEFAULTS } from '../../wc-api/constants';
import sanitizeHTML from '../../lib/sanitize-html';
import StoreAlertsPlaceholder from './placeholder';

Expand Down
3 changes: 1 addition & 2 deletions client/layout/transient-notices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { Component } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import PropTypes from 'prop-types';
import { SnackbarList } from '@wordpress/components';
import { withDispatch } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import './style.scss';
import withSelect from '../../wc-api/with-select';

class TransientNotices extends Component {
render() {
Expand Down
2 changes: 1 addition & 1 deletion client/lib/async-requests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { addQueryArgs } from '@wordpress/url';
import apiFetch from '@wordpress/api-fetch';
import { identity } from 'lodash';
import { getIdsFromQuery } from '@woocommerce/navigation';
import { NAMESPACE } from '@woocommerce/data';

/**
* Internal dependencies
*/
import { getTaxCode } from '../../analytics/report/taxes/utils';
import { NAMESPACE } from '../../wc-api/constants';

/**
* Get a function that accepts ids as they are found in url parameter and
Expand Down
5 changes: 2 additions & 3 deletions client/profile-wizard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { __ } from '@wordpress/i18n';
import { Component, createElement, Fragment } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { identity, pick } from 'lodash';
import { withDispatch } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';
import {
getHistory,
getNewPath,
Expand All @@ -17,6 +17,7 @@ import {
OPTIONS_STORE_NAME,
PLUGINS_STORE_NAME,
withPluginsHydration,
QUERY_DEFAULTS,
} from '@woocommerce/data';
import { recordEvent } from '@woocommerce/tracks';

Expand All @@ -28,10 +29,8 @@ import BusinessDetails from './steps/business-details';
import Industry from './steps/industry';
import ProductTypes from './steps/product-types';
import ProfileWizardHeader from './header';
import { QUERY_DEFAULTS } from '../wc-api/constants';
import StoreDetails from './steps/store-details';
import Theme from './steps/theme';
import withSelect from '../wc-api/with-select';
import './style.scss';

class ProfileWizard extends Component {
Expand Down
Loading

0 comments on commit 7232d51

Please sign in to comment.