Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Multi-site Duplicator Support #8665

Merged
merged 20 commits into from
Oct 20, 2023
Merged

[4.x] Multi-site Duplicator Support #8665

merged 20 commits into from
Oct 20, 2023

Conversation

duncanmcclean
Copy link
Member

This pull request adds multi-site support to the Duplicate action available on entries.

Closes statamic/ideas#942.

Usage

When duplicating an entry, you'll get to pick between two "duplication modes":

  • All Localizations: this will duplicate the entry, along with any of its localizations.
  • Current Localization: this will duplicate the entry, but only in the current site.

Arc - Team Members ‹ Collections ‹ Statamic - 2 September 2023

@duncanmcclean duncanmcclean changed the title Multi-site Duplicator Support [4.x] Multi-site Duplicator Support Sep 2, 2023
@jasonvarga
Copy link
Member

Let's revisit this once #5946 is done, then we should make sure this action has appropriate permissions wired into it.

@jasonvarga jasonvarga marked this pull request as draft October 2, 2023 19:16
@jasonvarga
Copy link
Member

jasonvarga commented Oct 16, 2023

I tweaked a few things:

  1. Simplified the UI to a toggle.
    CleanShot 2023-10-16 at 13 26 12

  2. If the entry has no localizations, it doesn't even prompt you.
    CleanShot 2023-10-16 at 13 27 29

  3. When you try to duplicate a localization, it'll duplicate the root origin instead, and warn you about it.

    This was the biggest issue I had. I noticed the same problem happens in your addon. If you duplicate a localization, you lose a bunch of content because it only duplicates the localized bits, and it loses to the link to the origin.

    • Linking to the origin would be wrong because then you'd have two entries in the same locale pointing to the same origin.
    • Bringing over the content from the origin into the localization also felt wrong because the data fallback behavior flow ends up different than what you just duplicated.

    Both kinda felt weird so enforcing that the origin gets duplicated felt like a good solution to me.

    CleanShot 2023-10-16 at 13 28 16
    CleanShot 2023-10-16 at 13 29 25

  4. Piggybacking on 3, if you select an entry and its localization, it'll dedupe your selections appropriately and only duplicate the origin.

@jasonvarga
Copy link
Member

jasonvarga commented Oct 19, 2023

Once digging into to hooking up permissions, it got more complicated. There were a bunch of edge cases to think about.

We ended up simplifying it by getting rid of the toggle to choose whether localizations are duplicated or not.

Now, they are always duplicated. However if you don't have permission for a particular site, the entries won't get duplicated into those.


Answering my own questions from the issue:

If you duplicate an entry that has localizations, should they also get duplicated?

Yup.

If the entry wasn't localized into all sites, should the new entry get localized into all sites, or only the ones the original was localized into?

Just the ones it was already localized in.

If you duplicate a localized entry, what do you do with its origin?

The origin gets targeted for duplication instead, and thus all the localizations get duplicated.

What if you just wanted to just localize an entry into another site, you might think the duplicate action would do that.

Well, it doesn't. So don't.

@jasonvarga jasonvarga marked this pull request as ready for review October 20, 2023 15:41
@jasonvarga jasonvarga merged commit 49d96a5 into statamic:4.x Oct 20, 2023
16 checks passed
@duncanmcclean duncanmcclean deleted the duplicator-multisite-support branch October 20, 2023 16:00
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.

Make Duplicator action work for multi-site
2 participants