2024-04-08 08:29:49 +00:00
/ * *
* External dependencies
* /
2024-08-20 05:06:57 +00:00
import { OPTIONS_STORE_NAME , useUserPreferences } from '@woocommerce/data' ;
import { useSelect } from '@wordpress/data' ;
2024-04-08 08:29:49 +00:00
import { useState } from 'react' ;
export const useSiteVisibilityTour = ( ) = > {
const [ showTour , setShowTour ] = useState ( true ) ;
2024-08-20 05:06:57 +00:00
// Tour should only be shown if the user has not seen it before and the `woocommerce_show_lys_tour` option is "yes" (for sites upgrading from a previous WooCommerce version)
const shouldStoreShowLYSTour = useSelect (
( select ) = >
select ( OPTIONS_STORE_NAME ) . getOption (
'woocommerce_show_lys_tour'
) === 'yes'
) ;
/ * *
* This is temporary to support sites upgrading from a previous version of WooCommerce .
* We used user meta to store the tour dismissal state but now we use WooCommerce meta instead .
* It will be removed in WC 9.4 .
* /
const hasUserDismissedTourMeta = useSelect ( ( select ) = > {
const currentUser = select ( 'core' ) . getCurrentUser ( ) ;
if ( ! currentUser ) {
// If the user is not logged in, we don't want to show the tour.
return true ;
}
return (
Update to pnpm 9.1 (#47385)
* Update to pnpm 9.1 and fix a mini css bug
* Add changefile(s) from automation for the following project(s): @woocommerce/tracks, @woocommerce/product-editor, @woocommerce/onboarding, @woocommerce/number, @woocommerce/notices, @woocommerce/navigation, @woocommerce/internal-js-tests, @woocommerce/extend-cart-checkout-block, @woocommerce/expression-evaluation, @woocommerce/explat, @woocommerce/experimental, @woocommerce/eslint-plugin, @woocommerce/dependency-extraction-webpack-plugin, @woocommerce/date, @woocommerce/data, @woocommerce/customer-effort-score, @woocommerce/currency, @woocommerce/csv-export, @woocommerce/create-woo-extension, @woocommerce/create-product-editor-block, @woocommerce/components, @woocommerce/api, @woocommerce/ai, @woocommerce/admin-e2e-tests, woocommerce-blocks, woocommerce-beta-tester, woocommerce, woo-ai
* temporarily disable swallowing build output to diagnose issue with perf workflow
* Ignore some type issues that commonly resurface when deps slightly change
* Fix persistent type issues that have recurred many times
* Add more ignores
* Fix lint issue
* Revert change to swallow build error
* Improve access of the config that needs updated build dir.
---------
Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 13:57:39 +00:00
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
2024-08-20 05:06:57 +00:00
( currentUser as { meta : { [ key : string ] : string } } ) . meta
. woocommerce_launch_your_store_tour_hidden === 'yes'
) ;
2024-04-08 08:29:49 +00:00
} ) ;
2024-08-20 05:06:57 +00:00
const {
launch_your_store_tour_hidden : lysTourHidden ,
updateUserPreferences ,
} = useUserPreferences ( ) ;
2024-04-08 08:29:49 +00:00
const onClose = ( ) = > {
2024-08-20 05:06:57 +00:00
updateUserPreferences ( {
launch_your_store_tour_hidden : 'yes' ,
2024-04-08 08:29:49 +00:00
} ) ;
} ;
return {
onClose ,
2024-08-20 05:06:57 +00:00
shouldTourBeShown :
shouldStoreShowLYSTour &&
! ( hasUserDismissedTourMeta || lysTourHidden ) ,
2024-04-08 08:29:49 +00:00
showTour ,
setShowTour ,
} ;
} ;