-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): workflow editor autosave (#6718)
- Loading branch information
Showing
17 changed files
with
1,041 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/dashboard/src/components/primitives/sonner-helpers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ReactNode } from 'react'; | ||
import { ExternalToast, toast } from 'sonner'; | ||
import { SmallToast } from './sonner'; | ||
|
||
export const smallToast = ({ children, options }: { children: ReactNode; options: ExternalToast }) => { | ||
return toast(<SmallToast>{children}</SmallToast>, { | ||
duration: 5000, | ||
unstyled: true, | ||
...options, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { cn } from '@/utils/ui'; | ||
import { useTheme } from 'next-themes'; | ||
import { Toaster as Sonner } from 'sonner'; | ||
|
||
type ToasterProps = React.ComponentProps<typeof Sonner>; | ||
|
||
const SmallToast = ({ children, className, ...props }: React.HTMLAttributes<HTMLDivElement>) => { | ||
return ( | ||
<div | ||
className={cn( | ||
'text-foreground-950 border-neutral-alpha-200 flex items-center gap-1 rounded-lg border px-2.5 py-2 shadow-md', | ||
className | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
const Toaster = ({ ...props }: ToasterProps) => { | ||
const { theme = 'system' } = useTheme(); | ||
|
||
return ( | ||
<Sonner | ||
theme={theme as ToasterProps['theme']} | ||
className="toaster group" | ||
toastOptions={{ | ||
classNames: { | ||
toast: | ||
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg', | ||
description: 'group-[.toast]:text-muted-foreground', | ||
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground', | ||
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground', | ||
}, | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export { Toaster, SmallToast }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useRef } from 'react'; | ||
|
||
export const useDataRef = <T>(data: T) => { | ||
const ref = useRef<T>(data); | ||
ref.current = data; | ||
|
||
return ref; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useCallback, useEffect } from 'react'; | ||
import debounce from 'lodash.debounce'; | ||
import { useDataRef } from './use-data-ref'; | ||
|
||
export const useDebounce = <Arguments = unknown | unknown[]>(callback: (args?: Arguments) => void, ms = 0) => { | ||
const callbackRef = useDataRef(callback); | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const debouncedCallback = useCallback(debounce(callbackRef.current, ms), [callbackRef, ms]); | ||
|
||
useEffect(() => debouncedCallback.cancel, [debouncedCallback.cancel]); | ||
|
||
return debouncedCallback; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.