fix: don't show entitlement modal if dragging file backup

This commit is contained in:
Mo
2022-05-13 01:10:10 -05:00
parent 131f13c558
commit d47d295298
4 changed files with 64 additions and 44 deletions

View File

@@ -84,11 +84,6 @@ export const AttachedFilesButton: FunctionComponent<Props> = observer(
}, [application, note]) }, [application, note])
const toggleAttachedFilesMenu = useCallback(async () => { const toggleAttachedFilesMenu = useCallback(async () => {
if (!appState.features.hasFiles) {
premiumModal.activate('Files')
return
}
const rect = buttonRef.current?.getBoundingClientRect() const rect = buttonRef.current?.getBoundingClientRect()
if (rect) { if (rect) {
const { clientHeight } = document.documentElement const { clientHeight } = document.documentElement
@@ -111,7 +106,20 @@ export const AttachedFilesButton: FunctionComponent<Props> = observer(
setOpen(newOpenState) setOpen(newOpenState)
} }
}, [appState.features.hasFiles, onClickPreprocessing, open, premiumModal]) }, [onClickPreprocessing, open])
const prospectivelyShowFilesPremiumModal = useCallback(() => {
if (!appState.features.hasFiles) {
premiumModal.activate('Files')
return
}
}, [appState.features.hasFiles, premiumModal])
const toggleAttachedFilesMenuWithEntitlementCheck = useCallback(async () => {
prospectivelyShowFilesPremiumModal()
await toggleAttachedFilesMenu()
}, [toggleAttachedFilesMenu, prospectivelyShowFilesPremiumModal])
const deleteFile = async (file: SNFile) => { const deleteFile = async (file: SNFile) => {
const shouldDelete = await confirmDialog({ const shouldDelete = await confirmDialog({
@@ -318,6 +326,7 @@ export const AttachedFilesButton: FunctionComponent<Props> = observer(
setIsDraggingFiles(false) setIsDraggingFiles(false)
if (!appState.features.hasFiles) { if (!appState.features.hasFiles) {
prospectivelyShowFilesPremiumModal()
return return
} }
@@ -348,7 +357,14 @@ export const AttachedFilesButton: FunctionComponent<Props> = observer(
dragCounter.current = 0 dragCounter.current = 0
} }
}, },
[appState.files, appState.features.hasFiles, attachFileToNote, currentTab, application], [
appState.files,
appState.features.hasFiles,
attachFileToNote,
currentTab,
application,
prospectivelyShowFilesPremiumModal,
],
) )
useEffect(() => { useEffect(() => {
@@ -367,7 +383,7 @@ export const AttachedFilesButton: FunctionComponent<Props> = observer(
return ( return (
<div ref={containerRef}> <div ref={containerRef}>
<Disclosure open={open} onChange={toggleAttachedFilesMenu}> <Disclosure open={open} onChange={toggleAttachedFilesMenuWithEntitlementCheck}>
<DisclosureButton <DisclosureButton
onKeyDown={(event) => { onKeyDown={(event) => {
if (event.key === 'Escape') { if (event.key === 'Escape') {

View File

@@ -9,7 +9,7 @@ import {
} from '@/Components/Preferences/PreferencesComponents' } from '@/Components/Preferences/PreferencesComponents'
import { useCallback, useEffect, useMemo, useState } from 'preact/hooks' import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'
import { Button } from '@/Components/Button/Button' import { Button } from '@/Components/Button/Button'
import { FileBackupMetadataFile, FileContent, FileHandleRead } from '@standardnotes/snjs' import { FileBackupMetadataFile, FileBackupsConstantsV1, FileContent, FileHandleRead } from '@standardnotes/snjs'
import { Switch } from '@/Components/Switch' import { Switch } from '@/Components/Switch'
import { HorizontalSeparator } from '@/Components/Shared/HorizontalSeparator' import { HorizontalSeparator } from '@/Components/Shared/HorizontalSeparator'
import { EncryptionStatusItem } from '../Security/Encryption' import { EncryptionStatusItem } from '../Security/Encryption'
@@ -102,7 +102,7 @@ export const FileBackups = observer(({ application }: Props) => {
<> <>
<Text className="mb-3"> <Text className="mb-3">
Files backups are enabled. When you upload a new file on any device and open this application, files Files backups are enabled. When you upload a new file on any device and open this application, files
will be downloaded in encrypted form to: will be backed up in encrypted form to:
</Text> </Text>
<EncryptionStatusItem <EncryptionStatusItem
@@ -304,16 +304,20 @@ export const BackupsDropZone: FunctionComponent<Props> = ({ application }) => {
<> <>
<Title>Backup Decryption</Title> <Title>Backup Decryption</Title>
<Subtitle className="success"> <EncryptionStatusItem
Successfully decrypted metadata file for <i>{decryptedFileContent.name}.</i> status={decryptedFileContent.name}
</Subtitle> icon={[<Icon type="attachment-file" className="min-w-5 min-h-5" />]}
checkmark={true}
/>
<HorizontalSeparator classes={'mt-3 mb-3'} /> <HorizontalSeparator classes={'mt-3 mb-3'} />
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<div> <div>
<Subtitle>1. Choose related data file</Subtitle> <Subtitle>1. Choose related data file</Subtitle>
<Text>{droppedFile.file.uuid}</Text> <Text className={`text-xs mr-3 em ${binaryFile ? 'font-bold success' : ''}`}>
{droppedFile.file.uuid}/{FileBackupsConstantsV1.BinaryFileName}
</Text>
</div> </div>
<div> <div>
<Button <Button

View File

@@ -70,9 +70,9 @@
"@reach/tooltip": "^0.16.2", "@reach/tooltip": "^0.16.2",
"@reach/visually-hidden": "^0.16.0", "@reach/visually-hidden": "^0.16.0",
"@standardnotes/components": "1.8.0", "@standardnotes/components": "1.8.0",
"@standardnotes/filepicker": "1.14.0", "@standardnotes/filepicker": "1.14.1",
"@standardnotes/sncrypto-web": "1.9.2", "@standardnotes/sncrypto-web": "1.9.2",
"@standardnotes/snjs": "2.107.0", "@standardnotes/snjs": "2.107.2",
"@standardnotes/stylekit": "5.26.0", "@standardnotes/stylekit": "5.26.0",
"@zip.js/zip.js": "^2.4.10", "@zip.js/zip.js": "^2.4.10",
"mobx": "^6.5.0", "mobx": "^6.5.0",

View File

@@ -2461,14 +2461,14 @@
"@standardnotes/auth" "^3.18.13" "@standardnotes/auth" "^3.18.13"
"@standardnotes/features" "^1.42.1" "@standardnotes/features" "^1.42.1"
"@standardnotes/encryption@^1.7.0": "@standardnotes/encryption@^1.7.1":
version "1.7.0" version "1.7.1"
resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.7.0.tgz#3012bed5283e23ddeaae01e9fbaa80c24e8af42d" resolved "https://registry.yarnpkg.com/@standardnotes/encryption/-/encryption-1.7.1.tgz#7d84389e204a6ca2906617daa62423ce9ec38879"
integrity sha512-gBVcTCZ53Eg3/2eZkVrBrS98BU95CR2h23ofnNGhCcy0FlWwv6fAqupSsPufOdce8gh27gF0mhRbi80ljYxCUA== integrity sha512-5SZy5MG0ike80y889SmBTJMGAG753PdvOtc23+tNwbleBoubZjzw8gTgZYY52kl74KLtXmAEKiw2Ym2Pq5FcOg==
dependencies: dependencies:
"@standardnotes/models" "^1.8.0" "@standardnotes/models" "^1.8.0"
"@standardnotes/responses" "^1.6.19" "@standardnotes/responses" "^1.6.19"
"@standardnotes/services" "^1.11.0" "@standardnotes/services" "^1.11.1"
"@standardnotes/features@^1.42.1": "@standardnotes/features@^1.42.1":
version "1.42.1" version "1.42.1"
@@ -2478,24 +2478,24 @@
"@standardnotes/auth" "^3.18.13" "@standardnotes/auth" "^3.18.13"
"@standardnotes/common" "^1.19.8" "@standardnotes/common" "^1.19.8"
"@standardnotes/filepicker@1.14.0", "@standardnotes/filepicker@^1.14.0": "@standardnotes/filepicker@1.14.1", "@standardnotes/filepicker@^1.14.1":
version "1.14.0" version "1.14.1"
resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.14.0.tgz#f1ea5e66a453cfc2131bbf665f676b430f649cf2" resolved "https://registry.yarnpkg.com/@standardnotes/filepicker/-/filepicker-1.14.1.tgz#81a3ba2be6e3615103875e528dc1720fa3698dea"
integrity sha512-E/frksUJhHbMVlLNu4UdHLIdFNuQe9Co8dq/WQgeK/X+Ic+5t5Jm91c4GA1LvCUVF1vhYl/Vo76LY8gE1J2mfg== integrity sha512-AOR+iQqNqbfZU7ur/LKsF/M0x9EoBT0kXhewZBs7h3OwrtJES7nFRr/janJMrecvUL/ZdfXmazudadZdvcxPyg==
dependencies: dependencies:
"@standardnotes/common" "^1.19.8" "@standardnotes/common" "^1.19.8"
"@standardnotes/services" "^1.11.0" "@standardnotes/services" "^1.11.1"
"@standardnotes/utils" "^1.6.6" "@standardnotes/utils" "^1.6.6"
"@standardnotes/files@^1.1.0": "@standardnotes/files@^1.1.2":
version "1.1.0" version "1.1.2"
resolved "https://registry.yarnpkg.com/@standardnotes/files/-/files-1.1.0.tgz#c2499f50fdc31addf3b0307388d4c78420415dfe" resolved "https://registry.yarnpkg.com/@standardnotes/files/-/files-1.1.2.tgz#6e75d6233975f359173ddcb352647b21c587be89"
integrity sha512-O4cB8nxBTSLPUCoLyglzbj5oshaJ6hKuBleAWPaC+treaiwpWVyfxn3TF7G4MejlNUMIrGfb566YAZ3R5YVfGg== integrity sha512-Q3f+gYd/FkWb8nuNHgUqGSxkAKkAU3kwb+Ar89LhqSNkgq0e4MsUigy+lzOagdiavwT/C1SE8j5d7E4oIZWynw==
dependencies: dependencies:
"@standardnotes/encryption" "^1.7.0" "@standardnotes/encryption" "^1.7.1"
"@standardnotes/models" "^1.8.0" "@standardnotes/models" "^1.8.0"
"@standardnotes/responses" "^1.6.19" "@standardnotes/responses" "^1.6.19"
"@standardnotes/services" "^1.11.0" "@standardnotes/services" "^1.11.1"
"@standardnotes/utils" "^1.6.6" "@standardnotes/utils" "^1.6.6"
"@standardnotes/models@^1.8.0": "@standardnotes/models@^1.8.0":
@@ -2516,10 +2516,10 @@
"@standardnotes/common" "^1.19.8" "@standardnotes/common" "^1.19.8"
"@standardnotes/features" "^1.42.1" "@standardnotes/features" "^1.42.1"
"@standardnotes/services@^1.11.0": "@standardnotes/services@^1.11.1":
version "1.11.0" version "1.11.1"
resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.11.0.tgz#7b214093a4d5ef540ce2b6a40cf0f83517c1a2da" resolved "https://registry.yarnpkg.com/@standardnotes/services/-/services-1.11.1.tgz#2fa3ce3c7025a048964204321a4c50591134d7ac"
integrity sha512-bR084UoR7EzTC6GD5QxFi7FmcoqhOhZmdeWIwByEOQEDeWG9h0i/lNZo4pAyYykDDv8Z/U3+kNjify4wI+ksZw== integrity sha512-MvDAJM1Cn9586sMm+w4iCgznsqT6uli3bpf/xZKOHWITkrH6dik/FpgpbxmRfOz2VnbZ6lyLVjsnNDIWFZDqxw==
dependencies: dependencies:
"@standardnotes/auth" "^3.18.13" "@standardnotes/auth" "^3.18.13"
"@standardnotes/common" "^1.19.8" "@standardnotes/common" "^1.19.8"
@@ -2546,21 +2546,21 @@
buffer "^6.0.3" buffer "^6.0.3"
libsodium-wrappers "^0.7.9" libsodium-wrappers "^0.7.9"
"@standardnotes/snjs@2.107.0": "@standardnotes/snjs@2.107.2":
version "2.107.0" version "2.107.2"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.107.0.tgz#1254f8ae439023e6dab60dae73b4c8435bf117d2" resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.107.2.tgz#b50be49a44a96eac0158e44df7d547e2b1ecfe5a"
integrity sha512-3FOxSDlRADoQoSr3gSvAA9eFQbvo7vOaeeLXtoN7ElUUtG78DadPORtwyQtsUee9EfxQnlaWBXVImPAoy2LUew== integrity sha512-zTa1n+Bed6ElWOepA/5gJew1aI03XB4lKiysJmDduKS2QsYEdyeQ2p3SuJZSDFX57e/PVYnU9uI851CobrN/Fg==
dependencies: dependencies:
"@standardnotes/auth" "^3.18.13" "@standardnotes/auth" "^3.18.13"
"@standardnotes/common" "^1.19.8" "@standardnotes/common" "^1.19.8"
"@standardnotes/domain-events" "^2.28.3" "@standardnotes/domain-events" "^2.28.3"
"@standardnotes/encryption" "^1.7.0" "@standardnotes/encryption" "^1.7.1"
"@standardnotes/features" "^1.42.1" "@standardnotes/features" "^1.42.1"
"@standardnotes/filepicker" "^1.14.0" "@standardnotes/filepicker" "^1.14.1"
"@standardnotes/files" "^1.1.0" "@standardnotes/files" "^1.1.2"
"@standardnotes/models" "^1.8.0" "@standardnotes/models" "^1.8.0"
"@standardnotes/responses" "^1.6.19" "@standardnotes/responses" "^1.6.19"
"@standardnotes/services" "^1.11.0" "@standardnotes/services" "^1.11.1"
"@standardnotes/settings" "^1.14.3" "@standardnotes/settings" "^1.14.3"
"@standardnotes/sncrypto-common" "^1.8.2" "@standardnotes/sncrypto-common" "^1.8.2"
"@standardnotes/utils" "^1.6.6" "@standardnotes/utils" "^1.6.6"