refactor: replace plantuml error message with a custom hedgedoc error alert

Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Philip Molares 2023-08-05 22:11:08 +02:00 committed by Tilman Vatteroth
parent ce64fa118d
commit e3c7d0ae8a
12 changed files with 217 additions and 25 deletions

View file

@ -13,10 +13,6 @@ exports[`PlantUML markdown extensions renders a plantuml codeblock 1`] = `
exports[`PlantUML markdown extensions renders an error if no server is defined 1`] = `
<div>
<p
class="alert alert-danger"
>
renderer.plantuml.notConfigured
</p>
This is a mock for "TranslatedApplicationErrorAlert". Props: {"errorI18nKey":"renderer.plantuml.notConfigured"}
</div>
`;

View file

@ -7,10 +7,18 @@ import { TestMarkdownRenderer } from '../../../components/markdown-renderer/test
import { mockI18n } from '../../../test-utils/mock-i18n'
import { PlantumlMarkdownExtension } from './plantuml-markdown-extension'
import { render } from '@testing-library/react'
import type { PropsWithChildren } from 'react'
import React from 'react'
jest.mock('../../../components/common/application-error-alert/translated-application-error-alert', () => ({
TranslatedApplicationErrorAlert: (props: PropsWithChildren) =>
`This is a mock for "TranslatedApplicationErrorAlert". Props: ${JSON.stringify(props)}`
}))
describe('PlantUML markdown extensions', () => {
beforeAll(() => mockI18n())
beforeAll(async () => {
await mockI18n()
})
it('renders a plantuml codeblock', () => {
const view = render(

View file

@ -1,20 +1,14 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { TranslatedApplicationErrorAlert } from '../../../components/common/application-error-alert/translated-application-error-alert'
/**
* Renders an alert if plantuml is not configured.
*/
export const PlantumlNotConfiguredAlert: React.FC = () => {
useTranslation()
return (
<p className='alert alert-danger'>
<Trans i18nKey={'renderer.plantuml.notConfigured'} />
</p>
)
return <TranslatedApplicationErrorAlert errorI18nKey={'renderer.plantuml.notConfigured'} />
}