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: show hidden fields in history frontend #20201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to change the entire layout, which is basically the child of the strapi component field, doesn't it just make more sense to enable children
to be passed? We'd then export the component without children applied, it could be moved up to a more generic domain e.g. components
and in the EditView we add the current layout and in history we add your revised layout requirements?
How did we come to the conclusion this was the right solution? I'm just trying to weigh up the right direction in the long term... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this error:
I'm not sure exactly how it would work with you remaining fields function but I'm curious what you think of using children instead of two render props. I believe this is working and accomplishes the same thing: https://github.com/strapi/strapi/pull/20207/files
packages/core/content-manager/admin/src/history/components/VersionInputRenderer.tsx
Outdated
Show resolved
Hide resolved
...ages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Input.tsx
Outdated
Show resolved
Hide resolved
...ages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Input.tsx
Outdated
Show resolved
Hide resolved
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -211,6 +207,8 @@ const RepeatableComponent = ({ | |||
<AccordionGroup error={error}> | |||
<AccordionContent aria-describedby={ariaDescriptionId}> | |||
{value.map(({ __temp_key__: key, id }, index) => { | |||
const nameWithIndex = `${name}.${index}`; | |||
const safeKey = key ?? nameWithIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__temp_key__
is undefined in history, I'm not sure how it can be defined in a proper way (or it is matters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to avoid creating keys like this if possible, we had this in V4 and it got very messy and quite buggy to follow, especially if it leaks into the EditView, the re-ordering will crash.
We create tmp keys when we fetch the document:
const initialValues = React.useMemo(() => { |
const prepareTempKeys = traverseData( |
You could use the same pipe funcs perhaps? or maybe just the tmp key one.
packages/core/content-manager/admin/src/history/components/VersionInputRenderer.tsx
Outdated
Show resolved
Hide resolved
@joshuaellis I think I see what you're saying, but with the current state solution I think I'm happy where things stand:
For components I agree it could be nice to not have some layout logic in the input renderer for components. But I feel like extracting things to a hook will add more complexity rather than simplify things 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying several approaches to find what will work best for us 🙏 . I like what you have here.
@markkaylor thanks for bug report! I was only checking with content types that had hidden fields. About the hidden fields section. I thought about that but I'm not sure it's a good idea. I think it's important that unkown fields remain clearly different from the rest, because they're the ones that actually behave differently, as they can't be restored. If we have three different sections, we lose a bit of the clear page distinction between restorable and non-restorable. So I'm afraid trying to over-explain things by would actually create confusion. There's also the issue of hidden fields inside of components. You can't extract them into their own section of the page, since they would lose their context. So you'd have to split each component into a known and an unknown section. It's not something I'm excited about. We can also check with Lucas when he's back, but he's OOO until the Barcelona |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also the issue of hidden fields inside of components. You can't extract them into their own section of the page, since they would lose their context. So you'd have to split each component into a known and an unknown section. It's not something I'm excited about
I think I see what you mean here and that does sound like a bummer. I noticed if I hide a field in a component via configure the view, then in the EditView it's hidden but in the history version it's just still there in the component. On the other hand if I hid the entire component via configure the view it shows up in the panel with the other hidden fields as expected. I guess that's the kind of thing you are talking about here and that's tomorrow's problem?
- I found one last error when finishing my QA when trying to access history of a content type that does not have a component:
Besides that I'm good to approve 👍
...ages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Input.tsx
Show resolved
Hide resolved
...ages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Input.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job sticking with it to find the best API we can for the component stuff 👏🏼 I've not QAd but code makes sense ⭐
@markkaylor I can't reproduce this, could you tell me which content type you tested with? I think tried content types with and without components, with and without data in them, with and without hidden fields
I believe both cases are what we want, what is the issue you're seeing? Seeing a hidden field within a component is the reason I'm doing this whole refactoring. And for the hidden component there's no other choice but to show it at the bottom |
So for components, I can hide a component and it works as expected: Screen.Recording.2024-04-30.at.17.34.20.movBut if I try and hide a field inside a component, then in the EditView it's hidden but in history it is not represented as a hidden field. Screen.Recording.2024-04-30.at.17.33.17.movLet me know if it's clear or if you prefer to take a look on discord or something. For the error, I had it on the Tag content type but I am unable to reproduce now too. Maybe it was stale data or something 🤷♂️ |
What does it do?
Makes hidden fields visible in the History page. This is not about internal fields like id, but about the ones the user may have deleted from the layout via the configure the view page. I called them "remaining fields" in the code, to match what was already done in the code for that page.
It applies the fix in two places:
renderLayout
. It has the benefit of avoiding duplicating logic between repeatable and non-repeatable components, and avoids some prop drilling forrenderInput
.I want to write e2e tests for this, they have issues we need to fix first.
Why is it needed?
Because even though they're not visible in the edit view, the fields that aren't in the layout would still be restored if the history version is restored. It's therefore important to show them regardless, so that users know what they're restoring.
How to test it?
Go to the configure the view page for a content type. Delete a root field there (not in the CTB), as well as a field that's inside a component.
Now open the history page for an entry of that content type. You should see the deleted root field on a new line at the bottom of the page, but above the unknown fields.
Also check that component inputs work as expected in the Edit View page, since their code was refactored.