-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(console): block page navigation when uploading custom ui ass…
…ets (#6342)
- Loading branch information
1 parent
fb5b02b
commit 33a1ac1
Showing
12 changed files
with
119 additions
and
26 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
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
File renamed without changes.
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
48 changes: 48 additions & 0 deletions
48
...ges/console/src/pages/SignInExperience/contexts/SignInExperienceContextProvider/index.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,48 @@ | ||
import { noop } from '@silverhand/essentials'; | ||
import { createContext, useMemo, useRef, useState } from 'react'; | ||
|
||
type SignInExperienceContextType = { | ||
isUploading: boolean; | ||
cancelUpload?: () => void; | ||
setIsUploading: (value: boolean) => void; | ||
setCancelUpload: (cancelFunction?: () => void) => void; | ||
}; | ||
|
||
type Props = { | ||
readonly children?: React.ReactNode; | ||
}; | ||
|
||
export const SignInExperienceContext = createContext<SignInExperienceContextType>({ | ||
isUploading: false, | ||
cancelUpload: noop, | ||
setIsUploading: noop, | ||
setCancelUpload: noop, | ||
}); | ||
|
||
function SignInExperienceContextProvider({ children }: Props) { | ||
const [isUploading, setIsUploading] = useState(false); | ||
const cancelUploadRef = useRef<() => void>(); | ||
|
||
const handleSetCancelUpload = (cancelFunction?: () => void) => { | ||
// eslint-disable-next-line @silverhand/fp/no-mutation | ||
cancelUploadRef.current = cancelFunction; | ||
}; | ||
|
||
const contextValue = useMemo( | ||
() => ({ | ||
isUploading, | ||
cancelUpload: cancelUploadRef.current, | ||
setIsUploading, | ||
setCancelUpload: handleSetCancelUpload, | ||
}), | ||
[isUploading] | ||
); | ||
|
||
return ( | ||
<SignInExperienceContext.Provider value={contextValue}> | ||
{children} | ||
</SignInExperienceContext.Provider> | ||
); | ||
} | ||
|
||
export default SignInExperienceContextProvider; |
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