-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show resource validation errors in a scrollable modal when the …
…error icon is pressed
- Loading branch information
1 parent
444bf97
commit 7541c9f
Showing
7 changed files
with
127 additions
and
11 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
53 changes: 53 additions & 0 deletions
53
src/components/molecules/ValidationErrorsModal/ValidationErrorsModal.tsx
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,53 @@ | ||
import React from 'react'; | ||
import {Modal} from 'antd'; | ||
import {ResourceValidationError} from '@models/k8sresource'; | ||
import styled from 'styled-components'; | ||
|
||
const StyledContainer = styled.div` | ||
margin: 20px 10px; | ||
overflow-y: auto; | ||
display: block; | ||
height: 100%; | ||
max-height: 500px; | ||
`; | ||
|
||
const StyledErrorList = styled.ul` | ||
margin: 0; | ||
padding: 5px; | ||
padding-left: 15px; | ||
height: 100%; | ||
width: 100%; | ||
display: block; | ||
`; | ||
|
||
const StyledErrorProperty = styled.span` | ||
font-weight: 600; | ||
display: block; | ||
`; | ||
const StyledErrorMessage = styled.span` | ||
margin-left: 5px; | ||
font-style: italic; | ||
display: block; | ||
`; | ||
|
||
const ValidationErrorsModal = (props: {errors: ResourceValidationError[]; isVisible: boolean; onClose: () => void}) => { | ||
const {errors, isVisible, onClose} = props; | ||
return ( | ||
<Modal centered visible={isVisible} onCancel={() => onClose()} footer={null}> | ||
<StyledContainer> | ||
<StyledErrorList> | ||
{errors.map(error => { | ||
return ( | ||
<li> | ||
<StyledErrorProperty>{error.property}</StyledErrorProperty> | ||
<StyledErrorMessage>{error.message}</StyledErrorMessage> | ||
</li> | ||
); | ||
})} | ||
</StyledErrorList> | ||
</StyledContainer> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ValidationErrorsModal; |
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 @@ | ||
export {default} from './ValidationErrorsModal'; |
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