mirror of https://github.com/portainer/portainer
fix(app/edge): race between redirects when selecting a template (#12230)
parent
d647980c3a
commit
61353cbe8a
|
@ -92,7 +92,7 @@ function getTemplateValues(
|
||||||
type: 'custom' | 'app' | undefined,
|
type: 'custom' | 'app' | undefined,
|
||||||
template: TemplateViewModel | CustomTemplate | undefined
|
template: TemplateViewModel | CustomTemplate | undefined
|
||||||
): TemplateValues {
|
): TemplateValues {
|
||||||
if (!type) {
|
if (!type || !template) {
|
||||||
return getInitialTemplateValues();
|
return getInitialTemplateValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
import { useRouter } from '@uirouter/react';
|
||||||
|
|
||||||
import { useParamState } from '@/react/hooks/useParamState';
|
import { useParamState } from '@/react/hooks/useParamState';
|
||||||
|
|
||||||
export function useTemplateParams() {
|
export function useTemplateParams() {
|
||||||
const [id, setTemplateId] = useParamState('templateId', (param) => {
|
const router = useRouter();
|
||||||
|
const [id] = useParamState('templateId', (param) => {
|
||||||
if (!param) {
|
if (!param) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +17,7 @@ export function useTemplateParams() {
|
||||||
return templateId;
|
return templateId;
|
||||||
});
|
});
|
||||||
|
|
||||||
const [type, setTemplateType] = useParamState('templateType', (param) => {
|
const [type] = useParamState('templateType', (param) => {
|
||||||
if (param === 'app' || param === 'custom') {
|
if (param === 'app' || param === 'custom') {
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +34,10 @@ export function useTemplateParams() {
|
||||||
id: number | undefined;
|
id: number | undefined;
|
||||||
type: 'app' | 'custom' | undefined;
|
type: 'app' | 'custom' | undefined;
|
||||||
}) {
|
}) {
|
||||||
setTemplateId(id);
|
router.stateService.go(
|
||||||
setTemplateType(type);
|
'.',
|
||||||
|
{ templateId: id, templateType: type },
|
||||||
|
{ reload: false }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue