tests: vaults-2 (#2368)
This commit is contained in:
@@ -4,7 +4,7 @@ import DecoratedInput from '@/Components/Input/DecoratedInput'
|
||||
import { useApplication } from '@/Components/ApplicationProvider'
|
||||
import {
|
||||
ChangeVaultKeyOptionsDTO,
|
||||
KeySystemRootKeyPasswordType,
|
||||
KeySystemPasswordType,
|
||||
KeySystemRootKeyStorageMode,
|
||||
SharedVaultInviteServerHash,
|
||||
SharedVaultUserServerHash,
|
||||
@@ -32,9 +32,7 @@ const EditVaultModal: FunctionComponent<Props> = ({ onCloseDialog, existingVault
|
||||
const [members, setMembers] = useState<SharedVaultUserServerHash[]>([])
|
||||
const [invites, setInvites] = useState<SharedVaultInviteServerHash[]>([])
|
||||
const [isAdmin, setIsAdmin] = useState<boolean>(true)
|
||||
const [passwordType, setPasswordType] = useState<KeySystemRootKeyPasswordType>(
|
||||
KeySystemRootKeyPasswordType.Randomized,
|
||||
)
|
||||
const [passwordType, setPasswordType] = useState<KeySystemPasswordType>(KeySystemPasswordType.Randomized)
|
||||
const [keyStorageMode, setKeyStorageMode] = useState<KeySystemRootKeyStorageMode>(KeySystemRootKeyStorageMode.Synced)
|
||||
const [customPassword, setCustomPassword] = useState<string | undefined>(undefined)
|
||||
|
||||
@@ -94,7 +92,7 @@ const EditVaultModal: FunctionComponent<Props> = ({ onCloseDialog, existingVault
|
||||
throw new Error('Password type is not changing')
|
||||
}
|
||||
|
||||
if (passwordType === KeySystemRootKeyPasswordType.UserInputted) {
|
||||
if (passwordType === KeySystemPasswordType.UserInputted) {
|
||||
if (!customPassword) {
|
||||
throw new Error('Custom password is not set')
|
||||
}
|
||||
@@ -113,7 +111,7 @@ const EditVaultModal: FunctionComponent<Props> = ({ onCloseDialog, existingVault
|
||||
await application.vaults.changeVaultOptions({
|
||||
vault,
|
||||
newPasswordType: isChangingPasswordType ? getPasswordTypeParams() : undefined,
|
||||
newKeyStorageMode: isChangingKeyStorageMode ? keyStorageMode : undefined,
|
||||
newStorageMode: isChangingKeyStorageMode ? keyStorageMode : undefined,
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -121,7 +119,7 @@ const EditVaultModal: FunctionComponent<Props> = ({ onCloseDialog, existingVault
|
||||
)
|
||||
|
||||
const createNewVault = useCallback(async () => {
|
||||
if (passwordType === KeySystemRootKeyPasswordType.UserInputted) {
|
||||
if (passwordType === KeySystemPasswordType.UserInputted) {
|
||||
if (!customPassword) {
|
||||
throw new Error('Custom key is not set')
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { KeySystemRootKeyPasswordType } from '@standardnotes/snjs'
|
||||
import { KeySystemPasswordType } from '@standardnotes/snjs'
|
||||
import StyledRadioInput from '@/Components/Radio/StyledRadioInput'
|
||||
import DecoratedPasswordInput from '@/Components/Input/DecoratedPasswordInput'
|
||||
import { useState } from 'react'
|
||||
|
||||
type PasswordTypePreference = {
|
||||
value: KeySystemRootKeyPasswordType
|
||||
value: KeySystemPasswordType
|
||||
label: string
|
||||
description: string
|
||||
}
|
||||
|
||||
const options: PasswordTypePreference[] = [
|
||||
{
|
||||
value: KeySystemRootKeyPasswordType.Randomized,
|
||||
value: KeySystemPasswordType.Randomized,
|
||||
label: 'Randomized (Recommended)',
|
||||
description: 'Your vault key will be randomly generated and synced to your account.',
|
||||
},
|
||||
{
|
||||
value: KeySystemRootKeyPasswordType.UserInputted,
|
||||
value: KeySystemPasswordType.UserInputted,
|
||||
label: 'Custom (Advanced)',
|
||||
description:
|
||||
'Choose your own key for your vault. This is an advanced option and is not recommended for most users.',
|
||||
@@ -28,8 +28,8 @@ export const PasswordTypePreference = ({
|
||||
onChange,
|
||||
onCustomKeyChange,
|
||||
}: {
|
||||
value: KeySystemRootKeyPasswordType
|
||||
onChange: (value: KeySystemRootKeyPasswordType) => void
|
||||
value: KeySystemPasswordType
|
||||
onChange: (value: KeySystemPasswordType) => void
|
||||
onCustomKeyChange: (value: string) => void
|
||||
}) => {
|
||||
const [customKey, setCustomKey] = useState('')
|
||||
@@ -57,7 +57,7 @@ export const PasswordTypePreference = ({
|
||||
)
|
||||
})}
|
||||
|
||||
{value === KeySystemRootKeyPasswordType.UserInputted && (
|
||||
{value === KeySystemPasswordType.UserInputted && (
|
||||
<div>
|
||||
<div className="text-gray-500 mt-3 text-sm">{options[1].description}</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user