fix: circular dependencies (#1040)
This commit is contained in:
@@ -10,13 +10,7 @@ import { CreateAccount } from './CreateAccount'
|
|||||||
import { ConfirmPassword } from './ConfirmPassword'
|
import { ConfirmPassword } from './ConfirmPassword'
|
||||||
import { JSXInternal } from 'preact/src/jsx'
|
import { JSXInternal } from 'preact/src/jsx'
|
||||||
import { ApplicationGroup } from '@/UIModels/ApplicationGroup'
|
import { ApplicationGroup } from '@/UIModels/ApplicationGroup'
|
||||||
|
import { AccountMenuPane } from './AccountMenuPane'
|
||||||
export enum AccountMenuPane {
|
|
||||||
GeneralMenu,
|
|
||||||
SignIn,
|
|
||||||
Register,
|
|
||||||
ConfirmPassword,
|
|
||||||
}
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appState: AppState
|
appState: AppState
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export enum AccountMenuPane {
|
||||||
|
GeneralMenu,
|
||||||
|
SignIn,
|
||||||
|
Register,
|
||||||
|
ConfirmPassword,
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { AppState } from '@/UIModels/AppState'
|
|||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
||||||
import { AccountMenuPane } from './AccountMenu'
|
import { AccountMenuPane } from './AccountMenuPane'
|
||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { Checkbox } from '@/Components/Checkbox/Checkbox'
|
import { Checkbox } from '@/Components/Checkbox/Checkbox'
|
||||||
import { DecoratedPasswordInput } from '@/Components/Input/DecoratedPasswordInput'
|
import { DecoratedPasswordInput } from '@/Components/Input/DecoratedPasswordInput'
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AppState } from '@/UIModels/AppState'
|
|||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { StateUpdater, useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
import { StateUpdater, useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
||||||
import { AccountMenuPane } from './AccountMenu'
|
import { AccountMenuPane } from './AccountMenuPane'
|
||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { DecoratedInput } from '@/Components/Input/DecoratedInput'
|
import { DecoratedInput } from '@/Components/Input/DecoratedInput'
|
||||||
import { DecoratedPasswordInput } from '@/Components/Input/DecoratedPasswordInput'
|
import { DecoratedPasswordInput } from '@/Components/Input/DecoratedPasswordInput'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { formatLastSyncDate } from '@/Components/Preferences/Panes/Account/Sync'
|
|||||||
import { SyncQueueStrategy } from '@standardnotes/snjs'
|
import { SyncQueueStrategy } from '@standardnotes/snjs'
|
||||||
import { STRING_GENERIC_SYNC_ERROR } from '@/Strings'
|
import { STRING_GENERIC_SYNC_ERROR } from '@/Strings'
|
||||||
import { useCallback, useMemo, useState } from 'preact/hooks'
|
import { useCallback, useMemo, useState } from 'preact/hooks'
|
||||||
import { AccountMenuPane } from './AccountMenu'
|
import { AccountMenuPane } from './AccountMenuPane'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { Menu } from '@/Components/Menu/Menu'
|
import { Menu } from '@/Components/Menu/Menu'
|
||||||
import { MenuItem, MenuItemSeparator, MenuItemType } from '@/Components/Menu/MenuItem'
|
import { MenuItem, MenuItemSeparator, MenuItemType } from '@/Components/Menu/MenuItem'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { isDev } from '@/Utils'
|
|||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
||||||
import { AccountMenuPane } from './AccountMenu'
|
import { AccountMenuPane } from './AccountMenuPane'
|
||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { Checkbox } from '@/Components/Checkbox/Checkbox'
|
import { Checkbox } from '@/Components/Checkbox/Checkbox'
|
||||||
import { DecoratedInput } from '@/Components/Input/DecoratedInput'
|
import { DecoratedInput } from '@/Components/Input/DecoratedInput'
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { Icon } from '@/Components/Icon/Icon'
|
import { Icon } from '@/Components/Icon/Icon'
|
||||||
import { Menu } from '@/Components/Menu/Menu'
|
import { Menu } from '@/Components/Menu/Menu'
|
||||||
import { MenuItem, MenuItemType } from '@/Components/Menu/MenuItem'
|
import { MenuItem, MenuItemType } from '@/Components/Menu/MenuItem'
|
||||||
import {
|
|
||||||
reloadFont,
|
|
||||||
transactionForAssociateComponentWithCurrentNote,
|
|
||||||
transactionForDisassociateComponentWithCurrentNote,
|
|
||||||
} from '@/Components/NoteView/NoteView'
|
|
||||||
import { usePremiumModal } from '@/Hooks/usePremiumModal'
|
import { usePremiumModal } from '@/Hooks/usePremiumModal'
|
||||||
import { STRING_EDIT_LOCKED_ATTEMPT } from '@/Strings'
|
import { STRING_EDIT_LOCKED_ATTEMPT } from '@/Strings'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
@@ -23,6 +18,11 @@ import { useCallback, useEffect, useState } from 'preact/hooks'
|
|||||||
import { EditorMenuItem, EditorMenuGroup } from '@/Components/NotesOptions/ChangeEditorOption'
|
import { EditorMenuItem, EditorMenuGroup } from '@/Components/NotesOptions/ChangeEditorOption'
|
||||||
import { createEditorMenuGroups } from './createEditorMenuGroups'
|
import { createEditorMenuGroups } from './createEditorMenuGroups'
|
||||||
import { PLAIN_EDITOR_NAME } from '@/Constants'
|
import { PLAIN_EDITOR_NAME } from '@/Constants'
|
||||||
|
import {
|
||||||
|
transactionForAssociateComponentWithCurrentNote,
|
||||||
|
transactionForDisassociateComponentWithCurrentNote,
|
||||||
|
} from '../NoteView/TransactionFunctions'
|
||||||
|
import { reloadFont } from '../NoteView/FontFunctions'
|
||||||
|
|
||||||
type ChangeEditorMenuProps = {
|
type ChangeEditorMenuProps = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ import {
|
|||||||
STRING_UPGRADE_ACCOUNT_CONFIRM_BUTTON,
|
STRING_UPGRADE_ACCOUNT_CONFIRM_BUTTON,
|
||||||
} from '@/Strings'
|
} from '@/Strings'
|
||||||
import { alertDialog, confirmDialog } from '@/Services/AlertService'
|
import { alertDialog, confirmDialog } from '@/Services/AlertService'
|
||||||
import { AccountMenu, AccountMenuPane } from '@/Components/AccountMenu/AccountMenu'
|
import { AccountMenu } from '@/Components/AccountMenu/AccountMenu'
|
||||||
import { AppStateEvent, EventSource } from '@/UIModels/AppState'
|
import { AppStateEvent, EventSource } from '@/UIModels/AppState'
|
||||||
import { Icon } from '@/Components/Icon/Icon'
|
import { Icon } from '@/Components/Icon/Icon'
|
||||||
import { QuickSettingsMenu } from '@/Components/QuickSettingsMenu/QuickSettingsMenu'
|
import { QuickSettingsMenu } from '@/Components/QuickSettingsMenu/QuickSettingsMenu'
|
||||||
import { SyncResolutionMenu } from '@/Components/SyncResolutionMenu/SyncResolutionMenu'
|
import { SyncResolutionMenu } from '@/Components/SyncResolutionMenu/SyncResolutionMenu'
|
||||||
import { Fragment } from 'preact'
|
import { Fragment } from 'preact'
|
||||||
|
import { AccountMenuPane } from '../AccountMenu/AccountMenuPane'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export const reloadFont = (monospaceFont?: boolean) => {
|
||||||
|
const root = document.querySelector(':root') as HTMLElement
|
||||||
|
const propertyName = '--sn-stylekit-editor-font-family'
|
||||||
|
if (monospaceFont) {
|
||||||
|
root.style.setProperty(propertyName, 'var(--sn-stylekit-monospace-font)')
|
||||||
|
} else {
|
||||||
|
root.style.setProperty(propertyName, 'var(--sn-stylekit-sans-serif-font)')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,7 @@ import {
|
|||||||
SNNote,
|
SNNote,
|
||||||
ComponentArea,
|
ComponentArea,
|
||||||
PrefKey,
|
PrefKey,
|
||||||
ComponentMutator,
|
|
||||||
ComponentViewer,
|
ComponentViewer,
|
||||||
TransactionalMutation,
|
|
||||||
ItemMutator,
|
|
||||||
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
||||||
NoteViewController,
|
NoteViewController,
|
||||||
PayloadEmitSource,
|
PayloadEmitSource,
|
||||||
@@ -33,6 +30,11 @@ import { PanelSide, PanelResizer, PanelResizeType } from '@/Components/PanelResi
|
|||||||
import { ElementIds } from '@/ElementIDs'
|
import { ElementIds } from '@/ElementIDs'
|
||||||
import { ChangeEditorButton } from '@/Components/ChangeEditor/ChangeEditorButton'
|
import { ChangeEditorButton } from '@/Components/ChangeEditor/ChangeEditorButton'
|
||||||
import { AttachedFilesButton } from '@/Components/AttachedFilesPopover/AttachedFilesButton'
|
import { AttachedFilesButton } from '@/Components/AttachedFilesPopover/AttachedFilesButton'
|
||||||
|
import {
|
||||||
|
transactionForAssociateComponentWithCurrentNote,
|
||||||
|
transactionForDisassociateComponentWithCurrentNote,
|
||||||
|
} from './TransactionFunctions'
|
||||||
|
import { reloadFont } from './FontFunctions'
|
||||||
|
|
||||||
const MINIMUM_STATUS_DURATION = 400
|
const MINIMUM_STATUS_DURATION = 400
|
||||||
const TEXTAREA_DEBOUNCE = 100
|
const TEXTAREA_DEBOUNCE = 100
|
||||||
@@ -47,40 +49,6 @@ function sortAlphabetically(array: SNComponent[]): SNComponent[] {
|
|||||||
return array.sort((a, b) => (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1))
|
return array.sort((a, b) => (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const transactionForAssociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
|
||||||
const transaction: TransactionalMutation = {
|
|
||||||
itemUuid: component.uuid,
|
|
||||||
mutate: (m: ItemMutator) => {
|
|
||||||
const mutator = m as ComponentMutator
|
|
||||||
mutator.removeDisassociatedItemId(note.uuid)
|
|
||||||
mutator.associateWithItem(note.uuid)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return transaction
|
|
||||||
}
|
|
||||||
|
|
||||||
export const transactionForDisassociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
|
||||||
const transaction: TransactionalMutation = {
|
|
||||||
itemUuid: component.uuid,
|
|
||||||
mutate: (m: ItemMutator) => {
|
|
||||||
const mutator = m as ComponentMutator
|
|
||||||
mutator.removeAssociatedItemId(note.uuid)
|
|
||||||
mutator.disassociateWithItem(note.uuid)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return transaction
|
|
||||||
}
|
|
||||||
|
|
||||||
export const reloadFont = (monospaceFont?: boolean) => {
|
|
||||||
const root = document.querySelector(':root') as HTMLElement
|
|
||||||
const propertyName = '--sn-stylekit-editor-font-family'
|
|
||||||
if (monospaceFont) {
|
|
||||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-monospace-font)')
|
|
||||||
} else {
|
|
||||||
root.style.setProperty(propertyName, 'var(--sn-stylekit-sans-serif-font)')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
availableStackComponents: SNComponent[]
|
availableStackComponents: SNComponent[]
|
||||||
editorComponentViewer?: ComponentViewer
|
editorComponentViewer?: ComponentViewer
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { SNComponent, SNNote, ComponentMutator, TransactionalMutation, ItemMutator } from '@standardnotes/snjs'
|
||||||
|
|
||||||
|
export const transactionForAssociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||||
|
const transaction: TransactionalMutation = {
|
||||||
|
itemUuid: component.uuid,
|
||||||
|
mutate: (m: ItemMutator) => {
|
||||||
|
const mutator = m as ComponentMutator
|
||||||
|
mutator.removeDisassociatedItemId(note.uuid)
|
||||||
|
mutator.associateWithItem(note.uuid)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return transaction
|
||||||
|
}
|
||||||
|
|
||||||
|
export const transactionForDisassociateComponentWithCurrentNote = (component: SNComponent, note: SNNote) => {
|
||||||
|
const transaction: TransactionalMutation = {
|
||||||
|
itemUuid: component.uuid,
|
||||||
|
mutate: (m: ItemMutator) => {
|
||||||
|
const mutator = m as ComponentMutator
|
||||||
|
mutator.removeAssociatedItemId(note.uuid)
|
||||||
|
mutator.disassociateWithItem(note.uuid)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return transaction
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenu'
|
|
||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { PreferencesGroup, PreferencesSegment, Text, Title } from '@/Components/Preferences/PreferencesComponents'
|
import { PreferencesGroup, PreferencesSegment, Text, Title } from '@/Components/Preferences/PreferencesComponents'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
@@ -6,6 +5,7 @@ import { AppState } from '@/UIModels/AppState'
|
|||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { AccountIllustration } from '@standardnotes/icons'
|
import { AccountIllustration } from '@standardnotes/icons'
|
||||||
|
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane'
|
||||||
|
|
||||||
export const Authentication: FunctionComponent<{
|
export const Authentication: FunctionComponent<{
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { LinkButton, Text } from '@/Components/Preferences/PreferencesComponents
|
|||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { useState } from 'preact/hooks'
|
import { useState } from 'preact/hooks'
|
||||||
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowWrapper'
|
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowFunctions'
|
||||||
|
|
||||||
export const NoSubscription: FunctionalComponent<{
|
export const NoSubscription: FunctionalComponent<{
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AppState } from '@/UIModels/AppState'
|
import { AppState } from '@/UIModels/AppState'
|
||||||
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowState'
|
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowPane'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks'
|
import { useEffect, useRef, useState } from 'preact/hooks'
|
||||||
import { FloatingLabelInput } from '@/Components/Input/FloatingLabelInput'
|
import { FloatingLabelInput } from '@/Components/Input/FloatingLabelInput'
|
||||||
import { isEmailValid } from '@/Utils'
|
import { isEmailValid } from '@/Utils'
|
||||||
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowWrapper'
|
|
||||||
import { BlueDotIcon, CircleIcon, DiamondIcon, CreateAccountIllustration } from '@standardnotes/icons'
|
import { BlueDotIcon, CircleIcon, DiamondIcon, CreateAccountIllustration } from '@standardnotes/icons'
|
||||||
|
import { loadPurchaseFlowUrl } from '../PurchaseFlowFunctions'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appState: AppState
|
appState: AppState
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Button } from '@/Components/Button/Button'
|
import { Button } from '@/Components/Button/Button'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AppState } from '@/UIModels/AppState'
|
import { AppState } from '@/UIModels/AppState'
|
||||||
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowState'
|
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowPane'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks'
|
import { useEffect, useRef, useState } from 'preact/hooks'
|
||||||
import { FloatingLabelInput } from '@/Components/Input/FloatingLabelInput'
|
import { FloatingLabelInput } from '@/Components/Input/FloatingLabelInput'
|
||||||
import { isEmailValid } from '@/Utils'
|
import { isEmailValid } from '@/Utils'
|
||||||
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowWrapper'
|
|
||||||
import { BlueDotIcon, CircleIcon, DiamondIcon } from '@standardnotes/icons'
|
import { BlueDotIcon, CircleIcon, DiamondIcon } from '@standardnotes/icons'
|
||||||
|
import { loadPurchaseFlowUrl } from '../PurchaseFlowFunctions'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appState: AppState
|
appState: AppState
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
|
import { getWindowUrlParams, isDesktopApplication } from '@/Utils'
|
||||||
|
|
||||||
|
export const getPurchaseFlowUrl = async (application: WebApplication): Promise<string | undefined> => {
|
||||||
|
const currentUrl = window.location.origin
|
||||||
|
const successUrl = isDesktopApplication() ? 'standardnotes://' : currentUrl
|
||||||
|
if (application.noAccount()) {
|
||||||
|
return `${window.purchaseUrl}/offline?&success_url=${successUrl}`
|
||||||
|
}
|
||||||
|
const token = await application.getNewSubscriptionToken()
|
||||||
|
if (token) {
|
||||||
|
return `${window.purchaseUrl}?subscription_token=${token}&success_url=${successUrl}`
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export const loadPurchaseFlowUrl = async (application: WebApplication): Promise<boolean> => {
|
||||||
|
const url = await getPurchaseFlowUrl(application)
|
||||||
|
const params = getWindowUrlParams()
|
||||||
|
const period = params.get('period') ? `&period=${params.get('period')}` : ''
|
||||||
|
const plan = params.get('plan') ? `&plan=${params.get('plan')}` : ''
|
||||||
|
if (url) {
|
||||||
|
window.location.assign(`${url}${period}${plan}`)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AppState } from '@/UIModels/AppState'
|
import { AppState } from '@/UIModels/AppState'
|
||||||
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowState'
|
import { PurchaseFlowPane } from '@/UIModels/AppState/PurchaseFlowPane'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { CreateAccount } from './Panes/CreateAccount'
|
import { CreateAccount } from './Panes/CreateAccount'
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AppState } from '@/UIModels/AppState'
|
import { AppState } from '@/UIModels/AppState'
|
||||||
import { getWindowUrlParams, isDesktopApplication } from '@/Utils'
|
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { PurchaseFlowView } from './PurchaseFlowView'
|
import { PurchaseFlowView } from './PurchaseFlowView'
|
||||||
@@ -10,31 +9,6 @@ export type PurchaseFlowWrapperProps = {
|
|||||||
application: WebApplication
|
application: WebApplication
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getPurchaseFlowUrl = async (application: WebApplication): Promise<string | undefined> => {
|
|
||||||
const currentUrl = window.location.origin
|
|
||||||
const successUrl = isDesktopApplication() ? 'standardnotes://' : currentUrl
|
|
||||||
if (application.noAccount()) {
|
|
||||||
return `${window.purchaseUrl}/offline?&success_url=${successUrl}`
|
|
||||||
}
|
|
||||||
const token = await application.getNewSubscriptionToken()
|
|
||||||
if (token) {
|
|
||||||
return `${window.purchaseUrl}?subscription_token=${token}&success_url=${successUrl}`
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
export const loadPurchaseFlowUrl = async (application: WebApplication): Promise<boolean> => {
|
|
||||||
const url = await getPurchaseFlowUrl(application)
|
|
||||||
const params = getWindowUrlParams()
|
|
||||||
const period = params.get('period') ? `&period=${params.get('period')}` : ''
|
|
||||||
const plan = params.get('plan') ? `&plan=${params.get('plan')}` : ''
|
|
||||||
if (url) {
|
|
||||||
window.location.assign(`${url}${period}${plan}`)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PurchaseFlowWrapper: FunctionComponent<PurchaseFlowWrapperProps> = observer(
|
export const PurchaseFlowWrapper: FunctionComponent<PurchaseFlowWrapperProps> = observer(
|
||||||
({ appState, application }) => {
|
({ appState, application }) => {
|
||||||
if (!appState.purchaseFlow.isOpen) {
|
if (!appState.purchaseFlow.isOpen) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { destroyAllObjectProperties, isDev } from '@/Utils'
|
|||||||
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
|
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
|
||||||
import { ApplicationEvent, ContentType, DeinitSource, SNNote, SNTag } from '@standardnotes/snjs'
|
import { ApplicationEvent, ContentType, DeinitSource, SNNote, SNTag } from '@standardnotes/snjs'
|
||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenu'
|
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane'
|
||||||
import { AbstractState } from './AbstractState'
|
import { AbstractState } from './AbstractState'
|
||||||
|
|
||||||
type StructuredItemsCount = {
|
type StructuredItemsCount = {
|
||||||
|
|||||||
@@ -30,17 +30,7 @@ import { FilePreviewModalState } from './FilePreviewModalState'
|
|||||||
import { AbstractState } from './AbstractState'
|
import { AbstractState } from './AbstractState'
|
||||||
import { SelectedItemsState } from './SelectedItemsState'
|
import { SelectedItemsState } from './SelectedItemsState'
|
||||||
import { ListableContentItem } from '@/Components/ContentListView/Types/ListableContentItem'
|
import { ListableContentItem } from '@/Components/ContentListView/Types/ListableContentItem'
|
||||||
|
import { AppStateEvent } from './AppStateEvent'
|
||||||
export enum AppStateEvent {
|
|
||||||
TagChanged,
|
|
||||||
ActiveEditorChanged,
|
|
||||||
PanelResized,
|
|
||||||
EditorFocused,
|
|
||||||
BeganBackupDownload,
|
|
||||||
EndedBackupDownload,
|
|
||||||
WindowDidFocus,
|
|
||||||
WindowDidBlur,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PanelResizedData = {
|
export type PanelResizedData = {
|
||||||
panel: string
|
panel: string
|
||||||
|
|||||||
10
app/assets/javascripts/UIModels/AppState/AppStateEvent.ts
Normal file
10
app/assets/javascripts/UIModels/AppState/AppStateEvent.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export enum AppStateEvent {
|
||||||
|
TagChanged,
|
||||||
|
ActiveEditorChanged,
|
||||||
|
PanelResized,
|
||||||
|
EditorFocused,
|
||||||
|
BeganBackupDownload,
|
||||||
|
EndedBackupDownload,
|
||||||
|
WindowDidFocus,
|
||||||
|
WindowDidBlur,
|
||||||
|
}
|
||||||
@@ -15,9 +15,10 @@ import {
|
|||||||
DisplayOptions,
|
DisplayOptions,
|
||||||
} from '@standardnotes/snjs'
|
} from '@standardnotes/snjs'
|
||||||
import { action, computed, makeObservable, observable, reaction, runInAction } from 'mobx'
|
import { action, computed, makeObservable, observable, reaction, runInAction } from 'mobx'
|
||||||
import { AppState, AppStateEvent } from '.'
|
|
||||||
import { WebApplication } from '../Application'
|
import { WebApplication } from '../Application'
|
||||||
import { AbstractState } from './AbstractState'
|
import { AbstractState } from './AbstractState'
|
||||||
|
import { AppState } from './AppState'
|
||||||
|
import { AppStateEvent } from './AppStateEvent'
|
||||||
import { WebDisplayOptions } from './WebDisplayOptions'
|
import { WebDisplayOptions } from './WebDisplayOptions'
|
||||||
|
|
||||||
const MinNoteCellHeight = 51.0
|
const MinNoteCellHeight = 51.0
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export enum PurchaseFlowPane {
|
||||||
|
SignIn,
|
||||||
|
CreateAccount,
|
||||||
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowWrapper'
|
import { loadPurchaseFlowUrl } from '@/Components/PurchaseFlow/PurchaseFlowFunctions'
|
||||||
import { action, makeObservable, observable } from 'mobx'
|
import { action, makeObservable, observable } from 'mobx'
|
||||||
import { WebApplication } from '../Application'
|
import { WebApplication } from '../Application'
|
||||||
import { AbstractState } from './AbstractState'
|
import { AbstractState } from './AbstractState'
|
||||||
|
import { PurchaseFlowPane } from './PurchaseFlowPane'
|
||||||
export enum PurchaseFlowPane {
|
|
||||||
SignIn,
|
|
||||||
CreateAccount,
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PurchaseFlowState extends AbstractState {
|
export class PurchaseFlowState extends AbstractState {
|
||||||
isOpen = false
|
isOpen = false
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
export { AppState, AppStateEvent, EventSource, PanelResizedData } from './AppState'
|
export { AppState, EventSource, PanelResizedData } from './AppState'
|
||||||
|
export * from './AppStateEvent'
|
||||||
|
export * from './PurchaseFlowPane'
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||||
"@typescript-eslint/parser": "^5.20.0",
|
"@typescript-eslint/parser": "^5.20.0",
|
||||||
"babel-loader": "^8.2.5",
|
"babel-loader": "^8.2.5",
|
||||||
|
"circular-dependency-plugin": "^5.2.2",
|
||||||
"css-loader": "^6.7.1",
|
"css-loader": "^6.7.1",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"eslint": "^8.13.0",
|
"eslint": "^8.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
|
const CircularDependencyPlugin = require('circular-dependency-plugin')
|
||||||
const mergeWithEnvDefaults = require('./webpack-defaults')
|
const mergeWithEnvDefaults = require('./webpack-defaults')
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
|
|
||||||
@@ -12,6 +13,19 @@ module.exports = (env) => {
|
|||||||
filename: './javascripts/app.js',
|
filename: './javascripts/app.js',
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new CircularDependencyPlugin({
|
||||||
|
// exclude detection of files based on a RegExp
|
||||||
|
exclude: /a\.js|node_modules/,
|
||||||
|
// include specific files based on a RegExp
|
||||||
|
include: /app\/assets\/javascripts/,
|
||||||
|
// add errors to webpack instead of warnings
|
||||||
|
failOnError: true,
|
||||||
|
// allow import cycles that include an asyncronous import,
|
||||||
|
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
||||||
|
allowAsyncCycles: false,
|
||||||
|
// set the current working directory for displaying module paths
|
||||||
|
cwd: process.cwd(),
|
||||||
|
}),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
__VERSION__: JSON.stringify(require('./package.json').version),
|
__VERSION__: JSON.stringify(require('./package.json').version),
|
||||||
__WEB__: JSON.stringify(env.platform === 'web'),
|
__WEB__: JSON.stringify(env.platform === 'web'),
|
||||||
|
|||||||
@@ -3884,6 +3884,11 @@ cint@^8.2.1:
|
|||||||
resolved "https://registry.yarnpkg.com/cint/-/cint-8.2.1.tgz#70386b1b48e2773d0d63166a55aff94ef4456a12"
|
resolved "https://registry.yarnpkg.com/cint/-/cint-8.2.1.tgz#70386b1b48e2773d0d63166a55aff94ef4456a12"
|
||||||
integrity sha1-cDhrG0jidz0NYxZqVa/5TvRFahI=
|
integrity sha1-cDhrG0jidz0NYxZqVa/5TvRFahI=
|
||||||
|
|
||||||
|
circular-dependency-plugin@^5.2.2:
|
||||||
|
version "5.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/circular-dependency-plugin/-/circular-dependency-plugin-5.2.2.tgz#39e836079db1d3cf2f988dc48c5188a44058b600"
|
||||||
|
integrity sha512-g38K9Cm5WRwlaH6g03B9OEz/0qRizI+2I7n+Gz+L5DxXJAPAiWQvwlYNm1V1jkdpUv95bOe/ASm2vfi/G560jQ==
|
||||||
|
|
||||||
cjs-module-lexer@^1.0.0:
|
cjs-module-lexer@^1.0.0:
|
||||||
version "1.2.2"
|
version "1.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40"
|
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40"
|
||||||
|
|||||||
Reference in New Issue
Block a user