Commit 9148e425 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added custom 404 error message for MP entries.

parent bd83d704
Pipeline #82122 passed with stages
in 21 minutes and 22 seconds
......@@ -204,14 +204,14 @@ export const domains = ({
supportsSort: true
},
'ems.chemical': {
label: 'Material name',
label: 'Material name'
},
'ems.method': {
label: 'Method',
supportsSort: true
},
'ems.data_type': {
label: 'Data',
label: 'Data'
},
'ems.origin_time': {
label: 'Date',
......
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles, Typography } from '@material-ui/core'
import { withStyles, Typography, Link } from '@material-ui/core'
import { compose } from 'recompose'
import { withApi, DoesNotExist } from '../api'
import { withRouter } from 'react-router'
......@@ -22,7 +22,8 @@ class EntryQuery extends React.Component {
}
static defaultState = {
doesNotExist: false
doesNotExist: false,
queryParams: null
}
state = {...EntryQuery.defaultState}
......@@ -43,7 +44,7 @@ class EntryQuery extends React.Component {
}
}).catch(error => {
if (error.name === 'DoesNotExist') {
this.setState({doesNotExist: true})
this.setState({doesNotExist: true, queryParams: queryParams})
} else {
this.props.raiseError(error)
}
......@@ -63,12 +64,19 @@ class EntryQuery extends React.Component {
render() {
const { classes, api } = this.props
const { doesNotExist } = this.state
const { doesNotExist, queryParams } = this.state
let message = 'loading ...'
if (doesNotExist) {
if (api.isLoggedIn) {
console.log(queryParams)
if (queryParams && queryParams['external_id'] && queryParams['external_id'].startsWith('mp-')) {
message = <React.Fragment>
This particular calculation <Link href={`https://materialsproject.org/tasks/${queryParams['external_id']}#`}>
{queryParams['external_id']}
</Link> has not yet been provided to NOMAD by the Materials Project.
</React.Fragment>
} else if (api.isLoggedIn) {
message = `
This URL points to an entry that either does not exist, or that you are not
authorized to see.`
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment