/** * WordPress dependencies */ import { Button } from '@safe-wordpress/components'; import { useSelect } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { store as NAB_DATA } from '@nab/data'; /** * Internal dependencies */ import './style.scss'; import { RunningExperiment } from './running-experiment'; type RunningExperimentsProps = { readonly onExtendedClicked: () => void; }; export function RunningExperiments( { onExtendedClicked, }: RunningExperimentsProps ): JSX.Element { const { allRunningUrl, experiments, isLoading, runningCount } = useSelect( ( select ) => ( { allRunningUrl: select( NAB_DATA ).getAdminUrl( 'edit.php?post_type=nab_experiment&post_status=nab_running&order=desc' ), experiments: select( NAB_DATA ).getRunningExperimentSummaries(), isLoading: select( NAB_DATA ).getRunningExperimentSummaries().length ? false : ! select( NAB_DATA ).isRecommendationEngineDataLoaded(), runningCount: select( NAB_DATA ).getRunningExperimentCount(), } ), [] ); if ( ! experiments.length || isLoading ) { return ( { _x( 'Running tests', 'text', 'nelio-ab-testing' ) } 🧪 { isLoading ? _x( 'Loading…', 'text', 'nelio-ab-testing' ) : _x( 'No tests running yet', 'text', 'nelio-ab-testing' ) } { ! isLoading && ( { _x( 'Launch a test to start collecting insights.', 'user', 'nelio-ab-testing' ) } ) } ); } return ( { _x( 'Running tests', 'text', 'nelio-ab-testing' ) } { runningCount } { _x( 'Extended view →', 'text', 'nelio-ab-testing' ) } { experiments.map( ( experiment ) => ( ) ) } { _x( 'All running tests →', 'text', 'nelio-ab-testing' ) } ); }
{ _x( 'Launch a test to start collecting insights.', 'user', 'nelio-ab-testing' ) }