Redirect with query params and update EE form with hub image data

This commit is contained in:
Marliana Lara
2021-09-22 10:41:08 -04:00
committed by mabashian
parent 7eefa897b3
commit 8e34898b4e
2 changed files with 23 additions and 1 deletions

View File

@@ -100,7 +100,7 @@ const AuthorizedRoutes = ({ routeConfig }) => {
const ProtectedRoute = ({ children, ...rest }) => { const ProtectedRoute = ({ children, ...rest }) => {
const { authRedirectTo, setAuthRedirectTo } = useSession(); const { authRedirectTo, setAuthRedirectTo } = useSession();
const { pathname } = useLocation(); const location = useLocation();
useEffect(() => { useEffect(() => {
setAuthRedirectTo(authRedirectTo === '/logout' ? '/' : pathname); setAuthRedirectTo(authRedirectTo === '/logout' ? '/' : pathname);
@@ -116,6 +116,12 @@ const ProtectedRoute = ({ children, ...rest }) => {
); );
} }
setAuthRedirectTo(
authRedirectTo === '/logout'
? '/'
: `${location.pathname}${location.search}`
);
return <Redirect to="/login" />; return <Redirect to="/login" />;
}; };

View File

@@ -27,6 +27,21 @@ function ExecutionEnvironmentAdd() {
const handleCancel = () => { const handleCancel = () => {
history.push(`/execution_environments`); history.push(`/execution_environments`);
}; };
const hubParams = {
image: '',
credential: null // reverse lookup?
};
history.location.search.replace(/^\?/, '')
.split('&')
.map((s) => s.split('='))
.forEach(([key, val]) => {
if (!(key in hubParams)) {
return;
}
hubParams[key] = decodeURIComponent(val);
});
return ( return (
<PageSection> <PageSection>
<Card> <Card>
@@ -38,6 +53,7 @@ function ExecutionEnvironmentAdd() {
submitError={submitError} submitError={submitError}
onCancel={handleCancel} onCancel={handleCancel}
me={me || {}} me={me || {}}
executionEnvironment={hubParams}
/> />
)} )}
</Config> </Config>