diff --git a/packages/ui/src/components/Visualization/CanvasFallback/CanvasFallback.tsx b/packages/ui/src/components/Visualization/CanvasFallback/CanvasFallback.tsx index acdd9bff5..81c409f69 100644 --- a/packages/ui/src/components/Visualization/CanvasFallback/CanvasFallback.tsx +++ b/packages/ui/src/components/Visualization/CanvasFallback/CanvasFallback.tsx @@ -1,20 +1,7 @@ -import { - Bullseye, - Button, - EmptyState, - EmptyStateActions, - EmptyStateBody, - EmptyStateFooter, - EmptyStateHeader, - EmptyStateIcon, -} from '@patternfly/react-core'; -import { ArrowLeftIcon, EyeSlashIcon } from '@patternfly/react-icons'; -import { Links } from '../../../router/links.models'; -import { useComponentLink } from '../../../hooks/ComponentLink'; +import { Bullseye, EmptyState, EmptyStateBody, EmptyStateHeader, EmptyStateIcon } from '@patternfly/react-core'; +import { EyeSlashIcon } from '@patternfly/react-icons'; export const CanvasFallback = () => { - const backLink = useComponentLink(Links.SourceCode); - return ( @@ -28,13 +15,6 @@ export const CanvasFallback = () => {

Try to go back to the source code and check if the source code is valid.

- - - - -
); diff --git a/packages/ui/src/components/Visualization/CanvasFallback/__snapshots__/CanvasFallback.test.tsx.snap b/packages/ui/src/components/Visualization/CanvasFallback/__snapshots__/CanvasFallback.test.tsx.snap index b0e0a736d..fec0b527a 100644 --- a/packages/ui/src/components/Visualization/CanvasFallback/__snapshots__/CanvasFallback.test.tsx.snap +++ b/packages/ui/src/components/Visualization/CanvasFallback/__snapshots__/CanvasFallback.test.tsx.snap @@ -52,41 +52,6 @@ exports[`CanvasFallback renders correctly 1`] = ` Try to go back to the source code and check if the source code is valid.

- diff --git a/packages/ui/src/components/Visualization/Visualization.tsx b/packages/ui/src/components/Visualization/Visualization.tsx index 80bade112..0626d3ef1 100644 --- a/packages/ui/src/components/Visualization/Visualization.tsx +++ b/packages/ui/src/components/Visualization/Visualization.tsx @@ -1,4 +1,4 @@ -import { FunctionComponent, PropsWithChildren } from 'react'; +import { FunctionComponent, PropsWithChildren, ReactNode } from 'react'; import { BaseVisualCamelEntity } from '../../models/visualization/base-visual-entity'; import { ErrorBoundary } from '../ErrorBoundary'; import { Canvas } from './Canvas'; @@ -10,12 +10,13 @@ import { VisibleFlowsProvider } from '../../providers/visible-flows.provider'; interface CanvasProps { className?: string; entities: BaseVisualCamelEntity[]; + fallback?: ReactNode; } export const Visualization: FunctionComponent> = (props) => { return (
- }> + }> } entities={props.entities} /> diff --git a/packages/ui/src/pages/Design/DesignPage.tsx b/packages/ui/src/pages/Design/DesignPage.tsx index 531620b43..9b77f7288 100644 --- a/packages/ui/src/pages/Design/DesignPage.tsx +++ b/packages/ui/src/pages/Design/DesignPage.tsx @@ -3,6 +3,7 @@ import { FunctionComponent, useContext } from 'react'; import { Visualization } from '../../components/Visualization'; import { CatalogModalProvider } from '../../providers/catalog-modal.provider'; import { EntitiesContext } from '../../providers/entities.provider'; +import { ReturnToSourceCodeFallback } from './ReturnToSourceCodeFallback'; import './DesignPage.scss'; export const DesignPage: FunctionComponent = () => { @@ -14,7 +15,11 @@ export const DesignPage: FunctionComponent = () => { Visualization - + } + />
); diff --git a/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.test.tsx b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.test.tsx new file mode 100644 index 000000000..4336cf98e --- /dev/null +++ b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.test.tsx @@ -0,0 +1,14 @@ +import { render } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { ReturnToSourceCodeFallback } from './ReturnToSourceCodeFallback'; + +describe('ReturnToSourceCodeFallback', () => { + it('renders correctly', () => { + const wrapper = render( + + + , + ); + expect(wrapper.asFragment()).toMatchSnapshot(); + }); +}); diff --git a/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.tsx b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.tsx new file mode 100644 index 000000000..98b4e2426 --- /dev/null +++ b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/ReturnToSourceCodeFallback.tsx @@ -0,0 +1,41 @@ +import { + Bullseye, + Button, + EmptyState, + EmptyStateActions, + EmptyStateBody, + EmptyStateFooter, + EmptyStateHeader, + EmptyStateIcon, +} from '@patternfly/react-core'; +import { ArrowLeftIcon, EyeSlashIcon } from '@patternfly/react-icons'; +import { Links } from '../../../router/links.models'; +import { useComponentLink } from '../../../hooks/ComponentLink'; + +export const ReturnToSourceCodeFallback = () => { + const backLink = useComponentLink(Links.SourceCode); + + return ( + + + } + /> + +

It might be that the source code is not available, or that the source code is not valid.

+
+

Try to go back to the source code and check if the source code is valid.

+
+ + + + + +
+
+ ); +}; diff --git a/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/__snapshots__/ReturnToSourceCodeFallback.test.tsx.snap b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/__snapshots__/ReturnToSourceCodeFallback.test.tsx.snap new file mode 100644 index 000000000..e7b841153 --- /dev/null +++ b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/__snapshots__/ReturnToSourceCodeFallback.test.tsx.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ReturnToSourceCodeFallback renders correctly 1`] = ` + +
+
+
+
+
+ +
+
+

+ The provided source code cannot be shown +

+
+
+
+

+ It might be that the source code is not available, or that the source code is not valid. +

+
+

+ Try to go back to the source code and check if the source code is valid. +

+
+ +
+
+
+
+`; diff --git a/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/index.ts b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/index.ts new file mode 100644 index 000000000..9895b1159 --- /dev/null +++ b/packages/ui/src/pages/Design/ReturnToSourceCodeFallback/index.ts @@ -0,0 +1 @@ +export * from './ReturnToSourceCodeFallback';