Keep a reopened template draft off the setup questions.

This commit is contained in:
adilallo committed 2026-11-09 17:42:04 -07:00
1 parent 6498d52541
commit c7f88e5515
3 files changed
+55 -3

No files matched your search

+16 -3
View File
@@ -25,6 +25,7 @@ import {
CREATE_FLOW_REVIEW_RETURN_QUERY_KEY, CREATE_FLOW_REVIEW_RETURN_QUERY_KEY,
getNextStep, getNextStep,
parseReviewReturnSearchParam, parseReviewReturnSearchParam,
templatePathSkippedCommunityRedirect,
shouldOfferCreateFlowSaveAndExit, shouldOfferCreateFlowSaveAndExit,
isDirectTemplateReviewEntry, isDirectTemplateReviewEntry,
createFlowStepUsesSelectSplitScroll, createFlowStepUsesSelectSplitScroll,
@@ -101,6 +102,7 @@ import {
EMPTY_SETUP_TRAITS, EMPTY_SETUP_TRAITS,
hasTickedSetupTrait, hasTickedSetupTrait,
} from "../../../lib/create/setupTraits"; } from "../../../lib/create/setupTraits";
import { templatePathFromState } from "../../../lib/create/templatePath";
import { useAuthModal } from "../../contexts/AuthModalContext"; import { useAuthModal } from "../../contexts/AuthModalContext";
import { useMessages, useTranslation } from "../../contexts/MessagesContext"; import { useMessages, useTranslation } from "../../contexts/MessagesContext";
import { PostLoginDraftTransfer } from "./PostLoginDraftTransfer"; import { PostLoginDraftTransfer } from "./PostLoginDraftTransfer";
@@ -424,7 +426,18 @@ function CreateFlowLayoutContent({
await runAuthenticatedExit(opts); await runAuthenticatedExit(opts);
}; };
const templatePathRedirect = templatePathSkippedCommunityRedirect(
currentStep,
templatePathFromState(state)?.mode,
);
useEffect(() => { useEffect(() => {
if (!templatePathRedirect) return;
router.replace(createFlowStepPath(templatePathRedirect));
}, [router, templatePathRedirect]);
useEffect(() => {
if (templatePathRedirect) return;
if ( if (
sessionResolved && sessionResolved &&
sessionUser && sessionUser &&
@@ -432,7 +445,7 @@ function CreateFlowLayoutContent({
) { ) {
router.replace(CREATE_ROUTES.review); router.replace(CREATE_ROUTES.review);
} }
}, [sessionResolved, sessionUser, currentStep, router]); }, [sessionResolved, sessionUser, currentStep, router, templatePathRedirect]);
useEffect(() => { useEffect(() => {
clearAttempted(); clearAttempted();
@@ -967,9 +980,9 @@ function CreateFlowLayoutContent({
<main <main
className={`flex min-h-0 min-w-0 flex-1 w-full max-w-full overflow-x-hidden ${CREATE_FLOW_SCROLL_REGION_CLASS} ${mainContentClass} ${mainResponsiveLayout}`} className={`flex min-h-0 min-w-0 flex-1 w-full max-w-full overflow-x-hidden ${CREATE_FLOW_SCROLL_REGION_CLASS} ${mainContentClass} ${mainResponsiveLayout}`}
> >
{children} {templatePathRedirect ? null : children}
</main> </main>
{!isCompletedStep && ( {!isCompletedStep && !templatePathRedirect && (
<CreateFlowFooter <CreateFlowFooter
className="shrink-0" className="shrink-0"
contentMaxClass={getCreateFlowContentMaxClass({ contentMaxClass={getCreateFlowContentMaxClass({
+14
View File
@@ -96,6 +96,20 @@ function shouldSkipStep(
); );
} }
/**
* Where to send a template-path draft that reopened on a community setup
* step. Customize resumes at values; Use without changes resumes at final
* review. Deck steps stay put so final-review + Add can open one.
*/
export function templatePathSkippedCommunityRedirect(
currentStep: CreateFlowStep | null | undefined,
mode: CreateFlowNavigationOptions["templatePathMode"],
): CreateFlowStep | null {
if (!currentStep || !mode) return null;
if (!TEMPLATE_PATH_COMMUNITY_SKIP.has(currentStep)) return null;
return mode === "customize" ? "core-values" : "final-review";
}
/** /**
* Returns the next step in the flow, or null if current is last/invalid * Returns the next step in the flow, or null if current is last/invalid
*/ */
+25
View File
@@ -10,6 +10,7 @@ import {
parseCreateFlowScreenFromPathname, parseCreateFlowScreenFromPathname,
resolveCreateFlowBackTarget, resolveCreateFlowBackTarget,
shouldOfferCreateFlowSaveAndExit, shouldOfferCreateFlowSaveAndExit,
templatePathSkippedCommunityRedirect,
isDirectTemplateReviewEntry, isDirectTemplateReviewEntry,
isCreateFlowTemplatesPickerPath, isCreateFlowTemplatesPickerPath,
createFlowStepUsesSelectSplitScroll, createFlowStepUsesSelectSplitScroll,
@@ -113,6 +114,30 @@ describe("flowSteps", () => {
expect(getPreviousStep("final-review", opts)).toBeNull(); expect(getPreviousStep("final-review", opts)).toBeNull();
}); });
it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => {
expect(
templatePathSkippedCommunityRedirect("setup-questions", "customize"),
).toBe("core-values");
expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe(
"core-values",
);
expect(
templatePathSkippedCommunityRedirect(
"community-name",
"useWithoutChanges",
),
).toBe("final-review");
expect(
templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"),
).toBeNull();
expect(
templatePathSkippedCommunityRedirect("final-review", "customize"),
).toBeNull();
expect(
templatePathSkippedCommunityRedirect("setup-questions", undefined),
).toBeNull();
});
it("templatePathMode composes with skipCommunitySave", () => { it("templatePathMode composes with skipCommunitySave", () => {
const opts = { const opts = {
skipCommunitySave: true, skipCommunitySave: true,