Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue where metadata dataset.name disappeared #22

Merged
merged 3 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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