Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
refactor(*): Small fixes
Browse files Browse the repository at this point in the history
Merge pull request #434 from qri-io/small_fixes
  • Loading branch information
ramfox authored Dec 13, 2018
2 parents 645f1c7 + 9ce5fbb commit 17aa8e8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/components/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export default class Network extends Base {
componentWillMount () {
if (!this.props.skipLoad && this.props.sessionProfile) {
this.props.loadProfiles()
} else if (!this.props.datasets && !this.props.datasetsFetchedAll && !this.props.datasetsFetchedError) {
}
if (!this.props.datasets && !this.props.datasetsFetchedAll && !this.props.datasetsFetchedError) {
this.props.loadRegistryDatasets().then(action => this.handleLoadDatasetsError(action))
}
}

componentWillReceiveProps (nextProps) {
if (!nextProps.datasetsFetchedAll && !nextProps.datasetsLoading && !nextProps.datasetsFetchedError) {
this.props.loadRegistryDatasets().then(action => this.handleLoadDatasetsError(action))
if (this.props.skipLoad !== nextProps.skipLoad && !nextProps.skipload && nextProps.sessionProfile) {
this.props.loadProfiles()
}
}

Expand Down
26 changes: 23 additions & 3 deletions lib/components/dataset/Dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ const RENAME_DATASET_MODAL = 'RENAME_DATASET_MODAL'

export default class Dataset extends Base {
constructor (props) {
super(props);
super(props)

this.state = {
publishing: false
};

[
'handleDownloadDataset',
Expand All @@ -30,7 +34,8 @@ export default class Dataset extends Base {
'handleGoBack',
'handleAddDataset',
'handleReload',
'handleRenameDataset'
'handleRenameDataset',
'handleTogglePublish'
].forEach((m) => { this[m] = this[m].bind(this) })
}

Expand Down Expand Up @@ -150,6 +155,18 @@ export default class Dataset extends Base {
})
}

handleTogglePublish () {
const { peername, name, datasetRef } = this.props
this.setState(
{ publishing: true },
() => {
this.props.togglePublishDataset(peername, name, datasetRef.path, datasetRef.published).then(() => {
this.setState({ publishing: false })
})
}
)
}

template (css) {
const {
datasetRef,
Expand All @@ -172,6 +189,8 @@ export default class Dataset extends Base {
isInNamespace,
registryVersion } = this.props

const { publishing } = this.state

if (!datasetRef) {
return <Spinner large />
}
Expand Down Expand Up @@ -235,7 +254,8 @@ export default class Dataset extends Base {
onRemove={this.handleDeleteDataset}
onAdd={this.handleAddDataset}
onEdit={this.handleEditDataset}
onTogglePublish={() => { this.props.togglePublishDataset(peername, name, datasetRef.path, datasetRef.published) }}
onTogglePublish={this.handleTogglePublish}
publishing={publishing}
exportPath={this.handleDownloadDataset()}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion lib/components/dataset/DatasetButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class DatasetButtonGroup extends Base {
onAdd,
transfering,
onPublish,
publishing,
published,
onEdit,
exportPath,
Expand All @@ -29,7 +30,7 @@ export default class DatasetButtonGroup extends Base {

const publishedText = published ? 'Unpublish' : 'Publish'
if (isLocal && isInNamespace && isLatestDataset && onPublish) {
buttons.push({ onClick: onPublish, text: publishedText })
buttons.push({ onClick: onPublish, text: publishedText, loading: publishing })
}

if (isLatestDataset && !fromRegistry && onEdit) {
Expand Down
2 changes: 2 additions & 0 deletions lib/components/dataset/DatasetRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DatasetRouter extends Base {
datasetRef,
onAdd,
onTogglePublish,
publishing,
onEdit,
exportPath,
onRemove,
Expand All @@ -47,6 +48,7 @@ class DatasetRouter extends Base {
onAdd={onAdd}
onPublish={onTogglePublish}
published={datasetRef.published}
publishing={publishing}
onEdit={onEdit}
exportPath={exportPath}
onRemove={onRemove}
Expand Down
2 changes: 1 addition & 1 deletion lib/reducers/paginate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const paginate = ({ types, mapActionToKey, name }) => {
isFetching: false,
ids: union(state.ids, action.response.result.data),
// nextPageUrl: action.response.nextPageUrl,
fetchedAll: (action.response.result.data.length < action.pageSize),
fetchedAll: (action.response.result.data && action.response.result.data.length < action.pageSize),
pageCount: action.page,
error: ''
})
Expand Down
7 changes: 6 additions & 1 deletion lib/selectors/transfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ export function selectTransferStatus (state, id) {
}

export function selectIsTransfering (state, id) {
return state && state.transfers && !!Object.keys(state.transfers).find(elm => elm === id)
const path = state && state.transfers && Object.keys(state.transfers).find(elm => elm === id)
if (!path) {
return false
}
const status = state.transfers[path]
return status <= 0
}

export function selectTransfers (state) {
Expand Down
2 changes: 1 addition & 1 deletion version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '0.6.1'
export default '0.6.2-dev'

0 comments on commit 17aa8e8

Please sign in to comment.