mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
chore: fix demo by adapting to new constraints flow
This commit is contained in:
parent
7c31ec71a1
commit
21a88bfd2a
@ -139,6 +139,14 @@ export const DemoSteps = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
step.onStep?.({
|
||||||
|
el,
|
||||||
|
index,
|
||||||
|
next,
|
||||||
|
step,
|
||||||
|
signal: abortController.signal,
|
||||||
|
});
|
||||||
|
|
||||||
if (!step.nextButton) {
|
if (!step.nextButton) {
|
||||||
const clickHandler = (e: Event) => {
|
const clickHandler = (e: Event) => {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
|
@ -12,6 +12,13 @@ export interface ITutorialTopicStep extends Step {
|
|||||||
backCloseModal?: boolean;
|
backCloseModal?: boolean;
|
||||||
backCollapseExpanded?: boolean;
|
backCollapseExpanded?: boolean;
|
||||||
preventDefault?: boolean;
|
preventDefault?: boolean;
|
||||||
|
onStep?: (params: {
|
||||||
|
el: HTMLElement;
|
||||||
|
index: number;
|
||||||
|
next: (i?: number) => void;
|
||||||
|
step: ITutorialTopicStep;
|
||||||
|
signal: AbortSignal;
|
||||||
|
}) => void;
|
||||||
anyClick?: boolean;
|
anyClick?: boolean;
|
||||||
optional?: boolean;
|
optional?: boolean;
|
||||||
focus?: boolean | string;
|
focus?: boolean | string;
|
||||||
@ -246,6 +253,16 @@ export const TOPICS: ITutorialTopic[] = [
|
|||||||
placement: 'right',
|
placement: 'right',
|
||||||
backCloseModal: true,
|
backCloseModal: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Add constraint value',
|
||||||
|
target: 'button[data-testid="CONSTRAINT_ADD_VALUES_BUTTON"]',
|
||||||
|
content: (
|
||||||
|
<Description>
|
||||||
|
Add a new constraint value by using this button.
|
||||||
|
</Description>
|
||||||
|
),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Input value',
|
title: 'Input value',
|
||||||
target: 'div[data-testid="CONSTRAINT_VALUES_INPUT"]',
|
target: 'div[data-testid="CONSTRAINT_VALUES_INPUT"]',
|
||||||
@ -273,15 +290,29 @@ export const TOPICS: ITutorialTopic[] = [
|
|||||||
placement: 'right',
|
placement: 'right',
|
||||||
nextButton: true,
|
nextButton: true,
|
||||||
focus: 'input',
|
focus: 'input',
|
||||||
|
onStep: ({ el, next, index, signal }) => {
|
||||||
|
const input = el.querySelector('input');
|
||||||
|
|
||||||
|
input?.addEventListener(
|
||||||
|
'keydown',
|
||||||
|
(e) => {
|
||||||
|
if (e.key === 'Enter' && input.value.trim()) {
|
||||||
|
next(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Add value',
|
title: 'Add value',
|
||||||
target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]',
|
target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]:not(:disabled)',
|
||||||
content: (
|
content: (
|
||||||
<Description>
|
<Description>
|
||||||
Add the constraint value by using this button.
|
Add the constraint value by using this button.
|
||||||
</Description>
|
</Description>
|
||||||
),
|
),
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Save constraint setup',
|
title: 'Save constraint setup',
|
||||||
@ -623,6 +654,16 @@ export const TOPICS: ITutorialTopic[] = [
|
|||||||
placement: 'right',
|
placement: 'right',
|
||||||
backCloseModal: true,
|
backCloseModal: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Add constraint value',
|
||||||
|
target: 'button[data-testid="CONSTRAINT_ADD_VALUES_BUTTON"]',
|
||||||
|
content: (
|
||||||
|
<Description>
|
||||||
|
Add a new constraint value by using this button.
|
||||||
|
</Description>
|
||||||
|
),
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Input value',
|
title: 'Input value',
|
||||||
target: 'div[data-testid="CONSTRAINT_VALUES_INPUT"]',
|
target: 'div[data-testid="CONSTRAINT_VALUES_INPUT"]',
|
||||||
@ -650,15 +691,29 @@ export const TOPICS: ITutorialTopic[] = [
|
|||||||
placement: 'right',
|
placement: 'right',
|
||||||
nextButton: true,
|
nextButton: true,
|
||||||
focus: 'input',
|
focus: 'input',
|
||||||
|
onStep: ({ el, next, index, signal }) => {
|
||||||
|
const input = el.querySelector('input');
|
||||||
|
|
||||||
|
input?.addEventListener(
|
||||||
|
'keydown',
|
||||||
|
(e) => {
|
||||||
|
if (e.key === 'Enter' && input.value.trim()) {
|
||||||
|
next(index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Add value',
|
title: 'Add value',
|
||||||
target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]',
|
target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]:not(:disabled)',
|
||||||
content: (
|
content: (
|
||||||
<Description>
|
<Description>
|
||||||
Add the constraint value by using this button.
|
Add the constraint value by using this button.
|
||||||
</Description>
|
</Description>
|
||||||
),
|
),
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Save constraint setup',
|
title: 'Save constraint setup',
|
||||||
|
@ -130,6 +130,7 @@ export const AddValuesPopover: FC<AddValuesProps> = ({
|
|||||||
inputProps={{
|
inputProps={{
|
||||||
...inputProps,
|
...inputProps,
|
||||||
}}
|
}}
|
||||||
|
data-testid='CONSTRAINT_VALUES_INPUT'
|
||||||
/>
|
/>
|
||||||
<AddButton
|
<AddButton
|
||||||
variant='text'
|
variant='text'
|
||||||
@ -137,6 +138,7 @@ export const AddValuesPopover: FC<AddValuesProps> = ({
|
|||||||
size='small'
|
size='small'
|
||||||
color='primary'
|
color='primary'
|
||||||
disabled={!inputValue?.trim()}
|
disabled={!inputValue?.trim()}
|
||||||
|
data-testid='CONSTRAINT_VALUES_ADD_BUTTON'
|
||||||
>
|
>
|
||||||
Add
|
Add
|
||||||
</AddButton>
|
</AddButton>
|
||||||
|
@ -74,6 +74,7 @@ export const AddValuesWidget = forwardRef<HTMLButtonElement, AddValuesProps>(
|
|||||||
ref={positioningRef}
|
ref={positioningRef}
|
||||||
onClick={() => setOpen(true)}
|
onClick={() => setOpen(true)}
|
||||||
type='button'
|
type='button'
|
||||||
|
data-testid='CONSTRAINT_ADD_VALUES_BUTTON'
|
||||||
>
|
>
|
||||||
<Add />
|
<Add />
|
||||||
<span>Add values</span>
|
<span>Add values</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user