-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(dashboard,api-service,framework): email editor digest block #8122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
payloadExample: _.merge( | ||
previewTemplateData.payloadExample, | ||
multiplyArrayItems(variablesObject, userPayloadExample as Record<string, unknown> | undefined, 3) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve the logic of duplicating array items for the preview; now if the users are providing more than default 3 we will render more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look here - I've removed this multiplyArrayItems
completely: #8119
since the amount of iterations is now handled by the "repeat" number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, then we don't need my changes :)
@@ -205,7 +210,8 @@ export function multiplyArrayItems(obj: Record<string, unknown>, multiplyBy = 3) | |||
return key === 'events' ? { payload: {} } : value[0]; | |||
}); | |||
} else if (typeof value === 'object' && value !== null) { | |||
result[key] = multiplyArrayItems(value as Record<string, unknown>, multiplyBy); | |||
const refValue = ref?.[key] as Record<string, unknown> | undefined; | |||
result[key] = multiplyArrayItems(value as Record<string, unknown>, refValue, multiplyBy); | |||
} | |||
}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the below are image files that I decided to compress to webp, now they weight way less and load faster
import { StepResponseDto } from '@novu/shared'; | ||
import { RiShadowLine } from 'react-icons/ri'; | ||
|
||
export const createDigestBlock = (props: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the email digest block
{ | ||
type: 'repeat', | ||
attrs: { | ||
each: `steps.${digestStepBeforeCurrent.stepId}.events`, | ||
isUpdatingKey: false, | ||
showIfKey: null, | ||
iterations: maxIterations, | ||
}, | ||
content: [ | ||
{ | ||
type: 'paragraph', | ||
attrs: { | ||
textAlign: null, | ||
showIfKey: null, | ||
}, | ||
content: [], | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeat block with max items set to 5 and empty paragraph
type: 'paragraph', | ||
attrs: { | ||
textAlign: null, | ||
showIfKey: null, | ||
}, | ||
content: [ | ||
{ | ||
type: 'variable', | ||
attrs: { | ||
id: `steps.digest-step.eventCount | minus: ${maxIterations} | pluralize: 'more comment', ''`, | ||
label: null, | ||
fallback: null, | ||
required: false, | ||
aliasFor: null, | ||
}, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the paragraph with the variable that uses steps.digest-step.eventCount
and filters
if (isEnhancedDigestEnabled && digestStepBeforeCurrent) { | ||
highlightBlocks.unshift(createDigestBlock({ track, digestStepBeforeCurrent })); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the digest block to the list of highlighted blocks
@@ -58,6 +59,43 @@ export const WorkflowProvider = ({ children }: { children: ReactNode }) => { | |||
); | |||
}, [workflow, stepSlug]); | |||
|
|||
const isStepAfterDigest = useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code copied from the PR: #8097
@@ -32,6 +33,10 @@ export function pluralize(item: unknown, singular: string = '', plural: string = | |||
count = 0; | |||
} | |||
|
|||
if (count <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improved the pluralize
LiquidJS filter to render nothing when the value is <= 0
commit: |
payloadExample: _.merge( | ||
previewTemplateData.payloadExample, | ||
multiplyArrayItems(variablesObject, userPayloadExample as Record<string, unknown> | undefined, 3) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look here - I've removed this multiplyArrayItems
completely: #8119
since the amount of iterations is now handled by the "repeat" number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changed? Why was the change needed?
Requires Maily PR to be merged: novuhq/maily.to#17, arikchakma/maily.to#184
The changes:
pluralize
filter to render nothing if thevalue
is <= 0Screenshots
Screen.Recording.2025-04-11.at.17.28.51.mov