Skip to content

Various improvements for the presentation-links component#21338

Merged
paescuj merged 23 commits intomainfrom
fix-presentation-link-refetching
Feb 14, 2024
Merged

Various improvements for the presentation-links component#21338
paescuj merged 23 commits intomainfrom
fix-presentation-link-refetching

Conversation

@DanielBiegler
Copy link
Contributor

@DanielBiegler DanielBiegler commented Feb 6, 2024

Scope

What's changed:

Sadly the translation interface issue has thus far eluded my fixing wrath

Potential Risks / Drawbacks

  • Potentially breaking existing links for users but my (ofc limited) tests were good

Review Notes / Questions

So after looking into how the presentation-link component works I found out that the only reason we are fetching data at all is because of relations. For the other fields we can just access values of the v-form. For relations however we need to resolve the relation of course so we use the api to get the needed nested-fields.

This uncovered to me that we can optimize this component in the following ways:

  1. We dont need to fetch anything as long as we dont use relations. We can check beforehand whether or not the templated string contains relations.
  2. We only need to resolve the relation to get the nested-value, if that nested-value has not been edited. This is because if the value got edited, it will appear in the v-forms provided values.
  3. This is another bug currently where we dont actually update the presentation-link to use the edited nested-value. Currently we only use the api response for that. This is inconsistent because we do use the edited values for non-nested fields in the presentation-link.
  4. And there is another bug when dealing with the translation interface: If you have a translation interface that contains presentation-links, said links will not be able to use relational fields such as languages.code up until you change one field inside the translation-interface because that leads to a create call in use-relation-multiple.ts which initializes the edited values with our $type and $index notation.
  5. If we'll merge this it'd be good to open a new improvement-issue to allow refetching when changing an existing relation to a new relation for example you change your existing m2o relation from ID=1 to ID=2

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2024

🦋 Changeset detected

Latest commit: 0afb7cc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@directus/app Patch
@directus/api Patch
directus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DanielBiegler DanielBiegler marked this pull request as ready for review February 12, 2024 18:11
@DanielBiegler DanielBiegler changed the title Avoid presentation link refetching primary key if its undefined Various improvements for the presentation-links component Feb 12, 2024
@DanielBiegler DanielBiegler marked this pull request as draft February 12, 2024 18:16
@DanielBiegler DanielBiegler marked this pull request as ready for review February 12, 2024 22:12
Copy link
Contributor

@paescuj paescuj left a comment

Choose a reason for hiding this comment

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

Great work, behaving much better now 🚀

@paescuj paescuj merged commit c358ba2 into main Feb 14, 2024
@paescuj paescuj deleted the fix-presentation-link-refetching branch February 14, 2024 15:35
@github-actions github-actions bot added this to the Next Release milestone Feb 14, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App: Calls to undefined from presentation links within translations interface

3 participants