Run Use without changes through name, description, and photo so final review never holds an editable field.

This commit is contained in:
adilallo committed 2026-11-24 21:05:40 -07:00
1 parent 53e27ef122
commit 6bf890fa78
13 files changed
+156 -145

No files matched your search

@@ -36,8 +36,9 @@ const blurActiveElement = (): void => {
* {@link parseCreateFlowScreenFromPathname} (flowSteps). Footer Back uses
* {@link resolveCreateFlowBackTarget}: template **Customize** walks values
* then the four decks, and Back from `core-values` returns to
* `/create/review-template/{slug}`. **Use without changes** lands on
* `final-review`; Back from that step returns to the template.
* `/create/review-template/{slug}`. **Use without changes** opens name,
* description, and photo, then `final-review`. Back from name returns to
* the template; Back from final review returns to the photo screen.
*
* Template review footer Back uses {@link buildTemplateReviewHref}’s
* `?fromFlow=1` marker (and persisted `templateReviewEntryFromCreateFlow`) so
@@ -57,9 +57,10 @@ export type UseTemplateReviewActionsResult = {
*/
handleCustomize: () => Promise<void>;
/**
* Use without changes: seed the template's cards and go to final review.
* Direct entry clears leftover identity so the Rule card can collect name,
* photo, and description. In-flow keeps the community answers already given.
* Use without changes: seed the template's cards and go to the name screen,
* then description and photo, then final review. Direct entry clears leftover
* identity. In-flow keeps the community answers already given so those
* screens are pre-filled.
*/
handleUseWithoutChanges: () => Promise<void>;
customizeDialog: TemplateCustomizeDialogModel | null;
@@ -256,7 +257,7 @@ export function useTemplateReviewActions({
: undefined,
}),
);
router.push(createFlowStepPath("final-review"));
router.push(createFlowStepPath("community-name"));
}, [
confirmReplaceDraft,
keepInFlowIdentity,
@@ -95,8 +95,8 @@ export function CommunityReviewScreen() {
/**
* Leftover pin from an older draft: bounce off community review onto the
* template path. Customize walks the decks; Use without changes lands on
* final review. The pin stays so decks skip the engine.
* template path. Customize walks the decks; Use without changes opens
* name, then description and photo. The pin stays so decks skip the engine.
*
* Ref guard covers React 18 StrictMode's double-mount in dev so we don't
* fire `router.replace` twice on the same transition.
@@ -109,7 +109,7 @@ export function CommunityReviewScreen() {
firedRedirectRef.current = true;
router.replace(
createFlowStepPath(
pending.mode === "customize" ? "core-values" : "final-review",
pending.mode === "customize" ? "core-values" : "community-name",
),
);
}, [router, state.pendingTemplateAction]);
@@ -32,19 +32,11 @@ import {
type FinalReviewChipEditPatch,
type FinalReviewChipEditTarget,
} from "../../components/FinalReviewChipEditModal";
import {
FinalReviewCommunityContextEditModal,
COMMUNITY_CONTEXT_FIELD_MAX_LENGTH,
} from "../../components/FinalReviewCommunityContextEditModal";
import {
FinalReviewTitleEditModal,
COMMUNITY_TITLE_FIELD_MAX_LENGTH,
} from "../../components/FinalReviewTitleEditModal";
import { FinalReviewCommunityContextEditModal } from "../../components/FinalReviewCommunityContextEditModal";
import { FinalReviewTitleEditModal } from "../../components/FinalReviewTitleEditModal";
import { useCommunityAvatarDisplayUrl } from "../../hooks/useCommunityAvatarDisplayUrl";
import { usePreviewSurfaceColor } from "../../hooks/usePreviewSurfaceColor";
import { useCreateFlowNavigation } from "../../hooks/useCreateFlowNavigation";
import { useCommunityAvatarUpload } from "../../hooks/useCommunityAvatarUpload";
import { isTemplateCreatePath } from "../../../../../lib/create/templatePath";
import { createFlowStepForFacetGroup } from "../../utils/facetGroupToCreateFlowStep";
import { isPreviewSurfaceColor } from "../../../../../lib/create/previewSurfaceColor";
import {
@@ -242,10 +234,7 @@ export function FinalReviewScreen({
[state],
);
const templatePath = isTemplateCreatePath(state);
const avatarUpload = useCommunityAvatarUpload();
const serverAvatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
const avatarUrl = avatarUpload.displaySrc ?? serverAvatarUrl;
const avatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
const storedFallback =
typeof state.previewSurfaceColor === "string"
? state.previewSurfaceColor
@@ -308,62 +297,14 @@ export function FinalReviewScreen({
hasTrailingIcon={false}
/>
) : null}
{templatePath ? (
<input
ref={avatarUpload.fileInputRef}
type="file"
className="sr-only"
tabIndex={-1}
accept={avatarUpload.accept}
aria-label={m.create.community.communityUpload.title}
onChange={(event) => void avatarUpload.handleFileChange(event)}
/>
) : null}
<Rule
title={ruleCardTitle}
description={
templatePath ? rawCommunityContextForModal : ruleCardDescription
}
interactive={!templatePath}
hasNameField={templatePath}
nameValue={rawTitleForModal}
nameLabel={m.create.community.communityName.inputLabel}
namePlaceholder={m.create.community.communityName.placeholder}
onNameChange={
templatePath
? (value) => {
markCreateFlowInteraction();
updateState({
title: value.slice(0, COMMUNITY_TITLE_FIELD_MAX_LENGTH),
});
}
: undefined
}
onTitleClick={
templatePath ? undefined : () => setTitleModalOpen(true)
}
description={ruleCardDescription}
onTitleClick={() => setTitleModalOpen(true)}
titleEditAriaLabel={t("titleEditModal.ariaEditTitle")}
onDescriptionClick={
templatePath ? undefined : () => setCommunityContextModalOpen(true)
}
onDescriptionClick={() => setCommunityContextModalOpen(true)}
descriptionEmptyHint={descriptionEmptyHint}
descriptionEditAriaLabel={t("communityContextEditModal.ariaEditDescription")}
descriptionLabel={m.create.community.communityContext.title}
descriptionPlaceholder={m.create.community.communityContext.placeholder}
descriptionHelperText={m.create.community.communityContext.optional}
onDescriptionChange={
templatePath
? (value) => {
markCreateFlowInteraction();
const next = value.slice(0, COMMUNITY_CONTEXT_FIELD_MAX_LENGTH);
updateState({ communityContext: next, summary: next });
}
: undefined
}
onLogoClick={
templatePath ? avatarUpload.handlePickFile : undefined
}
logoUploadAriaLabel={m.create.community.communityUpload.title}
size={mdUp ? "L" : "M"}
expanded={true}
descriptionAtBottom
@@ -372,12 +313,10 @@ export function FinalReviewScreen({
logoUrl={avatarUrl ?? undefined}
logoAlt={ruleCardTitle}
communityInitials={
avatarUrl || templatePath
? undefined
: communityInitialsFromTitle(ruleCardTitle)
avatarUrl ? undefined : communityInitialsFromTitle(ruleCardTitle)
}
categories={finalReviewCategories}
className={`${CREATE_FLOW_REVIEW_RULE_LAYOUT_CLASS}${surfaceColor ? "" : " invisible"}`}
className={`${CREATE_FLOW_REVIEW_RULE_LAYOUT_CLASS}${surfaceColor ? "" : "invisible"}`}
onClick={() => {}}
/>
<FinalReviewChipEditModal
@@ -395,28 +334,24 @@ export function FinalReviewScreen({
onClose={() => setActiveReadOnlyDetail(null)}
detail={activeReadOnlyDetail}
/>
{templatePath ? null : (
<>
<FinalReviewTitleEditModal
isOpen={titleModalOpen}
onClose={() => setTitleModalOpen(false)}
initialValue={rawTitleForModal}
onSave={(value) => {
markCreateFlowInteraction();
updateState({ title: value });
}}
/>
<FinalReviewCommunityContextEditModal
isOpen={communityContextModalOpen}
onClose={() => setCommunityContextModalOpen(false)}
initialValue={rawCommunityContextForModal}
onSave={(value) => {
markCreateFlowInteraction();
updateState({ communityContext: value, summary: value });
}}
/>
</>
)}
<FinalReviewTitleEditModal
isOpen={titleModalOpen}
onClose={() => setTitleModalOpen(false)}
initialValue={rawTitleForModal}
onSave={(value) => {
markCreateFlowInteraction();
updateState({ title: value });
}}
/>
<FinalReviewCommunityContextEditModal
isOpen={communityContextModalOpen}
onClose={() => setCommunityContextModalOpen(false)}
initialValue={rawCommunityContextForModal}
onSave={(value) => {
markCreateFlowInteraction();
updateState({ communityContext: value, summary: value });
}}
/>
</CreateFlowLockupCardStepShell>
);
}
+4 -4
View File
@@ -221,9 +221,9 @@ export interface CreateFlowState {
/**
* Set when a user starts from a template (Customize or Use without changes).
* Kept for the rest of the wizard so community setup is skipped, decks skip
* the engine, and final-review Back / identity fields know which path it is.
* Customize walks values and the four decks; Use without changes lands on
* final review. Cleared when the flow is reset.
* the engine, and Back knows which path it is. Customize walks values and
* the four decks; Use without changes runs name, description, and photo,
* then final review. Cleared when the flow is reset.
*/
pendingTemplateAction?: {
slug: string;
@@ -231,7 +231,7 @@ export interface CreateFlowState {
};
/**
* Template-review slug to return to from Customize values or from
* Use-without-changes final review. Cleared when the flow state is cleared.
* Use-without-changes name. Cleared when the flow state is cleared.
*/
templateReviewBackSlug?: string;
/**
+34 -15
View File
@@ -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 };
}
}