-
Notifications
You must be signed in to change notification settings - Fork 407
RI-6841: Add close button for unsupported key types #4401
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4695589
add close button to module types details, unsuported type details and…
dantovska ca2732b
remove the key from onClose parameter as it is not used hence not needed
dantovska 6052c84
add the custom details wrapper
dantovska 6c2e932
rename custom details wrapper to text details wrapper
dantovska d943e11
side fix: make a property optional
dantovska ffc00eb
wrap module type details with text details wrapper to reuse functiona…
dantovska 8220f4c
wrap too long key name details with text details wrapper to reuse fun…
dantovska 9fba2f9
wrap unsupported type details with text details wrapper to reuse func…
dantovska 2b7ab7f
remove unused property from key details header, as keyProp is no long…
dantovska 2038249
fix existing components tests and add wrapper tests
dantovska 4d395cb
Add test ids
dantovska 34d5a42
rename wrongly named test
dantovska a18a79c
Add ModuleTypeDetailsProps type
dantovska 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
4 changes: 4 additions & 0 deletions
4
.../src/pages/browser/modules/key-details/components/modules-type-details/styles.module.scss
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,4 @@ | ||
.link { | ||
text-decoration: underline; | ||
color: var(--euiColorFullShade); | ||
} |
29 changes: 29 additions & 0 deletions
29
...s/browser/modules/key-details/components/text-details-wrapper/TextDetailsWrapper.spec.tsx
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,29 @@ | ||
import React from "react" | ||
import TextDetailsWrapper from "./TextDetailsWrapper" | ||
import { fireEvent, render, screen } from "uiSrc/utils/test-utils"; | ||
|
||
describe('TextDetailsWrapper', () => { | ||
it('should render children correctly', () => { | ||
const { queryByTestId } = render( | ||
<TextDetailsWrapper onClose={jest.fn()}> | ||
<div data-testid="children-wrapper">Children</div> | ||
</TextDetailsWrapper> | ||
); | ||
|
||
expect(queryByTestId('children-wrapper')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onClose when close button is clicked', () => { | ||
const mockOnClose = jest.fn(); | ||
|
||
render( | ||
<TextDetailsWrapper onClose={mockOnClose}> | ||
<div data-testid="children-wrapper">Children</div> | ||
</TextDetailsWrapper> | ||
); | ||
|
||
fireEvent.click(screen.getByTestId("close-key-btn")); | ||
|
||
expect(mockOnClose).toBeCalledTimes(1); | ||
}); | ||
}) |
38 changes: 38 additions & 0 deletions
38
.../pages/browser/modules/key-details/components/text-details-wrapper/TextDetailsWrapper.tsx
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,38 @@ | ||
import React, { ReactNode } from 'react'; | ||
|
||
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from "@elastic/eui"; | ||
|
||
import styles from './styles.module.scss'; | ||
|
||
const TextDetailsWrapper = ( | ||
{ onClose, children, testid }: { onClose: () => void, children: ReactNode, testid?: string } | ||
) => { | ||
const getDataTestid = (suffix: string) => (testid ? `${testid}-${suffix}` : suffix); | ||
|
||
return ( | ||
<div className={styles.container} data-testid={getDataTestid('details')}> | ||
<EuiToolTip | ||
content="Close" | ||
position="left" | ||
anchorClassName={styles.closeRightPanel} | ||
> | ||
<EuiButtonIcon | ||
iconType="cross" | ||
color="primary" | ||
aria-label="Close key" | ||
className={styles.closeBtn} | ||
onClick={() => onClose()} | ||
data-testid={getDataTestid('close-key-btn')} | ||
/> | ||
</EuiToolTip> | ||
<EuiFlexGroup alignItems="center" justifyContent="center"> | ||
<EuiFlexItem className={styles.textWrapper}> | ||
<div>{children}</div> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
export default TextDetailsWrapper; |
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
5 changes: 2 additions & 3 deletions
5
...r/modules/key-details/components/too-long-key-name-details/TooLongKeyNameDetails.spec.tsx
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import React from 'react' | ||
import { render } from 'uiSrc/utils/test-utils' | ||
import TooLongKeyNameDetails | ||
from 'uiSrc/pages/browser/modules/key-details/components/too-long-key-name-details/TooLongKeyNameDetails' | ||
import TooLongKeyNameDetails from './TooLongKeyNameDetails'; | ||
|
||
describe('TooLongKeyNameDetails', () => { | ||
it('should render', () => { | ||
expect(render(<TooLongKeyNameDetails />)).toBeTruthy() | ||
expect(render(<TooLongKeyNameDetails onClose={jest.fn()}/>)).toBeTruthy() | ||
}) | ||
}) |
26 changes: 11 additions & 15 deletions
26
...rowser/modules/key-details/components/too-long-key-name-details/TooLongKeyNameDetails.tsx
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 |
---|---|---|
@@ -1,21 +1,17 @@ | ||
import React from 'react' | ||
import { EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui' | ||
import { EuiText, EuiTitle } from '@elastic/eui' | ||
|
||
import styles from './styles.module.scss' | ||
import TextDetailsWrapper from '../text-details-wrapper/TextDetailsWrapper' | ||
|
||
const TooLongKeyNameDetails = () => ( | ||
<div className={styles.container} data-testid="too-long-key-name-details"> | ||
<EuiFlexGroup alignItems="center" justifyContent="center"> | ||
<EuiFlexItem className={styles.textWrapper}> | ||
<EuiTitle> | ||
<h4>The key name is too long</h4> | ||
</EuiTitle> | ||
<EuiText size="s"> | ||
Details cannot be displayed. | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
const TooLongKeyNameDetails = ({ onClose }: { onClose: () => void}) => ( | ||
<TextDetailsWrapper onClose={onClose} testid="too-long-key-name"> | ||
<EuiTitle> | ||
<h4>The key name is too long</h4> | ||
</EuiTitle> | ||
<EuiText size="s"> | ||
Details cannot be displayed. | ||
</EuiText> | ||
</TextDetailsWrapper> | ||
) | ||
|
||
export default TooLongKeyNameDetails |
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
44 changes: 21 additions & 23 deletions
44
...rowser/modules/key-details/components/unsupported-type-details/UnsupportedTypeDetails.tsx
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 |
---|---|---|
@@ -1,31 +1,29 @@ | ||
import React from 'react' | ||
import { EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui' | ||
import { EuiText, EuiTitle } from '@elastic/eui' | ||
|
||
import { EXTERNAL_LINKS } from 'uiSrc/constants/links' | ||
import TextDetailsWrapper from '../text-details-wrapper/TextDetailsWrapper'; | ||
|
||
import styles from './styles.module.scss' | ||
|
||
const UnsupportedTypeDetails = () => ( | ||
<div className={styles.container} data-testid="unsupported-type-details"> | ||
<EuiFlexGroup alignItems="center" justifyContent="center"> | ||
<EuiFlexItem className={styles.textWrapper}> | ||
<EuiTitle> | ||
<h4>This key type is not currently supported.</h4> | ||
</EuiTitle> | ||
<EuiText size="s"> | ||
See{' '} | ||
<a | ||
href={EXTERNAL_LINKS.githubRepo} | ||
className={styles.link} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
our repository | ||
</a> | ||
{' '}for the list of supported key types. | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
const UnsupportedTypeDetails = ({ onClose }: { onClose: () => void }) => ( | ||
<TextDetailsWrapper onClose={onClose} testid="unsupported-type"> | ||
<EuiTitle> | ||
<h4>This key type is not currently supported.</h4> | ||
</EuiTitle> | ||
<EuiText size="s"> | ||
See{' '} | ||
<a | ||
href={EXTERNAL_LINKS.githubRepo} | ||
className={styles.link} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
our repository | ||
</a> | ||
{' '}for the list of supported key types. | ||
</EuiText> | ||
</TextDetailsWrapper> | ||
) | ||
|
||
export default UnsupportedTypeDetails |
26 changes: 2 additions & 24 deletions
26
.../pages/browser/modules/key-details/components/unsupported-type-details/styles.module.scss
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 |
---|---|---|
@@ -1,26 +1,4 @@ | ||
.container { | ||
display: flex; | ||
flex-grow: 1; | ||
padding: 16px 40px 30px; | ||
|
||
text-align: center; | ||
color: #FFFFFFAD; | ||
|
||
h4 { | ||
font-size: 18px; | ||
font-weight: normal; | ||
margin-bottom: 18px; | ||
line-height: 24px; | ||
} | ||
} | ||
|
||
.textWrapper { | ||
max-width: 640px; | ||
position: relative; | ||
top: -7%; | ||
} | ||
|
||
.link { | ||
text-decoration: underline; | ||
color: var(--euiColorFullShade); | ||
} | ||
color: var(--euiColorFullShade) !important; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, if this really is not used