Skip to content

Commit

Permalink
fix(workingDatasetReducer): if 422 error, don't clear dataset state
Browse files Browse the repository at this point in the history
if the error was 422, the dataset still exists, don't clear state, we are about to request the dataset info again.
  • Loading branch information
ramfox committed Sep 23, 2019
1 parent 45b4262 commit 4a95f5b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
14 changes: 4 additions & 10 deletions app/components/DatasetSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ComponentList from './ComponentList'
import classNames from 'classnames'
import Spinner from './chrome/Spinner'

import { WorkingDataset, ComponentType, Selections, CommitDetails } from '../models/store'
import { WorkingDataset, ComponentType, Selections } from '../models/store'

interface HistoryListItemProps {
path: string
Expand Down Expand Up @@ -45,7 +45,6 @@ export interface DatasetSidebarProps {
selections: Selections
workingDataset: WorkingDataset
hideCommitNudge: boolean
commitDetails: CommitDetails
setActiveTab: (activeTab: string) => Action
setSelectedListItem: (type: ComponentType, activeTab: string) => Action
fetchWorkingHistory: (page?: number, pageSize?: number) => ApiActionThunk
Expand All @@ -62,13 +61,11 @@ const DatasetSidebar: React.FunctionComponent<DatasetSidebarProps> = (props) =>
setSelectedListItem,
fetchWorkingHistory,
discardChanges,
setHideCommitNudge,
commitDetails
setHideCommitNudge
} = props

const { path, fsiPath, history, status, components } = workingDataset
const { isLoading: commitIsLoading, components: commitComponents } = commitDetails
const { body: commitBody } = commitComponents

const {
activeTab,
component: selectedComponent,
Expand All @@ -84,9 +81,6 @@ const DatasetSidebar: React.FunctionComponent<DatasetSidebarProps> = (props) =>
const historyLoaded = !history.pageInfo.isFetching
const statusLoaded = !!status
const bodyLoaded = !body.pageInfo.isFetching
const commitLoaded = !commitIsLoading
const commitBodyLoaded = !commitBody.pageInfo.isFetching

const noHistory = history.value.length === 0

const handleHistoryScroll = (e: any) => {
Expand Down Expand Up @@ -191,7 +185,7 @@ const DatasetSidebar: React.FunctionComponent<DatasetSidebarProps> = (props) =>
</div>
</CSSTransition>
{
!hideCommitNudge && bodyLoaded && commitLoaded && commitBodyLoaded && statusLoaded && historyLoaded && noHistory && datasetSelected && (
!hideCommitNudge && bodyLoaded && statusLoaded && historyLoaded && noHistory && datasetSelected && (
<div className='commit-nudge'>
<div className='commit-nudge-text'>
You&apos;re ready to make your first commit on this dataset! Verify that the body and meta are accurate, enter a commit message below, and click Submit.
Expand Down
4 changes: 1 addition & 3 deletions app/containers/DatasetSidebarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const DatasetSidebarContainer = connect(
const {
selections,
workingDataset,
commitDetails,
ui
} = state

Expand All @@ -42,8 +41,7 @@ const DatasetSidebarContainer = connect(
selections,
workingDataset,
setModal,
hideCommitNudge,
commitDetails
hideCommitNudge
}, ownProps)
},
{
Expand Down
5 changes: 5 additions & 0 deletions app/reducers/workingDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const workingDatasetsReducer: Reducer = (state = initialState, action: AnyAction
}
}
case DATASET_FAIL:
// if the error is 422, we are going to rerequest this
// dataset using 'fsi=false'
if (action.payload.err.code === 422) {
return state
}
return {
...initialState,
isLoading: false
Expand Down

0 comments on commit 4a95f5b

Please sign in to comment.