Commit 93dd8040 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Various smaller fixes.

parent 2307ef65
Pipeline #62814 passed with stages
in 21 minutes and 26 seconds
import React from 'react'
import PropTypes, { instanceOf } from 'prop-types'
import PropTypes from 'prop-types'
/**
* This is a kinda-HOC that allows to keep a component alive while not being visible.
......
......@@ -120,11 +120,11 @@ function handleApiError(e) {
throw e
}
let error = null
if (e.response) {
const body = e.response.body
const message = (body && body.message) ? body.message : e.response.statusText
const errorMessage = `${message} (${e.response.status})`
let error = null
if (e.response.status === 404) {
error = new DoesNotExist(errorMessage)
} else if (e.response.status === 401) {
......@@ -135,11 +135,16 @@ function handleApiError(e) {
error = new Error(errorMessage)
}
error.status = e.response.status
throw error
} else {
const errorMessage = e.status ? `${e} (${e.status})` : '' + e
throw new Error(errorMessage)
if (e.message === 'Failed to fetch') {
error = new ApiError(e.message)
error.status = 400
} else {
const errorMessage = e.status ? `${e} (${e.status})` : '' + e
error = new Error(errorMessage)
}
}
throw error
}
class Api {
......
......@@ -67,12 +67,14 @@ class ArchiveEntryView extends React.Component {
static defaultState = {
data: null,
metaInfo: null,
showMetaInfo: false,
doesNotExist: false
}
state = {...ArchiveEntryView.defaultState}
state = {
metaInfo: null,
...ArchiveEntryView.defaultState
}
constructor(props) {
super(props)
......@@ -90,7 +92,6 @@ class ArchiveEntryView extends React.Component {
componentDidUpdate(prevProps) {
if (prevProps.api !== this.props.api || prevProps.info !== this.props.info) {
this.setState(ArchiveEntryView.defaultState)
this.updateMetaInfo()
}
......@@ -103,7 +104,7 @@ class ArchiveEntryView extends React.Component {
}
updateMetaInfo() {
if (this.props.api && this.props.info) {
if (this.props.api && this.props.info && !this.state.metaInfo) {
this.props.api.getMetaInfo(this.props.info.domain.metainfo.all_package).then(metaInfo => {
if (!this.unmounted) {
this.setState({metaInfo: metaInfo})
......
......@@ -44,7 +44,7 @@ class ErrorSnacksUnstyled extends React.Component {
let errorStr = 'Unexpected error. Please try again and let us know, if this error keeps happening.'
if (error instanceof Error) {
if (error.name === 'CannotReachApi') {
errorStr = 'Cannot reach the NOMAD API, please try again later.'
errorStr = 'Cannot reach the NOMAD, please try again later.'
} else if (error.name === 'DoesNotExist') {
errorStr = 'You are trying to access information that does not exist. Please try again and let us know, if this error keeps happening.'
} else if (error.name === 'VersionMismatch') {
......
......@@ -183,7 +183,8 @@ class CardCompartmentUnstyled extends React.Component {
},
minHeader: {
position: 'relative',
minHeight: 16 + theme.spacing.unit
minHeight: 16 + theme.spacing.unit,
overflowY: 'hidden'
},
foldButton: {
position: 'absolute',
......
Markdown is supported
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