Commit Graph

40 Commits

Author SHA1 Message Date
Kevin Ansfield
887f4d3ac2
🐛 Fixed editor unsaved changes modal showing too often (#20787)
ref [ENG-661](https://linear.app/tryghost/issue/ENG-661/) 
ref [ONC-253](https://linear.app/tryghost/issue/ONC-253/)
ref [PLG-174](https://linear.app/tryghost/issue/PLG-174/)

- restored the original but reverted fix for unsaved changes modal from https://github.com/TryGhost/Ghost/pull/20687
- updated code to remove some incorrect early-falsy-return logic in `editorController.hasDirtyAttributes` that prevented save of unsaved changes on the underlying model (e.g. excerpt)
- updated unit tests so they are testing real post model instances and therefore are testing what we expect them to test
- added acceptance tests to ensure autosave is working for title and excerpt fields

---------

Co-authored-by: Ronald Langeveld <hi@ronaldlangeveld.com>
2024-08-19 18:03:13 +00:00
Ronald Langeveld
6ebcd10288
Revert "Fixed draft posts not autosaving without title (#20774)" (#20776)
This reverts commit aad438ba0b.

- reverts the commit so that we can merge it together with PLG-174
2024-08-19 10:19:53 +00:00
Ronald Langeveld
aad438ba0b
Fixed draft posts not autosaving without title (#20774)
ref [ENG-661](https://linear.app/tryghost/issue/ENG-661/) ONC-253

- Reverts the revert of
93cbb94b90
of the intial bug fix.
- Updated hasDirtyAttributes logic to ensure the dirty state changes
when typing a draft, despite not title.
- Updated tests and added tests missing from the hasDirtyAttributes
logic
2024-08-19 12:21:35 +07:00
Chris Raible
77b18916f4
🐛 Fixed a bug causing new drafts to only save if the title is populated (#20769)
ref
https://linear.app/tryghost/issue/ONC-253/drafts-only-save-if-the-title-is-populated

- A
[commit](c8ba9e8027)
in `v5.89.1` introduced a bug that caused new drafts to only save if the
post title was populated, causing potential data loss if a user is
working on a new draft without setting the title.
- This commit reverts the one that introduced this bug to prevent data
loss.

This reverts commit c8ba9e8027.
2024-08-16 12:09:11 -07:00
Ronald Langeveld
c8ba9e8027
🐛 Fixed unsaved changes confirmation on Lexical schema change (#20687)
refs ENG-661

Fixes a long-standing issue where an outdated Lexical schema in the
database triggered the unsaved changes confirmation dialog incorrectly.
Implemented a secondary hidden Lexical instance that loads the state
from the database, renders it, and uses this updated state to compare
with the live editor's scratch.
This ensures the unsaved changes prompt appears only when there are real
changes from the user.
2024-08-05 12:58:58 +00:00
Kevin Ansfield
202fd7ebbd Added fallback to current excerpt when revision excerpt is null
no issue

- following on from the removal of the `post_revisions.custom_excerpt` column population it was possible in some circumstances to lose your excerpt when restoring an old version
- this change means when no custom_excerpt exists on a revision we both preview and restore the current custom_excerpt to avoid any data loss
2024-06-06 17:25:42 +01:00
Kevin Ansfield
b447a26832
Added custom excerpt to post revisions (#20323)
closes https://linear.app/tryghost/issue/MOM-170

When the subtitle field is included in the editor it creates a disconnect with post revisions if the underlying custom excerpt data is not included so we'd like to both preview and restore the subtitle when the in-editor subtitle field is enabled.

- added `post_revisions.custom_excerpt` column to schema
- added migration to add `post_revisions.custom_excerpt` to existing databases
- added migration to populate `post_revisions.custom_excerpt` with the current `post.custom_excerpt` value from the associated record
  - ensures no data is inadvertently lost when restoring an old version
- using current data matches what would have happened previously where custom_excerpt was never overwritten when restoring an old version
- updated post revisions handling to accept the `custom_excerpt` field
- updated Admin's revision preview and restoration to display and set the `custom_excerpt` field
2024-06-05 14:47:33 +01:00
Kevin Ansfield
36ba47604f Added Admin acceptance test for post revision restoration
ref https://linear.app/tryghost/issue/ENG-1078

- adds required setup for acceptance testing post revisions
- adds happy-path test for listing, previewing, and restoring a post revision
2024-06-04 20:16:19 +01:00
Daniel Lockyer
532a7cf6e3 Fixed loading assets from CDN URL
refs https://ghost.slack.com/archives/C027S85FS/p1690202522054729

- this is another set of places where we load assets slightly
  differently
- this should fix user profile images when using assets from a CDN
2023-07-24 16:12:29 +02:00
Michael Barrett
ef92028b22
Removed post diffing from post history feature (#16904)
refs https://github.com/TryGhost/Team/issues/3337

Removed post diffing from post history feature as this functionality is
likely to be reworked in a future cycle
2023-06-01 13:22:51 +01:00
Ronald Langeveld
6189040fc4
Added unpublished reason to post revisions (#16726)
closes https://github.com/TryGhost/Team/issues/3137

We have now included the ability to display an "Unpublished" tag for revisions that have been unpublished. The tag is only displayed when the revision's reason property is set to "unpublished". A new revision is triggered when a post is unpublished, regardless whether there's a change in the content.
2023-05-03 09:20:34 +02:00
Fabien 'egg' O'Carroll
d87da627d9
Added author image to revision history list (#16724)
refs https://github.com/TryGhost/Team/issues/3129

This has copied the same pattern from the gh-user-list-item component.

Co-authored-by: Sanne de Vries <sannedv@protonmail.com>
2023-05-02 19:38:31 -04:00
Ronald
ad3c5d1a0b Fixed linting
refs https://ghost.slack.com/archives/C02G9E68C/p1683036435533879

- Indentation errors was being ignored by eslint.
- Fixed it to bring it up to standard.
2023-05-02 19:55:51 +02:00
Ronald
df1329f5e9 Added unpublished logic to revisionList.
refs https://github.com/TryGhost/Team/issues/3123

Refactor revisionList function to use a more concise logic for finding new published and unpublished revisions.
2023-05-02 09:11:56 +02:00
Ronald
904a03f81a Sort revision list by createdAt.
refs https://ghost.slack.com/archives/C02G9E68C/p1682941387256079?thread_ts=1682507718.761429&cid=C02G9E68C https://github.com/TryGhost/Team/issues/3123

This commit modifies the revisionList method to sort the revisions array by createdAt property in descending order, instead of reversing the order of the array. This makes the code more intuitive and easier to follow for future developers.

Additionally, the published_latest key-value pair is renamed to initial_publish to better reflect its meaning. This key-value pair is added to the revision object at the index where the post status changed from 'draft' to 'published', indicating the initial publication of the post.
2023-05-01 14:13:05 +02:00
Ronald
d6794e6c43 Added "published_latest" key to revisionList
refs https://github.com/TryGhost/Team/issues/3123

This commit modifies the revisionList method to add a new key-value pair published_latest: true to the object if the current index matches with the index of the latest published revision with the reason 'published'. The change only affects the latest published revision and doesn't modify any existing data. This update improves the display of post revisions by highlighting the latest published revision in the list.
2023-05-01 10:30:02 +02:00
Ronald
47a327a4ba Added ESC handling to modal-post-history
no issue

- added esc key handling
2023-04-21 16:25:14 +01:00
Fabien "egg" O'Carroll
f92def8dde Exposed feature image meta data to post revision modal template
This will allow Sanne to wire it up to the output
2023-04-21 16:02:02 +01:00
Sanne de Vries
22c45ee9b1 Updated copy for deleted staff users in post history
No ref
2023-04-21 15:27:40 +01:00
Sanne de Vries
d3a60c760b Updated feature image positioning in post history
No ref
2023-04-21 14:14:32 +01:00
Ronald
f37d7a3fc7 Wired up revision post status and reason to admin
no issue

We can now get post_status and reason in admin for each post_revision
object
2023-04-21 14:05:27 +01:00
Michael Barrett
1538b18d4e
Added post revision anonymous author label (#16697)
refs https://github.com/TryGhost/Team/issues/3104

When a post revision author has been deleted, or there is no author
associated with a post revision, the label "Anonymous" is used for the
revision author
2023-04-21 13:52:08 +01:00
Fabien "egg" O'Carroll
f33f9cc530 Added feature_image to the post history modal
This allows us to diff and review previous revisions feature images
2023-04-21 13:20:41 +01:00
Michael Barrett
a9ee30f8b0
Fixed issue with restoring post revision (#16694)
refs https://github.com/TryGhost/Team/issues/3102

Post revision restoration was failing due a few failing edge cases that
occurred during the refactor of the post history modal
2023-04-21 11:55:24 +01:00
Ronald
6d4bee82f0 Add flag val to showDifferences in post history
no issue

- set the tracked value to showDifferences state in modal-post-history
2023-04-21 11:22:08 +01:00
Ronald Langeveld
a13ac255f3
Refactored post history modal to Glimmer component (#16690)
closes https://github.com/TryGhost/Team/issues/3077

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 27c2916</samp>

This pull request refactors the modal-post-history component from a
classic Ember component to a glimmer component, using the latest APIs
and syntax. This improves the code quality and aligns with the Octane
edition of Ember. The changes affect the
`ghost/admin/app/components/modal-post-history.js` and
`ghost/admin/app/components/modal-post-history.hbs` files.
2023-04-21 09:45:28 +01:00
Michael Barrett
49eac033a3
Added confirmation modal when restoring a post revision (#16689)
no issue

Added confirmation modal when restoring a post revision
2023-04-20 17:01:17 +01:00
Fabien "egg" O'Carroll
e3fbab9dad Refactored the card diffing into a separate method
This makes it easier to enable and disable the card diffing in dev
2023-04-20 15:23:08 +01:00
Michael Barrett
096a31cf7e
Added post revision restoration (#16680)
no issue

Added functionality to restore a post revision
2023-04-20 11:43:22 +01:00
Ronald
66e8d2a51e Added placeholder remover on post history
no issue

- removes the div containing the initial "Begin writing your post" from
  being part of the compared by the differ
2023-04-20 10:31:53 +01:00
Fabien "egg" O'Carroll
f9e3813b08 Updated diff generation to treat cards atomically
Rather than displaying changes inside cards, we want to show a complete
replacement of the card. The current html diffing library is not capable of
supporting this so we have to use the approach here. First we find all cards
with changes in them, and then pull out the changes into two duplicated version
of the card, once for removals and one for additions.
2023-04-20 10:23:23 +01:00
Ronald
9b00411e3f Added diff toggling for post history
no issue

- adds diff toggling inside the post history modal
2023-04-19 17:40:06 +01:00
Fabien "egg" O'Carroll
5175987920 Fixed revisionList not updating selected values
Because we're using the old style components we need to make this a computed
property for changes to it to cause a rerender. We also add a latest property
to the first revision so that it can be rendered differently
2023-04-19 14:30:15 +01:00
Fabien "egg" O'Carroll
a65f928932 Added support for viewing different revisions
The Lexical editor isn't passed the editor state it's passed the _initial_
editor state, which means that subsequent renders will not use an updated
state. To work around this we store a reference to the editor api and manually
set the state ourselves when the selected revision is changed.
2023-04-19 13:57:35 +01:00
Ronald
56b6fedb72 Sorted post revisions by timestamp
no issue

- reversed timestamps of post revisions
2023-04-18 16:17:06 +01:00
Ronald Langeveld
30535eb8f5
Added post revision sidebar list (#16666)
no issue

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
copilot:summary
2023-04-18 16:10:41 +01:00
Fabien "egg" O'Carroll
0ef05d4bed Added initial version of post revision diffing
We want the diff to be based on what the editor looks like, so we render two
hidden koenig instances and diff the html output, as opposed to using lexical
to render the "frontend" HTML. We also have some weirdness with the last
revision being the same content as the current state of the post. We can look
to fix that at the storage or API level in future
2023-04-18 14:58:22 +01:00
Chris Raible
af367a2a18
Added post_revisions as a default include for posts (#16660)
no issue

- post_revisions will now be included in any request to the /posts
endpoint
- updated admin models to include post_revisions
- post revisions can now be accessed in the modal-portal-history via
this.post.post_revisions
2023-04-18 11:12:35 +01:00
Ronald Langeveld
b13677085d
Added html difference library (#16658)
no issue

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 2839ca2</samp>

This pull request adds a feature to show the HTML diff of the post
content changes in the post history modal. It uses the `node-htmldiff`
module to generate the diff and updates the `modal-post-history`
component and its template and style files.

---------

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2023-04-18 09:20:24 +01:00
Chris Raible
79a95268b6
Added Post History modal to the editor behind postHistory flag (#16651)
no issue

- added modal-post-history component and wired it up to the
lexical-editor

### <samp>🤖 Generated by Copilot at b726dd5</samp>

> _`Post history` is the key to the past_
> _Unveil the changes in a modal so vast_
> _But beware of the doom that lurks in the edits_
> _The lexical-editor is a portal to the abyss_
2023-04-17 15:25:52 +01:00