Page MenuHomePhabricator

[web] Make NavigationPanel reusable
ClosedPublic

Authored by tomek on Mar 4 2022, 8:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 15, 5:17 AM
Unknown Object (File)
Tue, Nov 5, 9:44 PM
Unknown Object (File)
Sun, Nov 3, 1:22 PM
Unknown Object (File)
Oct 14 2024, 2:19 AM
Unknown Object (File)
Oct 14 2024, 2:19 AM
Unknown Object (File)
Oct 14 2024, 2:19 AM
Unknown Object (File)
Oct 14 2024, 2:19 AM
Unknown Object (File)
Oct 14 2024, 2:19 AM

Details

Summary

The final diff of NavigationPanel refactoring. NavigationPanel receives a list of items and renders them. AppSwitcher provides a list with available apps.
Depends on D3340

Test Plan

Check if AppSwitcher still works correctly

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Most of the code is just moved from navigation-panel to app-switcher. I'm marking all the code that is more than a simple move. Code which currently is located in navigation-panel is new.

web/sidebar/app-switcher.react.js
74–95 ↗(On Diff #10083)

These were rendered by navigation-panel. They we're extracted from there and wrapped by memo.

97–106 ↗(On Diff #10083)

Here we're constructing a list of navigation items. This is a new code.

web/sidebar/left-layout-aside.css
60–65 ↗(On Diff #10083)

We need to have high specificity here, so that this overrides .container colors. Now we apply the classes to li instead of p.

tomek requested review of this revision.Mar 4 2022, 8:28 AM
benschac added inline comments.
web/sidebar/app-switcher.react.js
29 ↗(On Diff #10083)

nit / general comment: We use this selector quite a bit, could be worth turning into it's own selector.

Image 2022-03-07 at 10.00.40 AM.jpg (1×1 px, 242 KB)

This revision is now accepted and ready to land.Mar 7 2022, 7:30 AM
web/sidebar/app-switcher.react.js
29 ↗(On Diff #10083)

I think there are a couple of selectors that are duplicated throughout the codebase. I created a task to track improving it https://linear.app/comm/issue/ENG-844/extract-commonly-used-selectors-to-a-common-place

Looks good to me, added a few comments inline.

Adding @ashoat as blocking reviewer on this one to be safe since this diff touches a lot.

web/sidebar/app-switcher.react.js
22 ↗(On Diff #10083)

nit: maybe mostRecentlyReadThread?

23 ↗(On Diff #10083)

nit: thoughts on naming this to something like isActiveThreadCurrentlyUnread?

68 ↗(On Diff #10083)

I think we usually include the name of the variable in the invariant message?

81 ↗(On Diff #10083)

I address this in a later diff, but we should increase the click area from just the "Chat" text to include the icon and surrounding area.

Doesn't need to be addressed in this diff, just wanted to flag it

This revision now requires review to proceed.Mar 8 2022, 9:08 AM
ashoat added inline comments.
web/sidebar/navigation-panel.react.js
11–14 ↗(On Diff #10083)

I think it would be more idiomatic for this to be children, so it would look something like this:

<NavigationPanel.Container>
  <NavigationPanel.Item tab="chat">
    {chatNavigationItem}>
  </NavigationPanel.Item>
  <NavigationPanel.Item tab="calendar">
    {calendarNavigationItem}>
  </NavigationPanel.Item>
</NavigationPanel.Container>
This revision is now accepted and ready to land.Mar 8 2022, 10:59 AM
web/sidebar/app-switcher.react.js
22 ↗(On Diff #10083)

This diff was only moving this code, but I agree with these suggestions - going to open a new diff after this one so that the complexity of this diff doesn't increase

81 ↗(On Diff #10083)

Thanks for the info. Yeah, I agree it was a good move

web/sidebar/navigation-panel.react.js
11–14 ↗(On Diff #10083)

Makes sense - I'll try to modify this diff with the suggested approach

Rebase and use children. All the renames will be made as a next diff.

tomek requested review of this revision.Mar 9 2022, 8:52 AM
tomek added inline comments.
web/sidebar/app-switcher.react.js
129–135 ↗(On Diff #10227)

I've chosen this approach instead of <NavigationPanel.Item> here so that a calendar that is rendered conditionally can be cleanly expressed. But I'm still open to move NavigationPanel.Items to this return - something like in the suggestion

web/sidebar/app-switcher.react.js
22 ↗(On Diff #10083)

Addressed in D3387

23 ↗(On Diff #10083)

Addressed in D3388

68 ↗(On Diff #10083)

Addressed in D3388. I realized we don't need this invariant as we're not using the viewerID - deleted that variable.

Looks great!

web/sidebar/navigation-panel.react.js
17 ↗(On Diff #10227)

Why is it necessary to wrap in a React.Fragment?

This revision is now accepted and ready to land.Mar 10 2022, 8:01 PM
web/sidebar/navigation-panel.react.js
17 ↗(On Diff #10227)

Good point. It isn't necessary - will update the diff with return children.

Return childrent without wrapping in fragment