Skip to content

Conversation

@youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Mar 13, 2025

Related issues

Summary

  • Adds ability to add, modify, or remove custom domains on existing sites
  • Ensures consistent domain validation and handling across site creation and editing
  • Ensures we update the hosts file and the database content when the domain is updated.

Testing instructions

  • Create a site (once with a custom domain, and once without)
  • Try updating domains for running and stopped sites

@youknowriad youknowriad requested review from a team and mcsf March 13, 2025 12:42
@youknowriad youknowriad self-assigned this Mar 13, 2025
@youknowriad youknowriad force-pushed the add/allow-updating-custom-domain branch from 2c7503d to c1eb800 Compare March 13, 2025 16:05
@youknowriad
Copy link
Contributor Author

Can I get some reviews here?

@youknowriad youknowriad changed the title Custom Domain: Allow updating domains for existing sites. STU-72 Custom Domain: Allow updating domains for existing sites. Mar 19, 2025
Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Great feature!
Added some comments, but overall I think this looks great!

Something I noticed during my tests:

  • Having an invalid domain disables the submit, even when "Use custom domain" isn't checked. I recorded on "Edit Site" but the same behavior happens on "Add Site":
Screen.Recording.2025-03-19.at.18.28.37.mov

}
};

export const replaceDomainInHosts = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this function as it handles all possible domain change scenarios.

And to keep the format consistent, move the replacing logic to its own replaceDomainInHosts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand this comment fully but I renamed the function.

( selectedSite?.phpVersion as AllowedPHPVersion ) ?? DEFAULT_PHP_VERSION
);
const [ selectedWpVersion, setSelectedWpVersion ] = useState( currentWpVersion );
const [ useCustomDomain, setUseCustomDomain ] = useState( Boolean( selectedSite?.customDomain ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a lot of this logic is very similar to the one we added to site-form
I believe there's an opportunity here to create a shared component/hook, to avoid repetition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Entirely agree but this is not new. The way the form works today is not great and would deserve a refactor but it's not a small change.

@youknowriad
Copy link
Contributor Author

I fixed the validation bug.

@youknowriad youknowriad requested a review from bcotrim March 20, 2025 06:40
@wojtekn wojtekn changed the title STU-72 Custom Domain: Allow updating domains for existing sites. Custom Domain: Allow updating domains for existing sites. Mar 20, 2025
Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes.
I added a small comment, but it shouldn't be blocking.

I noticed the custom domain error message get cut when we display multiple errors.
This should be fixed with this change but something to re-test later.

image

@youknowriad youknowriad enabled auto-merge (squash) March 20, 2025 12:12
@youknowriad youknowriad merged commit 49f713d into trunk Mar 20, 2025
3 of 7 checks passed
@youknowriad youknowriad deleted the add/allow-updating-custom-domain branch March 20, 2025 12:13
@wojtekn
Copy link
Contributor

wojtekn commented Mar 21, 2025

Having an invalid domain disables the submit, even when "Use custom domain" isn't checked. I recorded on "Edit Site" but the same behavior happens on "Add Site":

@bcotrim I tested it when I rebased #1078 and noticed it is fixed in Add Site, but it still happens in Edit Site. Are you also reproduce it there?

@bcotrim
Copy link
Contributor

bcotrim commented Mar 21, 2025

Having an invalid domain disables the submit, even when "Use custom domain" isn't checked. I recorded on "Edit Site" but the same behavior happens on "Add Site":

@bcotrim I tested it when I rebased #1078 and noticed it is fixed in Add Site, but it still happens in Edit Site. Are you also reproduce it there?

I don't see it happening on "Add Site" or "Edit Site".
Note that if you don't have any change compared the existing settings the button is still disabled due to the form being unchanged, not the validation error.

Screen.Recording.2025-03-21.at.10.01.25.mov

@wojtekn
Copy link
Contributor

wojtekn commented Mar 21, 2025

Note that if you don't have any change compared the existing settings the button is still disabled due to the form being unchanged, not the validation error.

Oh, it was that. Thanks for clarifying. When I edit the site name, then enable a custom domain and enter an invalid one, Save button toggles correctly when I keep disabling and enabling a custom domain.

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.

Feature Request: Allow modifying the custom domain of a given site

4 participants