-
Notifications
You must be signed in to change notification settings - Fork 974
Conversation
3e38b43
to
3b0dd8d
Compare
blocked by #8238 |
820518d
to
8d07cee
Compare
74b26a1
to
7168987
Compare
8d07cee
to
fb31a99
Compare
f29bc26
to
a5aeadf
Compare
a5aeadf
to
c6206a9
Compare
e509fd2
to
cd44019
Compare
dc3207d
to
e18f46d
Compare
@bsclifton @bridiver @bbondy unit test is still failing, but we need to review this and merge it, otherwise merge conflicts will start popping up. There is still room for improvements, but would like to do it multiple steps. This PR implemented redux component and simplify as much as possible. Next PR should be focused on simplifying actions, because right now we are sending all frameProps or all settings instead of only things that we need in the store/reducers. When that PR is in we could continue with Frame simplification. Unit test problem |
sorry for stepping in but if you have several PRs expecting I think you are expected to work on another base branch like |
@luixxiul thank you for feedback. I understand that and I added label for a review only today. I don't expect or demand from them to do it today 😃. All three of them already helped me a lot on this PR, for which I am really grateful. Why I think we can't go with a base branch is that things couldn't be merged after redux is done. There would be to much mess and conflicts. What we are doing with redux components and moving things into state is a new way of writing components. Because of that some things are not compatible and we will change a lot functions and how they are called. And if we don't merge this on a frequent basis, other developers would adding code that will be then removed for example or using functions that are not valid anymore. This way they will waste time writing an old code. Because of that we wanted to approach this redux refactoring with small PR's and not doing everything in one big swing. @bridiver did already a lot of amazing work for url bar (changing to redux and optimizing things) and it's in master already. This way developers can start using this new approach faster. For test's I didn't add any specific one (except for my new code for the state), because we already have test's for frames and with this PR I didn't implement any new feature, just move things around and implement redux. |
e18f46d
to
bde4204
Compare
Sometimes even doing so would cause troubles (slow performance etc.). If you improve something with this PR would you mind adding a manual test plan even if it would be a tiny one? like:
Otherwise more simply: |
@@ -3,20 +3,34 @@ | |||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
|
|||
const React = require('react') | |||
const ImmutableComponent = require('../immutableComponent') | |||
const {StyleSheet, css} = require('aphrodite') |
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't it be aphrodite/no-important?
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.
@luixxiul not sure, we need to ask @bsclifton about this code, I just reordered imports.
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.
@luixxiul maybe? we could do that, but it would require testing. I would vote to leave it as is. IMO, using no-important
takes away the benefit we get by using Aphrodite.
We introduced Aphrodite to our code base because we were getting destroyed by regressions and the goal (I thought) was to make styles NOT overridable. When it's no-important
, styles might be overridden (which can cause regression).
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.
OK, I understand. I proposed it so we could remove styles in the existing LESS files at the same time. It is fine to replace them with later.
Otherwise: I'm thinking we would set no-important
to the general components (such as ones in common
folder) and not to other specific ones, considering the possibility of removing !important from everything.
That means:
aphrodite
for files inapp/renderer/components/
such asreleaseNotes.js
aphrodite/no-important
for files inapp/renderer/components/common/
such asdropdown.js
What do you guys think? @bsclifton @cezaraugusto @NejcZdovc. By doing so we could avoid overwriting !important
with !important
, which is obviously not a good habit on CSS.
The thing is that I noticed that it seemed to be impossible to cascade styles with cx
as we usually do with CSS, which I noticed during refactoring modalOverlay.js
and paymentTab.js
. eg:
<div className={cx({
[modalOverlay__generalHeaderStyles]: true,
[css(styles.modalOverlay__paymentHistoryHeaderStyles)]: true
})}
I thought that kind of styling should work, overwriting the styles specified with modalOverlay__generalHeaderStyles
, but I could not find the proper way, instead of creating another wrapper div
for that div
. If any, please let me know. @bsclifton @cezaraugusto @NejcZdovc
We could discuss the thing on another issue if you wish.
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.
I think I need to understand more about Aphrodite and the use cases for this (I think I'm missing something). Let's definitely chat more about 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.
yep per @luixxiul example, Aphrodite will concatenate styles and the last would take precedence. I think that doesn't happen with cx
but definitely happen with standard css(style1, style2)
.
I'm against !important
whenever possible. I would compare it to JS eval()
, it takes precedence whenever it's defined, and that's a bad pattern. It's a feature that might be useful for some edge-cases until we aren't using Aphrodite 100% but long term we should avoid.
For new components, !important
is a no-op but this is a huge PR and if that was previously defined we should keep it as-is. As we head closer to 1.0 we should avoid re-work and reduce regression risk at all costs. However, wouldn't mind reviewing a follow-up removing that, but for this PR I think we are fine with what we have.
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.
I think that doesn't happen with
cx
Can we improve it to support cascading styles?
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.
cx()
is just a lib to apply styles conditionally, so it's affected by the same rules as CSS like deeply nested selectors taking precedence, and !important
which overrides everything.
I don't think there's anything we can do with that but just avoid adding new LESS stuff and keep using until it can be removed.
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.
@cezaraugusto I understand how !important
can be viewed negatively like eval(). However, until we're fully switched over, I can see having !important
be a great way to prevent regressions. When we get close to 100% Aphrodite, then you just switch aphrodite
=> aphrodite/no-important
😄
All that said, we've done an amazing job with our styles since introducing Aphrodite. Before (2016), we were always fighting regressions. Now, we rarely have them (if ever), even with no-important
. I fully support whatever makes the most sense 😄
@luixxiul sure I can do this, not a problem. And I agree completely with you. |
bde4204
to
1b1998f
Compare
@NejcZdovc please make sure to add test steps to the 1st post for fixes of these fails on travis: https://travis-ci.org/brave/browser-laptop/jobs/226054730#L2461 |
1b1998f
to
54f34ef
Compare
dd129e1
to
16dd2a3
Compare
After discussion with @bsclifton unit test was disabled for frame for now. We will address issue of fixing unit tests for redux components in a different PR. We will track all this problems in #8528 |
app/common/state/siteState.js
Outdated
@@ -0,0 +1,18 @@ | |||
const assert = require('assert') | |||
const { makeImmutable, isMap, isList } = require('./immutableUtil') |
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.
nitpick- I don't think it's documented anywhere, but we don't have spaces when doing destructuring in most of our code. So it could look like this instead:
const {makeImmutable, isMap, isList} = require('./immutableUtil')
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.
Fixed
Resovles brave#8392 Auditors: @bridiver @bbondy Test plan: - test should be green
16dd2a3
to
913813f
Compare
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 PR! Great work on this 😄
We still need to revisit the tests for frame. I tried a few things and didn't have much luck. I believe you created an issue to track the need to fix the tests (but if not let's make sure there is one)
numberOfMatches: -1, | ||
activeMatchOrdinal: 0 | ||
})) | ||
frameStateUtil.onFindBarHide(activeFrame.get('key')) |
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.
nice cleanup 👍
@@ -3,20 +3,34 @@ | |||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
|
|||
const React = require('react') | |||
const ImmutableComponent = require('../immutableComponent') | |||
const {StyleSheet, css} = require('aphrodite') |
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.
@cezaraugusto I understand how !important
can be viewed negatively like eval(). However, until we're fully switched over, I can see having !important
be a great way to prevent regressions. When we get close to 100% Aphrodite, then you just switch aphrodite
=> aphrodite/no-important
😄
All that said, we've done an amazing job with our styles since introducing Aphrodite. Before (2016), we were always fighting regressions. Now, we rarely have them (if ever), even with no-important
. I fully support whatever makes the most sense 😄
@@ -0,0 +1,7 @@ | |||
module.exports.createWebView = () => { |
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.
this is awesome- great use of a util. People might think it's silly having this, but it makes mocking VERY easy 😄 👍
enableNoScript={siteSettingsState.isNoScriptEnabled(this.props.appState, this.frameSiteSettings(frame.get('location')))} | ||
braveryDefaults={braveryDefaults} | ||
isPreview={frame.get('key') === this.props.windowState.get('previewFrameKey')} | ||
isActive={frameStateUtil.isFrameKeyActive(this.props.windowState, frame.get('key'))} | ||
/>) |
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.
Bye bye code! 🗑
😄
I will merge this. If we find some more improvements, we can do follow up later on. I need this PR merged so that I can continue with work on #8651. @bsclifton I added note about unit test in #8528. |
Perfect, thanks @NejcZdovc 😄 |
git rebase -i
to squash commits (if needed).Resolves #8392
Test Plan:
test that the browser starts normally