Skip to content

Commit

Permalink
feat(dashboard): fix code defined delay copy (#7661)
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge authored Feb 5, 2025
1 parent 87bb59e commit 21b8ad1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions apps/dashboard/src/components/workflow-editor/workflow-canvas.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnvironmentEnum, FeatureFlagsKeysEnum } from '@novu/shared';
import { EnvironmentEnum, FeatureFlagsKeysEnum, WorkflowOriginEnum } from '@novu/shared';
import {
Background,
BackgroundVariant,
Expand Down Expand Up @@ -66,8 +66,12 @@ const panOnDrag = [1, 2];
// y distance = node height + space between nodes
const Y_DISTANCE = NODE_HEIGHT + 50;

const mapStepToNodeContent = (step: Step): string | undefined => {
const mapStepToNodeContent = (step: Step, workflowOrigin: WorkflowOriginEnum): string | undefined => {
const controlValues = step.controls.values;
const delayMessage =
workflowOrigin === WorkflowOriginEnum.EXTERNAL
? 'Delay duration defined in code'
: `Delay for ${controlValues.amount} ${controlValues.unit}`;

switch (step.type) {
case StepTypeEnum.TRIGGER:
Expand All @@ -83,7 +87,7 @@ const mapStepToNodeContent = (step: Step): string | undefined => {
case StepTypeEnum.CHAT:
return 'Sends Chat message to your subscribers';
case StepTypeEnum.DELAY:
return `Delay for ${controlValues.amount} ${controlValues.unit}`;
return delayMessage;
case StepTypeEnum.DIGEST:
return 'Batches events into one coherent message before delivery to the subscriber.';
case StepTypeEnum.CUSTOM:
Expand All @@ -98,13 +102,15 @@ const mapStepToNode = ({
previousPosition,
step,
readOnly,
workflowOrigin = WorkflowOriginEnum.NOVU_CLOUD,
}: {
addStepIndex: number;
previousPosition: { x: number; y: number };
step: Step;
readOnly?: boolean;
workflowOrigin?: WorkflowOriginEnum;
}): Node<NodeData, keyof typeof nodeTypes> => {
const content = mapStepToNodeContent(step);
const content = mapStepToNodeContent(step, workflowOrigin);

const error = getFirstBodyErrorMessage(step.issues) || getFirstControlsErrorMessage(step.issues);

Expand Down Expand Up @@ -152,6 +158,7 @@ const WorkflowCanvasChild = ({ steps, readOnly }: { steps: Step[]; readOnly?: bo
previousPosition,
addStepIndex: index,
readOnly,
workflowOrigin: currentWorkflow?.origin,
});
previousPosition = node.position;
return node;
Expand Down

0 comments on commit 21b8ad1

Please sign in to comment.