Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const newestSnapshot = snapshots[0].tag
// Trim trailing slash if needed
const currentPath = this.props.location.pathname.replace(/\/$/, '')
const newestSnapshotUrl = `${currentPath}/versions/${newestSnapshot}`
return (
)
} else {
return null
}
}
}
export default graphql(datasets.getDataset, {
name: 'getDataset',
options: props => ({
variables: {
id: bids.decodeId(props.match.params.datasetId),
},
}),
})(withRouter(DatasetLoader))
queryDataset(datasetId, callback) {
console.log('datasetId in graphql query:', bids.decodeId(datasetId))
const query = datasets.getDataset
client.query({
query: query,
variables: {
id: bids.decodeId(datasetId)
}
})
.then(data => {
data = clone(data)
let snapshots = data.data.dataset.snapshots.slice(0)
for (let snapshot of snapshots) {
let splitId = snapshot.id.split(':')
snapshot._id = splitId[splitId.length -1]
snapshot.original = splitId[0]
}
data.data.dataset.files = data.data.dataset.draft ? data.data.dataset.draft.files : []
return callback(data)
) : (
content
)}
)
}
}
Snapshot.propTypes = {
show: PropTypes.bool,
onHide: PropTypes.func,
history: PropTypes.object,
location: PropTypes.object,
}
export default graphql(openneuroDatasets.getDataset, {
name: 'getDataset',
options: props => ({
variables: {
id: props.match.params.datasetId,
},
}),
})(withRouter(Snapshot))
.then(() => {
this.setState({ datasetId })
client
.query({
query: datasets.getDataset,
variables: {
id: datasetId,
},
})
.then(() => {
mutation
.createSnapshot(client, datasetId)
.then(() => {
this.setState({ uploading: false })
this.uploadCompleteAction()
})
.catch(err => {
this.setState({ uploading: false })
throw err
})
})
export const getDataset = (client, dir, datasetId) => {
return client
.query({
query: datasets.getDataset,
variables: { id: datasetId },
})
.then(() => datasetId)
}
) : (
content
)}
)
}
}
Snapshot.propTypes = {
show: PropTypes.bool,
onHide: PropTypes.func,
history: PropTypes.object,
location: PropTypes.object,
}
export default graphql(datasets.getDataset, {
name: 'getDataset',
options: props => ({
variables: {
id: props.match.params.datasetId,
},
}),
})(withRouter(Snapshot))