Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Refactor of paymentTab #7481

Merged
merged 1 commit into from
Mar 12, 2017
Merged

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Mar 3, 2017

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Resolves #7501

Auditors

@bsclifton @cezaraugusto

Test plan

Everything should be the same as was before the change

@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch from 6bc57e5 to 1f9d193 Compare March 3, 2017 17:26
@NejcZdovc NejcZdovc self-assigned this Mar 4, 2017
@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch 5 times, most recently from d0d903e to cd94b65 Compare March 4, 2017 22:59
@NejcZdovc NejcZdovc added this to the 0.13.6 milestone Mar 4, 2017
@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Mar 4, 2017

Open questions:

  • do we need to translate this?
  • should I add aphrodite for ModalOverlay in this PR or create a separate PR. I changed a lot of things in this PR already
  • how to fix this mock problem with png images
Preferences component "before all" hook:
     SyntaxError: app/extensions/brave/img/private_internet_access.png: Unexpected character '�' (1:0)

And I will squash after reviews are done, so that it's easier to track changes when reviewing.

cc @bsclifton @cezaraugusto

@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch 3 times, most recently from 6a2d73e to b4ae95e Compare March 5, 2017 12:50
@NejcZdovc
Copy link
Contributor Author

Question number 3 was solved with @bsclifton help. We only have two more 😃

@cezaraugusto
Copy link
Contributor

About #7481 (comment):

  1. Yes, not necessarily on this PR if you don't want but as a follow-up definitely
  2. I think this PR addressed several components and we can move that for another PR

@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch 2 times, most recently from 3e8cfe1 to 47e03f8 Compare March 8, 2017 10:16
@NejcZdovc NejcZdovc mentioned this pull request Mar 8, 2017
4 tasks
@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Mar 8, 2017

@cezaraugusto I agree. I added translations and we should leave ModalOverlay for another PR. All questions answered.

@NejcZdovc NejcZdovc mentioned this pull request Mar 8, 2017
4 tasks
@luixxiul
Copy link
Contributor

luixxiul commented Mar 8, 2017

@cezaraugusto
Copy link
Contributor

needs rebase.

@NejcZdovc how doable it is to split each refactored/moved component in its own PR? This way we can speed-up code review and reduce regression risks.

@cezaraugusto
Copy link
Contributor

If you do please open an issue as tracking reference, similar to #7380

@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Mar 11, 2017

If it's ok with you I would rebase it after I squash it, otherwise merge mistake is quite possible, because I created 14 commits. I presume that there will be more conflicts, because it will take some time to review it and new changes will land in the master. If you don't need multiple commits for easier review, I can squash it right now.

I think it would take too time consuming to split it now. I started really slow and small, but things are so connected (to do big changes) that I end up with one big PR. Sorry about that.

@cezaraugusto
Copy link
Contributor

ok np, just fix conflict/squash and we can start reviewing

@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch from 81a36a2 to 90f2314 Compare March 11, 2017 18:44
@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented Mar 11, 2017

@cezaraugusto conflict resolved, you can start with the review


// style
const globalStyles = require('../../styles/global')
const paymentStyles = require('../../styles/payment')
Copy link
Contributor

Choose a reason for hiding this comment

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

super ++

Copy link
Member

Choose a reason for hiding this comment

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

❤️

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a typo on file name: advanceSettings -> advancedSettings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++

minimumPageTimeHigh=1 minute
minimumVisitsLow=1 visit
minimumVisitsMedium=5 visits
minimumVisitsHigh=10 visits
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for this

Copy link
Member

Choose a reason for hiding this comment

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

++!

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

Feedback left, great job 😄 This has some really nice cleanup which makes both maintaining the code and testing easier

Ping me once you've addressed the feedback by Cezar and I and we can squash + merge 😄

@@ -39,3 +40,41 @@ module.exports.shouldTrackView = (view, responseList) => {
}
return false
}

