mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
refactor: use application error alert in vega-lite-chart
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
9cf450a622
commit
cb38d5dedf
2 changed files with 19 additions and 5 deletions
|
@ -15,3 +15,19 @@ exports[`Vega-Lite markdown extensions renders a vega-lite codeblock 1`] = `
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Vega-Lite markdown extensions shows an error on invalid json 1`] = `
|
||||||
|
<div>
|
||||||
|
<pre>
|
||||||
|
<span>
|
||||||
|
this is a mock for vega lite
|
||||||
|
<code>
|
||||||
|
wpieoghwpoegj
|
||||||
|
|
||||||
|
</code>
|
||||||
|
</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
|
@ -8,10 +8,10 @@ import { ShowIf } from '../../../components/common/show-if/show-if'
|
||||||
import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer'
|
import type { CodeProps } from '../../../components/markdown-renderer/replace-components/code-block-component-replacer'
|
||||||
import { Logger } from '../../../utils/logger'
|
import { Logger } from '../../../utils/logger'
|
||||||
import React, { useEffect, useRef } from 'react'
|
import React, { useEffect, useRef } from 'react'
|
||||||
import { Alert } from 'react-bootstrap'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
|
||||||
import { useAsync } from 'react-use'
|
import { useAsync } from 'react-use'
|
||||||
import type { VisualizationSpec } from 'vega-embed'
|
import type { VisualizationSpec } from 'vega-embed'
|
||||||
|
import { TranslatedApplicationErrorAlert } from '../../../components/common/application-error-alert/translated-application-error-alert'
|
||||||
|
|
||||||
const log = new Logger('VegaChart')
|
const log = new Logger('VegaChart')
|
||||||
|
|
||||||
|
@ -60,9 +60,7 @@ export const VegaLiteChart: React.FC<CodeProps> = ({ code }) => {
|
||||||
return (
|
return (
|
||||||
<AsyncLoadingBoundary loading={libLoading || !vegaEmbed} error={libLoadingError} componentName={'Vega Lite'}>
|
<AsyncLoadingBoundary loading={libLoading || !vegaEmbed} error={libLoadingError} componentName={'Vega Lite'}>
|
||||||
<ShowIf condition={!!renderingError}>
|
<ShowIf condition={!!renderingError}>
|
||||||
<Alert variant={'danger'}>
|
<TranslatedApplicationErrorAlert errorI18nKey={'renderer.vega-lite.errorJson'} />
|
||||||
<Trans i18nKey={'renderer.vega-lite.errorJson'} />
|
|
||||||
</Alert>
|
|
||||||
</ShowIf>
|
</ShowIf>
|
||||||
<div className={'text-center'}>
|
<div className={'text-center'}>
|
||||||
<div ref={diagramContainer} />
|
<div ref={diagramContainer} />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue