From 45373f655f68fdd0b320cde175b6108454ad4731 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 17 Jul 2021 20:32:22 +0530 Subject: Removed Franz paid plans features: - serviceLimit - planSelection - trialStatusBar and other Franz features that were for different tiers of subscription. --- src/stores/FeaturesStore.js | 18 ------------ src/stores/PaymentStore.js | 68 --------------------------------------------- src/stores/ServicesStore.js | 34 ----------------------- src/stores/UserStore.js | 65 +------------------------------------------ src/stores/index.js | 6 ---- 5 files changed, 1 insertion(+), 190 deletions(-) delete mode 100644 src/stores/PaymentStore.js (limited to 'src/stores') diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index 2fee9bdda..ac623c258 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js @@ -1,15 +1,12 @@ import { computed, observable, - reaction, runInAction, } from 'mobx'; import Store from './lib/Store'; import CachedRequest from './lib/CachedRequest'; -import delayApp from '../features/delayApp'; -import spellchecker from '../features/spellchecker'; import serviceProxy from '../features/serviceProxy'; import basicAuth from '../features/basicAuth'; import workspaces from '../features/workspaces'; @@ -19,12 +16,9 @@ import publishDebugInfo from '../features/publishDebugInfo'; import shareFranz from '../features/shareFranz'; import announcements from '../features/announcements'; import settingsWS from '../features/settingsWS'; -import serviceLimit from '../features/serviceLimit'; import communityRecipes from '../features/communityRecipes'; import todos from '../features/todos'; import appearance from '../features/appearance'; -import planSelection from '../features/planSelection'; -import trialStatusBar from '../features/trialStatusBar'; import { DEFAULT_FEATURES_CONFIG } from '../config'; @@ -43,13 +37,6 @@ export default class FeaturesStore extends Store { await this.featuresRequest._promise; setTimeout(this._setupFeatures.bind(this), 1); - - // single key reaction - reaction(() => this.stores.user.data.isPremium, () => { - if (this.stores.user.isLoggedIn) { - this.featuresRequest.invalidate({ immediately: true }); - } - }); } @computed get anonymousFeatures() { @@ -80,8 +67,6 @@ export default class FeaturesStore extends Store { } _setupFeatures() { - delayApp(this.stores, this.actions); - spellchecker(this.stores, this.actions); serviceProxy(this.stores, this.actions); basicAuth(this.stores, this.actions); workspaces(this.stores, this.actions); @@ -91,11 +76,8 @@ export default class FeaturesStore extends Store { shareFranz(this.stores, this.actions); announcements(this.stores, this.actions); settingsWS(this.stores, this.actions); - serviceLimit(this.stores, this.actions); communityRecipes(this.stores, this.actions); todos(this.stores, this.actions); appearance(this.stores, this.actions); - planSelection(this.stores, this.actions); - trialStatusBar(this.stores, this.actions); } } diff --git a/src/stores/PaymentStore.js b/src/stores/PaymentStore.js deleted file mode 100644 index 05bb5b3d0..000000000 --- a/src/stores/PaymentStore.js +++ /dev/null @@ -1,68 +0,0 @@ -import { action, observable, computed } from 'mobx'; -import { BrowserWindow, getCurrentWindow } from '@electron/remote'; - -import Store from './lib/Store'; -import CachedRequest from './lib/CachedRequest'; -import Request from './lib/Request'; - -export default class PaymentStore extends Store { - @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); - - @observable createHostedPageRequest = new Request(this.api.payment, 'getHostedPage'); - - constructor(...args) { - super(...args); - - this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); - this.actions.payment.upgradeAccount.listen(this._upgradeAccount.bind(this)); - } - - @computed get plan() { - if (this.plansRequest.isError) { - return {}; - } - return this.plansRequest.execute().result || {}; - } - - @action _createHostedPage({ planId }) { - const request = this.createHostedPageRequest.execute(planId); - - return request; - } - - @action _upgradeAccount({ planId, onCloseWindow = () => null }) { - let hostedPageURL = this.stores.features.features.subscribeURL; - - const parsedUrl = new URL(hostedPageURL); - const params = new URLSearchParams(parsedUrl.search.slice(1)); - - params.set('plan', planId); - - hostedPageURL = this.stores.user.getAuthURL(`${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`); - - const win = new BrowserWindow({ - parent: getCurrentWindow(), - modal: true, - title: '🔒 Upgrade Your Franz Account', - width: 800, - height: window.innerHeight - 100, - maxWidth: 800, - minWidth: 600, - autoHideMenuBar: true, - webPreferences: { - nodeIntegration: true, - webviewTag: true, - enableRemoteModule: true, - contextIsolation: false, - }, - }); - win.loadURL(`file://${__dirname}/../index.html#/payment/${encodeURIComponent(hostedPageURL)}`); - - win.on('closed', () => { - this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); - this.stores.features.featuresRequest.invalidate({ immediately: true }); - - onCloseWindow(); - }); - } -} diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 9b69cb7c6..9521f8493 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -18,8 +18,6 @@ import { matchRoute } from '../helpers/routing-helpers'; import { isInTimeframe } from '../helpers/schedule-helpers'; import { getRecipeDirectory, getDevRecipeDirectory } from '../helpers/recipe-helpers'; import { workspaceStore } from '../features/workspaces'; -import { serviceLimitStore } from '../features/serviceLimit'; -import { RESTRICTION_TYPES } from '../models/Service'; import { KEEP_WS_LOADED_USID } from '../config'; import { SPELLCHECKER_LOCALES } from '../i18n/languages'; @@ -94,7 +92,6 @@ export default class ServicesStore extends Store { this._saveActiveService.bind(this), this._logoutReaction.bind(this), this._handleMuteSettings.bind(this), - this._restrictServiceAccess.bind(this), this._checkForActiveService.bind(this), ]); @@ -297,8 +294,6 @@ export default class ServicesStore extends Store { async _createService({ recipeId, serviceData, redirect = true, skipCleanup = false, }) { - if (serviceLimitStore.userHasReachedServiceLimit) return; - if (!this.stores.recipes.isInstalled(recipeId)) { debug(`Recipe "${recipeId}" is not installed, installing recipe`); await this.stores.recipes._install({ recipeId }); @@ -961,35 +956,6 @@ export default class ServicesStore extends Store { return serviceData; } - _restrictServiceAccess() { - const { features } = this.stores.features; - const { userHasReachedServiceLimit, serviceLimit } = this.stores.serviceLimit; - - this.all.map((service, index) => { - if (userHasReachedServiceLimit) { - service.isServiceAccessRestricted = index >= serviceLimit; - - if (service.isServiceAccessRestricted) { - service.restrictionType = RESTRICTION_TYPES.SERVICE_LIMIT; - - debug('Restricting access to server due to service limit'); - } - } - - if (service.isUsingCustomUrl) { - service.isServiceAccessRestricted = !features.isCustomUrlIncludedInCurrentPlan; - - if (service.isServiceAccessRestricted) { - service.restrictionType = RESTRICTION_TYPES.CUSTOM_URL; - - debug('Restricting access to server due to custom url'); - } - } - - return service; - }); - } - _checkForActiveService() { if (!this.stores.router.location || this.stores.router.location.pathname.includes('auth/signup')) { return; diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 7947e5a27..8a525c2ef 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js @@ -2,16 +2,13 @@ import { observable, computed, action } from 'mobx'; import moment from 'moment'; import jwt from 'jsonwebtoken'; import localStorage from 'mobx-localstorage'; -import ms from 'ms'; import { session } from '@electron/remote'; import { isDevMode } from '../environment'; import Store from './lib/Store'; import Request from './lib/Request'; import CachedRequest from './lib/CachedRequest'; -import { sleep } from '../helpers/async-helpers'; -import { getPlan } from '../helpers/plan-helpers'; -import { PLANS, TODOS_PARTITION_ID } from '../config'; +import { TODOS_PARTITION_ID } from '../config'; const debug = require('debug')('Ferdi:UserStore'); @@ -27,8 +24,6 @@ export default class UserStore extends Store { SIGNUP_ROUTE = `${this.BASE_ROUTE}/signup`; - PRICING_ROUTE = `${this.BASE_ROUTE}/signup/pricing`; - SETUP_ROUTE = `${this.BASE_ROUTE}/signup/setup`; IMPORT_ROUTE = `${this.BASE_ROUTE}/signup/import`; @@ -45,8 +40,6 @@ export default class UserStore extends Store { @observable passwordRequest = new Request(this.api.user, 'password'); - @observable activateTrialRequest = new Request(this.api.user, 'activateTrial'); - @observable inviteRequest = new Request(this.api.user, 'invite'); @observable getUserInfoRequest = new CachedRequest(this.api.user, 'getInfo'); @@ -71,8 +64,6 @@ export default class UserStore extends Store { @observable hasCompletedSignup = false; - @observable hasActivatedTrial = false; - @observable userData = {}; @observable actionStatus = []; @@ -93,7 +84,6 @@ export default class UserStore extends Store { this.actions.user.retrievePassword.listen(this._retrievePassword.bind(this)); this.actions.user.logout.listen(this._logout.bind(this)); this.actions.user.signup.listen(this._signup.bind(this)); - this.actions.user.activateTrial.listen(this._activateTrial.bind(this)); this.actions.user.invite.listen(this._invite.bind(this)); this.actions.user.update.listen(this._update.bind(this)); this.actions.user.resetStatus.listen(this._resetStatus.bind(this)); @@ -104,7 +94,6 @@ export default class UserStore extends Store { this.registerReactions([ this._requireAuthenticatedUser.bind(this), this._getUserData.bind(this), - this._resetTrialActivationState.bind(this), ]); } @@ -126,10 +115,6 @@ export default class UserStore extends Store { return this.SIGNUP_ROUTE; } - get pricingRoute() { - return this.PRICING_ROUTE; - } - get setupRoute() { return this.SETUP_ROUTE; } @@ -172,31 +157,6 @@ export default class UserStore extends Store { return this.data.team || null; } - @computed get isPremium() { - return true; - } - - @computed get isPremiumOverride() { - return ((!this.team || !this.team.plan) && this.isPremium) || (this.team && this.team.state === 'expired' && this.isPremium); - } - - @computed get isPersonal() { - if (!this.team || !this.team.plan) return false; - const plan = getPlan(this.team.plan); - - return plan === PLANS.PERSONAL; - } - - @computed get isPro() { - return true; - // if (this.isPremiumOverride) return true; - - // if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false; - // const plan = getPlan(this.team.plan); - - // return plan === PLANS.PRO || plan === PLANS.LEGACY; - } - @computed get legacyServices() { return this.getLegacyServicesRequest.execute() || {}; } @@ -244,21 +204,6 @@ export default class UserStore extends Store { this.actionStatus = request.result.status || []; } - @action async _activateTrial({ planId }) { - debug('activate trial', planId); - - this.activateTrialRequest.execute({ - plan: planId, - }); - - await this.activateTrialRequest._promise; - - this.hasActivatedTrial = true; - - this.stores.features.featuresRequest.invalidate({ immediately: true }); - this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); - } - @action async _invite({ invites }) { const data = invites.filter(invite => invite.email !== ''); @@ -386,14 +331,6 @@ export default class UserStore extends Store { } } - async _resetTrialActivationState() { - if (this.hasActivatedTrial) { - await sleep(ms('12s')); - - this.hasActivatedTrial = false; - } - } - // Helpers _parseToken(authToken) { try { diff --git a/src/stores/index.js b/src/stores/index.js index 4eeef7982..b6e481e8a 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -6,16 +6,13 @@ import ServicesStore from './ServicesStore'; import RecipesStore from './RecipesStore'; import RecipePreviewsStore from './RecipePreviewsStore'; import UIStore from './UIStore'; -import PaymentStore from './PaymentStore'; import NewsStore from './NewsStore'; import RequestStore from './RequestStore'; import GlobalErrorStore from './GlobalErrorStore'; import { workspaceStore } from '../features/workspaces'; import { announcementsStore } from '../features/announcements'; -import { serviceLimitStore } from '../features/serviceLimit'; import { communityRecipesStore } from '../features/communityRecipes'; import { todosStore } from '../features/todos'; -import { planSelectionStore } from '../features/planSelection'; export default (api, actions, router) => { const stores = {}; @@ -29,16 +26,13 @@ export default (api, actions, router) => { recipes: new RecipesStore(stores, api, actions), recipePreviews: new RecipePreviewsStore(stores, api, actions), ui: new UIStore(stores, api, actions), - payment: new PaymentStore(stores, api, actions), news: new NewsStore(stores, api, actions), requests: new RequestStore(stores, api, actions), globalError: new GlobalErrorStore(stores, api, actions), workspaces: workspaceStore, announcements: announcementsStore, - serviceLimit: serviceLimitStore, communityRecipes: communityRecipesStore, todos: todosStore, - planSelection: planSelectionStore, }); // Initialize all stores Object.keys(stores).forEach((name) => { -- cgit v1.2.3-70-g09d2