module.exports.btcToCurrencyString = (btc, ledgerData) => {
Copy link
Member

Choose a reason for hiding this comment

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

Awesome! thanks for pulling this out- will make testing easy

const minDuration = this.props.ledgerData.getIn(['synopsisOptions', 'minDuration'])
const minPublisherVisits = this.props.ledgerData.getIn(['synopsisOptions', 'minPublisherVisits'])

// TODO translate seconds, minute and visits
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this TODO since you put it into the preferences.properties 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

} else if (ledgerData.get('created')) {
const transactions = ledgerData.get('transactions')
const pendingFunds = Number(ledgerData.get('unconfirmed') || 0)

Copy link
Member

Choose a reason for hiding this comment

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

This entire method (walletStatus) could benefit from moving over to ledgerUtil 😄 (it would need to be reworked to take ledgerData as input). That would also make mocking it easier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved

}
}
}

.bitcoinDashboard {
Copy link
Member

Choose a reason for hiding this comment

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

Love seeing all this LESS being deleted 😄

}
}

// TODO check what to remove
Copy link
Member

Choose a reason for hiding this comment

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

Was there more that needed to be removed? or did you need to test anything which had been removed so far?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a left over

mockery.registerMock('../../../../extensions/brave/img/coinbase_2x.png')
mockery.registerMock('../../../../extensions/brave/img/coinbase_logo.png')
mockery.registerMock('../../../../extensions/brave/img/android_download.svg')
mockery.registerMock('../../../../extensions/brave/img/ios_download.svg')
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@cezaraugusto cezaraugusto 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 for all the hard-work. Bold - and very welcome - changes.

I left some comments and the only blocker is the crash of secondary key on ledger recovery.

@@ -0,0 +1,148 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a typo on file name -> advanceSettings/advancedSettings. This is replicated although the changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bsclifton fixed this

/>
<div className={css(styles.keyContainer)}>
<h3 className={css(styles.keyContainer__h3)} data-l10n-id='secondKey' />
<span className={css(styles.keyContainer__span)}>{passphrase}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

app crashes if I try to copy key 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, it's not crashing for me. Can you please provide some reproduction steps?

Copy link
Contributor

Choose a reason for hiding this comment

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

STR:

  1. Clear profile
  2. Enable payments
  3. Go to advanced settings
  4. Click backup your wallet
  5. Key 2 doesn't exist
  6. Try to copy key 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this steps, but key 2 exists for me and copy is working as well. So the problem is not in a copy but in fact that key 2 doesn't exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed on a Slack, this is specific to one ledger-state.json file and I can't reproduce it with my ledger or on fresh profile, so I think this is not related to this PR

}

return <div className={css(styles.historyFooter)}>
<div className={css(styles.nextPayement)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

return <div {...props}>
<SwitchControl id={this.props.prefKey}
small={this.props.small}
disabled={this.props.disabled}
onClick={this.onClick}
checkedOn={this.props.checked !== undefined ? this.props.checked : getSetting(this.props.prefKey, this.props.settings)} />
<label className={css(this.props.small && settingCheckboxStyles.label)} data-l10n-id={this.props.dataL10nId} htmlFor={this.props.prefKey} />
checkedOn={this.props.checked !== undefined ? this.props.checked : getSetting(this.props.prefKey, this.props.settings)}
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) can you stringify undefined to 'undefined'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would we want to compare it as a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant to typeof this.props.checked !== 'undefined', but doesn't matter result is the same, let's keep as-is, sorry

@@ -85,224 +83,6 @@ const braveryPermissionNames = {
'noScript': ['boolean', 'number']
}

class BitcoinDashboard extends ImmutableComponent {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you didn't yet, please reference that PR also closes #7380

Copy link
Contributor Author

Choose a reason for hiding this comment

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

f375451 it's already in


.nextReconcileDate {
margin-bottom: 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

YESSSS

The lesser the LESS, the less™

Resolves brave#7501 brave#7380 brave#6364

Auditors: @bsclifton @cezaraugusto

Test plan:
- everything should work the same as was before the chage
@NejcZdovc NejcZdovc force-pushed the feature/#7348-refactor branch from e0d5db1 to 405efe5 Compare March 12, 2017 17:45
@NejcZdovc
Copy link
Contributor Author

@cezaraugusto @bsclifton Fixed everything that was found in the review process. PR is also squashed now. Can you please do a final review?

Copy link
Contributor

@cezaraugusto cezaraugusto 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, thanks

@cezaraugusto cezaraugusto merged commit 0bfceeb into brave:master Mar 12, 2017
@bsclifton
Copy link
Member

++ great work, @NejcZdovc! Thanks for taking the time to review in detail too, @cezaraugusto 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants