Skip to content

Commit

Permalink
feat: always show status tab
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswhong committed Aug 29, 2019
1 parent d1cfbbc commit 9ae00fd
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/components/ComponentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const ComponentList: React.FunctionComponent<ComponentListProps> = (props: Compo
</div>
{
components.map(({ name, displayName, tooltip, icon }) => {
if (status[name]) {
if (status[name] && isLinked) {
const { filepath, status: fileStatus } = status[name]
let filename
if (filepath === 'repo') {
Expand All @@ -138,7 +138,7 @@ const ComponentList: React.FunctionComponent<ComponentListProps> = (props: Compo
displayName={displayName}
name={name}
icon={icon}
filename={isLinked ? filename : ''}
filename={filename}
status={fileStatus}
selected={selectedComponent === name}
selectionType={selectionType}
Expand Down
31 changes: 14 additions & 17 deletions app/components/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ApiAction, ApiActionThunk } from '../store/api'
import ExternalLink from './ExternalLink'
import { Resizable } from './Resizable'
import DatasetSidebar from './DatasetSidebar'
import UnlinkedDataset from './UnlinkedDataset'
import DatasetComponent from './DatasetComponent'
import DatasetListContainer from '../containers/DatasetListContainer'
import CommitDetailsContainer from '../containers/CommitDetailsContainer'
Expand Down Expand Up @@ -82,14 +83,7 @@ export default class Dataset extends React.Component<DatasetProps> {

componentDidMount () {
// poll for status
// setInterval(() => { this.props.fetchWorkingStatus() }, 5000)
const { selections, workingDataset } = this.props
const { activeTab, isLinked } = selections
if (activeTab === 'status' && !isLinked) {
this.props.setActiveTab('history')
} else if (activeTab === 'history' && workingDataset.history.pageInfo.error && workingDataset.history.pageInfo.error.includes('no history')) {
this.props.setActiveTab('status')
}
setInterval(() => { this.props.fetchWorkingStatus() }, 5000)

this.openWorkingDirectory = this.openWorkingDirectory.bind(this)
this.publishUnpublishDataset = this.publishUnpublishDataset.bind(this)
Expand All @@ -116,13 +110,6 @@ export default class Dataset extends React.Component<DatasetProps> {
// this "wires up" all of the tooltips, must be called on update, as tooltips
// in descendents can come and go
ReactTooltip.rebuild()
const { selections, workingDataset } = this.props
const { activeTab, isLinked } = selections
if (activeTab === 'status' && !isLinked) {
this.props.setActiveTab('history')
} else if (activeTab === 'history' && workingDataset.history.pageInfo.error && workingDataset.history.pageInfo.error.includes('no history')) {
this.props.setActiveTab('status')
}
}

// using component state + getDerivedStateFromProps to determine when a new
Expand Down Expand Up @@ -318,16 +305,26 @@ export default class Dataset extends React.Component<DatasetProps> {
/>
</Resizable>
<div className='content-wrapper'>
{/* Show the overlay to dim the rest of the app when the sidebar is open */}
{showDatasetList && <div className='overlay' onClick={toggleDatasetList}></div>}
<div className='transition-group' >
<CSSTransition
in={activeTab === 'status'}
in={(activeTab === 'status') && !isLinked}
classNames='fade'
timeout={300}
mountOnEnter
unmountOnExit
>
<UnlinkedDataset />
</CSSTransition>
<CSSTransition
in={activeTab === 'status' && isLinked}
classNames='fade'
timeout={300}
mountOnEnter
unmountOnExit
>
<DatasetComponent component={selectedComponent} componentStatus={status[selectedComponent]} isLoading={workingDataset.isLoading}/>
<DatasetComponent component={selectedComponent} componentStatus={status[selectedComponent]} isLoading={workingDataset.isLoading} />
</CSSTransition>
<CSSTransition
in={activeTab === 'history'}
Expand Down
8 changes: 4 additions & 4 deletions app/components/DatasetSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ const DatasetSidebar: React.FunctionComponent<DatasetSidebarProps> = ({
return (
<div className='dataset-sidebar'>
<div id='tabs' className='sidebar-list-item'>
{isLinked && <div
<div
className={classNames('tab', { 'active': activeTab === 'status' })}
onClick={() => { onTabClick('status') }}
data-tip='View the latest version or working changes<br/> to this dataset&apos;s components'
>
Status
</div>}
Status
</div>
{!(history.pageInfo.error && history.pageInfo.error.includes('no history')) && <div
className={classNames('tab', { 'active': activeTab === 'history' })}
onClick={() => { onTabClick('history') }}
data-tip={path ? 'Explore older versions of this dataset' : 'This dataset has no previous versions'}
>
History
History
</div>}
</div>
<div id='content'>
Expand Down
18 changes: 18 additions & 0 deletions app/components/UnlinkedDataset.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUnlink } from '@fortawesome/free-solid-svg-icons'

const UnlinkedDataset: React.FunctionComponent = () => (
<div className={'unlinked-dataset'}>
<div className={'message-container'}>
<div>
<h4>This is an Unlinked Dataset</h4>
<p>To use the status tab, link the dataset to your filesystem.</p>
<a href='#'>Link this Dataset</a>
</div>
<FontAwesomeIcon icon={faUnlink} color='#777'/>
</div>
</div>
)

export default UnlinkedDataset
11 changes: 10 additions & 1 deletion app/reducers/selections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ export default (state = initialState, action: AnyAction) => {
localStore().setItem('name', name)
localStore().setItem('isLinked', isLinked)
localStore().setItem('published', published)
return Object.assign({}, state, { peername, name, isLinked, published })

const newActiveTab = isLinked ? 'status' : 'history'

return Object.assign({}, state, {
peername,
name,
isLinked,
published,
activeTab: newActiveTab
})

case LIST_SUCC:
// if there is no peername + name in selections, use the first one on the list
Expand Down
25 changes: 25 additions & 0 deletions app/scss/_dataset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,28 @@ $header-font-size: .9rem;
border-bottom: $list-item-bottom-border;
}
}


////////////////////////////
// Unlinked Dataset //
////////////////////////////

.unlinked-dataset {
height: 100%;

.message-container {
h4 {
color: #777;
font-weight: 500;
}

color: #777;
display: flex;
flex-direction: row;
padding: 19px;
border: 2px solid #E9F0F7;
max-width: 475px;
margin: 150px auto;
border-radius: 5px;
}
}

0 comments on commit 9ae00fd

Please sign in to comment.