Run Use without changes through name, description, and photo so final review never holds an editable field.
This commit is contained in:
1 parent
53e27ef122
commit
6bf890fa78
13 files changed
+156
-145
No files matched your search
@@ -51,29 +51,35 @@ export type CreateFlowNavigationOptions = {
|
||||
skipCommunitySave?: boolean;
|
||||
/**
|
||||
* Template path. Skips size, kind, scale, maturity, and setup questions.
|
||||
* Customize still walks values and the four decks; Use without changes
|
||||
* jumps to final review. Identity is collected in the Customize dialog or
|
||||
* on the final-review Rule card.
|
||||
* Customize still walks values and the four decks; identity is collected
|
||||
* in the Customize dialog. Use without changes runs name, description,
|
||||
* and photo, then jumps to final review (no decks unless + Add opens one).
|
||||
*/
|
||||
templatePathMode?: "customize" | "useWithoutChanges";
|
||||
};
|
||||
|
||||
/**
|
||||
* Community questionnaire skipped on both template-path modes. Identity is
|
||||
* collected in the Customize dialog or on the final-review Rule card.
|
||||
* Community questionnaire skipped on both template-path modes.
|
||||
*/
|
||||
const TEMPLATE_PATH_COMMUNITY_SKIP = new Set<CreateFlowStep>([
|
||||
"informational",
|
||||
"community-name",
|
||||
"community-structure",
|
||||
"community-context",
|
||||
"community-size",
|
||||
"setup-questions",
|
||||
"community-upload",
|
||||
"community-save",
|
||||
"review",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Customize collects identity in its dialog, so it also skips name,
|
||||
* description, and photo. Use without changes runs those three screens.
|
||||
*/
|
||||
const TEMPLATE_PATH_CUSTOMIZE_IDENTITY_SKIP = new Set<CreateFlowStep>([
|
||||
"community-name",
|
||||
"community-context",
|
||||
"community-upload",
|
||||
]);
|
||||
|
||||
/** Use without changes does not run values or the four decks unless + Add opens one. */
|
||||
const TEMPLATE_PATH_DECK_SKIP = new Set<CreateFlowStep>([
|
||||
"core-values",
|
||||
@@ -83,13 +89,25 @@ const TEMPLATE_PATH_DECK_SKIP = new Set<CreateFlowStep>([
|
||||
"conflict-management",
|
||||
]);
|
||||
|
||||
function isTemplatePathSkippedCommunityStep(
|
||||
step: CreateFlowStep,
|
||||
mode: NonNullable<CreateFlowNavigationOptions["templatePathMode"]>,
|
||||
): boolean {
|
||||
if (TEMPLATE_PATH_COMMUNITY_SKIP.has(step)) return true;
|
||||
return (
|
||||
mode === "customize" && TEMPLATE_PATH_CUSTOMIZE_IDENTITY_SKIP.has(step)
|
||||
);
|
||||
}
|
||||
|
||||
function shouldSkipStep(
|
||||
step: CreateFlowStep,
|
||||
options?: CreateFlowNavigationOptions,
|
||||
): boolean {
|
||||
if (options?.skipCommunitySave && step === "community-save") return true;
|
||||
if (!options?.templatePathMode) return false;
|
||||
if (TEMPLATE_PATH_COMMUNITY_SKIP.has(step)) return true;
|
||||
if (isTemplatePathSkippedCommunityStep(step, options.templatePathMode)) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
options.templatePathMode === "useWithoutChanges" &&
|
||||
TEMPLATE_PATH_DECK_SKIP.has(step)
|
||||
@@ -98,16 +116,16 @@ 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.
|
||||
* step. Customize resumes at values; Use without changes resumes at name.
|
||||
* 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";
|
||||
if (!isTemplatePathSkippedCommunityStep(currentStep, mode)) return null;
|
||||
return mode === "customize" ? "core-values" : "community-name";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +171,8 @@ export function getPreviousStep(
|
||||
* Template path:
|
||||
* - Customize: Back from `core-values` returns to template review; Back from
|
||||
* `final-review` is the conflict deck.
|
||||
* - Use without changes: Back from `final-review` returns to template review.
|
||||
* - Use without changes: Back from `community-name` returns to template
|
||||
* review; Back from `final-review` is the photo screen.
|
||||
*/
|
||||
export type CreateFlowBackTarget =
|
||||
| { kind: "step"; step: CreateFlowStep }
|
||||
@@ -173,7 +192,7 @@ export function resolveCreateFlowBackTarget(
|
||||
if (currentStep === "core-values" && mode === "customize") {
|
||||
return { kind: "templateReview", slug };
|
||||
}
|
||||
if (currentStep === "final-review" && mode !== "customize") {
|
||||
if (currentStep === "community-name" && mode !== "customize") {
|
||||
return { kind: "templateReview", slug };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user