/** * WordPress dependencies */ import { Button, Modal } from '@safe-wordpress/components'; import { createInterpolateElement, useState } from '@safe-wordpress/element'; import { _x } from '@safe-wordpress/i18n'; import { addQueryArgs } from '@safe-wordpress/url'; /** * External dependencies */ import { usePluginSetting } from '@nab/data'; /** * Internal dependencies */ import './style.scss'; import { ClipboardButton } from '../clipboard-button'; export function PreviewUrlButton(): JSX.Element | null { const isDebuggingEnabled = usePluginSetting( 'isDebuggingEnabled' ); const hasRunningExperiments = usePluginSetting( 'hasRunningExperiments' ); const homeUrl = usePluginSetting( 'homeUrl' ); const [ isModalVisible, showModal ] = useState( false ); if ( ! isDebuggingEnabled || ! hasRunningExperiments ) { return null; } const testUrl = addQueryArgs( homeUrl, { nabstaging: '1' } ); return ( <> { isModalVisible && ( showModal( false ) } >

{ createInterpolateElement( _x( 'Copy this URL and open it in an incognito window to preview active tests:', 'user', 'nelio-ab-testing' ), { strong: } ) }

) } ); }