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

feat(history): restore version #20102

Merged
merged 9 commits into from Apr 16, 2024
Merged

feat(history): restore version #20102

merged 9 commits into from Apr 16, 2024

Conversation

markkaylor
Copy link
Contributor

@markkaylor markkaylor commented Apr 12, 2024

What does it do?

  • Adds the logic to a version
  • Adds a simple dumb button on the FE + sets up the RTK mutation to make it easier to test

Why is it needed?

  • To restore a history version

How to test it?

  • Create a history version for an entry
  • Create another with some changes
  • Go to history and restore the previous version
  • It should create a new history version that restore your selected version

Test relations and media

  • Add relations/media to an entry, create a history version
  • Go delete the relation/media entries/assets, create another history version for the entry
  • Restore the version that had the relations/media
  • The deleted relations should not be restored, existing relations should be restored

Unknown fields:

  • Added fields should be in the restored version but with an empty value
  • Deleted fields should not be restored

Not supported:

  • polymorphic relations / components

NOTE

To ensure this work makes it into the beta blitz on monday tests will be handled in another PR CS-752

@markkaylor markkaylor added source: core:content-manager Source is core/content-manager package pr: feature This PR adds a new feature labels Apr 12, 2024
@markkaylor markkaylor self-assigned this Apr 12, 2024
@Marc-Roig
Copy link
Contributor

Marc-Roig commented Apr 12, 2024

History has only a single service, which is now in charge of :

  • Handling strapi lifecycles (bootstrap, destroy)
  • version management (createVersion, findVersionsPage, restoreVersion)

Would it make sense to split the history service into two?

  • lifecycles service exposing bootsrap() and destroy()
  • history-versions service exposing create() findPage() restore()

It could simplify method naming and split the services concerns

Copy link

vercel bot commented Apr 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 16, 2024 7:03am

@Marc-Roig
Copy link
Contributor

Marc-Roig commented Apr 12, 2024

unrelated to this PR, but you might want to change the following line in the history service:

// before
const localesService = strapi.plugin('i18n').service('locales');

// after
const localesService = strapi.plugin('i18n')?.service('locales');

// Return or handle it differently
if  (!localesService) return

if i18n is not enabled that might break

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

I think we're ready to merge and treat potential issues as bug fixes PRs

@markkaylor
Copy link
Contributor Author

markkaylor commented Apr 15, 2024

@remidej I'll push to address Marc's feedback for:
Two services lifecycles and history reverted, let's do this in another PR

  • Validate the request body

Then good to merge with follow up PRs for bug fixes + tests

@markkaylor
Copy link
Contributor Author

@remidej and/or @Marc-Roig could you please test the validation of the request body and the validation of update permissions. For the update permissions here I am getting 403 when I don't the permissions.

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

Tested again ✅

@markkaylor
Copy link
Contributor Author

The failing FE test is unrelated. Merging.

@markkaylor markkaylor merged commit b4f819a into v5/main Apr 16, 2024
23 of 25 checks passed
@markkaylor markkaylor deleted the feat/history-restore branch April 16, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: feature This PR adds a new feature source: core:content-manager Source is core/content-manager package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants