-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validates resource details page url's params
If url's params(resource name,resource kind name, resource catalog name) of details page is valid then it redirects to details page otherwise to the PageNotFound Signed-off-by: Shiv Verma <shverma@redhat.com>
- Loading branch information
1 parent
6ac010e
commit 546f8c4
Showing
7 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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,20 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { NotFound } from './index'; | ||
|
||
jest.mock('react-router-dom', () => { | ||
return { | ||
useHistory: () => { | ||
return { | ||
history: '' | ||
}; | ||
} | ||
}; | ||
}); | ||
|
||
describe('PageNotFound Component', () => { | ||
it('should render PageNotFound component', () => { | ||
const component = shallow(<NotFound />); | ||
expect(component.debug()).toMatchSnapshot(); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
ui/src/components/PageNotFound/__snapshots__/PageNotFound.test.tsx.snap
This file contains 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,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PageNotFound Component should render PageNotFound component 1`] = ` | ||
"<EmptyState variant=\\"small\\"> | ||
<EmptyStateIcon icon={[Function: warningIcon]} /> | ||
<Title headingLevel=\\"h5\\" size=\\"lg\\"> | ||
Page Not Found | ||
</Title> | ||
<Button variant=\\"primary\\" onClick={[Function: onClick]}> | ||
Back Home | ||
</Button> | ||
</EmptyState>" | ||
`; |
This file contains 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 React from 'react'; | ||
import { | ||
EmptyState, | ||
EmptyStateVariant, | ||
Title, | ||
Button, | ||
EmptyStateIcon | ||
} from '@patternfly/react-core'; | ||
import { IconSize } from '@patternfly/react-icons'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { Icons } from '../../common/icons'; | ||
import Icon from '../Icon'; | ||
|
||
export const NotFound: React.FC = () => { | ||
const history = useHistory(); | ||
|
||
const warningIcon = () => { | ||
return <Icon id={Icons.WarningTriangle} size={IconSize.xl} label="Page Not Found" />; | ||
}; | ||
|
||
return ( | ||
<EmptyState variant={EmptyStateVariant.small}> | ||
<EmptyStateIcon icon={warningIcon} /> | ||
<Title headingLevel="h5" size="lg"> | ||
Page Not Found | ||
</Title> | ||
<Button variant="primary" onClick={() => history.push('/')}> | ||
Back Home | ||
</Button> | ||
</EmptyState> | ||
); | ||
}; |
This file contains 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 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