-
Notifications
You must be signed in to change notification settings - Fork 7k
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: convert DataGridHeader into function component #24747
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.
It looks great! Thanks @ArturBa! ✨
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 work! Just two small polishing changes.
class DataGridHeader extends React.Component<Props> { | ||
renderHeaderElement(col: Column) { | ||
|
||
const DataGridHeader: React.FC<Props> = ({ columns }: Props) => { |
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 explicit type should not be needed.
|
||
return ( | ||
<div className='DataGrid_header'> | ||
{columns.map((col) => renderHeaderElement(col))} |
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.
Can be simplified
{columns.map((col) => renderHeaderElement(col))} | |
{columns.map(renderHeaderElement)} |
@ArturBa I just saw that the linter is failing. Probably just executing |
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.
Sorry but it would be great if you could do one extra change. Thanks 😄
class DataGridHeader extends React.Component<Props> { | ||
renderHeaderElement(col: Column) { | ||
const DataGridHeader = ({columns}: Props) => { | ||
const renderHeaderElement = (col: Column) => { |
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 renderHeaderElement
is a component itself, and doesn't need any of the props, so we could move that out of the component. So... we would have the code something like this:
const HeaderElement = ({col}: HeaderElementProps) => {
...
}
const DataGridHeader = ({columns}: Props) => {
return (
<div className='DataGrid_header'>
{columns.map((col) => <HeaderElement col=col>)}
</div>
)
}
Why this is better? If you declare the function outside of the component, it gets instantiated just once during the lifetime of the program. Otherwise, on every render of every data grid header you will instantiate the function and potentially remove all references at some point, which consumes extra memory and generates extra work for the GC.
Sorry for the back and forth with this. I just saw this approach on a different PR and realized it is something nice to do here too 😄
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.
Awesome! Thanks!
E2E tests not automatically triggered, because the PR is not in a mergeable state. Please update the branch with the base branch and resolve outstanding conflicts. |
/update-branch |
Hi @lindy65, I would like to test this PR as a QA. Looking forward to your guidance. |
Hi @Tahanima - thank you! I have set up a test server but first want to check with dev that the section in the System Console is, in fact, what I think it is... Also, if you haven't already, please join our Community Server where you'll be able to chat to other staff and community QAs :) @larkox - do you know whether the Please also run E2E tests |
/e2e-test |
Successfully triggered E2E testing! |
@lindy65 All "grid lists" on the admin console should use the the For example, the users lists, or the log list in the server logs should use this. |
Thanks for the explanation @larkox @Tahanima - the test server is ready. Log in a the system admin and go to the system console. Please go through all options in the left hand side (so we don't miss and grid type lists) and check that they are displayed correctly. A few examples:
Let me know if you have any questions :) |
I've tested the changes in the test server and it looks good to me. Steps
Operating SystemUbuntu 22.04.3 LTS RecordingsWeb Application
firefox.webm
chrome.webmDesktop Applicationdesktop.webmcc: @lindy65 |
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.
Test server destroyed |
Thank you for the contribution! |
…24747) * refactor: convert DataGridHeader into function component * fix: core review * split into 2 components * add key for maped items * lint firx * fix missing parentheses * fix bracket --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Summary
Convert DataGridHeader into function component
Ticket Link
#24742
Screenshots
Release Note