Merge pull request 'Run Use without changes through name, description, and photo so final review never holds an editable field' (#121) from adilallo/fix/CR-464-use-without-changes-name-first into main
Reviewed-on: #121
This commit was merged in pull request #121.
This commit is contained in:
commit
c221b0b3c9
16 files changed
+193
-141
No files matched your search
@@ -866,25 +866,19 @@ function CreateFlowLayoutContent({
|
||||
valuesCount={customizeDialog?.valuesCount ?? 0}
|
||||
cardsCount={customizeDialog?.cardsCount ?? 0}
|
||||
initialTitle={
|
||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
||||
? typeof state.title === "string"
|
||||
fromCreateWizard && typeof state.title === "string"
|
||||
? state.title
|
||||
: ""
|
||||
: ""
|
||||
}
|
||||
initialDescription={
|
||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
||||
? typeof state.communityContext === "string"
|
||||
fromCreateWizard && typeof state.communityContext === "string"
|
||||
? state.communityContext
|
||||
: ""
|
||||
: ""
|
||||
}
|
||||
initialLocation={
|
||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
||||
? typeof state.communityLocation === "string"
|
||||
fromCreateWizard && typeof state.communityLocation === "string"
|
||||
? state.communityLocation
|
||||
: ""
|
||||
: ""
|
||||
}
|
||||
onClose={closeCustomizeDialog}
|
||||
onContinue={confirmCustomizeDialog}
|
||||
|
||||
@@ -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;
|
||||
@@ -144,8 +145,7 @@ export function useTemplateReviewActions({
|
||||
pathname?.includes("/create/review-template/"),
|
||||
);
|
||||
|
||||
const keepInFlowIdentity =
|
||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true;
|
||||
const keepInFlowIdentity = fromCreateWizard;
|
||||
|
||||
const confirmReplaceDraft = useCallback(async (): Promise<boolean> => {
|
||||
if (!requestConfirm) return true;
|
||||
@@ -252,17 +252,19 @@ export function useTemplateReviewActions({
|
||||
title: state.title,
|
||||
communityContext: state.communityContext,
|
||||
communityLocation: state.communityLocation,
|
||||
communityAvatarUrl: state.communityAvatarUrl,
|
||||
}
|
||||
: undefined,
|
||||
}),
|
||||
);
|
||||
router.push(createFlowStepPath("final-review"));
|
||||
router.push(createFlowStepPath("community-name"));
|
||||
}, [
|
||||
confirmReplaceDraft,
|
||||
keepInFlowIdentity,
|
||||
markCreateFlowInteraction,
|
||||
replaceState,
|
||||
router,
|
||||
state.communityAvatarUrl,
|
||||
state.communityContext,
|
||||
state.communityLocation,
|
||||
signedIn,
|
||||
|
||||
@@ -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,8 +334,6 @@ export function FinalReviewScreen({
|
||||
onClose={() => setActiveReadOnlyDetail(null)}
|
||||
detail={activeReadOnlyDetail}
|
||||
/>
|
||||
{templatePath ? null : (
|
||||
<>
|
||||
<FinalReviewTitleEditModal
|
||||
isOpen={titleModalOpen}
|
||||
onClose={() => setTitleModalOpen(false)}
|
||||
@@ -415,8 +352,6 @@ export function FinalReviewScreen({
|
||||
updateState({ communityContext: value, summary: value });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</CreateFlowLockupCardStepShell>
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
/**
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@ The Figma **Create Community** sequence is the **source of truth** for the first
|
||||
|
||||
Treat these stages as the **canonical product sections** when adding chrome (e.g. stage headers, progress copy), breaking work across teams, or reusing flows in other surfaces. **Layout kind** is **not** encoded in the URL; it lives in [`CREATE_FLOW_SCREEN_REGISTRY`](../app/(app)/create/utils/createFlowScreenRegistry.ts) (Figma node id + `layoutKind` per step). Figma still names eight layout kinds: **informational**, **text**, **select**, **upload**, **review**, **card**, **right-rail**, **completed**. Question-and-options steps (**select**, **card**, **right-rail**) share [`CreateFlowTwoColumnSelectShell`](../app/(app)/create/components/CreateFlowTwoColumnSelectShell.tsx) and [`Selection`](../app/components/cards/Selection/) size variants (`s` chip, `m` tile, `l` row). `app/(app)/create/screens/` still mirrors the Figma kind names.
|
||||
|
||||
**Create from template:** Starting from a template skips size, kind, scale, maturity, and the six setup questions. The group enters only name, photo, and description. There is no recommendation engine on this path. **Customize** opens a dialog, then walks values and the four decks with the template’s cards first. **Use without changes** skips the dialog and decks and lands on final review with the template’s cards. Identity is collected in the Customize dialog or on the final-review Rule card (Has Name Field). The pin is `pendingTemplateAction: { slug, mode }` on `CreateFlowState`.
|
||||
**Create from template:** Starting from a template skips size, kind, scale, maturity, and the six setup questions. The group enters only name, photo, and description. There is no recommendation engine on this path. **Customize** opens a dialog, then walks values and the four decks with the template’s cards first. **Use without changes** skips the dialog and decks and runs the name, description, and photo screens, then final review with the template’s cards. Identity is collected in the Customize dialog or on those three screens. Final review shows the name and description as text on every path. The pin is `pendingTemplateAction: { slug, mode }` on `CreateFlowState`.
|
||||
|
||||
---
|
||||
|
||||
@@ -83,15 +83,15 @@ From that page, **Customize** opens a dialog for name, optional logo, descriptio
|
||||
|
||||
**Exit on template preview.** Direct catalog / marketing entry (`/create/review-template/[slug]` without `?fromFlow=1`) has nothing to save — top-nav **Exit** clears client state and goes home, with no save-progress modal and no leave confirm. In-flow (`?fromFlow=1`) still has community progress, so Exit keeps the usual save / leave-confirm path.
|
||||
|
||||
**Use without changes** skips the dialog, seeds the template’s cards (chip ids from [`templateChips.json`](../data/templates/templateChips.json) plus `state.sections` titles), pins `pendingTemplateAction: { slug, mode: "useWithoutChanges" }`, and routes to **`/create/final-review`**. Direct catalog entry clears leftover identity so the Rule card can collect name, photo, and description. In-flow keeps the community answers already given. Continue on final review waits for a name, then opens **Invite your members** with no login. **Finish without inviting** publishes and shows the finished Rule. **Send invitations** while logged out opens **Log in to invite your members** and returns here after the link is followed. Guests can publish without signing in (`POST /api/rules` with `userId` null); stakeholder invites are sent only when a session exists. Every card that reads the group’s share uses three quarters (`LAUNCH_SUPERMAJORITY_SHARE`); final review does not ask for a share.
|
||||
**Use without changes** skips the dialog, seeds the template’s cards (chip ids from [`templateChips.json`](../data/templates/templateChips.json) plus `state.sections` titles), pins `pendingTemplateAction: { slug, mode: "useWithoutChanges" }`, and routes to **`/create/community-name`**. From there Continue walks description (`community-context`, with optional city or region) then photo (`community-upload`), then **`/create/final-review`**. Direct catalog entry clears leftover identity so those screens start empty. In-flow keeps the community answers already given so the screens are pre-filled. Back from name returns to template review; Back from final review returns to the photo screen. Continue on final review waits for a name, then opens **Invite your members** with no login. **Finish without inviting** publishes and shows the finished Rule. **Send invitations** while logged out opens **Log in to invite your members** and returns here after the link is followed. Guests can publish without signing in (`POST /api/rules` with `userId` null); stakeholder invites are sent only when a session exists. Every card that reads the group’s share uses three quarters (`LAUNCH_SUPERMAJORITY_SHARE`); final review does not ask for a share.
|
||||
|
||||
**The pin stays for the rest of the wizard** so decks skip the engine, final review shows Has Name Field, and Back knows the path. If a leftover pin lands on `/create/review`, [`CommunityReviewScreen`](../app/(app)/create/screens/review/CommunityReviewScreen.tsx) `replace`s to `core-values` (Customize) or `final-review` (Use without changes).
|
||||
**The pin stays for the rest of the wizard** so decks skip the engine and Back knows the path. If a leftover pin lands on `/create/review`, [`CommunityReviewScreen`](../app/(app)/create/screens/review/CommunityReviewScreen.tsx) `replace`s to `core-values` (Customize) or `community-name` (Use without changes).
|
||||
|
||||
- **Customize** — dialog, then values and the four decks, then final review with the dialog’s Community name filled in. Add chips on final review open that template deck or the template values; Confirm returns to final review (`?reviewReturn=final-review`).
|
||||
- **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the final-review Rule card. Back returns to template review.
|
||||
- **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected. Back still returns to template review.
|
||||
- **Customize** — dialog, then values and the four decks, then final review with the dialog’s Community name filled in as text. Add chips on final review open that template deck or the template values; Confirm returns to final review (`?reviewReturn=final-review`).
|
||||
- **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the name, description, and photo screens. Back from name returns to template review.
|
||||
- **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected and pre-fills those three screens. Back from name still returns to template review.
|
||||
|
||||
**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template with no leftover logo or setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, and place already given. A hydration latch stops a saved server draft from overwriting the template after apply.
|
||||
**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template. Direct entry drops a leftover logo and setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, place, and photo already given. A hydration latch stops a saved server draft from overwriting the template after apply.
|
||||
|
||||
| Origin | Click-site behavior | URL the user lands on |
|
||||
| --- | --- | --- |
|
||||
|
||||
@@ -256,8 +256,9 @@ description dialog, prefills cards via
|
||||
[`buildTemplateCustomizePrefill`](../../lib/create/applyTemplatePrefill.ts),
|
||||
and routes to `core-values` (setup questions skipped). Template **Use
|
||||
without changes** writes the template’s cards and routes to
|
||||
`final-review`. Identity is collected in the dialog or on the
|
||||
final-review Rule card. The pin
|
||||
`community-name`, then description and photo, then `final-review`.
|
||||
Identity is collected in the dialog or on those three screens. Final
|
||||
review shows the name and description as text. The pin
|
||||
`pendingTemplateAction: { slug, mode: "customize" | "useWithoutChanges" }`
|
||||
stays for the rest of the wizard so decks skip the engine. See
|
||||
[`docs/create-flow.md`](../create-flow.md). The user exits via
|
||||
|
||||
@@ -238,6 +238,7 @@ export type TemplateApplyIdentity = {
|
||||
title?: string;
|
||||
communityContext?: string;
|
||||
communityLocation?: string;
|
||||
communityAvatarUrl?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,6 +257,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
|
||||
const title = args.identity?.title?.trim();
|
||||
const communityContext = args.identity?.communityContext?.trim();
|
||||
const communityLocation = args.identity?.communityLocation?.trim();
|
||||
const communityAvatarUrl = args.identity?.communityAvatarUrl?.trim();
|
||||
|
||||
const seeded: CreateFlowState = {
|
||||
...prefill,
|
||||
@@ -274,6 +276,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
|
||||
seeded.summary = communityContext;
|
||||
}
|
||||
if (communityLocation) seeded.communityLocation = communityLocation;
|
||||
if (communityAvatarUrl) seeded.communityAvatarUrl = communityAvatarUrl;
|
||||
if (args.identity) seeded.templateReviewEntryFromCreateFlow = true;
|
||||
|
||||
if (args.mode === "useWithoutChanges") {
|
||||
|
||||
@@ -13,8 +13,8 @@ export type TemplateChipSet = Record<DeckId | "coreValues", string[]>;
|
||||
|
||||
/**
|
||||
* Persistent template-path pin. Kept for the rest of the wizard so decks skip
|
||||
* the engine, final review shows identity fields, and Back knows whether to
|
||||
* return to the template or to the conflict deck.
|
||||
* the engine and Back knows whether to return to the template, the photo
|
||||
* screen, or the conflict deck.
|
||||
*/
|
||||
export function templatePathFromState(
|
||||
state: Pick<CreateFlowState, "pendingTemplateAction">,
|
||||
|
||||
@@ -1334,6 +1334,36 @@ describe("FinalReviewScreen — edit published title and description", () => {
|
||||
expect(screen.getByTestId("rule-description-edit")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows name and description as text on the template path, with no text input", async () => {
|
||||
function TemplatePathHarness() {
|
||||
const { replaceState } = useCreateFlow();
|
||||
useLayoutEffect(() => {
|
||||
replaceState({
|
||||
title: "Eastside Tenants Union",
|
||||
communityContext: "Neighbors sharing a building.",
|
||||
pendingTemplateAction: {
|
||||
slug: "woodline",
|
||||
mode: "useWithoutChanges",
|
||||
},
|
||||
});
|
||||
}, [replaceState]);
|
||||
return <FinalReviewScreen />;
|
||||
}
|
||||
render(<TemplatePathHarness />);
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Eastside Tenants Union")).toBeInTheDocument();
|
||||
});
|
||||
expect(
|
||||
screen.getByText("Neighbors sharing a building."),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("textbox", { name: /Community name/i }),
|
||||
).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("textbox"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("opens Save modal from title click and updates title", async () => {
|
||||
let latest: CreateFlowState = {};
|
||||
render(
|
||||
|
||||
@@ -196,10 +196,10 @@ describe("CommunityReviewScreen — pendingTemplateAction redirect", () => {
|
||||
expect(testRouter.push).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("redirects Use without changes leftover pins to final review", async () => {
|
||||
it("redirects Use without changes leftover pins to the name screen", async () => {
|
||||
render(<ReviewWithPendingAction mode="useWithoutChanges" />);
|
||||
await waitFor(() => {
|
||||
expect(testRouter.replace).toHaveBeenCalledWith("/create/final-review");
|
||||
expect(testRouter.replace).toHaveBeenCalledWith("/create/community-name");
|
||||
});
|
||||
expect(testRouter.push).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -248,6 +248,28 @@ describe("buildAppliedTemplateCreateFlowState", () => {
|
||||
mode: "useWithoutChanges",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps an in-flow photo when identity includes it", () => {
|
||||
const seeded = buildAppliedTemplateCreateFlowState({
|
||||
slug: "mutual-aid-mondays",
|
||||
body: {
|
||||
sections: [
|
||||
{
|
||||
categoryName: "Communication",
|
||||
entries: [{ title: "Signal" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
mode: "useWithoutChanges",
|
||||
identity: {
|
||||
title: "Neighborhood",
|
||||
communityAvatarUrl: " /api/uploads/logo ",
|
||||
},
|
||||
});
|
||||
expect(seeded.title).toBe("Neighborhood");
|
||||
expect(seeded.communityAvatarUrl).toBe("/api/uploads/logo");
|
||||
expect(seeded.templateReviewEntryFromCreateFlow).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("templatePresetDetailsFromPrefill", () => {
|
||||
|
||||
@@ -113,29 +113,43 @@ describe("flowSteps", () => {
|
||||
expect(getPreviousStep("final-review", opts)).toBe("conflict-management");
|
||||
});
|
||||
|
||||
it("templatePathMode useWithoutChanges skips community setup and the decks", () => {
|
||||
it("templatePathMode useWithoutChanges runs name, description, and photo, then skips the decks", () => {
|
||||
const opts = { templatePathMode: "useWithoutChanges" as const };
|
||||
expect(getNextStep("informational", opts)).toBe("final-review");
|
||||
expect(getNextStep("community-name", opts)).toBe("final-review");
|
||||
expect(getNextStep("setup-questions", opts)).toBe("final-review");
|
||||
expect(getNextStep("informational", opts)).toBe("community-name");
|
||||
expect(getNextStep("community-name", opts)).toBe("community-context");
|
||||
expect(getNextStep("community-context", opts)).toBe("community-upload");
|
||||
expect(getNextStep("community-upload", opts)).toBe("final-review");
|
||||
expect(getNextStep("setup-questions", opts)).toBe("community-upload");
|
||||
expect(getNextStep("core-values", opts)).toBe("final-review");
|
||||
expect(getNextStep("final-review", opts)).toBe("confirm-stakeholders");
|
||||
expect(getPreviousStep("final-review", opts)).toBeNull();
|
||||
expect(getPreviousStep("community-name", opts)).toBeNull();
|
||||
expect(getPreviousStep("community-context", opts)).toBe("community-name");
|
||||
expect(getPreviousStep("community-upload", opts)).toBe("community-context");
|
||||
expect(getPreviousStep("final-review", opts)).toBe("community-upload");
|
||||
});
|
||||
|
||||
it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => {
|
||||
expect(
|
||||
templatePathSkippedCommunityRedirect("setup-questions", "customize"),
|
||||
).toBe("core-values");
|
||||
expect(
|
||||
templatePathSkippedCommunityRedirect("community-name", "customize"),
|
||||
).toBe("core-values");
|
||||
expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe(
|
||||
"core-values",
|
||||
);
|
||||
expect(
|
||||
templatePathSkippedCommunityRedirect(
|
||||
"setup-questions",
|
||||
"useWithoutChanges",
|
||||
),
|
||||
).toBe("community-name");
|
||||
expect(
|
||||
templatePathSkippedCommunityRedirect(
|
||||
"community-name",
|
||||
"useWithoutChanges",
|
||||
),
|
||||
).toBe("final-review");
|
||||
).toBeNull();
|
||||
expect(
|
||||
templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"),
|
||||
).toBeNull();
|
||||
@@ -153,17 +167,27 @@ describe("flowSteps", () => {
|
||||
templatePathMode: "useWithoutChanges" as const,
|
||||
};
|
||||
expect(getNextStep("community-upload", opts)).toBe("final-review");
|
||||
expect(getPreviousStep("final-review", opts)).toBeNull();
|
||||
expect(getPreviousStep("final-review", opts)).toBe("community-upload");
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget returns template review from use-without-changes final-review", () => {
|
||||
it("resolveCreateFlowBackTarget returns template review from use-without-changes name", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget(
|
||||
"community-name",
|
||||
{ templatePathMode: "useWithoutChanges" },
|
||||
"mutual-aid-mondays",
|
||||
),
|
||||
).toEqual({ kind: "templateReview", slug: "mutual-aid-mondays" });
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget returns photo from use-without-changes final-review", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget(
|
||||
"final-review",
|
||||
{ templatePathMode: "useWithoutChanges" },
|
||||
"mutual-aid-mondays",
|
||||
),
|
||||
).toEqual({ kind: "templateReview", slug: "mutual-aid-mondays" });
|
||||
).toEqual({ kind: "step", step: "community-upload" });
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget returns template review from customize values", () => {
|
||||
@@ -186,10 +210,10 @@ describe("flowSteps", () => {
|
||||
).toEqual({ kind: "step", step: "conflict-management" });
|
||||
});
|
||||
|
||||
it("resolveCreateFlowBackTarget returns template review when a slug is set without a mode", () => {
|
||||
it("resolveCreateFlowBackTarget returns template review from name when a slug is set without a mode", () => {
|
||||
expect(
|
||||
resolveCreateFlowBackTarget(
|
||||
"final-review",
|
||||
"community-name",
|
||||
undefined,
|
||||
"mutual-aid-mondays",
|
||||
),
|
||||
|
||||
@@ -126,14 +126,14 @@ describe("useTemplateReviewActions", () => {
|
||||
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
|
||||
});
|
||||
|
||||
it("direct Use without changes goes to final review and clears leftover identity", async () => {
|
||||
it("direct Use without changes goes to the name screen and clears leftover identity", async () => {
|
||||
const { result } = renderActions({ title: "Neighborhood" });
|
||||
|
||||
await act(async () => {
|
||||
await result.current.handleUseWithoutChanges();
|
||||
});
|
||||
|
||||
expect(router.push).toHaveBeenCalledWith("/create/final-review");
|
||||
expect(router.push).toHaveBeenCalledWith("/create/community-name");
|
||||
expect(applied?.title).toBeUndefined();
|
||||
expect(applied?.communityContext).toBeUndefined();
|
||||
expect(applied?.communityAvatarUrl).toBeUndefined();
|
||||
@@ -145,12 +145,13 @@ describe("useTemplateReviewActions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("in-flow Use without changes keeps the community name and pins the template path", async () => {
|
||||
it("in-flow Use without changes keeps the community name, photo, and pins the template path", async () => {
|
||||
const { result } = renderActions(
|
||||
{
|
||||
title: "Neighborhood",
|
||||
communityContext: "We meet weekly",
|
||||
templateReviewEntryFromCreateFlow: true,
|
||||
communityLocation: "Oakland",
|
||||
communityAvatarUrl: "/api/uploads/logo",
|
||||
},
|
||||
true,
|
||||
);
|
||||
@@ -159,9 +160,11 @@ describe("useTemplateReviewActions", () => {
|
||||
await result.current.handleUseWithoutChanges();
|
||||
});
|
||||
|
||||
expect(router.push).toHaveBeenCalledWith("/create/final-review");
|
||||
expect(router.push).toHaveBeenCalledWith("/create/community-name");
|
||||
expect(applied?.title).toBe("Neighborhood");
|
||||
expect(applied?.communityContext).toBe("We meet weekly");
|
||||
expect(applied?.communityLocation).toBe("Oakland");
|
||||
expect(applied?.communityAvatarUrl).toBe("/api/uploads/logo");
|
||||
expect(applied?.setupTraits).toBeUndefined();
|
||||
expect(applied?.pendingTemplateAction).toEqual({
|
||||
slug: "mutual-aid-mondays",
|
||||
@@ -170,6 +173,24 @@ describe("useTemplateReviewActions", () => {
|
||||
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
|
||||
});
|
||||
|
||||
it("a persisted in-flow flag without ?fromFlow=1 clears leftover identity", async () => {
|
||||
const { result } = renderActions(
|
||||
{
|
||||
title: "Neighborhood",
|
||||
communityAvatarUrl: "/api/uploads/logo",
|
||||
templateReviewEntryFromCreateFlow: true,
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
await result.current.handleUseWithoutChanges();
|
||||
});
|
||||
|
||||
expect(applied?.title).toBeUndefined();
|
||||
expect(applied?.communityAvatarUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
it("asks before replacing a draft in progress", async () => {
|
||||
requestConfirm.mockResolvedValueOnce(false);
|
||||
const { result } = renderActions({ title: "Juniper Street Tenants" });
|
||||
|
||||
Reference in new issue
Block a user