LYS - Disable the save changes button until changes are made (#47316)
* Disable the save changes button until changes are made * Add changefile(s) from automation for the following project(s): woocommerce * Fix broken test * Test * Remove test code * Tmp fix - fix broken test * Fix incorrect comparison * Remove test code * minor refactor -- re-use setting * Remove use of loadash isequal --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
4ba770cbba
commit
5183b1bb1b
|
@ -11,6 +11,7 @@ import {
|
|||
useState,
|
||||
createInterpolateElement,
|
||||
createElement,
|
||||
useEffect,
|
||||
} from '@wordpress/element';
|
||||
import { registerPlugin } from '@wordpress/plugins';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
@ -32,23 +33,38 @@ import {
|
|||
const { Fill } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT );
|
||||
|
||||
const SiteVisibility = () => {
|
||||
const shareKey =
|
||||
window?.wcSettings?.admin?.siteVisibilitySettings
|
||||
?.woocommerce_share_key;
|
||||
const setting = window?.wcSettings?.admin?.siteVisibilitySettings || {};
|
||||
const shareKey = setting?.woocommerce_share_key;
|
||||
|
||||
const [ comingSoon, setComingSoon ] = useState(
|
||||
window?.wcSettings?.admin?.siteVisibilitySettings
|
||||
?.woocommerce_coming_soon || 'no'
|
||||
setting?.woocommerce_coming_soon || 'no'
|
||||
);
|
||||
const [ storePagesOnly, setStorePagesOnly ] = useState(
|
||||
window?.wcSettings?.admin?.siteVisibilitySettings
|
||||
?.woocommerce_store_pages_only
|
||||
setting?.woocommerce_store_pages_only || 'no'
|
||||
);
|
||||
const [ privateLink, setPrivateLink ] = useState(
|
||||
window?.wcSettings?.admin?.siteVisibilitySettings
|
||||
?.woocommerce_private_link
|
||||
setting?.woocommerce_private_link || 'no'
|
||||
);
|
||||
|
||||
useEffect( () => {
|
||||
const initValues = {
|
||||
comingSoon: setting.woocommerce_coming_soon,
|
||||
storePagesOnly: setting.woocommerce_store_pages_only,
|
||||
privateLink: setting.woocommerce_private_link || 'no',
|
||||
};
|
||||
|
||||
const currentValues = { comingSoon, storePagesOnly, privateLink };
|
||||
const saveButton = document.getElementsByClassName(
|
||||
'woocommerce-save-button'
|
||||
)[ 0 ];
|
||||
if ( saveButton ) {
|
||||
saveButton.disabled =
|
||||
initValues.comingSoon === currentValues.comingSoon &&
|
||||
initValues.storePagesOnly === currentValues.storePagesOnly &&
|
||||
initValues.privateLink === currentValues.privateLink;
|
||||
}
|
||||
}, [ comingSoon, storePagesOnly, privateLink ] );
|
||||
|
||||
const copyLink = __( 'Copy link', 'woocommerce' );
|
||||
const copied = __( 'Copied!', 'woocommerce' );
|
||||
const [ copyLinkText, setCopyLinkText ] = useState( copyLink );
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
LYS: disables the "Save changes" button until changes are made.
|
Loading…
Reference in New Issue