diff --git a/wagtail_ab_testing/static_src/components/GoalSelector/index.tsx b/wagtail_ab_testing/static_src/components/GoalSelector/index.tsx index bc92526..28a45fe 100644 --- a/wagtail_ab_testing/static_src/components/GoalSelector/index.tsx +++ b/wagtail_ab_testing/static_src/components/GoalSelector/index.tsx @@ -113,6 +113,8 @@ const Field = styled.div` display: ${(props) => (props.visible != false ? 'block' : 'none')}; `; +const RequiredMark = () => *; + interface GoalSelectorProps { goalTypesByPageType: { [pageType: string]: { @@ -148,38 +150,53 @@ const GoalSelector: FunctionComponent = ({ return (
- - + + {gettext('Which page is the goal on?')} - - {gettext('What is the goal?')} - + - ))} - -

- {gettext( - 'By default pages only have one goal (Page Visit). Read the developer docs to learn why, and how to add custom goals.', - )} -

+ {goalTypes.map(({ slug, name }) => ( + + ))} + +
+
+
+
+ {gettext( + 'By default pages only have one goal (Page Visit). Read the developer docs to learn why, and how to add custom goals.', + )} +
+
+
); }; export function initGoalSelector() { + const goalSelectorProps = JSON.parse( + document.getElementById('data-goal-selector-props')?.textContent || '', + ); + document .querySelectorAll('div[data-component="goal-selector"]') .forEach((element: HTMLDivElement) => { + element.setAttribute('data-props', goalSelectorProps); + if (!element.dataset.props) { return; }