Skip to content

Commit

Permalink
wot-author wrapping and routing (keybase#23458)
Browse files Browse the repository at this point in the history
* wot-author wrapping and routing

* yarn test -u Storyshots

* hide proofs option when lacking proofs

* feedback

* feedback

* feedback

* nav

* yarn test -u Storyshots

* key

* fix

* fix

* sort-keys

* uncomponent

* yarn test -u Storyshots
  • Loading branch information
mlsteele authored Apr 3, 2020
1 parent 31f382b commit 84b9105
Showing 10 changed files with 2,355 additions and 720 deletions.
2 changes: 2 additions & 0 deletions shared/common-adapters/modal/index.tsx
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ type Props = {
mobileStyle?: Styles.StylesCrossPlatform
noScrollView?: boolean
backgroundStyle?: Styles.StylesCrossPlatform
scrollViewRef?: React.Ref<ScrollView>

// Desktop only popup overrides
popupStyleClose?: Styles.StylesCrossPlatform
@@ -62,6 +63,7 @@ const ModalInner = (props: Props) => (
props.children
) : (
<Kb.ScrollView
ref={props.scrollViewRef}
alwaysBounceVertical={false}
style={Styles.collapseStyles([styles.scroll, props.backgroundStyle])}
contentContainerStyle={styles.scrollContentContainer}
2 changes: 1 addition & 1 deletion shared/common-adapters/plain-input.d.ts
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ export type Props = {
flexable?: boolean
maxLength?: number
// doesn't fire onChangeText if value would exceed maxBytes (utf-8)
// i.e. can only have an effect if this is a controlled input
// i.e. can only have an effect if this is an uncontrolled input
// doesn't enforce on longer `props.value`s coming in
maxBytes?: number
multiline?: boolean
6 changes: 6 additions & 0 deletions shared/constants/profile.tsx
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export const makeInitialState = (): Types.State => ({
searchShowingSuggestions: false,
username: '',
usernameValid: true,
wotAuthor: makeWotAuthor(),
})

export const makeProveGenericParams = (): Types.ProveGenericParams => ({
@@ -42,6 +43,11 @@ export const toProveGenericParams = (p: RPCGen.ProveParameters): Types.ProveGene
title: p.title,
})

export const makeWotAuthor = (): Types.WotAuthor => ({
error: '',
initialVerificationType: 'in_person',
})

export const waitingKey = 'profile:waiting'
export const uploadAvatarWaitingKey = 'profile:uploadAvatar'
export const blockUserWaitingKey = 'profile:blockUser'
10 changes: 9 additions & 1 deletion shared/constants/types/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as RPCTypes from './rpc-gen'
import {PlatformsExpandedType} from './more'
import {PlatformsExpandedType, WebOfTrustVerificationType} from './more'
import {SiteIconSet} from './tracker2'

export type ProveGenericParams = {
@@ -11,6 +11,13 @@ export type ProveGenericParams = {
readonly buttonLabel: string
}

export type WotAuthor = {
error: string
initialVerificationType: WebOfTrustVerificationType
}

export type WotAuthorQuestion = 'question1' | 'question2'

export type State = {
readonly errorCode?: number
readonly errorText: string
@@ -38,4 +45,5 @@ export type State = {
readonly username: string
readonly usernameValid: boolean
readonly searchShowingSuggestions: boolean
readonly wotAuthor: WotAuthor
}
4 changes: 4 additions & 0 deletions shared/profile/routes.tsx
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import ProfileProveEnterUsername from './prove-enter-username/container'
import ProfileProveWebsiteChoice from './prove-website-choice/container'
import ProfileRevoke from './revoke/container'
import ProfileShowcaseTeamOffer from './showcase-team-offer/container'
import ProfileWotAuthor from './wot-author/container'

export const newRoutes = {
profile: {getScreen: (): typeof Profile => require('./user/container').default},
@@ -47,5 +48,8 @@ export const newModalRoutes = {
profileShowcaseTeamOffer: {
getScreen: (): typeof ProfileShowcaseTeamOffer => require('./showcase-team-offer/container').default,
},
profileWotAuthor: {
getScreen: (): typeof ProfileWotAuthor => require('./wot-author/container').default,
},
...PGPRoutes,
}
7 changes: 5 additions & 2 deletions shared/profile/user/container.tsx
Original file line number Diff line number Diff line change
@@ -93,7 +93,10 @@ const connected = Container.namedConnect(
},
dispatch => ({
_onEditAvatar: () => dispatch(ProfileGen.createEditAvatar()),
_onIKnowThem: () => {}, // TODO: route to the new attestation flow
_onIKnowThem: (username: string) =>
dispatch(
RouteTreeGen.createNavigateAppend({path: [{props: {username}, selected: 'profileWotAuthor'}]})
),
_onReload: (username: string, isYou: boolean, state: Types.DetailsState) => {
if (state !== 'valid') {
// Might be a Keybase user or not, launch non-user profile fetch.
@@ -151,7 +154,7 @@ const connected = Container.namedConnect(
onAddIdentity,
onBack: dispatchProps.onBack,
onEditAvatar: stateProps.userIsYou ? dispatchProps._onEditAvatar : undefined,
onIKnowThem: stateProps.userIsYou ? undefined : dispatchProps._onIKnowThem, // PICNIC-847 open the modal
onIKnowThem: stateProps.userIsYou ? undefined : () => dispatchProps._onIKnowThem(stateProps.username),
onReload: () => dispatchProps._onReload(stateProps.username, stateProps.userIsYou, stateProps.state),
reason: stateProps.reason,
sbsAvatarUrl: stateProps.sbsAvatarUrl,
53 changes: 53 additions & 0 deletions shared/profile/wot-author/container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as React from 'react'
import {Question1, Question2} from '.'
import * as Container from '../../util/container'
import * as RouteTreeGen from '../../actions/route-tree-gen'
import * as Types from '../../constants/types/profile'

export type Props = Container.RouteProps<{username: string; question?: Types.WotAuthorQuestion}>

export const WotAuthorRoot = (props: Props) => {
const voucheeUsername = Container.getRouteProps(props, 'username', '')
const whichQuestion = Container.getRouteProps(props, 'question', 'question1')
const nav = Container.useSafeNavigation()
const dispatch = Container.useDispatch()
let {error, initialVerificationType} = Container.useSelector(state => state.profile.wotAuthor)
if (!error && !voucheeUsername) {
error = 'Routing missing username.'
}
if (whichQuestion === 'question1') {
const proofs = [{key: 'web', value: 'fake.proof'}] // PICNIC-1088 TODO
const onSubmit = answer => {
console.log(answer) // PICNIC-1087 TODO use values
dispatch(
nav.safeNavigateAppendPayload({
path: [{props: {question: 'question2', username: voucheeUsername}, selected: 'profileWotAuthor'}],
})
)
}
return (
<Question1
error={error}
initialVerificationType={initialVerificationType}
onSubmit={onSubmit}
proofs={proofs}
voucheeUsername={voucheeUsername}
/>
)
} else {
const onSubmit = answer => {
console.log(answer) // PICNIC-1087 TODO use values
dispatch(RouteTreeGen.createClearModals())
}
return (
<Question2
error={error}
onBack={() => dispatch(nav.safeNavigateUpPayload())}
onSubmit={onSubmit}
voucheeUsername={voucheeUsername}
/>
)
}
}

export default WotAuthorRoot
9 changes: 9 additions & 0 deletions shared/profile/wot-author/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -3,7 +3,15 @@ import * as Sb from '../../stories/storybook'
import {Question1, Question2} from '.'

const props = {
initialVerificationType: 'in_person' as 'in_person',
onBack: Sb.action('onBack'),
onSubmit: Sb.action('onSubmit'),
proofs: [
{key: 'twitter', value: 'cecileboucheron'},
{key: 'reddit', value: 'cecileboucheron'},
{key: 'pgp', value: '75BHEBEGEBES'},
{key: 'web', value: 'web.site'},
],
voucheeUsername: 'weijiekohyalenus',
}

@@ -18,6 +26,7 @@ const load = () => {
.add('Question2', () => <Question2 {...props} />)
.add('Question1 error', () => <Question1 {...props} {...errorProps} />)
.add('Question2 error', () => <Question2 {...props} {...errorProps} />)
.add('Question2 spinning', () => <Question2 {...props} waiting={true} />)
}

export default load
Loading

0 comments on commit 84b9105

Please sign in to comment.