-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add available variables dropdown #7964
Conversation
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.
PR Summary
This pull request introduces a new variable dropdown feature for the workflow editor, focusing on enhancing the user experience when working with variables. Here are the key changes:
- Implemented
SearchVariablesDropdown
component for selecting variables in workflows - Added
VariableTagInput
component, combining a Tiptap-based text editor with variable insertion functionality - Created utility functions for parsing and initializing editor content with variable tags
- Introduced unit tests for
initializeEditorContent
andparseEditorContent
functions - Updated
WorkflowEditActionFormSendEmail
to use the newVariableTagInput
for email and subject fields
14 file(s) reviewed, 22 comment(s)
Edit PR Review Bot Settings | Greptile
packages/twenty-front/src/modules/workflow/components/WorkflowEditActionFormSendEmail.tsx
Outdated
Show resolved
Hide resolved
...es/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdown.tsx
Outdated
Show resolved
Hide resolved
...es/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdown.tsx
Outdated
Show resolved
Hide resolved
...es/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdown.tsx
Outdated
Show resolved
Hide resolved
...y-front/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepItem.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/initializeEditorContent.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/initializeEditorContent.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/variableTag.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/variableTag.ts
Outdated
Show resolved
Hide resolved
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.
Really cool😍 LGTM
...es/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdown.tsx
Outdated
Show resolved
Hide resolved
...es/twenty-front/src/modules/workflow/search-variables/components/SearchVariablesDropdown.tsx
Outdated
Show resolved
Hide resolved
...ront/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx
Outdated
Show resolved
Hide resolved
...ront/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/components/VariableTagInput.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/variableTag.ts
Show resolved
Hide resolved
7cb545d
to
81d75ab
Compare
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.
Awesome work, @thomtrp! That's so nice to see the variable editor in work. You rock!
I wrote a few comments. Some nitpicks not really important, and some comments about Tiptap's use. I'm happy to discuss them with you. Thank you!
...ront/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx
Outdated
Show resolved
Hide resolved
...ront/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx
Outdated
Show resolved
Hide resolved
...ront/src/modules/workflow/search-variables/components/SearchVariablesDropdownStepSubItem.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/initializeEditorContent.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/components/VariableTagInput.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/getVariableTag.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/components/VariableTagInput.tsx
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/components/VariableTagInput.tsx
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/components/VariableTagInput.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/search-variables/utils/getVariableTag.ts
Outdated
Show resolved
Hide resolved
63698df
to
7dec88c
Compare
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.
Your updates are awesome. I left a few comments 😄
const parsedContent = parseEditorContent(jsonContent); | ||
onChange?.(parsedContent); | ||
}, 500); | ||
|
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.
I think you need to flush the debouncer to be sure to persist the changes when the right drawer is closed. If the user closes the drawer before the timer ends, the HTTP call will never be made.
I did it that way somewhere else in the application:
const saveAction = useDebouncedCallback(/* ... */);
useEffect(() => {
return () => {
saveAction.flush();
};
}, [saveAction]);
packages/twenty-front/src/modules/workflow/search-variables/utils/variableTag.ts
Show resolved
Hide resolved
// @ts-expect-error - addCommands is missing from the NodeConfig type | ||
addCommands: () => ({ | ||
insertVariableTag: | ||
(variable: string) => | ||
({ commands }: { commands: Partial<RawCommands> }) => { | ||
return commands.insertContent?.({ | ||
type: 'variableTag', | ||
attrs: { variable }, | ||
}); | ||
}, | ||
}), |
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.
I think you can make TypeScript happy with the following code. It seems to work still. Does it make sense?
// @ts-expect-error - addCommands is missing from the NodeConfig type | |
addCommands: () => ({ | |
insertVariableTag: | |
(variable: string) => | |
({ commands }: { commands: Partial<RawCommands> }) => { | |
return commands.insertContent?.({ | |
type: 'variableTag', | |
attrs: { variable }, | |
}); | |
}, | |
}), | |
addCommands: () => ({ | |
insertVariableTag: | |
(variable: string) => | |
({ commands }) => { | |
commands.insertContent({ | |
type: 'variableTag', | |
attrs: { variable }, | |
}); | |
return true; | |
}, | |
}), |
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.
🤯 I did try the boolean but I still using : { commands: Partial<RawCommands> }
as type. Thank you!
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.
Haha 😄 I found somewhere in the documentation where they added custom commands and used this syntax.
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.
Perfect!!
0ea9dcf
to
ace95a4
Compare
1de9d77
to
f3ec78d
Compare
{{stepName.object.myVar}}
and display onlymyVar
Enregistrement.de.l.ecran.2024-10-22.a.17.30.11.mov