/** * WordPress dependencies */ import { _x, sprintf } from '@safe-wordpress/i18n'; /** * External dependencies */ import type { ExperimentType } from '@nab/types'; /** * Internal dependencies */ import icon from './icon.svg'; import { Original } from './components/original'; import { Alternative } from './components/alternative'; import type { ControlAttributes, AlternativeAttributes } from './types'; export const settings: ExperimentType< ControlAttributes, AlternativeAttributes > = { name: 'nab/synced-pattern' as const, category: 'page', title: _x( 'WordPress Patterns', 'text (experiment name)', 'nelio-ab-testing' ), description: _x( 'Test alternative versions of synced patterns', 'user', 'nelio-ab-testing' ), labels: { create: _x( 'Add new A/B test of synced patterns', 'command', 'nelio-ab-testing' ), }, icon, supports: { alternativeApplication: ( control ) => ! control?.testAgainstExistingPatterns, alternativeEdition: { type: 'external', enabled: ( control ) => ! control.testAgainstExistingPatterns, }, postTypes: 'wp_block', }, checks: { getControlError: ( control ) => { if ( ! control.patternId ) { return _x( 'Please select the pattern you want to test', 'user', 'nelio-ab-testing' ); } return false; }, getAlternativeError: ( alternative, letter, control ) => { if ( control.testAgainstExistingPatterns && ! alternative.patternId ) { return sprintf( /* translators: %s: Letter of the variant. */ _x( 'Please select a pattern in variant %s', 'user', 'nelio-ab-testing' ), letter ); } return false; }, isAlternativePreviewDisabled: ( alternative, control ) => !! control.testAgainstExistingPatterns && ! alternative.patternId, }, help: { original: _x( 'Pattern split tests help you to improve the conversion rate of your WordPress blog by creating one or more variants of your WordPress patterns. The control version (commonly known as the “A” version) is an already-existing pattern, and the test will apply to all pages that use said pattern in their content.', 'user', 'nelio-ab-testing' ), alternative: _x( 'You can create one or more variants of your tested pattern. By default, each variant you create will be an exact copy of the tested pattern. Click on the “Edit” link of each variant to tweak it as you please.', 'user', 'nelio-ab-testing' ), }, defaults: { original: { patternId: 0, }, alternative: { name: '', patternId: 0, }, }, views: { original: Original, alternative: Alternative, }, };