Tweak copy and layout of app passwords

This commit is contained in:
Paul Frazee
2023-04-21 18:10:37 -05:00
parent fe72ae6d45
commit e9476d2706
2 changed files with 31 additions and 14 deletions
+23 -4
View File
@@ -2,6 +2,7 @@ import React, {useState} from 'react'
import {StyleSheet, TextInput, View, TouchableOpacity} from 'react-native' import {StyleSheet, TextInput, View, TouchableOpacity} from 'react-native'
import {Text} from '../util/text/Text' import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button' import {Button} from '../util/forms/Button'
import {s} from 'lib/styles'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {isDesktopWeb} from 'platform/detection' import {isDesktopWeb} from 'platform/detection'
@@ -71,6 +72,7 @@ export function Component({}: {}) {
}, [store]) }, [store])
const createAppPassword = async () => { const createAppPassword = async () => {
try {
const newPassword = await store.me.createAppPassword(name) const newPassword = await store.me.createAppPassword(name)
if (newPassword) { if (newPassword) {
setAppPassword(newPassword.password) setAppPassword(newPassword.password)
@@ -78,16 +80,26 @@ export function Component({}: {}) {
Toast.show('Failed to create app password.') Toast.show('Failed to create app password.')
// TODO: better error handling (?) // TODO: better error handling (?)
} }
} catch (e) {
Toast.show('Failed to create app password.')
store.log.error('Failed to create app password', {e})
}
} }
return ( return (
<View style={[styles.container, pal.view]} testID="addAppPasswordsModal"> <View style={[styles.container, pal.view]} testID="addAppPasswordsModal">
<View> <View>
{!appPassword ? (
<Text type="lg"> <Text type="lg">
{!appPassword Please enter a unique name for this App Password. We have generated
? 'Please enter a unique name for this App Password. We have generated a random name for you.' a random name for you.
: "Please save this secret key somewhere safe and accessible. For security reasons, you won't be able to view it again. If you lose this secret key, you'll need to generate a new one."}
</Text> </Text>
) : (
<Text type="lg">
<Text type="lg-bold">Here is your app password.</Text> Use this to
sign into the other app along with your handle.
</Text>
)}
{!appPassword ? ( {!appPassword ? (
<View style={[pal.btn, styles.textInputWrapper]}> <View style={[pal.btn, styles.textInputWrapper]}>
<TextInput <TextInput
@@ -127,6 +139,12 @@ export function Component({}: {}) {
</TouchableOpacity> </TouchableOpacity>
)} )}
</View> </View>
{appPassword ? (
<Text type="lg" style={[pal.textLight, s.mb10]}>
For security reasons, you won't be able to view this again. If you
lose this password, you'll need to generate a new one.
</Text>
) : null}
<View style={styles.btnContainer}> <View style={styles.btnContainer}>
<Button <Button
type="primary" type="primary"
@@ -172,11 +190,12 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
borderRadius: 10, borderRadius: 10,
marginTop: 16, marginTop: 16,
marginBottom: 8, marginBottom: 12,
}, },
btnContainer: { btnContainer: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'center', justifyContent: 'center',
marginTop: 12,
}, },
btn: { btn: {
flexDirection: 'row', flexDirection: 'row',
+1 -3
View File
@@ -31,8 +31,6 @@ export const AppPasswords = withAuthRequired(
) )
const onAdd = React.useCallback(async () => { const onAdd = React.useCallback(async () => {
// const createdPassword = await store.me.createAppPassword('test')
// console.log(createdPassword)
store.shell.openModal({name: 'add-app-password'}) store.shell.openModal({name: 'add-app-password'})
}, [store]) }, [store])
@@ -97,7 +95,7 @@ function AppPasswordsHeader() {
<> <>
<ViewHeader title="App Passwords" /> <ViewHeader title="App Passwords" />
<Text type="sm" style={[styles.description, pal.text]}> <Text type="sm" style={[styles.description, pal.text]}>
These app passwords can be used to log into Bluesky on other client apps These app passwords can be used to log onto Bluesky in other apps
without giving them full access to your account or your password. without giving them full access to your account or your password.
</Text> </Text>
</> </>