refactor: move Props

This commit is contained in:
EnixCoda 2019-11-09 13:28:51 +08:00
parent 8ed78e2a98
commit 570ab3915e
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
6 changed files with 24 additions and 21 deletions

View file

@ -3,25 +3,15 @@ import { Node } from 'components/Node'
import { SearchBar } from 'components/SearchBar'
import { connect } from 'driver/connect'
import { FileExplorerCore } from 'driver/core'
import { ConnectorState } from 'driver/core/FileExplorer'
import { ConnectorState, Props } from 'driver/core/FileExplorer'
import * as React from 'react'
import { FixedSizeList as List, ListChildComponentProps } from 'react-window'
import { cx } from 'utils/cx'
import { MetaData, TreeData } from 'utils/GitHubHelper'
import { usePrevious } from 'utils/hooks'
import { TreeNode, VisibleNodes } from 'utils/VisibleNodesGenerator'
import { Icon } from './Icon'
import { SizeObserver } from './SizeObserver'
export type Props = {
treeData?: TreeData
metaData: MetaData
freeze: boolean
compressSingletonFolder: boolean
accessToken: string | undefined
toggleShowSettings: React.MouseEventHandler
}
class RawFileExplorer extends React.Component<Props & ConnectorState> {
static defaultProps: Partial<Props & ConnectorState> = {
freeze: false,
@ -183,4 +173,4 @@ class RawFileExplorer extends React.Component<Props & ConnectorState> {
}
}
export const FileExplorer = connect<Props, ConnectorState>(FileExplorerCore)(RawFileExplorer)
export const FileExplorer = connect(FileExplorerCore)(RawFileExplorer)

View file

@ -6,12 +6,10 @@ import { SettingsBar } from 'components/SettingsBar'
import { ToggleShowButton } from 'components/ToggleShowButton'
import { connect } from 'driver/connect'
import { SideBarCore } from 'driver/core'
import { ConnectorState } from 'driver/core/SideBar'
import { ConnectorState, Props } from 'driver/core/SideBar'
import * as React from 'react'
import { cx } from 'utils/cx'
export type Props = {}
class RawGitako extends React.PureComponent<Props & ConnectorState> {
static defaultProps: Partial<Props & ConnectorState> = {
baseSize: 260,
@ -147,4 +145,4 @@ class RawGitako extends React.PureComponent<Props & ConnectorState> {
}
}
export const SideBar = connect<Props, ConnectorState>(SideBarCore)(RawGitako)
export const SideBar = connect(SideBarCore)(RawGitako)

View file

@ -47,7 +47,7 @@ export type MethodCreator<Props, State, Args extends any[] = []> = (
dispatch: Dispatch<Props, State>,
) => Method<Args>
type Sources<P, S> = {
export type Sources<P, S> = {
[key: string]: MethodCreator<P, S, any>
}
type WrappedMethods = {

View file

@ -1,4 +1,3 @@
import { Props } from 'components/FileExplorer'
import { GetCreatedMethod, MethodCreator } from 'driver/connect'
import * as ini from 'ini'
import { Base64 } from 'js-base64'
@ -10,6 +9,15 @@ import * as treeParser from 'utils/treeParser'
import * as URLHelper from 'utils/URLHelper'
import { TreeNode, VisibleNodes, VisibleNodesGenerator } from 'utils/VisibleNodesGenerator'
export type Props = {
treeData?: GitHubHelper.TreeData
metaData: GitHubHelper.MetaData
freeze: boolean
compressSingletonFolder: boolean
accessToken: string | undefined
toggleShowSettings: React.MouseEventHandler
}
export type ConnectorState = {
stateText: string
visibleNodes: VisibleNodes | null

View file

@ -1,4 +1,3 @@
import { Props } from 'components/SideBar'
import { GetCreatedMethod, MethodCreator } from 'driver/connect'
import * as configHelper from 'utils/configHelper'
import { Config } from 'utils/configHelper'
@ -8,6 +7,8 @@ import { MetaData, TreeData } from 'utils/GitHubHelper'
import * as keyHelper from 'utils/keyHelper'
import * as URLHelper from 'utils/URLHelper'
export type Props = {}
export type ConnectorState = {
// error message
error?: string

View file

@ -1,5 +1,11 @@
import { Sources } from 'driver/connect'
import * as FileExplorer from './FileExplorer'
import {
ConnectorState as FileExplorerConnectorState,
Props as FileExplorerProps,
} from './FileExplorer'
import * as SideBar from './SideBar'
import { ConnectorState as SideBarConnectorState, Props as SideBarProps } from './SideBar'
export const SideBarCore = SideBar
export const FileExplorerCore = FileExplorer
export const FileExplorerCore: Sources<FileExplorerProps, FileExplorerConnectorState> = FileExplorer
export const SideBarCore: Sources<SideBarProps, SideBarConnectorState> = SideBar