Pass next step to flow separator

[MAILPOET-6230]
This commit is contained in:
 Ján Mikláš
2024-09-19 22:15:43 +02:00
committed by Aschepikov
parent 696d448604
commit 7b84b93fbf
6 changed files with 43 additions and 10 deletions

View File

@@ -3,14 +3,23 @@ import { FlowSeparator } from './flow-separator';
import { Step as StepData } from './types'; import { Step as StepData } from './types';
type Props = { type Props = {
stepData: StepData; previousStepData: StepData;
index: number; index: number;
nextStepData?: StepData;
}; };
export function FlowEnding({ stepData, index }: Props): JSX.Element { export function FlowEnding({
previousStepData,
index,
nextStepData,
}: Props): JSX.Element {
return ( return (
<div className="mailpoet-automation-editor-step-wrapper"> <div className="mailpoet-automation-editor-step-wrapper">
<FlowSeparator stepData={stepData} index={index} /> <FlowSeparator
previousStepData={previousStepData}
nextStepData={nextStepData}
index={index}
/>
<Icon <Icon
className="mailpoet-automation-editor-automation-end" className="mailpoet-automation-editor-automation-end"
icon={check} icon={check}

View File

@@ -6,8 +6,9 @@ import { Step as StepData } from './types';
import { RenderStepSeparatorType } from '../../../types/filters'; import { RenderStepSeparatorType } from '../../../types/filters';
type Props = { type Props = {
stepData: StepData; previousStepData: StepData;
index: number; index: number;
nextStepData?: StepData;
}; };
export function FlowSeparator(props: Props): JSX.Element { export function FlowSeparator(props: Props): JSX.Element {
@@ -35,5 +36,9 @@ export function FlowSeparator(props: Props): JSX.Element {
), ),
[context], [context],
); );
return renderSeparator(props.stepData, props.index); return renderSeparator(
props.previousStepData,
props.index,
props.nextStepData,
);
} }

View File

@@ -40,13 +40,24 @@ export function Flow({ stepData, row }: Props): JSX.Element {
return nextStepData ? ( return nextStepData ? (
<div key={id}> <div key={id}>
{row > 0 && <FlowSeparator stepData={stepData} index={i} />} {row > 0 && (
<FlowSeparator
previousStepData={stepData}
index={i}
nextStepData={nextStepData}
/>
)}
<FlowStep stepData={nextStepData} index={i} /> <FlowStep stepData={nextStepData} index={i} />
<Flow stepData={nextStepData} row={row + 1} /> <Flow stepData={nextStepData} row={row + 1} />
</div> </div>
) : ( ) : (
// eslint-disable-next-line react/no-array-index-key <FlowEnding
<FlowEnding key={i} stepData={stepData} index={i} /> // eslint-disable-next-line react/no-array-index-key
key={i}
previousStepData={stepData}
index={i}
nextStepData={nextStepData}
/>
); );
})} })}
</div> </div>

View File

@@ -50,6 +50,7 @@ export function initHooks() {
return function StatisticSeparatorWrapper( return function StatisticSeparatorWrapper(
previousStepData: StepData, previousStepData: StepData,
index: number, index: number,
nextStepData: StepData,
) { ) {
return ( return (
<> <>
@@ -62,7 +63,11 @@ export function initHooks() {
} }
/> />
)} )}
<StatisticSeparator previousStep={previousStepData} index={index} /> <StatisticSeparator
previousStep={previousStepData}
nextStep={nextStepData}
index={index}
/>
</> </>
); );
}; };

View File

@@ -8,11 +8,13 @@ import { Step } from '../../../../../../editor/components/automation/types';
type Props = { type Props = {
previousStep: Step; previousStep: Step;
index: number; index: number;
nextStep?: Step;
}; };
export function StatisticSeparator({ export function StatisticSeparator({
previousStep, previousStep,
index, index,
nextStep,
}: Props): JSX.Element | null { }: Props): JSX.Element | null {
const { section, stepType } = useSelect( const { section, stepType } = useSelect(
(s) => ({ (s) => ({

View File

@@ -37,8 +37,9 @@ export type RenderStepFooterType = JSX.Element | null;
// mailpoet.automation.render_step_separator // mailpoet.automation.render_step_separator
export type RenderStepSeparatorType = ( export type RenderStepSeparatorType = (
step: Step, previousStep: Step,
index: number, index: number,
nextStep?: Step,
) => JSX.Element; ) => JSX.Element;
// mailpoet.automation.editor.create_store // mailpoet.automation.editor.create_store