-
Notifications
You must be signed in to change notification settings - Fork 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
fix(dashboard): Always trust the URL for the environment selection #7223
Conversation
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for dashboard-v2-novu-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
0acbdcd
to
119fb32
Compare
119fb32
to
ae30083
Compare
@novu/client
@novu/framework
@novu/node
@novu/notification-center
@novu/headless
novu
@novu/providers
@novu/shared
commit: |
@@ -17,28 +17,28 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; | |||
const request = async <T>( | |||
endpoint: string, | |||
options?: { | |||
data?: unknown; | |||
environment?: IEnvironment; |
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.
Inject the environment to API calls
export async function getBillingSubscription() { | ||
const { data } = await get<{ data: GetSubscriptionDto }>('/billing/subscription'); | ||
|
||
export async function getSubscription({ environment }: { environment: IEnvironment }) { |
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.
Simplify naming
@@ -1,25 +1,26 @@ | |||
import { useEffect, useState } 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.
Sort alphabetically to have it nice and tidy
@@ -9,7 +9,7 @@ import { useForm, Controller } from 'react-hook-form'; | |||
import { updateClerkOrgMetadata } from '../../api/organization'; | |||
import { hubspotCookie } from '../../utils/cookies'; | |||
import { identifyUser } from '../../api/telemetry'; | |||
import { useTelemetry } from '../../hooks'; | |||
import { useTelemetry } from '../../hooks/use-telemetry'; |
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 should avoid the index.ts barrel file. It destroys tree shaking, chunking and introduces an extra import and file resolution.
@@ -1,9 +0,0 @@ | |||
export * from './use-billing-subscription'; |
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.
const { mutateAsync, isPending } = useMutation({ | ||
mutationFn: async (data: CreateWorkflowDto) => createWorkflow(data), | ||
mutationFn: async (workflow: CreateWorkflowDto) => createWorkflow({ environment: currentEnvironment!, workflow }), |
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 a follow-up PR, currentEnvironment
will never be undefined or null to avoid the !
or ?._id
discomfort.
placeholderData: keepPreviousData, | ||
enabled: !!currentEnvironment?._id, | ||
refetchOnWindowFocus: 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.
This caters to the use case where customers will have their dev and prod environments side by side, and they will sync workflows between environments. They should be able to see the update without a full page reload.
- Pick an environment based on the URL and avoid race conditions using the local storage as we did in the old web app - Allow multiple environments open in separate browser tabs
This caters to the use case where customers will have their dev and prod environments side by side, and they will sync workflows between environments. They should be able to see the update without a full page reload.
c5e7fc6
to
a9be679
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.
lgtm 🙌
What changed? Why was the change needed?
What this PR doesn't contain?
-[] Unify the return types to always follow the { resourceName: data, ...restOfReactQuery } return type. This will be done separately in the future.