chore: clean code

This commit is contained in:
EnixCoda 2019-02-09 14:29:40 +08:00
parent 9b18b039ca
commit eb5ebce5bf
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
2 changed files with 24 additions and 14 deletions

View file

@ -59,11 +59,7 @@ export default class FileExplorer extends React.Component {
renderFiles(visibleNodes, onNodeClick) {
const { nodes, depths, focusedNode, expandedNodes } = visibleNodes
if (nodes.length === 0) {
return (
<label className={'no-results'}>
No results found.
</label>
)
return <label className={'no-results'}>No results found.</label>
}
return (
<div className={'files'}>
@ -82,19 +78,33 @@ export default class FileExplorer extends React.Component {
}
render() {
const { stateText, visibleNodes, freeze, handleKeyDown, handleSearchKeyChange, onNodeClick, toggleShowSettings, onFocusSearchBar } = this.props
const {
stateText,
visibleNodes,
freeze,
handleKeyDown,
handleSearchKeyChange,
onNodeClick,
toggleShowSettings,
onFocusSearchBar,
} = this.props
return (
<div className={cx(`file-explorer`, { freeze })} tabIndex={-1} onKeyDown={handleKeyDown} onClick={ freeze ? toggleShowSettings : null}>
{
stateText
? <LoadingIndicator text={stateText} />
: visibleNodes && (
<div
className={cx(`file-explorer`, { freeze })}
tabIndex={-1}
onKeyDown={handleKeyDown}
onClick={freeze ? toggleShowSettings : null}
>
{stateText ? (
<LoadingIndicator text={stateText} />
) : (
visibleNodes && (
<React.Fragment>
<SearchBar onSearchKeyChange={handleSearchKeyChange} onFocus={onFocusSearchBar} />
{this.renderFiles(visibleNodes, onNodeClick)}
</React.Fragment>
)
}
)}
</div>
)
}

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import React from 'react'
import ReactDOM from 'react-dom'
import Gitako from 'components/Gitako'
import { addMiddleware } from 'driver/connect'
import { withErrorLog } from 'analytics'