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

chore(tasks): move CommentsSetupProvider to core #5767

Merged
merged 5 commits into from
Feb 23, 2024
Merged

Conversation

pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Feb 16, 2024

Description

This PR moves the <CommentsSetupProvider> from comments plugin to core.
We need to move this provider because tasks and upcoming features will need to use the comments (addon) dataset to store data.
In favour of sharing code, this provider is moved to core.

The runSetup function has been refactored and rename to createAddonDataset to create the client but not create the comment / payload received, allowing for it's reusability.

Naming wise, we are keeping it has been renamed from CommentsSetupProvider to AddonDatasetProvider.

Main changes
File moved to core.
Function updated to only create the dataset.
Caller now creates the document.

What to review

Is the location of the new provider correct?

Testing

Creating a new comments dataset should work.

Notes for release

Moves the CommentSetupProvider into core for reusability.

Copy link

vercel bot commented Feb 16, 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 Feb 23, 2024 2:44pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 23, 2024 2:44pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 23, 2024 2:44pm

Copy link
Contributor

github-actions bot commented Feb 16, 2024

Package Documentation Change
sanity +2%
Full Report
sanity
This branch Next branch
180 documented 178 documented
850 not documented 853 not documented
@sanity/migrate
This branch Next branch
17 documented 17 documented
75 not documented 59 not documented
@sanity/diff
This branch Next branch
13 documented 13 documented
16 not documented 16 not documented
@sanity/block-tools
This branch Next branch
4 documented 4 documented
9 not documented 9 not documented
@sanity/types
This branch Next branch
55 documented 55 documented
233 not documented 239 not documented
sanity/desk
This branch Next branch
84 documented 84 documented
64 not documented 64 not documented
@sanity/portable-text-editor
This branch Next branch
21 documented 21 documented
44 not documented 44 not documented
@sanity/mutator
This branch Next branch
7 documented 7 documented
3 not documented 4 not documented
@sanity/cli
This branch Next branch
1 documented 1 documented
31 not documented 31 not documented
sanity/structure
This branch Next branch
2 documented 2 documented
8 not documented 8 not documented
@sanity/util/concurrency-limiter
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
@sanity/util/legacyDateFormat
This branch Next branch
0 documented 0 documented
4 not documented 5 not documented
@sanity/schema/_internal
This branch Next branch
0 documented 0 documented
12 not documented 12 not documented
@sanity/util/paths
This branch Next branch
1 documented 1 documented
15 not documented 15 not documented
sanity/router
This branch Next branch
17 documented 17 documented
26 not documented 26 not documented
@sanity/schema
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
sanity/cli
This branch Next branch
2 documented 2 documented
0 not documented 0 not documented
@sanity/vision
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/fs
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
sanity/_internal
This branch Next branch
0 documented 0 documented
1 not documented 1 not documented
@sanity/util/client
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
@sanity/util/createSafeJsonParser
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
sanity/_internalBrowser
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/content
This branch Next branch
1 documented 1 documented
5 not documented 5 not documented

Copy link
Contributor

github-actions bot commented Feb 16, 2024

Component Testing Report Updated Feb 23, 2024 2:47 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 22s 0 0 3
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 13s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 33s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 1s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 2s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

@pedrobonamin pedrobonamin marked this pull request as ready for review February 16, 2024 14:14
@pedrobonamin pedrobonamin requested a review from a team February 16, 2024 14:14
@pedrobonamin pedrobonamin requested a review from a team as a code owner February 16, 2024 14:14
@pedrobonamin pedrobonamin requested review from skogsmaskin, cngonzalez and hermanwikner and removed request for a team February 16, 2024 14:14
cngonzalez
cngonzalez previously approved these changes Feb 21, 2024
setIsRunningSetup(false)
return client
}
} catch (_) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid I'm not as close to this as you are, but is there a specific error we can catch here? I'm just concerned about valid errors being ignored and further work being done, getting into a strange state.

The additional error catching below might suffice, but was curious if we could get more specificity here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @cngonzalez will defer to @hermanwikner and @sjelfull on this.

Copy link
Member

Choose a reason for hiding this comment

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

Also realize that this is rearranging pre-exsiting code so maybe better to address in another PR 😅

Copy link
Member

Choose a reason for hiding this comment

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

I did some testing, and it appears we no longer need this check. The logic in this try/catch was initially added because the /setup endpoint used to return an error if the addon dataset had already been created. However, this no longer seems to be the case, as the endpoint now returns the name of the addon dataset if it has already been created instead – which is great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment below mentions that it could return an error also if the dataset doesn't exists. Maybe we can do a follow up to consider if we remove it or not, wouldn't feel confortable removing it in this one given it should be mostly focused on re-arranging the changes and not refactors.
But also tried it and it doesn't fail if the dataset doesn't exists.

@cngonzalez cngonzalez self-requested a review February 21, 2024 22:35
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.

Location of the new provider looks good to Studio DX!

Copy link
Member

@hermanwikner hermanwikner left a comment

Choose a reason for hiding this comment

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

Nice stuff – thanks @pedrobonamin 👍

I added one comment about renaming isRunningSetup to isCreatingDataset – but no blocker for merge!

@pedrobonamin pedrobonamin added this pull request to the merge queue Feb 23, 2024
Merged via the queue into next with commit dbff227 Feb 23, 2024
39 of 40 checks passed
@pedrobonamin pedrobonamin deleted the comments-setup branch February 23, 2024 15:32
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.

3 participants