-
Notifications
You must be signed in to change notification settings - Fork 364
Feature: support redirect param on creation page, redirect to the Safe app page if Safe was created from the landing #3790
Feature: support redirect param on creation page, redirect to the Safe app page if Safe was created from the landing #3790
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
b7aaab4
to
2414d14
Compare
2414d14
to
e9670f9
Compare
e9670f9
to
93f5ff2
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.
Looks good!
…into feat/create-safe-apps-redirect
@@ -75,6 +75,10 @@ const SafeAppLandingPage = (): ReactElement => { | |||
|
|||
const showLoader = isLoading || !safeAppDetails | |||
|
|||
if (!safeAppUrl) { | |||
return <Redirect to={WELCOME_ROUTE} /> |
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 edge case is already addressed in the first useEffect right?
What is your opinion about to remove this redundant redirection and keep showing the Loader? (and restore this 2 lines in the unit tests?)
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.
I don't think addressing it in useEffect
is the way to go. We don't need to render anything if there's no safeAppUrl
. This is also better for types stuff, because query.get
returns string | undefined
and this narrows it to string
, making it easer for subsequent access
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.
Then maybe makes sense update both useEffect
?. Something like this:
const SafeAppLandingPage = (): ReactElement => {
const query = useQuery()
const safeAppChainId = query.get('chainId')
const safeAppUrl = query.get('appUrl')
useEffect(() => {
if (isValidChainId(safeAppChainId)) {
setChainId(safeAppChainId)
}
}, [safeAppChainId])
[...] // other stuff
// the second useEffect is unnecessary, and instead, do:
const isSafeAppMissing = !isLoading && !safeAppDetails && isManifestError
if (!safeAppUrl || !safeAppChainId || isSafeAppMissing) {
return <Redirect to={WELCOME_ROUTE} />
}
const availableChains = safeAppDetails?.chainIds || []
const showLoader = isLoading || !safeAppDetails
return (
<Container>
<StyledCard>
[...]
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.
done senor
…into feat/create-safe-apps-redirect
18ea042
to
49fbce8
Compare
…fe-react into feat/create-safe-apps-redirect
ESLint Summary View Full Report
Report generated by eslint-plus-action |
What it solves
Resolves safe-global/safe-react-apps#417
How this PR fixes it
Adds new
redirect
param for the safe creation route. If the URL string has a template for Safe Route, it populates it with the address.How to test it