-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(api-service,dashboard): allow using the current variable in the repeat button #8225
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
fix(api-service,dashboard): allow using the current variable in the repeat button #8225
Conversation
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| <VariableIcon variableName={variableName} hasError={!!issues} /> | ||
| <span className="leading-1 max-w-[24ch] truncate" title={displayVariableName}> | ||
| {/* INFO: Keep the color defined on the span to avoid overriding it in maily components for example button */} | ||
| <span className="leading-1 text-text-sub max-w-[24ch] truncate" title={displayVariableName}> |
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 pill variable text was not visible when used with the Mailly black button
| if (!isInRepeatBlock && isEnhancedDigestEnabled && addDigestVariables) { | ||
| const mappedDigestVariables = DIGEST_VARIABLES.map((variable) => ({ | ||
| name: variable.name, | ||
| })); | ||
| baseVariables.push(...mappedDigestVariables); | ||
| } |
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 digest variables should not be accessible inside the repeat block
| // Case 2: Bubble menu (showIf) - allow only primitives and namespaces | ||
| case VariableFrom.Bubble: | ||
| return [...primitives, ...namespaces]; | ||
| return getVariables(); |
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.
in the bubble the current variable was not accessible
| return processedNode; | ||
| } | ||
|
|
||
| if (isButtonNode(processedNode)) { |
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 array item access in the button that is inside the repeat block was not working
| const aliasFor = resolveRepeatBlockAlias( | ||
| isTextVariable ? (text ?? '') : (url ?? ''), | ||
| editor, | ||
| isEnhancedDigestEnabled | ||
| ); | ||
| return commands.updateButton?.({ ...attrs, aliasFor: 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.
calculate the aliasFor for the text or url buttons that are variables
scopsy
left a comment
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.
👏
…nd the node marks; override maily blocks extensions to support aliasFor attribute
| return processedNode; | ||
| } | ||
|
|
||
| if (isImageNode(processedNode)) { |
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.
and the same thing for the other types of nodes
| if (processedNode.marks?.length) { | ||
| processedNode.marks = this.processForEachNodes( | ||
| processedNode.marks, | ||
| iterablePath, | ||
| index | ||
| ) as Array<MailyJSONMarks>; | ||
| } |
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.
We've been missing this piece of code that processes the node marks, for example, text that is the link; so this code ensures that if we use variables in the links, it will work
| if (type === MailyContentTypeEnum.INLINE_IMAGE) { | ||
| return [ | ||
| { attr: MailyAttrsEnum.SRC, flag: MailyAttrsEnum.IS_SRC_VARIABLE }, | ||
| { | ||
| attr: MailyAttrsEnum.EXTERNAL_LINK, | ||
| flag: MailyAttrsEnum.IS_EXTERNAL_LINK_VARIABLE, | ||
| }, | ||
| ...commonConfig, | ||
| ]; | ||
| } |
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.
seems that the variables never worked on the inline_image :/
|
|
||
| if (isEnhancedDigestEnabled) { | ||
| extensions.push( | ||
| ButtonExtension.extend({ |
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 piece of code allows us to hook into the node attributes update and set the aliasFor attribute that is used to resolve the variable
What changed? Why was the change needed?
THIS PR REQUIRES CHANGES IN MAILY: novuhq/maily.to#23
In this PR a few issues were fixed:
currentvariable was not accessiblealiasForwas not set on the buttons as we treat them differently so it resulted that thecurrentvariable was not workingScreenshots
Screen.Recording.2025-04-28.at.18.48.24.mov