generated from openmcp-project/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Add 404 pages #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add 404 pages #197
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c04b57
Add 404 pages
andreaskienle 630f577
Fix type
andreaskienle 547a52a
Fix type
andreaskienle 6de2267
Merge branch 'main' into feat/404
andreaskienle 7bebddb
Fix imports
andreaskienle 569b5fa
Merge branch 'main' into feat/404
andreaskienle 9a092d0
Merge branch 'main' into feat/404
lucasgoral File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import '@ui5/webcomponents-fiori/dist/illustrations/AllIllustrations.js'; | ||
import { NotFoundBanner } from './NotFoundBanner.tsx'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
describe('<NotFoundBanner />', () => { | ||
it('renders title and subtitle interpolating the entityType', () => { | ||
cy.mount( | ||
<MemoryRouter> | ||
<NotFoundBanner entityType="%entityType%" /> | ||
</MemoryRouter>, | ||
); | ||
|
||
cy.contains('%entityType% not found').should('be.visible'); | ||
cy.contains('Sorry, we couldn’t find what you are looking for').should('be.visible'); | ||
|
||
cy.get('ui5-button').contains('Back to Homepage'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.subtitleContainer { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.button { | ||
margin-inline: auto; | ||
margin-block: 2rem; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IllustratedBanner } from '../IllustratedBanner/IllustratedBanner.tsx'; | ||
import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import styles from './NotFoundBanner.module.css'; | ||
import { Button } from '@ui5/webcomponents-react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export interface NotFoundBannerProps { | ||
entityType: string; | ||
} | ||
export function NotFoundBanner({ entityType }: NotFoundBannerProps) { | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<IllustratedBanner | ||
illustrationName={IllustrationMessageType.PageNotFound} | ||
title={t('NotFoundBanner.titleMessage', { entityType })} | ||
subtitle={ | ||
<div className={styles.subtitleContainer}> | ||
<span> | ||
<Trans i18nKey="NotFoundBanner.subtitleMessage" values={{ entityType }} /> | ||
</span> | ||
<Button className={styles.button} onClick={() => navigate('/')}> | ||
{t('NotFoundBanner.navigateHome')} | ||
</Button> | ||
</div> | ||
} | ||
/> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { isNotFoundError, APIError } from './error'; | ||
|
||
describe('error', () => { | ||
describe('isNotFoundError', () => { | ||
it('should return true if error.status is 404', () => { | ||
expect(isNotFoundError(new APIError('', 404))).toBe(true); | ||
expect(isNotFoundError(new APIError('not found', 404))).toBe(true); | ||
}); | ||
|
||
it('should return true if error.status is 403', () => { | ||
expect(isNotFoundError(new APIError('', 403))).toBe(true); | ||
expect(isNotFoundError(new APIError('not found', 403))).toBe(true); | ||
}); | ||
|
||
it('should return false if error is undefined', () => { | ||
expect(isNotFoundError(undefined)).toBe(false); | ||
}); | ||
|
||
it('should return false if error is null', () => { | ||
expect(isNotFoundError(null)).toBe(false); | ||
}); | ||
|
||
it('should return false if error has no status field', () => { | ||
expect(isNotFoundError({} as APIError)).toBe(false); | ||
}); | ||
|
||
it('should return false if error.status is not 404 or 403', () => { | ||
expect(isNotFoundError(new APIError('', 500))).toBe(false); | ||
expect(isNotFoundError(new APIError('', 400))).toBe(false); | ||
expect(isNotFoundError(new APIError('', 401))).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.