Skip to content
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

Merged
merged 8 commits into from
Oct 19, 2023
Merged

refactor: convert DataGridHeader into function component #24747

merged 8 commits into from
Oct 19, 2023

Conversation

ArturBa
Copy link
Contributor

@ArturBa ArturBa commented Oct 6, 2023

Summary

Convert DataGridHeader into function component

Ticket Link

#24742

Screenshots

Release Note

NONE

@mm-cloud-bot mm-cloud-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note. labels Oct 6, 2023
@mattermost-build
Copy link
Contributor

Hello @ArturBa,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Copy link
Member

@jespino jespino left a 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! ✨

@jespino jespino added the 2: Dev Review Requires review by a developer label Oct 6, 2023
Copy link
Contributor

@larkox larkox left a 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) => {
Copy link
Contributor

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))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified

Suggested change
{columns.map((col) => renderHeaderElement(col))}
{columns.map(renderHeaderElement)}

@larkox
Copy link
Contributor

larkox commented Oct 6, 2023

@ArturBa I just saw that the linter is failing. Probably just executing npm run fix in the webapp/channels folder should fix those automatically.

@hanzei hanzei added the Awaiting Submitter Action Blocked on the author label Oct 6, 2023
@jespino jespino requested a review from larkox October 7, 2023 08:04
@jespino jespino removed the Awaiting Submitter Action Blocked on the author label Oct 7, 2023
Copy link
Contributor

@larkox larkox left a 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) => {
Copy link
Contributor

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 😄

Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks!

@larkox larkox added 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review QA-wanted Available for QA review by QA contributors during Hacktoberfest and removed 2: Dev Review Requires review by a developer labels Oct 7, 2023
@mattermost-build
Copy link
Contributor

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.

@larkox
Copy link
Contributor

larkox commented Oct 9, 2023

/update-branch

@Tahanima
Copy link

Hi @lindy65, I would like to test this PR as a QA. Looking forward to your guidance.

@larkox larkox requested a review from lindy65 October 17, 2023 08:39
@lindy65 lindy65 added Setup Cloud Test Server Setup an on-prem test server and removed QA-wanted Available for QA review by QA contributors during Hacktoberfest labels Oct 17, 2023
@lindy65
Copy link
Contributor

lindy65 commented Oct 17, 2023

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 data grid header referred to in Files Changed is, in fact, the System Console > Reporting > Team Statistics?
image

Please also run E2E tests @larkox - thanks!

@larkox
Copy link
Contributor

larkox commented Oct 17, 2023

/e2e-test

@mattermost-build
Copy link
Contributor

Successfully triggered E2E testing!
GitLab pipeline | Test dashboard

@larkox
Copy link
Contributor

larkox commented Oct 17, 2023

@lindy65 All "grid lists" on the admin console should use the the DataGrid component, and therefore the data grid header (top row of the grid showing the column headers).

For example, the users lists, or the log list in the server logs should use this.

@lindy65
Copy link
Contributor

lindy65 commented Oct 17, 2023

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:

  • System Console > Reporting > Team Statistics
  • System Console > User Management > Users

Let me know if you have any questions :)

@Tahanima
Copy link

Tahanima commented Oct 18, 2023

I've tested the changes in the test server and it looks good to me.

Steps

  • Log in to the application as a System Admin user (Username: sysadmin, Password: Sys@dmin123)
  • Navigate to the System Console
  • Go through each of the navigational options in the Sidebar and check whether they are displayed correctly.

Operating System

Ubuntu 22.04.3 LTS

Recordings

Web Application

  • Firefox (Version: 118.0.2)
firefox.webm
  • Chrome (Version: 118.0.5993.70)
chrome.webm

Desktop Application

desktop.webm

cc: @lindy65

Copy link
Contributor

@lindy65 lindy65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ArturBa - looks good 👍

Thank you @Tahanima for QA'ing!

cc @larkox

@lindy65 lindy65 added 4: Reviews Complete All reviewers have approved the pull request QA/Review Done QA review is completed but other reviews are outstanding (exception to usual process) and removed 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review Setup Cloud Test Server Setup an on-prem test server labels Oct 19, 2023
@mm-cloud-bot
Copy link

Test server destroyed

@larkox larkox merged commit ec394c1 into mattermost:master Oct 19, 2023
15 checks passed
@larkox
Copy link
Contributor

larkox commented Oct 19, 2023

Thank you for the contribution!

@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Oct 19, 2023
SaketKaswa20 pushed a commit to SaketKaswa20/mattermost that referenced this pull request Oct 19, 2023
…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>
@ArturBa ArturBa deleted the feat/24742 branch October 21, 2023 10:57
@jwilander jwilander added the kind/refactor Categorizes issue or PR as related to refactor of production code. label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Contributor Docs/Not Needed Does not require documentation Hacktoberfest kind/feature Categorizes issue or PR as related to a new feature. kind/refactor Categorizes issue or PR as related to refactor of production code. QA/Review Done QA review is completed but other reviews are outstanding (exception to usual process) release-note-none Denotes a PR that doesn't merit a release note.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants