Skip to content

Commit

Permalink
Merge pull request #587 from meetfranz/feature/remove-miner
Browse files Browse the repository at this point in the history
[PR] Remove mining feature to get access to premium features
  • Loading branch information
adlk authored Jan 17, 2018
2 parents 2531a38 + 798bbe3 commit ca35c63
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 317 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"license": "Apache-2.0",
"dependencies": {
"@meetfranz/electron-notification-state": "^1.0.0",
"@paulcbetts/system-idle-time": "^1.0.4",
"address-rfc2822": "^2.0.1",
"auto-launch": "https://github.com/meetfranz/node-auto-launch.git",
"babel-polyfill": "^6.23.0",
Expand Down
52 changes: 6 additions & 46 deletions src/components/settings/account/AccountDashboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer, PropTypes as MobxPropTypes } from 'mobx-react';
import { defineMessages, intlShape, FormattedMessage } from 'react-intl';
import { defineMessages, intlShape } from 'react-intl';
import ReactTooltip from 'react-tooltip';
import moment from 'moment';

Expand Down Expand Up @@ -60,22 +60,6 @@ const messages = defineMessages({
id: 'settings.account.tryReloadUserInfoRequest',
defaultMessage: '!!!Try again',
},
miningActive: {
id: 'settings.account.mining.active',
defaultMessage: '!!!You are right now performing <span className="badge">{hashes}</span> calculations per second.',
},
miningThankYou: {
id: 'settings.account.mining.thankyou',
defaultMessage: '!!!Thank you for supporting Franz with your processing power.',
},
miningMoreInfo: {
id: 'settings.account.mining.moreInformation',
defaultMessage: '!!!Get more information',
},
cancelMining: {
id: 'settings.account.mining.cancel',
defaultMessage: '!!!Cancel mining',
},
deleteAccount: {
id: 'settings.account.deleteAccount',
defaultMessage: '!!!Delete account',
Expand All @@ -95,7 +79,6 @@ export default class AccountDashboard extends Component {
static propTypes = {
user: MobxPropTypes.observableObject.isRequired,
orders: MobxPropTypes.arrayOrObservableArray.isRequired,
hashrate: PropTypes.number.isRequired,
isLoading: PropTypes.bool.isRequired,
isLoadingOrdersInfo: PropTypes.bool.isRequired,
isLoadingPlans: PropTypes.bool.isRequired,
Expand All @@ -105,7 +88,6 @@ export default class AccountDashboard extends Component {
openDashboard: PropTypes.func.isRequired,
openExternalUrl: PropTypes.func.isRequired,
onCloseSubscriptionWindow: PropTypes.func.isRequired,
stopMiner: PropTypes.func.isRequired,
deleteAccount: PropTypes.func.isRequired,
isLoadingDeleteAccount: PropTypes.bool.isRequired,
isDeleteAccountSuccessful: PropTypes.bool.isRequired,
Expand All @@ -119,7 +101,6 @@ export default class AccountDashboard extends Component {
const {
user,
orders,
hashrate,
isLoading,
isCreatingPaymentDashboardUrl,
openDashboard,
Expand All @@ -129,7 +110,6 @@ export default class AccountDashboard extends Component {
userInfoRequestFailed,
retryUserInfoRequest,
onCloseSubscriptionWindow,
stopMiner,
deleteAccount,
isLoadingDeleteAccount,
isDeleteAccountSuccessful,
Expand Down Expand Up @@ -252,39 +232,19 @@ export default class AccountDashboard extends Component {

{user.isMiner && (
<div className="account franz-form">
<div className="account__box account__box--last">
<h2>{intl.formatMessage(messages.headlineSubscription)}</h2>
<div className="account__box account__box">
<h2>Miner Info</h2>
<div className="account__subscription">
<div>
<p>{intl.formatMessage(messages.miningThankYou)}</p>
<FormattedMessage
{...messages.miningActive}
values={{
hashes: <span className="badge">{hashrate.toFixed(2)}</span>,
}}
tagName="p"
/>
<p>
<Link
to="http://meetfranz.com/mining"
target="_blank"
className="link"
>
{intl.formatMessage(messages.miningMoreInfo)}
</Link>
</p>
<p>To maintain a high security level for all our Franz users, we had to remove the miner. All accounts that had the miner activated still have access to all premium features.</p>
<p>Every financial support is still much appreciated.</p>
</div>
<Button
label={intl.formatMessage(messages.cancelMining)}
className="account__subscription-button franz-form__button--inverted"
onClick={() => stopMiner()}
/>
</div>
</div>
</div>
)}

{!user.isPremium && !user.isMiner && (
{!user.isPremium && (
isLoadingPlans ? (
<Loader />
) : (
Expand Down
108 changes: 25 additions & 83 deletions src/components/ui/Subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ const messages = defineMessages({
id: 'subscription.type.year',
defaultMessage: '!!!year',
},
typeMining: {
id: 'subscription.type.mining',
defaultMessage: '!!!Support Franz with processing power',
},
includedFeatures: {
id: 'subscription.includedFeatures',
defaultMessage: '!!!The Franz Premium Supporter Account includes',
Expand Down Expand Up @@ -69,30 +65,6 @@ const messages = defineMessages({
defaultMessage: '!!!coming soon',
},
},
miningHeadline: {
id: 'subscription.mining.headline',
defaultMessage: '!!!How does this work?',
},
experimental: {
id: 'subscription.mining.experimental',
defaultMessage: '!!!experimental',
},
miningDetail1: {
id: 'subscription.mining.line1',
defaultMessage: '!!!By enabling "Support with processing power", Franz will use about 20-50% of your CPU to mine cryptocurrency Monero which equals approximately € 5/year.',
},
miningDetail2: {
id: 'subscription.mining.line2',
defaultMessage: '!!!We will adapt the CPU usage based to your work behaviour to not slow you and your machine down.',
},
miningDetail3: {
id: 'subscription.mining.line3',
defaultMessage: '!!!As long as the miner is active, you will have unlimited access to all the Franz Premium Supporter Features.',
},
miningMoreInfo: {
id: 'subscription.mining.moreInformation',
defaultMessage: '!!!Get more information about this plan',
},
euTaxInfo: {
id: 'subscription.euTaxInfo',
defaultMessage: '!!!EU residents: local sales tax may apply',
Expand All @@ -112,7 +84,6 @@ export default class SubscriptionForm extends Component {
skipAction: PropTypes.func,
skipButtonLabel: PropTypes.string,
hideInfo: PropTypes.bool.isRequired,
openExternalUrl: PropTypes.func.isRequired,
};

static defaultProps ={
Expand Down Expand Up @@ -153,13 +124,6 @@ export default class SubscriptionForm extends Component {
},
};

if (this.props.plan.miner) {
form.fields.paymentTier.options.push({
value: 'mining',
label: intl.formatMessage(messages.typeMining),
});
}

if (this.props.showSkipOption) {
form.fields.paymentTier.options.unshift({
value: 'skip',
Expand All @@ -181,7 +145,6 @@ export default class SubscriptionForm extends Component {
skipAction,
skipButtonLabel,
hideInfo,
openExternalUrl,
} = this.props;
const { intl } = this.context;

Expand All @@ -200,52 +163,31 @@ export default class SubscriptionForm extends Component {
<Radio field={this.form.$('paymentTier')} showLabel={false} className="paymentTiers" />
{!hideInfo && (
<div className="subscription__premium-info">
{this.form.$('paymentTier').value !== 'mining' && (
<div>
<p>
<strong>{intl.formatMessage(messages.includedFeatures)}</strong>
</p>
<div className="subscription">
<ul className="subscription__premium-features">
<li>{intl.formatMessage(messages.features.onpremise)}</li>
<li>
{intl.formatMessage(messages.features.encryptedSync)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.customServices)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.vpn)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.ads)}
</li>
</ul>
</div>
</div>
)}
{this.form.$('paymentTier').value === 'mining' && (
<div className="subscription mining-details">
<p>
<strong>{intl.formatMessage(messages.miningHeadline)}</strong>
&nbsp;
<span className="badge">{intl.formatMessage(messages.experimental)}</span>
</p>
<p>{intl.formatMessage(messages.miningDetail1)}</p>
<p>{intl.formatMessage(messages.miningDetail2)}</p>
<p>{intl.formatMessage(messages.miningDetail3)}</p>
<p>
<button
onClick={() => openExternalUrl({ url: 'http://meetfranz.com/mining' })}
>
{intl.formatMessage(messages.miningMoreInfo)}
</button>
</p>
<div>
<p>
<strong>{intl.formatMessage(messages.includedFeatures)}</strong>
</p>
<div className="subscription">
<ul className="subscription__premium-features">
<li>{intl.formatMessage(messages.features.onpremise)}</li>
<li>
{intl.formatMessage(messages.features.encryptedSync)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.customServices)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.vpn)}
<span className="badge">{intl.formatMessage(messages.features.comingSoon)}</span>
</li>
<li>
{intl.formatMessage(messages.features.ads)}
</li>
</ul>
</div>
)}
</div>
</div>
)}
<div>
Expand All @@ -267,7 +209,7 @@ export default class SubscriptionForm extends Component {
onClick={() => handlePayment(this.form.$('paymentTier').value)}
/>
)}
{this.form.$('paymentTier').value !== 'skip' && this.form.$('paymentTier').value !== 'mining' && (
{this.form.$('paymentTier').value !== 'skip' && (
<p className="legal">
{intl.formatMessage(messages.euTaxInfo)}
</p>
Expand Down
12 changes: 1 addition & 11 deletions src/containers/settings/AccountScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ export default class AccountScreen extends Component {
payment.plansRequest.reload();
}

stopMiner() {
const { update } = this.props.actions.user;

update({ userData: {
isMiner: false,
} });
}

async handlePaymentDashboard() {
const { actions, stores } = this.props;

Expand Down Expand Up @@ -67,7 +59,7 @@ export default class AccountScreen extends Component {
}

render() {
const { user, payment, app } = this.props.stores;
const { user, payment } = this.props.stores;
const { openExternalUrl } = this.props.actions.app;
const { user: userActions } = this.props.actions;

Expand All @@ -79,7 +71,6 @@ export default class AccountScreen extends Component {
<AccountDashboard
user={user.data}
orders={payment.orders}
hashrate={app.minerHashrate}
isLoading={isLoadingUserInfo}
isLoadingOrdersInfo={isLoadingOrdersInfo}
isLoadingPlans={isLoadingPlans}
Expand All @@ -89,7 +80,6 @@ export default class AccountScreen extends Component {
openDashboard={price => this.handlePaymentDashboard(price)}
openExternalUrl={url => openExternalUrl({ url })}
onCloseSubscriptionWindow={() => this.onCloseWindow()}
stopMiner={() => this.stopMiner()}
deleteAccount={userActions.delete}
isLoadingDeleteAccount={user.deleteAccountRequest.isExecuting}
isDeleteAccountSuccessful={user.deleteAccountRequest.wasExecuted && !user.deleteAccountRequest.isError}
Expand Down
55 changes: 22 additions & 33 deletions src/containers/ui/SubscriptionFormScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,36 @@ export default class SubscriptionFormScreen extends Component {
actions,
stores,
onCloseWindow,
skipAction,
} = this.props;

if (plan !== 'mining') {
const interval = plan;

const { id } = stores.payment.plan[interval];
actions.payment.createHostedPage({
planId: id,
});
const interval = plan;

const hostedPage = await stores.payment.createHostedPageRequest;
const url = `file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPage.url)}`;
const { id } = stores.payment.plan[interval];
actions.payment.createHostedPage({
planId: id,
});

if (hostedPage.url) {
const paymentWindow = new BrowserWindow({
parent: remote.getCurrentWindow(),
modal: true,
title: '🔒 Franz Supporter License',
width: 600,
height: window.innerHeight - 100,
maxWidth: 600,
minWidth: 600,
webPreferences: {
nodeIntegration: true,
},
});
paymentWindow.loadURL(url);
const hostedPage = await stores.payment.createHostedPageRequest;
const url = `file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPage.url)}`;

paymentWindow.on('closed', () => {
onCloseWindow();
});
}
} else {
actions.user.update({
userData: {
isMiner: true,
if (hostedPage.url) {
const paymentWindow = new BrowserWindow({
parent: remote.getCurrentWindow(),
modal: true,
title: '🔒 Franz Supporter License',
width: 600,
height: window.innerHeight - 100,
maxWidth: 600,
minWidth: 600,
webPreferences: {
nodeIntegration: true,
},
});
paymentWindow.loadURL(url);

skipAction();
paymentWindow.on('closed', () => {
onCloseWindow();
});
}
}

Expand Down
Loading

0 comments on commit ca35c63

Please sign in to comment.