| | import { registerStore } from '@wordpress/data'; |
| | import { controls } from '@wordpress/data-controls'; |
| | import { registerPlugins } from '../plugins'; |
| | import { controls as wpcomRequestControls } from '../wpcom-request-controls'; |
| | import * as actions from './actions'; |
| | import { STORE_KEY } from './constants'; |
| | import reducer, { State } from './reducer'; |
| | import { isHelpCenterShown } from './resolvers'; |
| | import * as selectors from './selectors'; |
| | export type { State }; |
| |
|
| | declare const helpCenterData: { isProxied: boolean; isSU: boolean; isSSP: boolean } | undefined; |
| | declare const isSupportSession: boolean; |
| | declare const isSSP: boolean; |
| |
|
| | let isRegistered = false; |
| |
|
| | |
| | const E2E_USER_AGENT = 'wp-e2e-tests'; |
| |
|
| | export const isE2ETest = () => |
| | typeof window !== 'undefined' && window.navigator.userAgent.includes( E2E_USER_AGENT ); |
| |
|
| | export const isInSupportSession = () => { |
| | if ( typeof window !== 'undefined' ) { |
| | return ( |
| | |
| | |
| | !! document.querySelector( '#wp-admin-bar-support-session-details' ) || |
| | !! document.querySelector( '#a8c-support-session-overlay' ) || |
| | |
| | document.body.classList.contains( 'support-session' ) || |
| | document.querySelector( '#wpcom > .is-support-session' ) || |
| | ( typeof isSupportSession !== 'undefined' && !! isSupportSession ) || |
| | ( typeof helpCenterData !== 'undefined' && helpCenterData?.isSU ) || |
| | ( typeof helpCenterData !== 'undefined' && helpCenterData?.isSSP ) || |
| | ( typeof isSSP !== 'undefined' && !! isSSP ) |
| | ); |
| | } |
| | return false; |
| | }; |
| |
|
| | export function register(): typeof STORE_KEY { |
| | const enabledPersistedOpenState = ! isE2ETest() && ! isInSupportSession(); |
| |
|
| | registerPlugins(); |
| |
|
| | if ( ! isRegistered ) { |
| | registerStore( STORE_KEY, { |
| | actions, |
| | reducer, |
| | controls: { ...controls, ...wpcomRequestControls }, |
| | selectors, |
| | persist: [ 'message', 'userDeclaredSite', 'userDeclaredSiteUrl', 'subject' ], |
| | |
| | resolvers: enabledPersistedOpenState ? { isHelpCenterShown } : undefined, |
| | } ); |
| | isRegistered = true; |
| | } |
| |
|
| | return STORE_KEY; |
| | } |
| |
|
| | export type { HelpCenterSite } from './types'; |
| |
|