Skip to content

Conversation

@katinthehatsite
Copy link
Contributor

@katinthehatsite katinthehatsite commented Dec 23, 2025

Related issues

Closes STU-1099

Proposed Changes

This PR refactors CreateSiteForm to take features prop and an onSubmit prop instead of all the value and setter props that it currently does.

Testing Instructions

  • Pull the changes from this branch
  • Start the app with npm start
  • Click on the Add site in the sidebar
  • Try all the options for creating sites and test those extensively e.g. for errors, using custom domain, renaming sites etc. to ensure it works as the current site creation process

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@katinthehatsite katinthehatsite self-assigned this Dec 23, 2025
@katinthehatsite katinthehatsite marked this pull request as draft December 23, 2025 10:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the CreateSiteForm component to manage its own state internally instead of receiving numerous value and setter props, reducing props drilling. The form now accepts defaultValues for initialization and an onSubmit callback that receives all form values, simplifying the component hierarchy and data flow.

Key Changes

  • The CreateSiteForm now owns its form state internally (site name, path, PHP/WP versions, custom domain settings) instead of relying on lifted state
  • The useAddSite hook has been restructured to expose path validation functions (selectPath, generateProposedPath) and a site creation function (handleCreateSite) instead of managing form state
  • The form submission mechanism now uses native form submission with a form ID, allowing the stepper's "Add site" button to submit the form via the form attribute

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/modules/add-site/index.tsx Refactored to pass defaultValues and callback functions to CreateSite instead of managing form state; added logic to build default values with blueprint preferred versions
src/modules/add-site/components/create-site.tsx Updated props interface to accept defaultValues and callbacks instead of individual state values and setters
src/modules/add-site/components/create-site-form.tsx Major refactor to internalize form state management; now accepts defaultValues for initialization and onSubmit callback that receives complete form values
src/modules/add-site/components/stepper.tsx Modified action button to use native form submission with createFormId for create paths instead of onClick handler
src/modules/add-site/hooks/use-stepper.ts Added isCreatePath boolean to identify when the form is on a create path
src/modules/add-site/components/index.ts Added exports for new types: CreateSiteFormValues, CreateSiteFormProps, and PathValidationResult
src/hooks/use-add-site.ts Significantly refactored to remove form state management and expose path validation and site creation functions instead; added type definitions for CreateSiteFormValues and PathValidationResult
src/hooks/tests/use-add-site.test.tsx Updated tests to work with new API that uses handleCreateSite with form values instead of individual setters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@katinthehatsite katinthehatsite requested a review from a team December 29, 2025 14:59
@katinthehatsite katinthehatsite marked this pull request as ready for review December 29, 2025 14:59
@github-actions
Copy link
Contributor

📊 Performance Test Results

Comparing 5e677bd vs trunk

site-editor

Metric trunk 5e677bd Diff Change
load 12067.00 ms 15535.00 ms +3468.00 ms 🔴 28.7%

site-startup

Metric trunk 5e677bd Diff Change
siteCreation 15482.00 ms 22616.00 ms +7134.00 ms 🔴 46.1%
siteStartup 6995.00 ms 6952.00 ms -43.00 ms 🟢 -0.6%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@katinthehatsite katinthehatsite mentioned this pull request Dec 31, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants