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(sanity): allow Actions API enablement based on Studio version semver constraint #6993

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Jun 19, 2024

Description

This change allows us to dynamically enable the Actions API based on the Studio version (post this release) from the Actions API. The API response now includes a compatibleStudioVersions property specifying a semver range that indicates the compatible Studio versions. If the feature toggle is enabled, Studio will first confirm it satisfies the semver constraint before enabling the gated functionality.

The feature toggle will never be acknowledged by existing Studio releases.

To briefly outline how this works in Studio:

  1. Existing Studio versions will treat the absence of the deprecated actions property as falsey, meaning they will never enable Actions API usage based on this feature toggle.
  2. Future Studio versions will enable Actions API usage based on this feature toggle as long as enabled is true and the Studio version satisfies the semver constraint specified in compatibleStudioVersions.

What to review

The resolution of the Actions API feature toggle (packages/sanity/src/core/store/_legacy/document/document-pair/utils/fetchFeatureToggle.ts).

Testing

  • Unit tests added in packages/sanity/src/core/store/_legacy/document/document-pair/utils/fetchFeatureToggle.test.ts.
  • E2E tests expanded and re-enabled in test/e2e/tests/document-actions/fetchFeatureToggle.spec.ts.

To manually test, find the GET request for data/actions in your dev tools and override the response body like so:

{
  "enabled": true,
  "compatibleStudioVersions": ">= 3"
}

After reloading the page, you should find the Actions API is being used.

Note: You must ensure the __internal_serverDocumentActions.enabled override is not present in your Studio config. It short-circuits the feature toggle.

Copy link

vercel bot commented Jun 19, 2024

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 10:14pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 10:14pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 10:14pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 10:14pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 10:14pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 8, 2024 10:14pm

Copy link

socket-security bot commented Jun 19, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

View full report↗︎

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jun 19, 2024

Component Testing Report Updated Jul 8, 2024 10:21 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 45s 2 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 26s 20 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 15s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 16s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 1m 49s 30 0 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 21s 3 0 0

@juice49 juice49 force-pushed the feat/sdx-1421/actions-feature-version-constraint branch from 392ec17 to 3c5efbe Compare June 19, 2024 14:41
@juice49 juice49 force-pushed the feat/sdx-1421/actions-feature-version-constraint branch from 3c5efbe to e6fb0df Compare June 20, 2024 08:12
@juice49 juice49 marked this pull request as ready for review June 20, 2024 14:19
@juice49 juice49 requested a review from a team as a code owner June 20, 2024 14:19
@juice49 juice49 requested review from rexxars and removed request for a team June 20, 2024 14:19
@rexxars rexxars requested review from a team, bjoerge, binoy14, ricokahler and cngonzalez and removed request for rexxars, a team and bjoerge June 27, 2024 21:51
cngonzalez
cngonzalez previously approved these changes Jul 2, 2024
Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

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

Nice, glad the feature toggle endpoint is getting enriched :) And thanks for the improved tests!

…test cases

This commit also removes the `__internal_serverDocumentActions` override from the E2E Studio.

Actions API enablement can now be controlled dynamically using the `mockActionsFeatureToggle`
helper.
Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

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

assume it's the same before the rebase!

@juice49
Copy link
Contributor Author

juice49 commented Jul 8, 2024

@cngonzalez It is. Thank you!

@juice49 juice49 merged commit daca8e9 into next Jul 8, 2024
42 checks passed
@juice49 juice49 deleted the feat/sdx-1421/actions-feature-version-constraint branch July 8, 2024 22:50
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.

2 participants