-
Notifications
You must be signed in to change notification settings - Fork 24
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
Refactor Antd Table columns #7772
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.
Thanks for fixing this 🎉
Judging from the antd documentation this seems to be the preferred way these days. (Similar to ,
etc).
Yes, you are correct as far as I remember 👍
Thanks for this PR. Please find my comments below.
One thing: The PR does not state why moving the column definition into an object instead of an react child fixes the Typescript hiccup. In case you know why, please add a short explanation in a comment in case someone later comes back to this PR and thus gets the proper reasoning / understanding for this change 🙏
Once the mini feedback is applied I'd say its all green 🟢
@@ -26,6 +26,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released | |||
- Toasts are shown until WEBKNOSSOS is running in the active browser tab again. Also, the content of most toasts that show errors or warnings is printed to the browser's console. [#7741](https://github.com/scalableminds/webknossos/pull/7741) | |||
- Improved UI speed when editing the description of an annotation. [#7769](https://github.com/scalableminds/webknossos/pull/7769) | |||
- Updated dataset animations to use the new meshing API. Animitation now support ad-hoc meshes and mappings. [#7692](https://github.com/scalableminds/webknossos/pull/7692) | |||
- Slightly refactored the `<FixExpandleTable/>`component to use columns as props. [#7772](https://github.com/scalableminds/webknossos/pull/7772) |
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 say that the changelog entry is not necessary as these changes are not user facing. But feel free to keep this :)
key: "name", | ||
sorter: Utils.localeCompareBy<RowRenderer>((rowRenderer) => rowRenderer.data.name), | ||
sortOrder: sortedInfo.columnKey === "name" ? sortedInfo.order : undefined, | ||
render: (_name: string, rowRenderer: RowRenderer) => rowRenderer.renderNameColumn(), |
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 still have the RowRenderer
type here. So moving this type into the column prop definition fixes the bug / recursive definition? Sorry, the PR description wasn't that clear to me to why this is actually fixing the typescript hiccup.
Co-authored-by: MichaelBuessemeyer <[email protected]>
I don't know why React v17 + Typescript ran into an issue. I can only assume that TS tries to automagically infer types for |
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 applying the suggestion.
Let's 🚢
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 think I found a bug, let me quick investigate before merging
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 found the bug: It was cased by name shadowing. Please see my comments below.
After this is fix, please ask for a quick re-testing that then it should be ready to merge (hopefully 🙈).
And sorry for the take backsies, but it was necessary
</div> | ||
{task.status.pending > 0 ? ( | ||
<div> | ||
<LinkButton onClick={_.partial(assignTaskToUser, task)}> |
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.
Here is an example that causes the rendering to crash as the current code shadows the lodash variable
</div> | ||
) : null} | ||
<div> | ||
<LinkButton onClick={_.partial(deleteTask, task)}> |
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.
Here as well btw :)
key="actions" | ||
width={170} | ||
fixed="right" | ||
render={(__, task: APITask) => ( |
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 previous code seems to have used two underscores to avoid the shadowing. Imo using _unused
is more explicit and easier to spot than using two underscores to avoid the name shadowing. Therefore, the _unused
approach is more explicit and therefore imo more preferable.
Co-authored-by: MichaelBuessemeyer <[email protected]>
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.
Now it works 🎉
In preparation for upgrading to React 17 (#7765), I ran into trouble with Typescript and infinite recursions ("type definition to deep") resulting in crashes. Most likely this is not caused by the React update per se but some other dependency, likely any from the
rc-*
packages used byantd
.In particular, Typescript was unhappy with the type
RowRenderer
in any of the table<Column>
elements:Instead of using
<Column />
children for theFixedExpandableTable
, I refactored this components to use objects and props instead, e.g.<Table columns={ ... } />
. Judging from the antd documentation this seems to be the preferred way these days. (Similar to<Dropdown />
,<Menu />
etc).Steps to test:
Issues:
(Please delete unneeded items, merge only when none are left open)