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

Preview of the published story #1149

Closed
dvoytenko opened this issue Apr 10, 2020 · 9 comments · Fixed by #1247
Closed

Preview of the published story #1149

dvoytenko opened this issue Apr 10, 2020 · 9 comments · Fixed by #1247
Assignees
Labels
P0 Critical, drop everything Type: Bug Something isn't working Type: Enhancement New feature or improvement of an existing feature

Comments

@dvoytenko
Copy link
Contributor

dvoytenko commented Apr 10, 2020

As a follow up on this thread. A possible proposal is:

  1. There are two versions of a document: draft and last published.
  2. After last publish: draft == published.
  3. If intermittent changes are needed, the draft is updated. But it doesn't change what's published is. I.e. draft > published.
  4. draft > publish is a clear signal that the document has unpublished changes since last publish.
  5. User can easily push the last draft to publish. In this case we're back to draft = publish.

Acceptance Criteria

  1. A user is able to preview updates made to a story that are not yet published. (draft > publish)
  2. After making updates to an already published story, the user can choose to update the published story
@dvoytenko dvoytenko added Type: Bug Something isn't working Type: Enhancement New feature or improvement of an existing feature labels Apr 10, 2020
@pbakaus
Copy link
Contributor

pbakaus commented Apr 10, 2020

SGTM. Somebody should do some discovery work here to find out how Gutenberg solves this.

@miina
Copy link
Contributor

miina commented Apr 10, 2020

Related: #221 -- since WP generates an auto-save post for previewing posts (if published).

@jauyong jauyong added the P0 Critical, drop everything label Apr 10, 2020
@pbakaus pbakaus added this to the 1.0 Alpha milestone Apr 11, 2020
@miina
Copy link
Contributor

miina commented Apr 13, 2020

Unless someone objects, then assigning myself for discovery, however, it would likely make sense to implement this together with #221. Or possibly this can create the basis for #221.

If someone was already doing the discovery, please LMK.

@miina miina self-assigned this Apr 13, 2020
@pbakaus pbakaus removed their assignment Apr 13, 2020
@pbakaus
Copy link
Contributor

pbakaus commented Apr 13, 2020

SGTM!

@miina
Copy link
Contributor

miina commented Apr 14, 2020

How it works in WP:

  • When post is a draft, auto-save takes place every 60 seconds.
  • User is visually let know that the draft was being auto-saved + the "Save Draft" button displays "Saved" instead.
  • Preview is opened in the same tab if a tab is already open for previewing that post (preview does not open multiple new tabs).

If the post is published, the preview link will get preview_id and preview_nonce in addition to to the URL for ensuring that the user is indeed allowed to check the preview.

  • One auto-save post is kept for every post (similar to Dima's proposal for keeping a draft)
  • This auto-save is overwritten by auto-saving every 60 seconds in case of a draft. EDIT: Actually in case of drafts, the post itself is saved over, no need to keep a separate auto-save.
  • The auto-save is overwritten by preview when opening a preview in case of non-draft posts.
  • The preview is displayed to the user if the user has permission to see the preview, otherwise, an error message is displayed instead ("Sorry, you are not allowed to preview drafts.")

It seems like it makes sense to use the existing auto-save logic for preview within this issue and then add the auto-save auto-updates every 60 seconds within #221.

LMK if you think otherwise.

@dvoytenko
Copy link
Contributor Author

@miina thanks for the research. I'd leave the decision to @pbakaus, but this sounds like a simple and straightforward flow to me. I only have a couple of questions:

  1. Are these mechanics available to our type of posts? Or should we do it manually?
  2. I assume we can get a clear boolean flag from the APIs that we can use to update UX. E.g. "you have unpublished changes: [preview] [re-publish]"?
  3. Can you ballpark the LOE for us?

@miina
Copy link
Contributor

miina commented Apr 14, 2020

  1. We should be able to add autosaving to the Preview button -- there is REST API endpoint for auto-saving. The only thing here would be ensuring that the JSON representation of the story gets saved, too, that shouldn't be an issue though.
  2. We are currently detecting unsaved changes (Add usePreventWindowUnload hook. #877) via history -- probably we should be able to use something similar here. Or did you mean something else?
  3. Perhaps M, however, it would reduce the LOE of Auto-Save #221.

@swissspidy swissspidy modified the milestones: 1.0 Alpha, 1.0 Beta Apr 14, 2020
@pbakaus
Copy link
Contributor

pbakaus commented Apr 14, 2020

@miina all of this sounds great. Let's do it! Thanks!

@dvoytenko
Copy link
Contributor Author

This all sounds great! Let's do this.

@kmyram kmyram removed this from the 1.0 Beta milestone Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Critical, drop everything Type: Bug Something isn't working Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants