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): workflow editor route and basic layout #6681

Merged
merged 14 commits into from
Oct 16, 2024

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

Workflow Editor route and basic layout

Screenshots

Screenshot 2024-10-11 at 16 59 07

Screen.Recording.2024-10-11.at.17.01.46.mov

@LetItRock LetItRock self-assigned this Oct 11, 2024
Copy link

linear bot commented Oct 11, 2024

@LetItRock LetItRock changed the title Nv 4477 workflow editor route and layout feat(dashboard): workflow editor render name Oct 11, 2024
Comment on lines +25 to +31
'@typescript-eslint/naming-convention': [
'error',
{
filter: '_',
selector: 'variableLike',
leadingUnderscore: 'allow',
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

allow using _ for the unused variables

Comment on lines +15 to +24
return (
<IntercomProvider appId={INTERCOM_APP_ID}>
<div className="relative flex w-full">
<div className="flex flex-1 flex-col overflow-y-auto overflow-x-hidden">
<HeaderNavigation startItems={headerStartItems} />

<div className="flex min-h-dvh flex-col overflow-y-auto overflow-x-hidden">{children}</div>
</div>
</div>
</IntercomProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

similar layout to the dashboard layout, but we might change here the header navigation and we don't need to show the side navigation

@@ -0,0 +1,50 @@
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.

the tabs component updated according to our designs

Comment on lines +32 to +45
const { workflowId } = useParams<{ workflowId?: string }>();
const navigate = useNavigate();
const form = useForm<z.infer<typeof formSchema>>({ mode: 'onSubmit', resolver: zodResolver(formSchema) });
const { handleSubmit, reset } = form;

const { workflow } = useFetchWorkflow({
workflowId,
onSuccess: (data) => {
reset(data);
},
onError: () => {
navigate(buildRoute(ROUTES.WORKFLOWS, { environmentId: currentEnvironment?._id ?? '' }));
},
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fetch the workflow and set it in the form state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when BE returns an error, navigate the user to the workflow list page

Comment on lines +163 to +174
<TruncatedText
className="cursor-pointer"
text={workflow.name}
onClick={() => {
navigate(
buildRoute(ROUTES.EDIT_WORKFLOW, {
environmentId: currentEnvironment?._id ?? '',
workflowId: workflow._id,
})
);
}}
/>
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 wasn't sure if this is what it should be because, from the designs, it's not clear. But decided to do it like when clicking on the workflow name, redirect the user to the workflow editor.

Copy link

pkg-pr-new bot commented Oct 11, 2024

Open in Stackblitz

novu

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

@novu/client

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

@novu/headless

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

@novu/framework

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

@novu/js

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

@novu/nest

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

@novu/nextjs

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

@novu/notification-center

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

@novu/node

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

@novu/react

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

@novu/providers

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

@novu/react-native

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

@novu/shared

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

@novu/stateless

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

commit: 8c70204

Base automatically changed from nv-4458-dashboard-header-nav to next October 11, 2024 15:12
Copy link

netlify bot commented Oct 11, 2024

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

Name Link
🔨 Latest commit 8c70204
🔍 Latest deploy log https://app.netlify.com/sites/novu-stg-vite-dashboard-poc/deploys/670ee8e393f802000826b81d
😎 Deploy Preview https://deploy-preview-6681--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.

@LetItRock LetItRock changed the title feat(dashboard): workflow editor render name feat(dashboard): workflow editor route and basic layout Oct 14, 2024
import { get, post } from './api.client';

export const getBridgeHealthCheck = async () => {
const { data } = await get<{ data: BridgeStatus }>('/bridge/status');
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to return errors as well. Then in a separate PR we need to wire them to a global error handler.

@@ -0,0 +1,124 @@
import { useLayoutEffect, useState } from 'react';
import { RiLinkM, RiPencilFill } from 'react-icons/ri';
import { PopoverPortal } from '@radix-ui/react-popover';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the recommended way to use a PopoverPortal for ShadCN? I'd expect this to come from primitives folder leveraging the ShadCN code downloaded via the CLI.

Copy link
Contributor Author

@LetItRock LetItRock Oct 15, 2024

Choose a reason for hiding this comment

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

Unfortunately, the cli doesn't generate the portal 🤷‍♂️ but we can re-export it, I'll do it

await updateBridgeUrl({ url: bridgeUrl, environmentId: currentEnvironment?._id ?? '' });
setBridgeUrl(bridgeUrl);
} else {
setError('bridgeUrl', { message: 'The provided URL is not the Novu Endpoint URL' });
Copy link
Contributor

Choose a reason for hiding this comment

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

The new API, the team, prepared has discrete error types. So we should use the server response instead of hardcoding a frontend error message.

See here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SokratisVidros, the updateBridgeUrl is calling the /environments/:environmentId endpoint. Do I miss something?

onClick={() => {
navigate(
buildRoute(ROUTES.EDIT_WORKFLOW, {
environmentId: currentEnvironment?._id ?? '',
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pure inner DX but also a way to prevent invalid states in the front end, such as a workflow route, without environmentId.

Can we please update the hook times so that they always return a currentEnvironment when used to avoid this ternary on each current environment?

There are two ways to go about this.

  1. The hook with throw an error if used and the environment is not set (fail fast), but the environment return type will always be IEnvironment.

  2. We can teach the hook to return the {isLoaded, currentEnvironment} tuple and use discriminated unions so that if isLoaded is true currentEnvironment is always an IEnvironment. Then, in all the components that use useEnvironment we can do if (!isLoaded) { return 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.

@SokratisVidros, it's not that simple:

  1. Throwing an error won't work, because on the initial render the currentEnvironment is always undefined, so the useEnvironment hook will always throw.
  2. That's a partial solution to this problem because all code above the if (!isLoaded) including hooks will still need to check whether the current env is present.

Copy link
Contributor

Choose a reason for hiding this comment

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

We will take this offline. It's not a good enough blocker for this PR.

@LetItRock LetItRock merged commit cc184b4 into next Oct 16, 2024
42 checks passed
@LetItRock LetItRock deleted the nv-4477-workflow-editor-route-and-layout branch October 16, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants