Skip to content

Commit

Permalink
Merge pull request #22 from cybera/fix-sidebar-nav
Browse files Browse the repository at this point in the history
Fix for issue where metadata dataset.name disappeared
  • Loading branch information
agentdave authored Dec 13, 2018
2 parents 6850e89 + 41c3441 commit b08a7dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
5 changes: 3 additions & 2 deletions client/src/components/DatasetColumnTagsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { withStyles } from '@material-ui/core/styles'
import Typography from '@material-ui/core/Typography'
import Paper from '@material-ui/core/Paper'

import { updateDatasetColumnsMutation, datasetColumnTagsQuery } from '../queries'
import { updateDatasetColumnsMutation, datasetColumnTagsQuery, datasetViewQuery } from '../queries'
import DatasetColumnTagsForm from './DatasetColumnTagsForm'
import PanelLoadingState from './PanelLoadingState'

Expand All @@ -25,7 +25,8 @@ const DatasetColumnTagsContainer = (props) => {
<Mutation
mutation={updateDatasetColumnsMutation}
refetchQueries={[
{ query: datasetColumnTagsQuery, variables: { id } }
{ query: datasetColumnTagsQuery, variables: { id } },
{ query: datasetViewQuery, variables: { id } }
]}
>
{ updateColumn => (
Expand Down
25 changes: 19 additions & 6 deletions client/src/components/DatasetMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import * as Ramda from 'ramda'
import ADIButton from './ADIButton'
import DatasetColumnTagsContainer from './DatasetColumnTagsContainer'
import PanelLoadingState from './PanelLoadingState'
import { datasetViewQuery } from '../queries'

export const datasetMetadataQuery = gql`
query($id: Int) {
dataset(id: $id) {
name
id
metadata {
title
contributor
Expand Down Expand Up @@ -150,7 +153,7 @@ const LocalDatePicker = (props) => {

LocalDatePicker.propTypes = {
label: PropTypes.string.isRequired,
value: PropTypes.string,
value: PropTypes.number,
onChange: PropTypes.func.isRequired,
className: PropTypes.string
}
Expand Down Expand Up @@ -461,19 +464,29 @@ const ConnectedDatasetMetadata = (props) => {
<Mutation
mutation={updateDatasetMetadataMutation}
refetchQueries={[
{ query: datasetMetadataQuery, variables: { id } }
{ query: datasetMetadataQuery, variables: { id } },
{ query: datasetViewQuery, variables: { id } }
]}
awaitRefetchQueries
>
{ updateDatasetMetadata => (
<Query query={datasetMetadataQuery} variables={{ id }}>
<Query
query={datasetMetadataQuery}
variables={{ id }}
fetchPolicy="cache-and-network"
>
{({ loading, error, data }) => {
if (loading) return <PanelLoadingState />
if (error) return <p>Error!</p>;

const fieldKeys = Object.keys(DatasetMetadata.defaultProps.fields)
let fields = Ramda.pick(fieldKeys, data.dataset[0].metadata)
fields = Ramda.reject(field => field == null, fields)
fields = Ramda.merge(DatasetMetadata.defaultProps.fields, fields)
let fields = {}

if (data.dataset) {
fields = Ramda.pick(fieldKeys, data.dataset[0].metadata)
fields = Ramda.reject(field => field == null, fields)
fields = Ramda.merge(DatasetMetadata.defaultProps.fields, fields)
}

return (
<StyledDatasetMetadata
Expand Down
2 changes: 2 additions & 0 deletions client/src/containers/DatasetTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const DatasetTitle = (props) => {
<Query
query={datasetViewQuery}
variables={{ id }}
fetchPolicy="cache-and-network"
partialRefetch
>
{
({ data }) => {
Expand Down

0 comments on commit b08a7dd

Please sign in to comment.