-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): test workflow functionality #6768
feat(dashboard): test workflow functionality #6768
Conversation
✅ Deploy Preview for novu-stg-vite-dashboard-poc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
}) as const satisfies JSONSchema; | ||
|
||
@Injectable() | ||
export class WorkflowTestDataUseCase { |
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 GET /workflow/:id/test-data
endpoint returns JSONSchema for the to
and payload
fields that are used to populate the Test Workflow form with the data on FE.
We agreed on this with @tatarco, and the work will be continued later.
@@ -22,9 +22,11 @@ | |||
"dependencies": { | |||
"@clerk/clerk-react": "^5.2.5", | |||
"@hookform/resolvers": "^3.9.0", | |||
"@monaco-editor/react": "^4.6.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.
The payload
JSON field is displayed in the monaco-editor.
I decided to use it because we will also use it in the Step Editor.
@@ -0,0 +1,60 @@ | |||
import * as React from 'react'; |
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.
Actually, I started to create the Panel
component as collapsible, but then later, we decided that there was no point in having the payload
field collapsible on the Test Workflow Page. So, I left this component.
}; | ||
|
||
export const CopyButton: React.FC<CopyButtonProps> = ({ content, className }) => { | ||
export const CopyButton: React.FC<CopyButtonProps> = ({ |
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 CopyButton
so it can be better reused; fixed the issue with the tooltip disappearing
|
||
export const smallToast = ({ children, options }: { children: ReactNode; options: ExternalToast }) => { | ||
return toast(<SmallToast>{children}</SmallToast>, { | ||
export const showToast = ({ |
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 toast helper function so we can pass the close
function to the tooltip body and use it there to close the tooltip with custom button
const to = useMemo( | ||
() => (typeof testData.to === 'object' ? makeObjectFromSchema({ properties: testData.to.properties ?? {} }) : {}), | ||
[testData] | ||
); |
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.
make form object with default values from JSONSchema
<span className="font-medium">Test workflow triggered successfully</span> | ||
<span className="text-foreground-600">{`Test workflow ${workflowId} was triggered successfully`}</span> | ||
<Link | ||
to={`${LEGACY_ROUTES.ACTIVITY_FEED}?transactionId=${transactionId}`} |
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.
link to the old activity feed page with transactionId preselected so the user will be able to check the execution logs
|
||
return ( | ||
<EditWorkflowLayout headerStartItems={<EditorBreadcrumbs />}> | ||
{testData && <TestWorkflowTabs testData={testData} />} |
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.
passing the testData
from this component because we need to generate the schema dynamically based on the response
@@ -0,0 +1,193 @@ | |||
import { API_HOSTNAME } from '@/config'; |
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.
this file contains snippets for different languages; it might seem to you that the code is wrong-formatted, but it's not, it renders properly in the editor
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.
btw it's copied from the old Web app but slightly improved interface
const searchParams = new URLSearchParams(search); | ||
const transactionId = searchParams.get('transactionId'); | ||
if (transactionId) { | ||
setValue('transactionId', transactionId); | ||
onFiltersChange({ transactionId }); | ||
} |
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.
handle the transactionId
from the query params
apps/dashboard/src/components/workflow-editor/test-workflow/test-workflow-form.tsx
Show resolved
Hide resolved
@novu/client
@novu/nest
@novu/framework
@novu/nextjs
@novu/node
@novu/headless
@novu/js
@novu/notification-center
novu
@novu/providers
@novu/react
@novu/react-native
@novu/shared
@novu/stateless
commit: |
...toastProps | ||
}: Omit<ToastProps, 'children'> & { | ||
options: ExternalToast; | ||
children: (args: { close: () => void }) => ReactNode; |
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.
Do you maybe need the instance of the toast
as the first argument in the close function so that you can control the dismissal from the caller of the close function?
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 close
in this case is the internal implementation of the toast; the problem that I faced was that I couldn't reference the id
in the content component to close the toast
const id = toast(<div onClick={() => toast.dismiss(id) <--- error }></div>, ...)
@@ -0,0 +1,63 @@ | |||
import React from 'react'; |
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.
Nit-picky one: breadcrumbs.tsx
. It's already under the workflow-editor
folder.
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 don't see it, it's under the src/components/primitives/breadcrumb.tsx
. Or maybe I didn't understand you correctly.
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 can make the changes separately, just let me know. I'll merge this for now.
What changed? Why was the change needed?
Dashboard Test Workflow functionality in the Workflow Editor:
GET /workflows/:id/test-data
endpoint that returns the JSONSchema for theto
andpayload
fields, that are used on the FE to build the formScreenshots
Screen.Recording.2024-10-24.at.17.30.40.mov
Screen.Recording.2024-10-24.at.22.42.59.mov
Screen.Recording.2024-10-24.at.22.43.36.mov