-
Notifications
You must be signed in to change notification settings - Fork 973
Refactors TabPage and TabPages into redux #9414
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.
Likely not caused by this PR, but I did discover a bug.
- Have two tab pages
- In tab page 1, mute one of the two videos
- Switch to tab page 2
- Right click tab page indicator, pick "Mute Tabs"
- Notice that the mute for tabs is toggled, not set to false
- Picking unmute seems to work fine
update: captured with #9464
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.
Left a comment regarding adding one unit test (for TabPages, the page count). Other properties being tested is welcomed too 😄
Test plan worked, other than the mute/unmute scenario I noted. I'll capture a separate issue for that (or if it exists, +1 it)
const sourceDragData = dndData.getDragData(e.dataTransfer, dragTypes.TAB) | ||
const sourceDragFromPageIndex = this.props.sourceDragFromPageIndex | ||
// This must be executed async because the state change that this causes | ||
// will cause the onDragEnd to never run | ||
setTimeout(() => { | ||
// If we're moving to a right page, then we're already shifting everything to the left by one, so we want | ||
// to drop it on the right. | ||
windowActions.moveTab(sourceDragData.get('key'), moveToFrame.get('key'), | ||
windowActions.moveTab(sourceDragData.get('key'), this.props.moveToFrameKey, |
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.
Should we still be using windowActions / frameKey? I think it would make more sense to use appAction / tabId
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.
Although, that change might be quite a bit larger. I'd be OK with us doing that later 😄
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.
Yeah when I am doing refactors I try to keep it as close as possible, because this way we are less error prone and we will have a few more iterations of redux components anyway when we will start moving into apps state (state helpers)
const tabsPerPage = Number(getSetting(settings.TABS_PER_PAGE)) | ||
|
||
const props = {} | ||
props.tabPageCount = Math.ceil(frames.size / tabsPerPage) |
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 this but put into a property? that way we can unit test it 😄
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 mean into function?
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.
@NejcZdovc yeah- basically the ES6 classes have "properties" when they're exposed using a getter. Like:
class TabPage extends React.Component {
//..
get tabPageCount () {
return Math.ceil(this.frames.size / this.tabsPerPage)
}
//..
versus a typical method or function
class TabPage extends React.Component {
//..
tabPageCount () {}
}
function tabPageCount() {}
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.
Getters are very easy to test using Enzyme 😄
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.
Problem is that you can't use getter in mergeProps, because you don't have access to the component. So what we can do is create helper in util file
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.
ahh that's right! I had forgotten 😄 I saw you use getters in #9413, but I now see those are in render
. Util function would be great 😄
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.
Yes you can use getters for html content so that renderer is not that big, but one thing that you need to be carful is that you always trigger re-render when needed. That means that you shouldn't do any calculation inside the getter that can change getter return.
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.
Moved into util file and added unit tests
Resolves brave#9339 Auditors: @bsclifton @bridiver Test Plan: - try to open enaugh tabs to trigger tab page (default is 20) - see if audio indicator is displayed if you have video playing in tab page - check if you can close tab page
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.
Huge thanks for adding the tests 😄 👍 Changes look great
Test Plan
Description
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #9339
Auditors: @bsclifton @bridiver
Reviewer Checklist: