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

Add 'Duplicate' action to elements. #770

Merged
merged 1 commit into from
May 1, 2020

Conversation

JoshuaCarter
Copy link

  • Duplicates element.
  • Adds ' (Copy)' to the Title.
  • Reorder duplicate to position after the cloned element.

We're currently on 4.0.5 so I've PR'd this to the 4.0 branch. I tried a quick cherry-pick onto the 4 branch but it didn't work right off the bat and I'm lazy 😪

Direction/feedback welcome.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Jan 9, 2020

Nice! Awesome to see some more contributions to this React stuff. Hopefully you found it actually kind of fun and easy?

This will need to be based on the 4 branch, as it's a minor feature it'll have to go into Elemental 4.4. You should be able to do this with:

git rebase HEAD~1 --onto origin/4

Assuming that you're checked out on the PR branch and "origin" in this case is a remote with an up to date copy of `4 (preferably origin is just this repo). You might have to solve conflicts with the rebase.

Additionally, the tests are failing as you need to ensure you commit the dist files for the JavaScript. Just a yarn build and commit whatever is changed.

I don't have time to check this out and play around sorry, I'll leave that to one of the SSLtd team.

@brynwhyman
Copy link

Awesome! There's actually an open issue for this requirement that includes some light requirements from the Silverstripe UX team (I've just asked them to make the design link public).

#562

@JoshuaCarter
Copy link
Author

Hey @ScopeyNZ and @brynwhyman, a few points/questions:

  1. I've moved the 'Duplicate' option before 'Archive'.
  2. Code now adds ' copy {optional number starting with 2}' rather than multiples of ' (Copy)'.
  3. I'm doing this for a client (on their dime) and they're using 4.0.5 which is why I've targeted the 4.0 branch. So I can't necessarily justify the additional work to make this work on the 4 branch (including animation/alert which aren't on 4.0).
  4. Would the work done on 4 normally be back-ported to 4.0? Given that each branch needs a different implementation (from my very quick look anyway), I'm guessing not.
  5. Any chance of this being merged into 4.0 for a 4.6 release, and then cherry-picked to 4 (and fixed/improvements made) by someone on your end? We may need to stick to a fork for now if not.

Cheers.

@ScopeyNZ
Copy link
Contributor

  1. Would the work done on 4 normally be back-ported to 4.0? Given that each branch needs a different implementation (from my very quick look anyway), I'm guessing not.

Not unless it's a bugfix

  1. Any chance of this being merged into 4.0 for a 4.6 release, and then cherry-picked to 4 (and fixed/improvements made) by someone on your end? We may need to stick to a fork for now if not.

Unfortunately, we can't put features like this in bugfix releases (4.0.next) as that would be breaking our semantic versioning commitments. You will have to stay on a fork, or use some form of composer-patches

I hope that doesn't discourage contributing back though, because once it's merged then we have to maintain it for you 😅

@JoshuaCarter
Copy link
Author

@ScopeyNZ Thanks for the info. We'll stick to a fork for now and aim to re-target this to 4 in the near future with an eye to upgrading the module on our end, etc.

Cheers.

@JoshuaCarter JoshuaCarter changed the base branch from 4.0 to 4 March 3, 2020 01:21
@JoshuaCarter
Copy link
Author

@ScopeyNZ Have re-targeted this PR to 4 and tested locally. Don't think that triggers the CI tests on here so might want to manually redo those.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Mar 3, 2020

As long as you switch the base branch first, it should run the suite when you force-push.

@JoshuaCarter
Copy link
Author

@ScopeyNZ You can see in the timeline that I switched branches and did a force push but that didn't seem to trigger the tests.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Mar 3, 2020

image
Looks like they did to me.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Mar 3, 2020

Although it looks like the commit reference is different 🤔 . The branch and time match up though.

@JoshuaCarter
Copy link
Author

Huh... I see:
image
Nvm I guess lol.

- Duplicates element.
- Adds ' copy' or ' copy {num}' to the Title.
- Reorder duplicate to position after the cloned element.
@JoshuaCarter
Copy link
Author

@ScopeyNZ force pushed the top commit (no changes) to trigger. Displayed properly for me this time, so good to go afaik!

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Mar 3, 2020

Sure. I don't have a capability/bandwidth to give this a final once-over right now - so I'll see if I can call some favours with the SSLtd. team this week.

@JoshuaCarter
Copy link
Author

Many thanks!

@JoshuaCarter
Copy link
Author

Hey @ScopeyNZ Just checking for movement here. Cheers.

Copy link
Contributor

@sachajudd sachajudd left a comment

Choose a reason for hiding this comment

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

Hey @JoshuaCarter, thanks for taking the time to make a contribution back to the module. I've just had a look at what you've built compared with our initial designs and from a UX perspective I'm happy to approve this PR.

Depending on if this PR gets a review and test from a technical perspective and is merged, I'll create some issues and update our designs based off our initial thoughts now that we can see it work in practice.

Notes for @silverstripeux team for after this is merged:
Provide some direction/designs for the following scenarios:

  • "Unsaved changes - Opened blocks will be saved before duplicate modal is copied".
  • If you copy 'Content block copy 2' it becomes 'Content block copy 3', if you duplicate 'Content block copy 2' again it creates another 'Content block copy 3'. We'll look into some other options around naming conventions and what makes the most sense in this scenario.

Other:

  • Toast confirm message missing from the top right
  • Core Elemental (Impact High, UX issue) — "Copies will be set in a Draft state". After a block has been duplicated it's state indicator is 'Modified' rather than 'Draft'. I can see the colours on the class are the wrong way around. I'll look into creating a PR for this next week.

Copy link
Contributor

@ScopeyNZ ScopeyNZ left a comment

Choose a reason for hiding this comment

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

I'm happy from a technical perspective. Note that you don't need to bundle translations yourself, as these should be overwritten on release with values from Transifex. If you've done any manual translation, you'll need to update Transifex instead.

Thanks @JoshuaCarter

@ScopeyNZ
Copy link
Contributor

Oh, I've lost my merge ability. Lol.

@sachajudd
Copy link
Contributor

sachajudd commented Mar 19, 2020

I've just chatted with the team at Silverstripe Ltd and it looks like they'll prioritise this issue in the next month or so unless a core contributor or an owner of this module gets to it first 🙂

Note for the team: It would be great if someone could test how this works with versioned-snapshots and check to see when duplicating a block if it adds a new block in History.

@Cheddam Cheddam self-assigned this Apr 30, 2020
Copy link
Member

@Cheddam Cheddam left a comment

Choose a reason for hiding this comment

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

The Duplicate operation does not trigger a snapshot in versioned-snapshots. When a block is next created, the duplicated block(s) will be included in the snapshot triggered by that operation. versioned-snapshots is handling the Elemental integration itself, so we can raise a separate issue there to get this working correctly once it's merged.

There are also some UX improvements to tackle, but they're minor and we'll split those out into separate issues to tackle at a later date.

Overall, I'm happy to merge this! Thanks so much for your contribution @JoshuaCarter, and if you have any feedback about the development tooling involved in this change we'd love to hear it.

@tractorcow
Copy link
Contributor

I just noticed that blocks with private static $inline_editable = false; don't have a duplicate menu. We can add this in via the gridfield actions right?

@srehman130
Copy link

I just noticed that blocks with private static $inline_editable = false; don't have a duplicate menu. We can add this in via the gridfield actions right?

We are having similar issues. Has anyone been able to look into this?

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.

7 participants