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,
|
||||
template: TemplateViewModel | CustomTemplate | undefined
|
||||
): TemplateValues {
|
||||
if (!type) {
|
||||
if (!type || !template) {
|
||||
return getInitialTemplateValues();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { useRouter } from '@uirouter/react';
|
||||
|
||||
import { useParamState } from '@/react/hooks/useParamState';
|
||||
|
||||
export function useTemplateParams() {
|
||||
const [id, setTemplateId] = useParamState('templateId', (param) => {
|
||||
const router = useRouter();
|
||||
const [id] = useParamState('templateId', (param) => {
|
||||
if (!param) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -14,7 +17,7 @@ export function useTemplateParams() {
|
|||
return templateId;
|
||||
});
|
||||
|
||||
const [type, setTemplateType] = useParamState('templateType', (param) => {
|
||||
const [type] = useParamState('templateType', (param) => {
|
||||
if (param === 'app' || param === 'custom') {
|
||||
return param;
|
||||
}
|
||||
|
@ -31,7 +34,10 @@ export function useTemplateParams() {
|
|||
id: number | undefined;
|
||||
type: 'app' | 'custom' | undefined;
|
||||
}) {
|
||||
setTemplateId(id);
|
||||
setTemplateType(type);
|
||||
router.stateService.go(
|
||||
'.',
|
||||
{ templateId: id, templateType: type },
|
||||
{ reload: false }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue