-
Notifications
You must be signed in to change notification settings - Fork 2
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: introduce temporary admin mode for site config #1033
base: main
Are you sure you want to change the base?
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 261 Passed, 36 Skipped, 47.08s Total Time |
ba63312
to
75b5952
Compare
75b5952
to
253b257
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.
minor issue - not too sure what the useEffect
is doing! i think because this affects end user sites (and the site wide config), we might want to sanitise the json object to make sure it's valid (cos we're just parsing to make sure it's valid json, but not that the jsonobject matches what we expect - eg: {siteNavItems: [...]}
vs {siteNavItem: [...]}
but no actionable re: the second point of matching - onlyi want to make sure the useEffect
isn't sussy
useEffect(() => { | ||
const handleRouteChange = (url: string) => { | ||
if (isDirty) { | ||
router.events.off("routeChangeStart", handleRouteChange) | ||
setNextUrl(url) | ||
router.events.emit("routeChangeError") | ||
// eslint-disable-next-line @typescript-eslint/only-throw-error | ||
throw "Error to abort router route change. Ignore this!" | ||
} | ||
} | ||
|
||
if (!isOpen) { | ||
router.events.on("routeChangeStart", handleRouteChange) | ||
} | ||
return () => { | ||
router.events.off("routeChangeStart", handleRouteChange) | ||
} | ||
}, [isOpen, router.events, isDirty]) |
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'm not quiet sure what this useEffect
does? if the modal is closed + there are changes, we unsub to routeChangeStart
(so this iwll only ever fire once) -> and we set the next url
why wouldn't we use the nextUrl
of the unsaved settings modal
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.
Hmm this was taken directly from the settings.tsx file, mainly to trigger the unsaved settings modal if the form is dirty and the user is attempting to change to a different route (e.g. clicking on the pages icon to go back to the site dashboard). This useEffect
will prevent that.
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.
ok, sounds good! this honestly look abit sus but given that it's used on settings.tsx , i think it's ok.
i think it might be worth to double-check the function is cleaning up properly; just based off what i see here, we turn off the events if isDirty then we setNextUrl, but we only turn on the event when the modal is closed again? wondering if it's possible for our users to bypass the !isOpen and for routeChangeStart to be off permanently
based off what i know i don't think so, because any closing of the modal will trigger the state change, but just wanted to be sure
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.
mostly lgtm - i think blind spots for me are the useEffect
, which is actually pretty confusing
the router method can be updated but not a real blocker, given that it's narrowly used and easy to infer from context
@@ -136,4 +144,51 @@ export const siteRouter = router({ | |||
|
|||
return input | |||
}), | |||
setSiteConfigAdmin: protectedProcedure |
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.
nit: i think this might be better named as setSiteConfigByAdmin
or setAdminSiteConfig
but very minor
Problem
Ops load on engineers is quite high for editing the site config, navbar and footer.
Solution
Breaking Changes
Features:
/admin
route for Isomer Admins to directly modify the site's config, theme, navbar and footer items.Before & After Screenshots
View for Isomer Admins:
View for unauthorised users:
Tests
/admin
to the URL and navigate to the page.