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 = ({ ...@@ -204,14 +204,14 @@ export const domains = ({
supportsSort: true supportsSort: true
}, },
'ems.chemical': { 'ems.chemical': {
label: 'Material name', label: 'Material name'
}, },
'ems.method': { 'ems.method': {
label: 'Method', label: 'Method',
supportsSort: true supportsSort: true
}, },
'ems.data_type': { 'ems.data_type': {
label: 'Data', label: 'Data'
}, },
'ems.origin_time': { 'ems.origin_time': {
label: 'Date', label: 'Date',
......
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' 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 { compose } from 'recompose'
import { withApi, DoesNotExist } from '../api' import { withApi, DoesNotExist } from '../api'
import { withRouter } from 'react-router' import { withRouter } from 'react-router'
...@@ -22,7 +22,8 @@ class EntryQuery extends React.Component { ...@@ -22,7 +22,8 @@ class EntryQuery extends React.Component {
} }
static defaultState = { static defaultState = {
doesNotExist: false doesNotExist: false,
queryParams: null
} }
state = {...EntryQuery.defaultState} state = {...EntryQuery.defaultState}
...@@ -43,7 +44,7 @@ class EntryQuery extends React.Component { ...@@ -43,7 +44,7 @@ class EntryQuery extends React.Component {
} }
}).catch(error => { }).catch(error => {
if (error.name === 'DoesNotExist') { if (error.name === 'DoesNotExist') {
this.setState({doesNotExist: true}) this.setState({doesNotExist: true, queryParams: queryParams})
} else { } else {
this.props.raiseError(error) this.props.raiseError(error)
} }
...@@ -63,12 +64,19 @@ class EntryQuery extends React.Component { ...@@ -63,12 +64,19 @@ class EntryQuery extends React.Component {
render() { render() {
const { classes, api } = this.props const { classes, api } = this.props
const { doesNotExist } = this.state const { doesNotExist, queryParams } = this.state
let message = 'loading ...' let message = 'loading ...'
if (doesNotExist) { 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 = ` message = `
This URL points to an entry that either does not exist, or that you are not This URL points to an entry that either does not exist, or that you are not
authorized to see.` 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