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

fix(core): disable scheduledPublishing and tasks if /features returns error #7517

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

pedrobonamin
Copy link
Contributor

Description

Some users have reported that they see the upsell ui even though the feature is enabled for the project.
That is due to the features api returning an error if the user doesn't have the right permissions to query it.

This PR adds the same check for scheduledPublishing and tasks plugins.
In comments we are currently doing that check here https://github.com/sanity-io/sanity/blob/edx-1599/packages/sanity/src/core/comments/hooks/useResolveCommentsEnabled.ts#L42-L43

What to review

Are this changes ok?

Testing

New tests have been introduced to guard this behavior.

Notes for release

Disable schedule publishing and tasks plugin if user doesn't have the right access.

Copy link

vercel bot commented Sep 17, 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 Oct 22, 2024 9:16am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 9:16am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 9:16am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 9:16am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 9:16am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Oct 22, 2024 9:16am

@pedrobonamin pedrobonamin requested review from a team and rexxars and removed request for a team September 17, 2024 12:11
@pedrobonamin pedrobonamin changed the title fix(core): disable scheduledPublishing and tasks plugins if features returns error fix(core): disable scheduledPublishing and tasks plugins if /features returns error Sep 17, 2024
@pedrobonamin pedrobonamin changed the title fix(core): disable scheduledPublishing and tasks plugins if /features returns error fix(core): disable scheduledPublishing and tasks if /features returns error Sep 17, 2024
Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Sep 17, 2024

Component Testing Report Updated Oct 22, 2024 9:09 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 38s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 46s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 41s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 17s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 27s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 36s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

<Container width={1} paddingTop={4}>
<Box paddingTop={4} paddingX={4}>
<ErrorCallout
description="You do not have permission to edit schedules."
Copy link
Contributor Author

@pedrobonamin pedrobonamin Sep 17, 2024

Choose a reason for hiding this comment

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

ℹ️ We don't have translations in scheduledPublishing
Instead of showing the same error that we show when the request fails we add an specific not enabled error.

Current error

Screenshot 2024-09-17 at 17 23 06

Updated error
Screenshot 2024-09-17 at 17 24 34

Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

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

Thanks for raising this! I've made changes to the backend API to avoid needing more permissions to read features, but this will still be nice for other errors.

@pedrobonamin
Copy link
Contributor Author

Thanks for raising this! I've made changes to the backend API to avoid needing more permissions to read features, but this will still be nice for other errors.

Thanks for reviewing @rexxars

So I think it would be better in this case to update the message to this

-            description="You do not have permission to edit schedules."
+            description="Something went wrong loading permissions, please try again."
-            title="Insufficient permissions"
+            title="Permissions check failed"

Copy link
Contributor

github-actions bot commented Oct 22, 2024

⚡️ Editor Performance Report

Updated Tue, 22 Oct 2024 09:11:38 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 16.5 efps (61ms) 16.4 efps (61ms) +1ms (+0.8%)
article (body) 59.5 efps (17ms) 56.5 efps (18ms) +1ms (+5.4%)
article (string inside object) 17.5 efps (57ms) 19.2 efps (52ms) -5ms (-8.8%)
article (string inside array) 14.1 efps (71ms) 14.9 efps (67ms) -4ms (-5.6%)
recipe (name) 29.4 efps (34ms) 30.3 efps (33ms) -1ms (-2.9%)
recipe (description) 33.3 efps (30ms) 34.5 efps (29ms) -1ms (-3.3%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (6ms) +0ms (-/-%)
synthetic (title) 15.9 efps (63ms) 15.9 efps (63ms) +0ms (-/-%)
synthetic (string inside object) 15.5 efps (65ms) 16.1 efps (62ms) -3ms (-3.9%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 61ms 64ms 76ms 250ms 440ms 13.9s
article (body) 17ms 19ms 26ms 136ms 340ms 5.7s
article (string inside object) 57ms 58ms 61ms 67ms 80ms 8.0s
article (string inside array) 71ms 77ms 88ms 272ms 1189ms 10.0s
recipe (name) 34ms 37ms 51ms 88ms 1ms 9.1s
recipe (description) 30ms 31ms 33ms 62ms 0ms 6.0s
recipe (instructions) 6ms 9ms 9ms 22ms 0ms 3.4s
synthetic (title) 63ms 66ms 71ms 95ms 688ms 12.6s
synthetic (string inside object) 65ms 68ms 76ms 409ms 802ms 16.3s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 61ms 65ms 84ms 131ms 334ms 14.4s
article (body) 18ms 20ms 23ms 145ms 180ms 5.8s
article (string inside object) 52ms 55ms 64ms 238ms 292ms 8.5s
article (string inside array) 67ms 72ms 82ms 223ms 935ms 9.6s
recipe (name) 33ms 37ms 46ms 82ms 21ms 9.3s
recipe (description) 29ms 32ms 37ms 60ms 4ms 6.2s
recipe (instructions) 6ms 9ms 9ms 13ms 0ms 3.2s
synthetic (title) 63ms 72ms 87ms 267ms 1560ms 15.9s
synthetic (string inside object) 62ms 68ms 75ms 455ms 1586ms 9.6s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

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