Entity type editor β Show correct properties in property selector, add edit bar, and minor changes - #1184
Conversation
|
This pull request introduces 1 alert when merging 739444a into 6303196 - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging 509121d into 074ed5d - view on LGTM.com new alerts:
|
kachkaev
left a comment
There was a problem hiding this comment.
The diff looks clean β I've left a couple of optional code style suggestions
| discardButtonProps: ButtonProps; | ||
| confirmButtonProps: ButtonProps; | ||
| }) => ( | ||
| <Container |
There was a problem hiding this comment.
Optional, for all similar cases: it'd useful to use explicit return statements in all React components instead of this arrow function shortcut. If we need to add some hook later, we won't end up with a crazy diff.
There was a problem hiding this comment.
Is there an autofixable lint rule for this? I tend to agree (from an "optimise for change" perspective) β although not for diff reasons because you can just hide whitespace in the diff, just for reducing friction of adding a hook. You could create a ticket?
There was a problem hiding this comment.
you can just hide whitespace in the diff
That won't help if JSX is wide enough to be re-formatted.
I created https://app.asana.com/0/1200211978612931/1203132574912430/f
| const EditBarContents = ({ | ||
| icon, | ||
| title, | ||
| label, | ||
| discardButtonProps, | ||
| confirmButtonProps, | ||
| }: { | ||
| icon: ReactNode; | ||
| title: ReactNode; | ||
| label: ReactNode; | ||
| discardButtonProps: ButtonProps; | ||
| confirmButtonProps: ButtonProps; | ||
| }) => ( |
There was a problem hiding this comment.
I remember us chatting about potential removal of FunctionComponent in code, but if we go for it, we should probably do so in some organised way. I'd stick with FunctionComponent for consistency for now, especially for exportable components. Defining type FooBarProps separately can also contribute to overall consistency. I'm not strongly opinionated about any of the styles, just suggesting to keep code rhythm as consistent as possible.
| const OntologyChipForwardRef = forwardRef(OntologyChip); | ||
|
|
||
| export { OntologyChipForwardRef as OntologyChip }; |
There was a problem hiding this comment.
| const OntologyChipForwardRef = forwardRef(OntologyChip); | |
| export { OntologyChipForwardRef as OntologyChip }; | |
| export const OntologyChip = forwardRef(RenderOntologyChip); |
| const OntologyChipForwardRef = forwardRef(OntologyChip); | |
| export { OntologyChipForwardRef as OntologyChip }; | |
| export const OntologyChip = forwardRef(renderOntologyChip); |
etc.
ForwardRefRenderFunction is not a React component because it has two args instead of one. It's useful to call ref forwarding functions distinctly to avoid accidental misuse or confusion.
There was a problem hiding this comment.
It's also worth saying forwardRef is a stop gap solution. They plan to remove it. reactjs/rfcs#107
There was a problem hiding this comment.
Oh right I did not know about that effect for the dev tools. I think I usually just call forwardRef inline, but I'm beginning to forget that. Need to write more react code π


π What is the purpose of this PR?
Next stage in entity type editor β see below.
π Related links
π« Blocked by
N/A
π What does this change?
Functionality changes:
Code changes:
useInitTypeSystemhook β and init the type system on the view entity type pageuseEntityTypehook now takes ononCompletedparam, which we use to reset the state of the editor whenever the entity type loadsrouter.asPathto resolve the entity type β this fixes a bug where hash or query params breaks finding the entity typedataTypeNamesto show the human readable name of data type chipsπ Does this require a change to the docs?
N/A
πΎ Next steps
π‘ What tests cover this?
β How to test this?