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

Disable 'Save' button when there are no changes #5595

Merged
merged 16 commits into from
Aug 3, 2021
Merged

Disable 'Save' button when there are no changes #5595

merged 16 commits into from
Aug 3, 2021

Conversation

bradystroud
Copy link
Contributor

@bradystroud bradystroud commented Jul 8, 2021

Summary

Closes #5553.

Test plan
Added a few tests

Screen Shot 2021-07-08 at 12 09 42 pm
Figure: When no changes have been made or saved

Screen Shot 2021-07-08 at 12 11 36 pm
Figure: When changes have been saved

Checklist

Please add a x inside each checkbox:

  • I have read the contribution guidelines.
  • Code is formatted via running yarn format.
  • Tests are passing via running yarn test.
  • The status checks are successful (continuous integration). Those can be seen below.

A picture of a cute animal (not mandatory but encouraged)

@bradystroud bradystroud requested a review from a team July 8, 2021 02:12
@erezrokah erezrokah added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jul 8, 2021
Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Hi @bradystroud! Thanks for another UI improvement 🚀
I've added a comment on the implementation.

Also I've noticed 2 issues:

  1. The CHANGES SAVED never appears in non editorial workflow mode. Should it show up after publishing?
  2. When transitioning between hiding UNSAVED CHANGES to showing it, there's a shift in the layout:
    layout_shift

@bradystroud
Copy link
Contributor Author

bradystroud commented Jul 12, 2021

Hi @erezrokah,

  1. The CHANGES SAVED never appears in non editorial workflow mode. Should it show up after publishing?

I guess it makes sense for it to show up after publishing, but ideally, I think the message should be different for non editorial workflows. e.g. CHANGES PUBLISHED but that should be a seperate issue.
For now, I have made it so after publishing, the changes saved message will show.

  1. When transitioning between hiding UNSAVED CHANGES to showing it, there's a shift in the layout:

I have fixed this in my latest commit.

Screen.Recording.2021-07-12.at.6.22.36.pm.mov

Figure: No layout shifting

@bradystroud bradystroud changed the title 5553 hide changes saved and save button Hide changes saved and save button Jul 12, 2021
@bradystroud bradystroud requested a review from erezrokah July 12, 2021 22:39
Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Hi @bradystroud, thanks for the follow up.

I would like to confirm the intended behavior before moving forward.

Editorial workflow

  1. A published entry with no linked draft - changes saved appears only after saving.
    not-linked

  2. A published entry with a linked draft - changes saved appears all the time including on first editor open.
    linked

  3. Unpublished draft - changes saved appears all the time including on first editor open.
    unpublished

  4. A new entry - changes saved appears only after saving.
    new

Simple workflow

  1. A published entry - changes saved appears all the time including on first editor open.
    simple-published

  2. A new entry - changes saved appears only after saving.
    simple-new

Is that expected?
Should the behavior be - never show changes saved on first editor open, then once the user clicks save always show it until the next time the editor is opened (as long as they are no pending changes).

Please let me know what you think

@erezrokah
Copy link
Contributor

As an additional note, how about separating disabling the save button into a separate PR? I think that part is much simpler and 100% done.

@bradystroud
Copy link
Contributor Author

Hi @erezrokah,

Is that expected?
Should the behavior be - never show changes saved on first editor open, then once the user clicks save always show it until the next time the editor is opened (as long as they are not pending changes).

It was not expected - Instead we agree with your suggestion.

As an additional note, how about separating disabling the save button into a separate PR? I think that part is much simpler and 100% done.

Since we agree on the expected behaviour, I don't think that is necessary. I will make these changes today.

@bradystroud
Copy link
Contributor Author

Hi @erezrokah,

I believe the expected behaviour is not possible as in the editorial workflows, the editor "reloads" and starts a new session when save is pressed.

Do you think this is a problem? When you press save, there is an alert anyway.


Alternatively, we could show 'CHANGES SAVED' if there is a saved draft. See this updated expected behaviour:

Editorial workflow

  • Blank on load (unless a draft exists)
  • If there is a draft, show 'CHANGES SAVED'
  • After making a change and pressing save, show 'CHANGES SAVED'
  • For new entries, it will be blank until changes are made.

Simple workflow

  • Blank on load
  • After making a change and pressing 'publish' it will show 'CHANGES SAVED'
  • If you return to the same entry, it will be blank.
  • For new entries, it will be blank until changes are made.

Let me know if any further clarification is needed.

Thanks,

-Brady

@erezrokah
Copy link
Contributor

Do you think this is a problem? When you press save, there is an alert anyway.

I'm not sure I understand the problem you're referring to nor the alert. Do you mean the publish alert? Saving doesn't show an alert.

Also to confirm - the editor reloads when you publish in simple workflow mode too, correct?

Let me know if any further clarification is needed.

I think those makes senes - I would prefer to have a better indiction if a workflow entry is new or linked to an existing published entry, but that's another issue.

@bradystroud
Copy link
Contributor Author

bradystroud commented Jul 28, 2021

Hi @erezrokah,

I am trying to fix the failing test.

I followed https://github.com/netlify/netlify-cms/blob/master/CONTRIBUTING.md#debugging-git-gateway to run the test locally, but it has succeeded.

I am using the same config.yml file, so I am not sure why I can't reproduce it.

@bradystroud
Copy link
Contributor Author

Hi @erezrokah,

Simple workflow

  • Blank on load
  • After making a change and pressing 'publish' it will show 'CHANGES SAVED'
  • If you return to the same entry, it will be blank.
  • For new entries, it will be blank until changes are made.

I don't think this behaviour is possible for the same reasons mentioned in #5595 (comment)

There are 2 alternative behaviours for the Simple Workflow

Simple workflow - alternative behaviour 1

  • Blank on load
  • After making a change it will show 'UNSAVED CHANGES'
  • After making a change and pressing 'publish' it won't show anything

Simple workflow - alternative behaviour 2 (original behaviour - same as before this PR)

  • Show 'CHANGES SAVED' on load
  • After making a change it will show 'UNSAVED CHANGES'
  • After making a change and pressing 'publish' it will show changes saved

Personally, I prefer Alternative 2.

Let me know what you think.

@erezrokah
Copy link
Contributor

Simple workflow - alternative behaviour 2 (original behaviour - same as before this PR)

  • Show 'CHANGES SAVED' on load
  • After making a change it will show 'UNSAVED CHANGES'
  • After making a change and pressing 'publish' it will show changes saved

Personally, I prefer Alternative 2.

Yes I prefer that too.

Would it make sense to keep this behavior for editorial workflow too for consistency?

Also, that test has been flaky on CI (I haven't been able to fix it yet) so if it passes locally you can ignore the failure.

@bradystroud bradystroud changed the title Hide changes saved and save button Disable saved changes button when there are no changes Jul 30, 2021
@bradystroud bradystroud changed the title Disable saved changes button when there are no changes Disable 'Save' button when there are no changes Jul 30, 2021
@bradystroud
Copy link
Contributor Author

Yes I prefer that too.

Would it make sense to keep this behavior for editorial workflow too for consistency?

Yes, I have made this change in my latest commit.

Copy link
Contributor

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

🚀

@erezrokah erezrokah merged commit 4b566a7 into decaporg:master Aug 3, 2021
@bradystroud bradystroud deleted the 5553-hide-changes-saved-and-save-button branch August 29, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide 'CHANGES SAVED' message and 'Save' button if no changes have been made
2 participants