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

[Content manager] Refactor edit view #14881

Merged
merged 11 commits into from
Nov 23, 2022
Merged

[Content manager] Refactor edit view #14881

merged 11 commits into from
Nov 23, 2022

Conversation

markkaylor
Copy link
Contributor

@markkaylor markkaylor commented Nov 15, 2022

What does it do?

  • Refactors nested loop over grids into a component for readability. I guess this isn't completely necessary but the EditView component is getting quite big
  • Remove use of useMemo and useCallback
  • Replace for...of loop with forEach to avoid eslint warning. I also decided to move all the logic inside the createAttributeLayout function.
  • Update the tests
  • Replaces prop drilling layout with useSelector

Why is it needed?

  • Mainly to reduce the use of useCallback and useMemo

How to test it?

  • Go to any content-type in the the content manager

@markkaylor markkaylor self-assigned this Nov 15, 2022
@markkaylor markkaylor added source: core:content-manager Source is core/content-manager package pr: chore This PR contains chore tasks (cleanups, configs, tooling...) labels Nov 15, 2022
@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Base: 59.61% // Head: 59.68% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (e63b41b) compared to base (a6193d0).
Patch coverage: 59.45% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14881      +/-   ##
==========================================
+ Coverage   59.61%   59.68%   +0.06%     
==========================================
  Files        1340     1342       +2     
  Lines       32639    32629      -10     
  Branches     6225     6224       -1     
==========================================
+ Hits        19459    19473      +14     
+ Misses      11316    11293      -23     
+ Partials     1864     1863       -1     
Flag Coverage Δ
back 49.70% <ø> (ø)
front 64.22% <59.45%> (+0.09%) ⬆️
unit_back 49.70% <ø> (ø)
unit_front 64.22% <59.45%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ntent-manager/pages/EditViewLayoutManager/index.js 50.00% <ø> (ø)
...in/src/content-manager/pages/EditView/selectors.js 40.00% <40.00%> (ø)
.../admin/src/content-manager/pages/EditView/index.js 45.07% <46.15%> (+14.00%) ⬆️
...rc/content-manager/pages/EditView/GridRow/index.js 61.53% <61.53%> (ø)
...ger/pages/EditView/utils/createAttributesLayout.js 100.00% <100.00%> (ø)
...ges/MarketplacePage/components/SortSelect/index.js 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@markkaylor markkaylor marked this pull request as ready for review November 16, 2022 08:46
);
})}
{row.map((grid, gridRowIndex) => (
<GridRow grid={grid} key={gridRowIndex} />
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about renaming grid to columns? I think if I'd look at the GridRow component it would be easier to understand ...

joshuaellis
joshuaellis previously approved these changes Nov 21, 2022
Copy link
Member

@joshuaellis joshuaellis 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 @markkaylor

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to improve the codebase 🙂

options: PropTypes.object.isRequired,
attributes: PropTypes.object.isRequired,
}).isRequired,
}).isRequired,
id: PropTypes.string,
isSingleType: PropTypes.bool,
goBack: PropTypes.func.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't comment below this line, but I think you can remove the commented code at the very end of the file. Also I don't think the named export is used anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry I forgot, will update now

@markkaylor markkaylor added this to the 4.5.3 milestone Nov 23, 2022
Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@joshuaellis joshuaellis left a comment

Choose a reason for hiding this comment

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

This brings me a lot of joy 🙇🏼‍♀️

@markkaylor markkaylor merged commit 94cd474 into main Nov 23, 2022
@markkaylor markkaylor deleted the chore/refactor-edit-view branch November 23, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:content-manager Source is core/content-manager package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants