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

Code Cleanup: Enforce Linting Rules & Update UNSAFE_ React Lifecycle Events #559

Merged
merged 33 commits into from Jun 4, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
75b0091
add linting for no-param-reassign and fix resulting linting errors
IAmThePan Apr 29, 2020
8d37082
add linting for prefer-object-spread and fix resulting linting errors
IAmThePan Apr 29, 2020
3049bd1
add linting for no-restricted-syntax and fix 1/2 of resulting errors
IAmThePan May 1, 2020
fe03ad7
add linting for no-prototype-builtins and fix resulting linting errors
IAmThePan May 4, 2020
f11bc18
add linting for class-methods-use-this and fix most resulting errors.…
IAmThePan May 5, 2020
5f3471e
finish linting for class-methods-use-this
IAmThePan May 6, 2020
d4d84dc
add linting for no-mixed-operators and fix resulting linting errors
IAmThePan May 6, 2020
17f90ed
add linting for import/prefer-default-export and fix resulting lintin…
IAmThePan May 8, 2020
a77cd1b
add linting for react/no-access-state-in-setstate and fix resulting l…
IAmThePan May 8, 2020
c31dbaf
add linting for react/jsx-props-no-spreading and fix resulting lintin…
IAmThePan May 11, 2020
3d50aff
finish linting errors for no-restricted-syntax. 1 remains: couldn't r…
IAmThePan May 12, 2020
227d012
Merge branch 'develop' into feature/update-linter
IAmThePan May 12, 2020
0988a29
Fix linting errors resulting from the merge with develop
IAmThePan May 12, 2020
b55be21
Refactor UNSAFE_componentWillMount into either constructor or compone…
IAmThePan May 14, 2020
241747c
Refactor UNSAFE_componentWillReceiveProps to componentDidUpdate or ge…
IAmThePan May 18, 2020
eb413fb
re-enable lint exception for no-prototype-builtins and revert calls b…
IAmThePan May 20, 2020
ac0ec93
add single line exception for no-restricted-syntax linting rule
IAmThePan May 20, 2020
fd954eb
add linting for react/destructuring-assignment and fix errors. ToDo: …
IAmThePan May 21, 2020
e815546
Fix minor bugs
IAmThePan May 22, 2020
ae8ffcc
Fix General Settings last updated text
IAmThePan May 22, 2020
4c56460
rework linting rule no-param-reassign to have more exceptions and par…
IAmThePan May 23, 2020
c5ef663
Remove file and line linting exceptions.
IAmThePan May 26, 2020
3ca2402
re-add linting rule react/sort-comp and fix resulting errors
IAmThePan May 26, 2020
4533fd7
remove added linting exception consistent-return and fix resulting er…
IAmThePan May 26, 2020
590aa60
remove added linting expression no-use-before-define and fix resultin…
IAmThePan May 26, 2020
ecb62e8
Fix linting error
IAmThePan May 26, 2020
f634c1d
fix minor bugs
IAmThePan May 26, 2020
ea51432
Code cleanup: fix PromoModal imports
IAmThePan May 26, 2020
75a88cb
Merge with develop. Fix resulting linting errors
IAmThePan May 26, 2020
68493d2
remove unnecessary hasOwnProperty calls after refactored for...in loops
IAmThePan May 28, 2020
6297062
Fix missing strings bug
IAmThePan May 28, 2020
9b4d16c
Fix last remaining string bug
IAmThePan May 28, 2020
2cb47a1
Merge branch 'develop' into feature/cleanup
IAmThePan Jun 4, 2020
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Merge with develop. Fix resulting linting errors

  • Loading branch information
IAmThePan committed May 26, 2020
commit 75a88cbce72ef843d6ebb1847e3385d618ccac88
@@ -108,7 +108,8 @@ class HomeViewContainer extends Component {
_render() {
const { justInstalled } = this.state;
const { home, user } = this.props;
const isPlus = (user && user.subscriptionsPlus) || false;
const isPlus = (user && user.plusAccess) || false;
const isPremium = (user && user.premiumAccess) || false;
const {
premium_promo_modal_shown,
setup_complete,
@@ -47,7 +47,7 @@ class PlusViewContainer extends Component {
const { user } = this.props;
return (
<PlusView
isPlus={(user && user.subscriptionsPlus) || false}
isPlus={(user && user.plusAccess) || false}
onPlusClick={this._sendPlusPing}
/>
);
@@ -73,7 +73,7 @@ class Detail extends React.Component {
* @return {ReactComponent} ReactComponent instance
*/
render() {
const { is_expanded, history, user } = this.props;
const { is_expanded, user, history } = this.props;
const condensedToggleClassNames = ClassNames('condensed-toggle', {
condensed: is_expanded,
});
@@ -94,7 +94,7 @@ class Detail extends React.Component {
<Route path="/detail/rewards" render={this.RewardsComponent} />
<DetailMenu
hasReward={false}
subscriptionsPlus={user && user.subscriptionsPlus}
plusAccess={user && user.plusAccess}
activeTab={activeTab}
/>
</div>
@@ -155,8 +155,9 @@ class Header extends React.Component {
const { history } = this.props;
sendMessage('ping', 'plus_panel_from_badge');
const { user } = this.props;
const subscriber = user && user.subscriptionsPlus;
history.push(subscriber ? '/subscription/info' : `/subscribe/${!!user}`);
const hasPlusAccess = user && user.plusAccess;
const hasPremiumAccess = user && user.premiumAccess;
history.push(hasPlusAccess || hasPremiumAccess ? '/subscription/info' : `/subscribe/${!!user}`);
}

/**
@@ -155,11 +155,11 @@ class HeaderMenu extends React.Component {
*/
clickSubscriber = () => {
const {
history, toggleDropdown, subscriber, loggedIn
history, hasPremiumAccess, hasPlusAccess, toggleDropdown
} = this.props;
sendMessage('ping', 'plus_panel_from_menu');
toggleDropdown();
history.push(subscriber ? '/subscription/info' : `/subscribe/${loggedIn}`);
history.push(hasPlusAccess || hasPremiumAccess ? '/subscription/info' : '/subscribe/false');
}

/**
@@ -168,10 +168,21 @@ class HeaderMenu extends React.Component {
*/
render() {
const {
loggedIn, email, subscriber, kebab
loggedIn,
email,
hasPremiumAccess,
hasPlusAccess,
kebab
} = this.props;
const optionClasses = ClassNames({ 'menu-option': subscriber, 'menu-option-non-subscriber': !subscriber });
const iconClasses = ClassNames('menu-icon-container', { subscriber }, { 'non-subscriber': !subscriber });
const optionClasses = ClassNames({
'menu-option': hasPlusAccess || hasPremiumAccess,
'menu-option-non-subscriber': !(hasPlusAccess || hasPremiumAccess)
});
const iconClasses = ClassNames('menu-icon-container', {
premium: hasPremiumAccess,
plus: !hasPremiumAccess && hasPlusAccess,
'non-subscriber': !(hasPremiumAccess || hasPlusAccess)
});
return (
<ClickOutside onClickOutside={this.handleClickOutside} excludeEl={kebab}>
<div ref={(node) => { this.node = node; }} className="dropdown-pane" id="header-dropdown">
@@ -31,7 +31,7 @@ class Stats extends React.Component {
*/
componentDidMount() {
sendMessage('ping', 'hist_stats_panel');
if (!this._isPlus(this.props)) {
if (!this._hasPlusAccess(this.props)) {
this.setState(this._reset(true));
return;
}
@@ -42,8 +42,8 @@ class Stats extends React.Component {
* Lifecycle event
*/
componentDidUpdate(prevProps) {
const thisPlus = this._isPlus(this.props);
const prevPlus = this._isPlus(prevProps);
const thisPlus = this._hasPlusAccess(this.props);
const prevPlus = this._hasPlusAccess(prevProps);
if (thisPlus !== prevPlus) {
if (thisPlus) {
this._init();
@@ -334,7 +334,7 @@ class Stats extends React.Component {
monthlyAverageData: clearData,
dailyAverageData: clearData,
showResetModal: false,
showPitchModal: (!user || !user.subscriptionsPlus),
showPitchModal: (!user || !user.plusAccess),
};
return clearOrDemoState;
}
@@ -38,7 +38,7 @@ function _handleManageClick() {
*/
const SubscriptionInfo = ({ subscriptionData }) => {
const {
active, plan_amount, plan_interval, charge_date, plan_ends, loading
productName, active, plan_amount, plan_interval, charge_date, plan_ends, loading
} = subscriptionData;
const subscriptionExpiration = (plan_ends > 1) ? t('subscription_days_left', plan_ends.toString()) : t('subscription_one_day_left');
return (
@@ -263,7 +263,7 @@ class Summary extends React.Component {
const { history, user } = this.props;
sendMessage('ping', 'plus_panel_from_badge');

history.push(this._isPlusSubscriber() ? '/subscription/info' : `/subscribe/${!!user}`);
history.push(this._hasPremiumAccess() || this._hasPlusAccess() ? '/subscription/info' : `/subscribe/${!!user}`);
}

/**
@@ -891,7 +891,7 @@ function onMessageHandler(request, sender, callback) {
.then((foundUser) => {
const user = { user: { ...foundUser } };
if (foundUser) {
user.user.subscriptionsPlus = account.hasScopesUnverified(['subscriptions:plus']);
user.user.premiumAccess = account.hasScopesUnverified(['subscriptions:premium']);
This conversation was marked as resolved by wlycdgr

This comment has been minimized.

@wlycdgr

wlycdgr Jun 11, 2020
Member

What about plusAccess, did you mean to delete that?

This comment has been minimized.

@IAmThePan

IAmThePan Jun 12, 2020
Author Contributor

Nice catch. No I did not mean to delete that. It got removed with a merge I did.

Added back on feature/cleanup-cleanup

This comment has been minimized.

@wlycdgr

wlycdgr Jun 15, 2020
Member

Cool beans

}
callback(user);
})
You are viewing a condensed version of this merge commit. You can view the full changes here.
ProTip! Use n and p to navigate between commits in a pull request.