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

#1030 add 'Duplicate document' action in menu #1040

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

florentinap
Copy link
Contributor

This PR adds Duplicate document action in menu of document from workspace page.

@fflorent
Copy link
Collaborator

Thanks for this enhancement @florentinap!

I share below a screenshot of the new feature to help understanding what is the menu item you propose to introduce:
"Duplicate document" menu for the documents in the home page

Copy link
Collaborator

@fflorent fflorent left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +538 to +542
if (!appModel.currentValidUser) {
page.clearUnsavedChanges();
window.location.href = getLoginOrSignupUrl({srcDocId: urlState().state.get().doc});
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wondered if there could be a case where an anonymous user would have access to this menu item, and there is: when they are shared a workspace or an organisation.

In such a case, the workflow is relevant: they are invited to login or to logon. So good catch, that's perfect! 👌

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you point me to a situation when this might happen?

@fflorent
Copy link
Collaborator

BTW, I am not able to merge your merge request, only Grist Labs is currently allowed to that (they have tools like internal CI that I don't have access).

@berhalak berhalak self-requested a review June 18, 2024 15:23
menuItem(() => {
const {appModel} = page;
if (!appModel.currentValidUser) {
page.clearUnsavedChanges();
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is not needed, is it? DocPageModel should be only created if we've opened a document. Here we are somehow "lucky" that this constructor isn't doing anything destructive, and is disposed when we open a document (thanks to the internal implementation in gristUrlState.ts/needPageLoad). But still it does create some listeners and computed properties (that do something when url is changed), which is not ideal, and can lead to unexpected bugs later - as, probably, the absence of doc in DocPageModel is rather perceived as temporary state, but here it is enforced.

I think the main culprit here is that clearUnsavedChanges is hold in the DocPageModel and not on the AppModel level, the ideal situation for me would be to refactor it:

  • Lift the clearUnsavedChanges method to the AppModel or TopAppModel
  • Don't create the DocPageModelImpl at all
  • Refactor makeCopy so that uses only AppModel instance (I looked into its code, and it only needs this clearUnsavedChanges method

Comment on lines +538 to +542
if (!appModel.currentValidUser) {
page.clearUnsavedChanges();
window.location.href = getLoginOrSignupUrl({srcDocId: urlState().state.get().doc});
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you point me to a situation when this might happen?

@paulfitz paulfitz added the preview Launch preview deployment of this PR label Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Deployed commit 83723f4eb01d6fe659e70e839c9ed5c7f0879a99 as https://grist-florentinap-grist-core-duplicate-documet.fly.dev (until 2024-08-02T19:58:28.395Z)

@paulfitz
Copy link
Member

paulfitz commented Jul 3, 2024

Now that we can fully preview PRs (thanks @SleepyLeslie!) I played with this. Feels good. Is a little disconcerting that the duplicated document is automatically opened, that makes less sense when duplicating from a workspace listing.

@dsagal
Copy link
Member

dsagal commented Aug 28, 2024

A related issue (#754) led to the same idea, and includes a mock-up: https://www.figma.com/design/wcpetFt6aOKzTszcvPPWLQ/%5B05%2F24%5D-Grist-Design?node-id=1222-73128&t=tM7yRRTAzdKqXnoA-1.

The only effect on this PR is to request that the new option be named "Duplicate", and moved up in the menu, between "Move" and "Remove":

Screenshot 2024-08-28 at 7 49 46 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Launch preview deployment of this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants