-
Notifications
You must be signed in to change notification settings - Fork 88
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
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:
|
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
useInitTypeSystem
hook β and init the type system on the view entity type pageuseEntityType
hook now takes ononCompleted
param, which we use to reset the state of the editor whenever the entity type loadsrouter.asPath
to resolve the entity type β this fixes a bug where hash or query params breaks finding the entity typedataTypeNames
to 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?