Skip to content
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

feat(dashboard,api-service,framework): email editor digest block #8122

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

Requires Maily PR to be merged: arikchakma/maily.to#184

The changes:

  • Added the Digest block in the Email Editor
  • Improved the pluralize filter to render nothing if the value is <= 0
  • Improved the preview logic of duplicating items in the array, now users will be able to render more items if they provide it in the UI

Screenshots

Screenshot 2025-04-11 at 17 29 53

Screenshot 2025-04-11 at 17 30 19

Screen.Recording.2025-04-11.at.17.28.51.mov

@LetItRock LetItRock self-assigned this Apr 11, 2025
Copy link

linear bot commented Apr 11, 2025

Copy link

netlify bot commented Apr 11, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 7dbe553
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/67f93a92c9f1560008173832
😎 Deploy Preview https://deploy-preview-8122.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +112 to +115
payloadExample: _.merge(
previewTemplateData.payloadExample,
multiplyArrayItems(variablesObject, userPayloadExample as Record<string, unknown> | undefined, 3)
),
Copy link
Contributor Author

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

@@ -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);
}
});

Copy link
Contributor Author

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: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the email digest block

Comment on lines +34 to +51
{
type: 'repeat',
attrs: {
each: `steps.${digestStepBeforeCurrent.stepId}.events`,
isUpdatingKey: false,
showIfKey: null,
iterations: maxIterations,
},
content: [
{
type: 'paragraph',
attrs: {
textAlign: null,
showIfKey: null,
},
content: [],
},
],
Copy link
Contributor Author

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

Comment on lines 54 to 70
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,
},
},
],
Copy link
Contributor Author

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

Comment on lines +73 to +75
if (isEnhancedDigestEnabled && digestStepBeforeCurrent) {
highlightBlocks.unshift(createDigestBlock({ track, digestStepBeforeCurrent }));
}
Copy link
Contributor Author

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(() => {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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

Copy link

pkg-pr-new bot commented Apr 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/novuhq/novu/@novu/framework@8122
npm i https://pkg.pr.new/novuhq/novu@8122

commit: 7dbe553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant