Skip to content

Conversation

@adamziel
Copy link
Collaborator

@adamziel adamziel commented Dec 6, 2025

Summary

This PR ensures that importing from GitHub or ZIP files always goes into a temporary Playground, protecting saved sites from accidental overwrite.

  • GitHub import modal: Before showing the import form, checks if the active site is saved. If so, switches to an existing temporary site or creates a new one.
  • ZIP import: When a file is selected while viewing a saved site, stores the file in state, switches to the temporary site, and completes the import via a useEffect once the switch is done.

Test plan

  • Open Playground and save a site with distinctive content
  • Import a ZIP file while the saved site is active
  • Verify the temporary Playground is selected after import
  • Switch back to the saved site and verify it's unchanged
  • Start Playground directly with ?site-slug=<saved-site> (no temporary site exists)
  • Import a ZIP file
  • Verify a new temporary site is created and selected
  • Verify the saved site remains unchanged

Two e2e tests have been added to verify this behavior automatically.

When importing from GitHub or a ZIP file, we now ensure the import
goes into a temporary Playground rather than overwriting a saved site.
This protects saved sites from accidental data loss.

For the GitHub import modal: Before showing the form, we check if
the active site is saved. If so, we switch to an existing temporary
site or create a new one.

For ZIP import: When a file is selected while viewing a saved site,
we store the file, switch to the temporary site, and then complete
the import via a useEffect hook once the switch is complete.

Added two e2e tests to verify:
1. Importing a ZIP while on a saved site switches to temporary site
2. Importing a ZIP when starting directly with a saved site slug
   creates a new temporary site for the import
@adamziel adamziel changed the title Always import into temporary Playground, never into saved sites [Website] Target temporary Playground in Import ZIP, Import from GitHub. Don't overwrite a saved site. Dec 6, 2025
const crc32 = calculateCrc32(phpBytes);

// Build the ZIP file structure
const localFileHeader = Buffer.alloc(30 + filePathBytes.length);
Copy link
Collaborator Author

@adamziel adamziel Dec 6, 2025

Choose a reason for hiding this comment

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

oh no, let's just use a library or a pre-made zip

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