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

converting more components to setup composition api #1892

Merged
merged 25 commits into from
Mar 19, 2023

Conversation

aweebs
Copy link
Contributor

@aweebs aweebs commented Feb 26, 2023

Converts the remaining components in the vite branch to setup composition api.

Replaces v-data-table usage in apikeys and devices with regular tables, since the data-table component is not available yet but also is likely overkill for this purpose. Let me know if you'd like these reverted.

Recommend reviewing commit by commit and hiding whitespace changes.

TODO

  • test logs and activities page
  • fix activity and log layouts
  • test devices page
  • remove SelectedDeviceInfo component since all data is in the table already
  • test ImageEditor and ImageSearch
  • test MetadataEditor, MetadataEditorDialog, and PersonEditor
  • test updated route pages
  • test setup wizard - couldn't fully test until vuetify 3 stepper is released
  • Change useDataFns to return direct value rather than ref for now because of fix(shared): unwrap refs in toDisplayString vuejs/core#7306

Follow up work (for future PRs)

  • Connect UpNext button again
  • metadata image adding

@jellyfin-bot jellyfin-bot added the vue Pull requests that edit or add Vue files label Feb 26, 2023
@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Feb 28, 2023
@jellyfin-bot jellyfin-bot removed the merge conflict Something has merge conflicts label Feb 28, 2023
Copy link
Member

@ferferga ferferga left a comment

Choose a reason for hiding this comment

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

First round of feedback, will carefully review the files later:

The layout at logs page is a bit borked (in master, the arrow is at the left):
image

I don't remember why we had the SelectedDeviceInfo component in the first place, the info it provides is the same that can be located at the table. @ThibaultNocchi do you remember something?
I think we can get off without it. In case we go for it again, the table should have a hover effect, so it's obvious for the user that there's an action on click.

The data returned by useDataFns has double quotes. This is because it's a ref, and it's handled upstream at vuejs/core#7306. For now, I would say just unwrap .value there.

In any case, those functions could be moved out of the template imo.

The check for the admin pages lives at plugins/router/middlewares/admin-pages.ts. If you look at the check, the redirection is made when the user is an admin, which should be changed to when the user IS NOT an admin.

@aweebs aweebs requested a review from ferferga March 4, 2023 07:06
@aweebs aweebs force-pushed the composition_api branch 2 times, most recently from 7f1cebc to eebd933 Compare March 7, 2023 07:03
@aweebs
Copy link
Contributor Author

aweebs commented Mar 7, 2023

@ferferga this is ready for a proper review, I've tested the changes locally fairly well to confirm things appear correct.

@ThibaultNocchi
Copy link
Member

@ferferga I don't remember why too, so I guess it can be left off.

frontend/src/components/Item/Metadata/ImageEditor.vue Outdated Show resolved Hide resolved
frontend/src/components/Item/Metadata/ImageEditor.vue Outdated Show resolved Hide resolved
frontend/src/components/Item/Metadata/ImageSearch.vue Outdated Show resolved Hide resolved
frontend/src/components/Item/Metadata/ImageSearch.vue Outdated Show resolved Hide resolved
frontend/src/components/Playback/UpNext.vue Outdated Show resolved Hide resolved
frontend/src/pages/item/_itemId/index.vue Outdated Show resolved Hide resolved
frontend/src/pages/item/_itemId/index.vue Outdated Show resolved Hide resolved
frontend/src/pages/person/_itemId/index.vue Show resolved Hide resolved
frontend/src/pages/series/_itemId/index.vue Outdated Show resolved Hide resolved
Copy link
Member

@ferferga ferferga left a comment

Choose a reason for hiding this comment

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

Change useDataFns to return direct value rather than ref for now

When I started the migration to Vue 3, I approached this problem like you did here. However, this is not correct because of the following reasons (in fact the useDateFns has been recently modified to always return refs):

  • I recall returning values directly broke reactivity in some situations, so it was inconsistent. Reactive effects (Ref or ComputedRef) always ensured a consistent experience in that regard.
  • Because you're returning a value, I believe the effects are not disposed properly when the component is unmounted, which could leak to memory leaks.
  • You don't really know if something is reactive or not when using primitives, but you do when using effects/refs. DX-wise this is much better when you know when stuff is reactive or not.

I know it's painful, but hopefully this gets fixed out soon. I'm already tracking that issue because I myself reported it in the Vue discord and fixing this in the future it's a matter of making a PR once the fix is upstream to replace .value }} with }}

@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Mar 7, 2023
@jellyfin-bot jellyfin-bot removed the merge conflict Something has merge conflicts label Mar 8, 2023
@aweebs aweebs requested review from ThibaultNocchi and ferferga and removed request for ThibaultNocchi March 8, 2023 07:52
@aweebs aweebs force-pushed the composition_api branch 2 times, most recently from 3cf6b22 to 8524b5a Compare March 8, 2023 08:42
@sonarcloud
Copy link

sonarcloud bot commented Mar 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@aweebs aweebs requested a review from ferferga March 17, 2023 07:53
@jellyfin-bot
Copy link

Cloudflare Pages deployment

Latest commit 991168a
Status ✅ Deployed!
Preview URL https://c6bbe1e8.jf-vue.pages.dev
Type 🔀 Preview

View build logs
View bot logs

Copy link
Member

@ferferga ferferga left a comment

Choose a reason for hiding this comment

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

I tried a bit with the commented reactivity bits for the pages (as they were the last concern I had) but the changes required go way beyond the scope of this PR.

Thank you very much for all your work!

Copy link
Member

@ThibaultNocchi ThibaultNocchi left a comment

Choose a reason for hiding this comment

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

LGTM, I think ferf will squash a few commits

@ferferga ferferga merged commit 1ad57fc into jellyfin:vite Mar 19, 2023
@aweebs aweebs deleted the composition_api branch March 27, 2023 07:50
@ferferga ferferga added this to the Vue 3 milestone Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue Pull requests that edit or add Vue files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants