Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop 1774 part 1 #4199

Merged
merged 8 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue
suppress_comment=\\(.\\|\n\\)*\\$ForceType

[version]
0.29.0
0.32.0
1 change: 1 addition & 0 deletions shared/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function parseRawResult (platform: SearchPlatforms, rr: RawResult, isFollowing:
service: 'external',
icon: platformToLogo32(serviceName),
username: rr.service && rr.service.username || '',
serviceAvatar: rr.service && rr.service.picture_url || '',
serviceName,
profileUrl: 'TODO',
extraInfo,
Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/avatar.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {isTesting} from '../local-debug'

export function createAvatarUrl (props: {url: ?string} | {username: ?string}): ?string {
if (__SCREENSHOT__ || isTesting) return null
if (props.url) return props.url
if (props.username) return `https://keybase.io/${props.username}/picture`
if (typeof props.url === 'string') return props.url
if (typeof props.username === 'string') return `https://keybase.io/${props.username}/picture`
return null
}
2 changes: 1 addition & 1 deletion shared/common-adapters/button.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {FlatButton} from 'material-ui'
import {globalStyles, globalColors} from '../styles'

class Button extends Component<void, Props, void> {
_styles (type: Props.type): Object {
_styles (type: $PropertyType<Props, 'type'>): Object {
let backgroundStyle = {}
let labelStyle = {}
let progressColor = globalColors.white
Expand Down
2 changes: 1 addition & 1 deletion shared/common-adapters/dropdown.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MenuItem extends Component<void, MenuItemProps, void> {

render () {
let textStyle : Object = {}
let textType: TextProps.type = 'HeaderBig'
let textType: $PropertyType<TextProps, 'type'> = 'HeaderBig'

switch (this.props.type || 'Normal') {
case 'Normal':
Expand Down
2 changes: 1 addition & 1 deletion shared/common-adapters/header.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type Props = {
}

export type DefaultProps = {
type: Props.type
type: $PropertyType<Props, 'type'>
}

declare export default class Header extends Component<DefaultProps, Props, void> {
Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/icon.desktop.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @flow
import * as shared from './icon.shared'
import React, {Component} from 'react'
import type {$Exact} from '../constants/types/more'
import type {Exact} from '../constants/types/more'
import type {Props} from './icon'
import {FontIcon} from 'material-ui'
import {globalStyles, globalColors} from '../styles'
import {resolveImageAsURL} from '../../desktop/resolve-root'

class Icon extends Component<void, $Exact<Props>, void> {
class Icon extends Component<void, Exact<Props>, void> {
render () {
let color = shared.defaultColor(this.props.type)
let hoverColor = shared.defaultHoverColor(this.props.type)
Expand Down
5 changes: 3 additions & 2 deletions shared/common-adapters/icon.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {Component} from 'react'
import type {IconType as _IconType} from './icon.constants'
export type IconType = _IconType
import type {$Exact} from '../constants/types/more'
import type {Exact} from '../constants/types/more'

export type Props = {
type: IconType,
Expand All @@ -12,9 +12,10 @@ export type Props = {
onMouseEnter?: () => void,
onMouseLeave?: () => void,
style?: Object,
opacity?: boolean,
inheritColor?: boolean,
underlayColor?: string,
className?: string
}

declare export default class Icon extends Component<void, $Exact<Props>, void> {}
declare export default class Icon extends Component<void, Exact<Props>, void> {}
4 changes: 2 additions & 2 deletions shared/common-adapters/icon.native.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @flow
import * as shared from './icon.shared'
import React, {Component} from 'react'
import type {$Exact} from '../constants/types/more'
import type {Exact} from '../constants/types/more'
import type {Props} from './icon'
import {NativeText, NativeImage} from './index.native'
import {TouchableHighlight} from 'react-native'
import {globalColors} from '../styles'
import {iconMeta} from './icon.constants'

class Icon extends Component<void, $Exact<Props>, void> {
class Icon extends Component<void, Exact<Props>, void> {
render () {
let color = shared.defaultColor(this.props.type)
let iconType = shared.typeToIconMapper(this.props.type)
Expand Down
10 changes: 6 additions & 4 deletions shared/common-adapters/tab-bar.js.flow
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @flow
import Avatar from './avatar'
import {Component} from 'react'
import type {$Exact} from '../constants/types/more'
import type {Exact} from '../constants/types/more'
import type {IconType} from './icon'
import type {TextType} from './text'

export type Props = $Exact<{
export type Props = Exact<{
style?: ?Object,
styleTabBar?: Object,
children?: Array<React$Element<ItemProps>>,
Expand All @@ -15,7 +15,7 @@ export type Props = $Exact<{

export default class TabBar extends Component<void, Props, void> { }

export type ItemProps = $Exact<{
export type ItemProps = Exact<{
tabBarButton?: React$Element<*>,
label?: string,
selected: boolean,
Expand All @@ -25,11 +25,13 @@ export type ItemProps = $Exact<{
style?: Object,
styleContainer?: Object,
children?: React$Element<*>,
onBottom?: boolean,
underlined?: boolean,
}>

export class TabBarItem extends Component<void, ItemProps, void> { }

export type TabBarButtonProps = $Exact<{
export type TabBarButtonProps = Exact<{
selected?: boolean,
source: {type: 'icon', icon: IconType} | {type: 'avatar', avatar: Avatar},
label?: string,
Expand Down
6 changes: 3 additions & 3 deletions shared/common-adapters/text.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const LinkTypes = {
class Text extends Component<void, Props, void> {
context: Context;

_terminalPrefix (type: Props.type): ?React$Element<*> {
_terminalPrefix (type: $PropertyType<Props, 'type'>): ?React$Element<*> {
return ({
'TerminalEmpty': <span>&nbsp;</span>,
'TerminalCommand': <span>> </span>,
'TerminalComment': <span># </span>,
}: {[key: string]: React$Element<*>})[type]
}

static _inlineStyle (type: Props.type, context: Context): Object {
static _inlineStyle (type: $PropertyType<Props, 'type'>, context: Context): Object {
switch (type) {
case 'Terminal':
case 'TerminalCommand':
Expand All @@ -40,7 +40,7 @@ class Text extends Component<void, Props, void> {
}
}

static _colorStyleBackgroundMode (backgroundMode: Background, type: Props.type): Object {
static _colorStyleBackgroundMode (backgroundMode: Background, type: $PropertyType<Props, 'type'>): Object {
if (backgroundMode === 'Information') {
return {color: globalColors.brown_60}
}
Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/text.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export type Props = {
}

declare export default class Text extends Component<void, Props, void> {
static _colorStyleBackgroundMode: (backgroundMode: Background, type: Props.type) => {color?: string};
static _inlineStyle: (type: Props.type, context: Context) => Object;
static _colorStyleBackgroundMode: (backgroundMode: Background, type: $PropertyType<Props, 'type'>) => {color?: string};
static _inlineStyle: (type: $PropertyType<Props, 'type'>, context: Context) => Object;
static textStyle: (props: Props, context: Context) => Object;
}

Expand Down
6 changes: 3 additions & 3 deletions shared/common-adapters/text.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class Text extends Component {
props: Props;
context: Context;

_terminalPrefix (type: Props.type): ?React$Element<*> {
_terminalPrefix (type: $PropertyType<Props, 'type'>): ?React$Element<*> {
return ({
'TerminalEmpty': <NativeText>&nbsp;</NativeText>,
'TerminalCommand': <NativeText>> </NativeText>,
'TerminalComment': <NativeText># </NativeText>,
}: {[key: string]: React$Element<*>})[type]
}

static _inlineStyle (type: Props.type, context: Context): Object {
static _inlineStyle (type: $PropertyType<Props, 'type'>, context: Context): Object {
switch (type) {
case 'Terminal':
case 'TerminalCommand':
Expand All @@ -35,7 +35,7 @@ class Text extends Component {
}
}

static _colorStyleBackgroundMode (backgroundMode: Background, type: Props.type, inTerminal: boolean): Object {
static _colorStyleBackgroundMode (backgroundMode: Background, type: $PropertyType<Props, 'type'>, inTerminal: boolean): Object {
if (backgroundMode === 'Information') {
return {color: globalColors.brown_60}
}
Expand Down
10 changes: 5 additions & 5 deletions shared/common-adapters/user-proofs.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ProofsRender extends Component<void, Props, void> {
}

render () {
const {loading, onClickProofMenu, showingMenuIndex} = this.props
const {loading, onClickProofMenu, showingMenuIndex, style} = this.props
const pad = idx => idx > 0 ? {marginTop: globalMargins.tiny} : {}
const missingProofsRealCSS = `
.user-proof-row .user-proof-row__name {
Expand All @@ -145,7 +145,7 @@ class ProofsRender extends Component<void, Props, void> {
}
`
return (
<Box style={{...styleContainer(loading), ...this.props.style}}>
<Box style={{...styleContainer(loading), ...style}}>
<ReactCSSTransitionGroup transitionName='fade-anim' transitionEnterTimeout={250} transitionLeaveTimeout={250}>
{loading
? (
Expand All @@ -154,7 +154,7 @@ class ProofsRender extends Component<void, Props, void> {
</Box>)
: (
<Box key='non-loading'>
{this.props.proofs && this.props.proofs.map((p, idx) =>
{this.props.tag === 'proofs' && this.props.proofs.map((p, idx) =>
<ProofRow
key={`${p.id || ''}${p.type}`}
ref={c => { this._rows[idx] = c }}
Expand All @@ -166,8 +166,8 @@ class ProofsRender extends Component<void, Props, void> {
style={pad(idx)}
/>
)}
{this.props.missingProofs && this.props.missingProofs.map((mp, idx) => <MissingProofRow key={mp.type} missingProof={mp} style={pad(idx)} />)}
{this.props.missingProofs && <style>{missingProofsRealCSS}</style>}
{this.props.tag === 'missingProofs' && this.props.missingProofs.map((mp, idx) => <MissingProofRow key={mp.type} missingProof={mp} style={pad(idx)} />)}
{this.props.tag === 'missingProofs' && <style>{missingProofsRealCSS}</style>}
</Box>)}
</ReactCSSTransitionGroup>
</Box>
Expand Down
2 changes: 2 additions & 0 deletions shared/common-adapters/user-proofs.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ type CommonProps = {
}

export type Props = ({
tag: 'proofs',
proofs: Array<Proof>,
} & CommonProps) | ({
tag: 'missingProofs',
missingProofs: Array<MissingProof>,
} & CommonProps)

Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/user-proofs.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ProofsRender extends Component<void, Props, void> {

return (
<Box style={{...stylesContainer, ...this.props.style}}>
{this.props.proofs && this.props.proofs.map((p, idx) =>
{this.props.tag === 'proofs' && this.props.proofs.map((p, idx) =>
<ProofRow
key={`${p.id || ''}${p.type}`}
proof={p}
Expand All @@ -127,7 +127,7 @@ class ProofsRender extends Component<void, Props, void> {
hasMenu={!!onClickProofMenu}
style={pad(idx)} />
)}
{this.props.missingProofs && this.props.missingProofs.map((mp, idx) =>
{this.props.tag === 'missingProofs' && this.props.missingProofs.map((mp, idx) =>
<MissingProofRow
key={mp.type}
missingProof={mp}
Expand Down
4 changes: 2 additions & 2 deletions shared/constants/dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type {TypedAction} from './types/flux'
import type {$Exact} from './types/more'
import type {Exact} from './types/more'

export const serializeRestore = 'dev:restoreState'
export const serializeSave = 'dev:saveState'
Expand All @@ -15,7 +15,7 @@ export type DebugConfig = {
}

export const updateDebugConfig = 'dev:updateDebugConfig'
export type UpdateDebugConfig = TypedAction<'dev:updateDebugConfig', $Exact<DebugConfig>, void>
export type UpdateDebugConfig = TypedAction<'dev:updateDebugConfig', Exact<DebugConfig>, void>

export const updateReloading = 'dev:updatehmrReloading'
export type UpdateReloading = TypedAction<'dev:updatehmrReloading', {reloading: boolean}, void>
Expand Down
10 changes: 5 additions & 5 deletions shared/constants/favorite.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @flow
import type {TypedAction} from '../constants/types/flux'
import type {$Exact} from '../constants/types/more'
import type {Exact} from '../constants/types/more'
import type {Folder} from '../constants/folders'

type ListState = $Exact<{
type ListState = Exact<{
tlfs?: Array<Folder>,
ignored?: Array<Folder>,
isPublic: boolean,
Expand All @@ -15,20 +15,20 @@ type ListState = $Exact<{
extraRows?: Array<React$Element<*>>
}>

export type FolderState = $Exact<{
export type FolderState = Exact<{
privateBadge: number,
private: ListState,
publicBadge: number,
public: ListState,
}>

export type ViewState = $Exact<{
export type ViewState = Exact<{
showingPrivate: boolean,
publicIgnoredOpen: boolean,
privateIgnoredOpen: boolean,
}>

export type FavoriteState = $Exact<{
export type FavoriteState = Exact<{
folderState: FolderState,
viewState: ViewState,
}>
Expand Down
1 change: 1 addition & 0 deletions shared/constants/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ export type State = {
sigID: ?SigID,
pgpInfo: PgpInfo & PgpInfoError,
pgpPublicKey: ?string,
proofText: ?string,
}
1 change: 1 addition & 0 deletions shared/constants/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type SearchResult = {
icon: IconType,
username: string,
serviceName: SearchPlatforms,
serviceAvatar: string, // i.e. with twitter it would be their twitter avatar url
profileUrl: string,
extraInfo: ExtraInfo,
keybaseSearchResult: ?SearchResult, // If we want to grab the keybase version of a search result
Expand Down
2 changes: 1 addition & 1 deletion shared/folders/files/paperkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
onBack: () => void,
onBackFromPaperKey: () => void,
toPaperKeyInput: () => void,
phase: StoreState.phase,
phase: $PropertyType<StoreState, 'phase'>,
checkPaperKey: (paperKey: HiddenString) => void,
}

Expand Down
2 changes: 1 addition & 1 deletion shared/folders/files/render.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Props = {
ignored: boolean,
allowIgnore: boolean,
visiblePopupMenu: boolean,
popupMenuItems: MenuProps.items,
popupMenuItems: $PropertyType<MenuProps, 'items'>,
selfUsername: string,
users: UserList,
showGroupIcon?: boolean, // TODO (this is not implemented, but this will show the group icon instead of user avatars)
Expand Down
5 changes: 3 additions & 2 deletions shared/login/register/error/index.render.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {ConstantsStatusCode} from '../../../constants/types/flow-types'
import {Text} from '../../../common-adapters'

const renderError = (error: RPCError) => {
const fields = (error.fields || []).reduce((acc, f) => {
acc[f.key] = f.value
const fields = (Array.isArray(error.fields) ? error.fields : []).reduce((acc, f) => {
const k = f && typeof f.key === 'string' ? f.key : ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐑 This is a little wonky (falling back to the key of '') but probably not worth complicating it more. Flow isn't really helping here :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was falling back to undefined before

acc[k] = f.value || ''
return acc
}, {})
switch (error.code) {
Expand Down
3 changes: 2 additions & 1 deletion shared/login/register/set-public-name/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SetPublicName extends Component<void, Props, State> {
}

render () {
const nameTaken = !!(this.props.existingDevices && this.props.existingDevices.indexOf(this.state.deviceName) !== -1)
const nameTaken = !!(this.props.existingDevices && this.state.deviceName && this.props.existingDevices.indexOf(this.state.deviceName) !== -1)
const submitEnabled = !!(this.state.deviceName && this.state.deviceName.length && !nameTaken)
const nameTakenError = nameTaken ? `The device name: ${this.state.deviceName || ''} is already taken` : null

Expand All @@ -28,6 +28,7 @@ class SetPublicName extends Component<void, Props, State> {
onSubmit={() => this.props.onSubmit(this.state.deviceName)}
onBack={this.props.onBack}
deviceNameError={nameTakenError || this.props.deviceNameError}
existingDevices={this.props.existingDevices}
submitEnabled={submitEnabled}
waiting={this.props.waiting}
/>
Expand Down
Loading