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): test workflow functionality #6768

Merged
merged 9 commits into from
Oct 29, 2024

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

Dashboard Test Workflow functionality in the Workflow Editor:

  • test workflow route + page with form and snippets; activity logs descoped;
  • implemented the dummy GET /workflows/:id/test-data endpoint that returns the JSONSchema for the to and payload fields, that are used on the FE to build the form
  • improved sonner toast component
  • improved copy button
  • implemented panel component

Screenshots

Screenshot 2024-10-24 at 23 09 44
Screenshot 2024-10-24 at 23 09 24

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

Copy link

linear bot commented Oct 24, 2024

Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for novu-stg-vite-dashboard-poc ready!

Name Link
🔨 Latest commit 05cba25
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/6720f33e2e2a0200084e9012
😎 Deploy Preview https://deploy-preview-6768--novu-stg-vite-dashboard-poc.netlify.app
📱 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.

}) as const satisfies JSONSchema;

@Injectable()
export class WorkflowTestDataUseCase {
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 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",
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 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';
Copy link
Contributor Author

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> = ({
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 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 = ({
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 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

Comment on lines +26 to +29
const to = useMemo(
() => (typeof testData.to === 'object' ? makeObjectFromSchema({ properties: testData.to.properties ?? {} }) : {}),
[testData]
);
Copy link
Contributor Author

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}`}
Copy link
Contributor Author

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} />}
Copy link
Contributor Author

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';
Copy link
Contributor Author

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

Copy link
Contributor Author

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

Comment on lines +96 to +101
const searchParams = new URLSearchParams(search);
const transactionId = searchParams.get('transactionId');
if (transactionId) {
setValue('transactionId', transactionId);
onFiltersChange({ transactionId });
}
Copy link
Contributor Author

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

Copy link

pkg-pr-new bot commented Oct 29, 2024

Open in Stackblitz

@novu/client

pnpm add https://pkg.pr.new/novuhq/novu/@novu/client@6768

@novu/nest

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nest@6768

@novu/framework

pnpm add https://pkg.pr.new/novuhq/novu/@novu/framework@6768

@novu/nextjs

pnpm add https://pkg.pr.new/novuhq/novu/@novu/nextjs@6768

@novu/node

pnpm add https://pkg.pr.new/novuhq/novu/@novu/node@6768

@novu/headless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/headless@6768

@novu/js

pnpm add https://pkg.pr.new/novuhq/novu/@novu/js@6768

@novu/notification-center

pnpm add https://pkg.pr.new/novuhq/novu/@novu/notification-center@6768

novu

pnpm add https://pkg.pr.new/novuhq/novu@6768

@novu/providers

pnpm add https://pkg.pr.new/novuhq/novu/@novu/providers@6768

@novu/react

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react@6768

@novu/react-native

pnpm add https://pkg.pr.new/novuhq/novu/@novu/react-native@6768

@novu/shared

pnpm add https://pkg.pr.new/novuhq/novu/@novu/shared@6768

@novu/stateless

pnpm add https://pkg.pr.new/novuhq/novu/@novu/stateless@6768

commit: 05cba25

...toastProps
}: Omit<ToastProps, 'children'> & {
options: ExternalToast;
children: (args: { close: () => void }) => ReactNode;
Copy link
Contributor

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?

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 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';
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@LetItRock LetItRock merged commit 9e90387 into next Oct 29, 2024
43 checks passed
@LetItRock LetItRock deleted the nv-4336-dashboard-workflow-test-functionality branch October 29, 2024 15:18
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.

3 participants