woocommerce/plugins/woocommerce-admin/client/index.js

181 lines
5.3 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import '@wordpress/notices';
import { createRoot } from '@wordpress/element';
import { CustomerEffortScoreTracksContainer } from '@woocommerce/customer-effort-score';
import {
withCurrentUserHydration,
withSettingsHydration,
} from '@woocommerce/data';
/**
* Internal dependencies
*/
import { initRemoteLogging } from './lib/init-remote-logging';
// Initialize remote logging early to log any errors that occur during initialization.
initRemoteLogging();
/**
* Internal dependencies
*/
import './stylesheets/_index.scss';
import { getAdminSetting } from '~/utils/admin-settings';
import { PageLayout, EmbedLayout, PrimaryLayout as NoticeArea } from './layout';
import { EmbeddedBodyLayout } from './embedded-body-layout';
import './xstate.js';
2023-09-20 02:47:05 +00:00
import { deriveWpAdminBackgroundColours } from './utils/derive-wp-admin-background-colours';
import { possiblyRenderSettingsSlots } from './settings/settings-slots';
import { registerTaxSettingsConflictErrorFill } from './settings/conflict-error-slotfill';
import { registerPaymentsSettingsBannerFill } from './payments/payments-settings-banner-slotfill';
import { registerSiteVisibilitySlotFill } from './launch-your-store';
add: render react placeholders for offline and woocommerce_payments settings sections (#50008) * Added a whitelist of sections to render an alternative output in the WC_Settings_Payment_Gateways_React class. * Renamed constant and updated its contents to only include 'offline' * Added a branch in the `output()` method to output an appropriate div with an id if the current section is in the whitelist. * Added "experimental" prefix to payment settings div ID. * Replicated the render for the offline section similar to the main payments settings. * Added a new settings-payments-offline screen to the WooCommerce admin plugin. * Implemented new offline settings page component. * Removed the ErrorBoundary components from the SettingsPaymentsMainWrapper and SettingsPaymentsOfflineWrapper. * Added a new SettingsPaymentsOfflineWrapper component and its corresponding SCSS styles. * Implemented the WooCommerce Payments section in the settings page. * Removed WooCommerce Payments settings logic and replaced with a placeholder. * Added a placeholder for the offline payments screen. * Added 'main' to the REACTIFY_RENDER_SECTIONS array and refactored the output method to improve readability and maintainability. * Renamed `render_gateway_section` method to `render_classic_gateway_settings_page` in the `class-wc-settings-payment-gateways-react.php` file. * Added a filter for the REACTIFY_RENDER_SECTIONS so that plugins can modify this list. * Added inline documentation for the filter in the `get_reactify_render_sections` method. * changelog * Matched the CSS styles for the WooCommerce Payments section to the offline section. * Removed unnecessary Card component and placeholder text from WooCommerce Payments settings. * Linted the `class-wc-settings-payment-gateways-react.php` file, addressing the reported linting issues. * Refactored the payment settings UI to use React components and lazy loading. * lint * Nit: Removed unnecessary comment and moved a small code * Update name to experimental * Fix save button missing from section pages * Fix saving sections --------- Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com>
2024-07-26 12:55:19 +00:00
import {
SettingsPaymentsMainWrapper,
SettingsPaymentsOfflineWrapper,
SettingsPaymentsWooCommercePaymentsWrapper,
} from './settings-payments';
import { ErrorBoundary } from './error-boundary';
blueprint - add php package and cli commands (#49763) * Add blueprint package * Add blueprint to composer * Register blueprint cli commands * Add feature flag * Add changefile(s) from automation for the following project(s): woocommerce * Update packages/php/blueprint/src/Exporters/HasAlias.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/Exporters/ExportInstallThemeSteps.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/UseWPFunctions.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Set destination correctly * Make sure the given path is within wp content dir * Remove debug code * Fix typo * Fix typo * Fix lint errors with README * Move READMD.md from src to the root directory and add development.md * Add run-unit-tests.sh * Setup test env * Create dirs recursively * Remove debug code * Update packages/php/blueprint/src/Util.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update packages/php/blueprint/src/ZipExportedSchema.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Check for steps key * Use if statement * Add hook comment for wooblueprint_exporters and wooblueprint_importers * Fix plugin activation condition * Check for download_link -- it can be empty * Check to make sure a file was written * Plugin must be deactivated before attemping to delete it * Lint fixes * Lint fixes * blueprint - add rest api (#49765) * Add blueprint rest api endpoint * Rename process to import * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove unavailable 2nd argument from get_param -- default values are already set from the rest api def. * blueprint - add builder page (#49774) * Add blueprint builder page * Change to the correct endpoint * Add changefile(s) from automation for the following project(s): woocommerce * Note that the builder intro page is temporary * Remove unused code --------- Co-authored-by: github-actions <github-actions@github.com> * blueprint - add blueprint settings page (#49775) * Add blueprint settings page * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Fix broken test * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update unit test env * Added composer scripts to setup and run tests * Moved tests to Unit dir to make space for Integration tests later * WIP Add tests * Use full if statement * Use the correct step names * Use activate_plugin and wp_get_thmes from wp functions trait * Skip inactive plugins * Use plural for collections * Add a comment for StepExporter * Remove unused construct code * Correct function return types * Update packages/php/blueprint/src/Importers/ImportActivateTheme.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Use full if statement * Make sure plugin is installed * Use functions from trait * Remove unused functions * Pass $force_convert correctly * Correctly assign $this->validator * Fix lint issues * Rename setOptions to setSiteOptions * Do not use die() -- throw an exception instead * Make sure slug is a valid WP plugin slug * Remove hardcoded string with get_step_name() * Fix lint issues * Update json example files * Removed woo-specific examples -- these should be placed in the core * Updated the built-in steps to reflect the recent changes * Update packages/php/blueprint/src/docs/json-examples/deletePlugin.json Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Rename to correct filename * Set version number * Use mime_content_type for checking mime type * Catch all exceptions * Only allow zip and json * Remove unused function * Remove unused functions * Add PHPCS command and ruleset * PHP lint fixes * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Add back removed functions * blueprint - Add woo blueprint exporters and importers (#50057) * Add woo blueprint exporters and importers * Comment fix * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Add a test for ImportSetWCTaxRates * Lint fixes * Lint fixes * Fix setWCShipping schema and data format * Add woocommerce_default_country option * Lint fixes * Fix typo -- it should be decode, not encode * Fix incorrect argument order * Fix typo * Export and import shipping method settings * Lint fixes * Lint fixes * Type functions -- base PR has changed --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Require admin for import and export * Use mime type from $_FILES -- mime_content_type can return incorrect mime type depending on the system configuration * Enable export button when backend errors out * Enable export button when backend errors out * Allow WooCommerce export * Change copy text * Remove redundant check * Fix lint issues * Fix lint issues --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
2024-08-12 23:33:05 +00:00
import { registerBlueprintSlotfill } from './blueprint';
const appRoot = document.getElementById( 'root' );
const embeddedRoot = document.getElementById( 'woocommerce-embedded-root' );
wp.data Settings refactor add data store for settings using wp.data add use-select-with-refresh example replace fresh-data usage with new settings data store for settings page Add data package move to packages Fix isDirty after save Add isBusy to primary button when saving update Readme remove comment readme to use useSelect Revert "update Readme" This reverts commit 7402fd49b8f384fde5878e0bee0616f0a87bb4f6. Data Layer: Settings page to use Settings store (https://github.com/woocommerce/woocommerce-admin/pull/3430) * Data Layer: Settings store as source of truth for settings page This reverts commit 7402fd49b8f384fde5878e0bee0616f0a87bb4f6. * fixup * save on reset * non mutable constants * add set/getSettings * save using setSettings * separate HOC * cleanup * remove settingsToData * withHydration * remove withSettings HOC * renmove useSettins for now * withSettingsHydration updates * Revert "withSettingsHydration updates" This reverts commit f2adf108fbe19b574978fea5925a1a18e7ed3007. * rename withSettingsHydration * redo withSettingsHydration simplification * restore * useSettings * render using useSettings * handleInputChange working * get setIsDirty working * saving works * reset and cleanup * cleanup * use snake case on hook files * use clearIsDirty * Avoid mutation on setting update * remove @todo * persiting -> isPersisting * better reducer ternaries * add wcSettings as arg to withSettingsHydration reset package-lock Settings: split out mutable wcAdminSettings (https://github.com/woocommerce/woocommerce-admin/pull/3675) Settings: handle async settings groups (https://github.com/woocommerce/woocommerce-admin/pull/3707)
2020-03-25 03:20:17 +00:00
const settingsGroup = 'wc_admin';
const hydrateUser = getAdminSetting( 'currentUserData' );
2023-09-20 02:47:05 +00:00
deriveWpAdminBackgroundColours();
if ( appRoot ) {
let HydratedPageLayout = withSettingsHydration(
settingsGroup,
window.wcSettings.admin
)( PageLayout );
const preloadSettings = window.wcSettings.admin
? window.wcSettings.admin.preloadSettings
: false;
const hydrateSettings = preloadSettings && preloadSettings.general;
if ( hydrateSettings ) {
HydratedPageLayout = withSettingsHydration( 'general', {
general: preloadSettings.general,
} )( HydratedPageLayout );
}
Migrate user store to wp.data (https://github.com/woocommerce/woocommerce-admin/pull/4505) * Initial user preferences custom hook (wc meta). * Organize dependencies. * Specify dependencies in useSelect() call. * Remove specifying preference keys. There's currently no performance benefit to be had. * Add HoC for hydrating current user data. * Add user prefs update method. * Export user prefs hook and HoC in data package. * Handle error condition when updating user preferences. * Use closure to get user ID for prefs update. * Refactor analytics dashboard to use new user hook. * Refactor ReportTable component to use new user hook. * Move prop access to top of function component. * Add todo for potential manual resolution logic. * Refactor DashboardCharts component to use new user preferences hook. * Move code out of functional component where possible. * Fix chart interval query property. * Refactor Leaderboards component to use new user preferences hook. * Move code out of functional component where possible. * Refactor Inbox panel to use user prefs hook. @todo - updating last read isn't working. * Use user prefs hook in StatsOverview component. * Export user preferences store name. * Use new store for unread inbox indicator. * Hydrate current user data higher up in the app. * Update "last read" timestamp in inbox panel. * Fix StatsOverview test. * Remove unused dispatch method from StorePerformance component. * Remove now defunct user methods from wc-api spec. * Add tests for isRequesting. * JSON decode WC meta on updated user object. * Test user prefs retrieval and save. * Remove todo comment. * Use user prefs hook in Jetpack install CTA on homepage.
2020-06-10 16:46:46 +00:00
if ( hydrateUser ) {
HydratedPageLayout =
withCurrentUserHydration( hydrateUser )( HydratedPageLayout );
Migrate user store to wp.data (https://github.com/woocommerce/woocommerce-admin/pull/4505) * Initial user preferences custom hook (wc meta). * Organize dependencies. * Specify dependencies in useSelect() call. * Remove specifying preference keys. There's currently no performance benefit to be had. * Add HoC for hydrating current user data. * Add user prefs update method. * Export user prefs hook and HoC in data package. * Handle error condition when updating user preferences. * Use closure to get user ID for prefs update. * Refactor analytics dashboard to use new user hook. * Refactor ReportTable component to use new user hook. * Move prop access to top of function component. * Add todo for potential manual resolution logic. * Refactor DashboardCharts component to use new user preferences hook. * Move code out of functional component where possible. * Fix chart interval query property. * Refactor Leaderboards component to use new user preferences hook. * Move code out of functional component where possible. * Refactor Inbox panel to use user prefs hook. @todo - updating last read isn't working. * Use user prefs hook in StatsOverview component. * Export user preferences store name. * Use new store for unread inbox indicator. * Hydrate current user data higher up in the app. * Update "last read" timestamp in inbox panel. * Fix StatsOverview test. * Remove unused dispatch method from StorePerformance component. * Remove now defunct user methods from wc-api spec. * Add tests for isRequesting. * JSON decode WC meta on updated user object. * Test user prefs retrieval and save. * Remove todo comment. * Use user prefs hook in Jetpack install CTA on homepage.
2020-06-10 16:46:46 +00:00
}
createRoot( appRoot ).render(
<ErrorBoundary>
<HydratedPageLayout />
</ErrorBoundary>
);
} else if ( embeddedRoot ) {
let HydratedEmbedLayout = withSettingsHydration(
settingsGroup,
window.wcSettings.admin
)( EmbedLayout );
Migrate user store to wp.data (https://github.com/woocommerce/woocommerce-admin/pull/4505) * Initial user preferences custom hook (wc meta). * Organize dependencies. * Specify dependencies in useSelect() call. * Remove specifying preference keys. There's currently no performance benefit to be had. * Add HoC for hydrating current user data. * Add user prefs update method. * Export user prefs hook and HoC in data package. * Handle error condition when updating user preferences. * Use closure to get user ID for prefs update. * Refactor analytics dashboard to use new user hook. * Refactor ReportTable component to use new user hook. * Move prop access to top of function component. * Add todo for potential manual resolution logic. * Refactor DashboardCharts component to use new user preferences hook. * Move code out of functional component where possible. * Fix chart interval query property. * Refactor Leaderboards component to use new user preferences hook. * Move code out of functional component where possible. * Refactor Inbox panel to use user prefs hook. @todo - updating last read isn't working. * Use user prefs hook in StatsOverview component. * Export user preferences store name. * Use new store for unread inbox indicator. * Hydrate current user data higher up in the app. * Update "last read" timestamp in inbox panel. * Fix StatsOverview test. * Remove unused dispatch method from StorePerformance component. * Remove now defunct user methods from wc-api spec. * Add tests for isRequesting. * JSON decode WC meta on updated user object. * Test user prefs retrieval and save. * Remove todo comment. * Use user prefs hook in Jetpack install CTA on homepage.
2020-06-10 16:46:46 +00:00
if ( hydrateUser ) {
HydratedEmbedLayout =
withCurrentUserHydration( hydrateUser )( HydratedEmbedLayout );
Migrate user store to wp.data (https://github.com/woocommerce/woocommerce-admin/pull/4505) * Initial user preferences custom hook (wc meta). * Organize dependencies. * Specify dependencies in useSelect() call. * Remove specifying preference keys. There's currently no performance benefit to be had. * Add HoC for hydrating current user data. * Add user prefs update method. * Export user prefs hook and HoC in data package. * Handle error condition when updating user preferences. * Use closure to get user ID for prefs update. * Refactor analytics dashboard to use new user hook. * Refactor ReportTable component to use new user hook. * Move prop access to top of function component. * Add todo for potential manual resolution logic. * Refactor DashboardCharts component to use new user preferences hook. * Move code out of functional component where possible. * Fix chart interval query property. * Refactor Leaderboards component to use new user preferences hook. * Move code out of functional component where possible. * Refactor Inbox panel to use user prefs hook. @todo - updating last read isn't working. * Use user prefs hook in StatsOverview component. * Export user preferences store name. * Use new store for unread inbox indicator. * Hydrate current user data higher up in the app. * Update "last read" timestamp in inbox panel. * Fix StatsOverview test. * Remove unused dispatch method from StorePerformance component. * Remove now defunct user methods from wc-api spec. * Add tests for isRequesting. * JSON decode WC meta on updated user object. * Test user prefs retrieval and save. * Remove todo comment. * Use user prefs hook in Jetpack install CTA on homepage.
2020-06-10 16:46:46 +00:00
}
// Render the header.
createRoot( embeddedRoot ).render( <HydratedEmbedLayout /> );
embeddedRoot.classList.remove( 'is-embed-loading' );
// Render notices just above the WP content div.
const wpBody = document.getElementById( 'wpbody-content' );
const wrap =
wpBody.querySelector( '.wrap.woocommerce' ) ||
document.querySelector( '#wpbody-content > .woocommerce' ) ||
wpBody.querySelector( '.wrap' );
const noticeContainer = document.createElement( 'div' );
2022-04-06 16:38:38 +00:00
createRoot( wpBody.insertBefore( noticeContainer, wrap ) ).render(
<div className="woocommerce-layout">
<NoticeArea />
</div>
);
const embeddedBodyContainer = document.createElement( 'div' );
createRoot(
wpBody.insertBefore( embeddedBodyContainer, wrap.nextSibling )
).render( <EmbeddedBodyLayout /> );
possiblyRenderSettingsSlots();
registerTaxSettingsConflictErrorFill();
registerPaymentsSettingsBannerFill();
if (
window.wcAdminFeatures &&
window.wcAdminFeatures[ 'launch-your-store' ] === true
) {
registerSiteVisibilitySlotFill();
}
blueprint - add php package and cli commands (#49763) * Add blueprint package * Add blueprint to composer * Register blueprint cli commands * Add feature flag * Add changefile(s) from automation for the following project(s): woocommerce * Update packages/php/blueprint/src/Exporters/HasAlias.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/Exporters/ExportInstallThemeSteps.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/UseWPFunctions.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Set destination correctly * Make sure the given path is within wp content dir * Remove debug code * Fix typo * Fix typo * Fix lint errors with README * Move READMD.md from src to the root directory and add development.md * Add run-unit-tests.sh * Setup test env * Create dirs recursively * Remove debug code * Update packages/php/blueprint/src/Util.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update packages/php/blueprint/src/ZipExportedSchema.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Check for steps key * Use if statement * Add hook comment for wooblueprint_exporters and wooblueprint_importers * Fix plugin activation condition * Check for download_link -- it can be empty * Check to make sure a file was written * Plugin must be deactivated before attemping to delete it * Lint fixes * Lint fixes * blueprint - add rest api (#49765) * Add blueprint rest api endpoint * Rename process to import * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove unavailable 2nd argument from get_param -- default values are already set from the rest api def. * blueprint - add builder page (#49774) * Add blueprint builder page * Change to the correct endpoint * Add changefile(s) from automation for the following project(s): woocommerce * Note that the builder intro page is temporary * Remove unused code --------- Co-authored-by: github-actions <github-actions@github.com> * blueprint - add blueprint settings page (#49775) * Add blueprint settings page * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Fix broken test * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update unit test env * Added composer scripts to setup and run tests * Moved tests to Unit dir to make space for Integration tests later * WIP Add tests * Use full if statement * Use the correct step names * Use activate_plugin and wp_get_thmes from wp functions trait * Skip inactive plugins * Use plural for collections * Add a comment for StepExporter * Remove unused construct code * Correct function return types * Update packages/php/blueprint/src/Importers/ImportActivateTheme.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Use full if statement * Make sure plugin is installed * Use functions from trait * Remove unused functions * Pass $force_convert correctly * Correctly assign $this->validator * Fix lint issues * Rename setOptions to setSiteOptions * Do not use die() -- throw an exception instead * Make sure slug is a valid WP plugin slug * Remove hardcoded string with get_step_name() * Fix lint issues * Update json example files * Removed woo-specific examples -- these should be placed in the core * Updated the built-in steps to reflect the recent changes * Update packages/php/blueprint/src/docs/json-examples/deletePlugin.json Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Rename to correct filename * Set version number * Use mime_content_type for checking mime type * Catch all exceptions * Only allow zip and json * Remove unused function * Remove unused functions * Add PHPCS command and ruleset * PHP lint fixes * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Add back removed functions * blueprint - Add woo blueprint exporters and importers (#50057) * Add woo blueprint exporters and importers * Comment fix * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Add a test for ImportSetWCTaxRates * Lint fixes * Lint fixes * Fix setWCShipping schema and data format * Add woocommerce_default_country option * Lint fixes * Fix typo -- it should be decode, not encode * Fix incorrect argument order * Fix typo * Export and import shipping method settings * Lint fixes * Lint fixes * Type functions -- base PR has changed --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Require admin for import and export * Use mime type from $_FILES -- mime_content_type can return incorrect mime type depending on the system configuration * Enable export button when backend errors out * Enable export button when backend errors out * Allow WooCommerce export * Change copy text * Remove redundant check * Fix lint issues * Fix lint issues --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
2024-08-12 23:33:05 +00:00
if ( window.wcAdminFeatures && window.wcAdminFeatures.blueprint === true ) {
registerBlueprintSlotfill();
}
}
// Render the CustomerEffortScoreTracksContainer only if
// the feature flag is enabled.
if (
window.wcAdminFeatures &&
window.wcAdminFeatures[ 'customer-effort-score-tracks' ] === true
) {
// Set up customer effort score survey.
( function () {
const root = appRoot || embeddedRoot;
createRoot(
root.insertBefore( document.createElement( 'div' ), null )
).render( <CustomerEffortScoreTracksContainer /> );
} )();
}
// Render the payment settings components only if
// the feature flag is enabled.
if (
window.wcAdminFeatures &&
window.wcAdminFeatures[ 'reactify-classic-payments-settings' ] === true
) {
( function () {
const paymentsMainRoot = document.getElementById(
'experimental_wc_settings_payments_main'
);
add: render react placeholders for offline and woocommerce_payments settings sections (#50008) * Added a whitelist of sections to render an alternative output in the WC_Settings_Payment_Gateways_React class. * Renamed constant and updated its contents to only include 'offline' * Added a branch in the `output()` method to output an appropriate div with an id if the current section is in the whitelist. * Added "experimental" prefix to payment settings div ID. * Replicated the render for the offline section similar to the main payments settings. * Added a new settings-payments-offline screen to the WooCommerce admin plugin. * Implemented new offline settings page component. * Removed the ErrorBoundary components from the SettingsPaymentsMainWrapper and SettingsPaymentsOfflineWrapper. * Added a new SettingsPaymentsOfflineWrapper component and its corresponding SCSS styles. * Implemented the WooCommerce Payments section in the settings page. * Removed WooCommerce Payments settings logic and replaced with a placeholder. * Added a placeholder for the offline payments screen. * Added 'main' to the REACTIFY_RENDER_SECTIONS array and refactored the output method to improve readability and maintainability. * Renamed `render_gateway_section` method to `render_classic_gateway_settings_page` in the `class-wc-settings-payment-gateways-react.php` file. * Added a filter for the REACTIFY_RENDER_SECTIONS so that plugins can modify this list. * Added inline documentation for the filter in the `get_reactify_render_sections` method. * changelog * Matched the CSS styles for the WooCommerce Payments section to the offline section. * Removed unnecessary Card component and placeholder text from WooCommerce Payments settings. * Linted the `class-wc-settings-payment-gateways-react.php` file, addressing the reported linting issues. * Refactored the payment settings UI to use React components and lazy loading. * lint * Nit: Removed unnecessary comment and moved a small code * Update name to experimental * Fix save button missing from section pages * Fix saving sections --------- Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com>
2024-07-26 12:55:19 +00:00
const paymentsOfflineRoot = document.getElementById(
'experimental_wc_settings_payments_offline'
);
const paymentsWooCommercePaymentsRoot = document.getElementById(
'experimental_wc_settings_payments_woocommerce_payments'
);
if ( paymentsMainRoot ) {
createRoot(
paymentsMainRoot.insertBefore(
document.createElement( 'div' ),
null
)
).render( <SettingsPaymentsMainWrapper /> );
}
add: render react placeholders for offline and woocommerce_payments settings sections (#50008) * Added a whitelist of sections to render an alternative output in the WC_Settings_Payment_Gateways_React class. * Renamed constant and updated its contents to only include 'offline' * Added a branch in the `output()` method to output an appropriate div with an id if the current section is in the whitelist. * Added "experimental" prefix to payment settings div ID. * Replicated the render for the offline section similar to the main payments settings. * Added a new settings-payments-offline screen to the WooCommerce admin plugin. * Implemented new offline settings page component. * Removed the ErrorBoundary components from the SettingsPaymentsMainWrapper and SettingsPaymentsOfflineWrapper. * Added a new SettingsPaymentsOfflineWrapper component and its corresponding SCSS styles. * Implemented the WooCommerce Payments section in the settings page. * Removed WooCommerce Payments settings logic and replaced with a placeholder. * Added a placeholder for the offline payments screen. * Added 'main' to the REACTIFY_RENDER_SECTIONS array and refactored the output method to improve readability and maintainability. * Renamed `render_gateway_section` method to `render_classic_gateway_settings_page` in the `class-wc-settings-payment-gateways-react.php` file. * Added a filter for the REACTIFY_RENDER_SECTIONS so that plugins can modify this list. * Added inline documentation for the filter in the `get_reactify_render_sections` method. * changelog * Matched the CSS styles for the WooCommerce Payments section to the offline section. * Removed unnecessary Card component and placeholder text from WooCommerce Payments settings. * Linted the `class-wc-settings-payment-gateways-react.php` file, addressing the reported linting issues. * Refactored the payment settings UI to use React components and lazy loading. * lint * Nit: Removed unnecessary comment and moved a small code * Update name to experimental * Fix save button missing from section pages * Fix saving sections --------- Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com>
2024-07-26 12:55:19 +00:00
if ( paymentsOfflineRoot ) {
createRoot(
paymentsOfflineRoot.insertBefore(
document.createElement( 'div' ),
null
)
).render( <SettingsPaymentsOfflineWrapper /> );
}
if ( paymentsWooCommercePaymentsRoot ) {
createRoot(
paymentsWooCommercePaymentsRoot.insertBefore(
document.createElement( 'div' ),
null
)
).render( <SettingsPaymentsWooCommercePaymentsWrapper /> );
}
} )();
}