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: fetch feature toggle to enable serverside document actions #6418

Merged
merged 13 commits into from May 15, 2024

Conversation

cngonzalez
Copy link
Member

@cngonzalez cngonzalez commented Apr 18, 2024

Description

As we move toward transitioning to server-side document actions, we'd like to have some ability to have a remote way to configure whether or not our end users' document actions should be utilizing the Actions API endpoint, in case there's some risk or problem in content creation.

This PR introduces a remote check used in those places that code paths might diverge based on whether or not to use server actions. This way, we can shut off server actions and revert to old and tested functionality if needed.

This is done through the following:

  1. Continuing to use the sanity.config.ts flag. If it is set to false, then the old mutations endpoint should be used, no matter what.
  2. Introducing a HTTP request that is fed into document-store. This HTTP request lasts, at most, two minutes (thanks very much to @bjoerge for refining this).
  3. Because the serverActionsEnabled parameter is observable, it is no longer included in memoization.

What to review

Any gotchas. As of this writing, the /data/actions GET request is returning a false -- so even if the config flag is set, users should continue to see the mutations endpoint being used.

Testing

There were already tests in place to ensure that checkoutPair sent the correct requests based on the serverActionsEnabled parameter. These have been updated to respect that it is now an observable.

An additional end-to-end test was added to spy on requests made on document load and edit -- to ensure that the actions we send follow what we receive from the feature toggle endpoint.

Copy link

vercel bot commented Apr 18, 2024

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview May 15, 2024 1:30pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2024 1:30pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2024 1:30pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 15, 2024 1:30pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Apr 18, 2024

Component Testing Report Updated May 15, 2024 1:35 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 38s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 6s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 4s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 22s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 23s 9 0 0

@cngonzalez cngonzalez force-pushed the sdx-1277/scaffold-feature-flag branch from 32dc7b1 to a4ecd32 Compare April 19, 2024 16:45
@cngonzalez cngonzalez changed the title feat: scaffold feature flag in studio feat: scaffold feature toggle fetch in studio Apr 19, 2024
@cngonzalez cngonzalez force-pushed the sdx-1277/scaffold-feature-flag branch from e903a86 to 4662b9b Compare May 8, 2024 13:33
@cngonzalez cngonzalez force-pushed the sdx-1277/scaffold-feature-flag branch from 4662b9b to cf1c9d4 Compare May 8, 2024 21:53
juice49
juice49 previously approved these changes May 15, 2024
Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

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

This is great!

@bjoerge bjoerge added this pull request to the merge queue May 15, 2024
Merged via the queue into next with commit ed40e3f May 15, 2024
35 of 36 checks passed
@bjoerge bjoerge deleted the sdx-1277/scaffold-feature-flag branch May 15, 2024 13:31
ricokahler pushed a commit that referenced this pull request May 15, 2024
* feature: scaffold feature flag function

* revert back operations for now until caching issue is fixed

* refactor: try memoizing featureToggle

* refactor: use shareReplay

* feat: add feature toggle requests to operations events etc.

* refactor: rename featureToggleRequest

* fix: do not pass canUseServerActions to snapshot pair

* refactor(document-store): pass in server actions config as observable (#6582)

* feat: use real endpoint in fetchFeatureToggle

* test: update checkoutPair and add featureToggle e2e test

* chore: remove comment now that proper endpoint is in place

* fix(document-store): timeout feature flag req after 2s and treat as 'false'

* fix(sanity): make config flag override server document actions (#6634)

---------

Co-authored-by: Bjørge Næss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants