Skip to content
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

fix(deployment): only set the template and redirect once when loading new deployment #394

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const NewDeploymentContainer: FC = () => {
const [activeStep, setActiveStep] = useState<number | null>(null);
const [selectedTemplate, setSelectedTemplate] = useState<TemplateCreation | null>(null);
const [editedManifest, setEditedManifest] = useState<string | null>(null);
const [isInit, setIsInit] = useState(false);
const deploySdl = useAtomValue(sdlStore.deploySdl);
const { getDeploymentData } = useLocalNotes();
const { getTemplateById } = useTemplates();
Expand All @@ -37,7 +38,7 @@ export const NewDeploymentContainer: FC = () => {
}, [searchParams]);

useEffect(() => {
if (!templates || editedManifest) return;
if (!templates || editedManifest || isInit) return;

const template = getRedeployTemplate() || getGalleryTemplate();

Expand All @@ -53,8 +54,11 @@ export const NewDeploymentContainer: FC = () => {
if (queryStep !== RouteStep.editDeployment) {
router.replace(UrlService.newDeployment({ ...searchParams, step: RouteStep.editDeployment }));
}

setIsInit(true);
}
}, [templates, editedManifest, searchParams, router, toggleCmp, hasComponent]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [templates, editedManifest, searchParams, router, toggleCmp, hasComponent, isInit]);

const getRedeployTemplate = () => {
let template: Partial<TemplateCreation> | null = null;
Expand Down
Loading