-
Notifications
You must be signed in to change notification settings - Fork 412
RI-5917-ShowTTL-checkbox-for-hash-fields #3624
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
kchepikava
merged 23 commits into
main
from
fe/feature/RI-5917-hide-ttl-for-individual-hash-fields
Aug 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e891e6d
RI-5917-ShowTTL-checkbox-for-hash-fields
kchepikava 24ab8a4
5917 comments resolve, show TTl checkbox only when necessary
kchepikava 383e17a
5917 fix tests
kchepikava a178747
Merge branch 'main' into fe/feature/RI-5917-hide-ttl-for-individual-h…
mariasergeenko 7e81886
Merge remote-tracking branch 'origin/release/2.54.0' into fe/feature/…
mariasergeenko c9d4023
RI-5959 fixed showttl not working
kchepikava ee2e973
RI-5960 fixed borders are not aligned
kchepikava 9332b5d
RI-5960-fix-style
kchepikava c7fc9a8
Merge pull request #3650 from RedisInsight/fe/bugfix/RI-5960-borders-…
mariasergeenko 7b302b7
Merge pull request #3649 from RedisInsight/fe/bugfix/RI-5959-show-ttl…
mariasergeenko 934e6d7
Merge remote-tracking branch 'origin/fe/feature/RI-5917-hide-ttl-for-…
mariasergeenko 2426d8d
Verify add show ttl
mariasergeenko 02be7e3
Merge remote-tracking branch 'origin' into fe/feature/RI-5917-hide-tt…
kchepikava bb5121d
Merge branch 'main' into fe/feature/RI-5917-hide-ttl-for-individual-h…
kchepikava 5252acf
Merge branch 'release/2.54.0' into fe/feature/RI-5917-hide-ttl-for-in…
kchepikava 9a9ea6b
Merge branch 'fe/feature/RI-5917-hide-ttl-for-individual-hash-fields'…
mariasergeenko 1a94b1c
remove only
mariasergeenko 667590a
remove config
mariasergeenko 1dad4ba
Merge pull request #3655 from RedisInsight/e2e/feature/RI-5917-hide-t…
mariasergeenko c1132af
RI-5917 add subheader for all fields
kchepikava 3c2a64c
RI-5917 move show ttl checkbox in hash actions
kchepikava 822eac7
RI 5917 returned margin to key-details-header-formatter
kchepikava 4a69cc2
Merge branch 'main' into fe/feature/RI-5917-hide-ttl-for-individual-h…
kchepikava 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
66 changes: 65 additions & 1 deletion
66
...ght/ui/src/pages/browser/modules/key-details/components/hash-details/HashDetails.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,12 +1,76 @@ | ||
| import React from 'react' | ||
| import { instance, mock } from 'ts-mockito' | ||
| import { render } from 'uiSrc/utils/test-utils' | ||
| import { render, screen, fireEvent } from 'uiSrc/utils/test-utils' | ||
| import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry' | ||
| import { INSTANCE_ID_MOCK } from 'uiSrc/mocks/handlers/instances/instancesHandlers' | ||
| import { Props, HashDetails } from './HashDetails' | ||
|
|
||
| const mockedProps = mock<Props>() | ||
|
|
||
| jest.mock('uiSrc/telemetry', () => ({ | ||
| ...jest.requireActual('uiSrc/telemetry'), | ||
| sendEventTelemetry: jest.fn(), | ||
| })) | ||
|
|
||
| describe('HashDetails', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks() | ||
| }) | ||
| it('should render', () => { | ||
| expect(render(<HashDetails {...instance(mockedProps)} />)).toBeTruthy() | ||
| }) | ||
|
|
||
| it('should render subheader', () => { | ||
| render(<HashDetails {...instance(mockedProps)} />) | ||
| expect(screen.getByText('Show TTL')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('opens and closes the add item panel', () => { | ||
| render( | ||
| <HashDetails | ||
| {...instance(mockedProps)} | ||
| onOpenAddItemPanel={() => {}} | ||
| onCloseAddItemPanel={() => {}} | ||
| /> | ||
| ) | ||
| fireEvent.click(screen.getByText('+')) | ||
| expect(screen.getByText('Save')).toBeInTheDocument() | ||
| fireEvent.click(screen.getByText('Cancel')) | ||
| expect(screen.queryByText('Save')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('toggles the show TTL button', () => { | ||
| render(<HashDetails {...instance(mockedProps)} />) | ||
| const el = screen.getByTestId('test-check-ttl') as HTMLInputElement | ||
| expect(el.checked).toBe(true) | ||
| fireEvent.click(el) | ||
| expect(el.checked).toBe(false) | ||
| }) | ||
|
|
||
| it('should call proper telemetry event after click on showTtl', () => { | ||
| const sendEventTelemetryMock = jest.fn(); | ||
| (sendEventTelemetry as jest.Mock).mockImplementation(() => sendEventTelemetryMock) | ||
|
|
||
| render(<HashDetails {...instance(mockedProps)} />) | ||
|
|
||
| fireEvent.click(screen.getByTestId('test-check-ttl')) | ||
|
|
||
| expect(sendEventTelemetry).toBeCalledWith({ | ||
| event: TelemetryEvent.SHOW_HASH_TTL_CLICKED, | ||
| eventData: { | ||
| databaseId: INSTANCE_ID_MOCK, | ||
| action: 'hide' | ||
| } | ||
| }) | ||
|
|
||
| fireEvent.click(screen.getByTestId('test-check-ttl')) | ||
|
|
||
| expect(sendEventTelemetry).toBeCalledWith({ | ||
| event: TelemetryEvent.SHOW_HASH_TTL_CLICKED, | ||
| eventData: { | ||
| databaseId: INSTANCE_ID_MOCK, | ||
| action: 'show' | ||
| } | ||
| }) | ||
| }) | ||
| }) |
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
29 changes: 29 additions & 0 deletions
29
...browser/modules/key-details/components/key-details-subheader/KeyDetailsSubheader.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 { render, fireEvent } from 'uiSrc/utils/test-utils' | ||
| import { KeyDetailsSubheader } from './KeyDetailsSubheader' | ||
|
|
||
| describe('KeyDetailsSubheader', () => { | ||
| const props = { | ||
| showTtl: false, | ||
| onShowTtl: jest.fn(), | ||
| onAddKey: jest.fn(), | ||
| } | ||
|
|
||
| it('should render', () => { | ||
| const { getByText, getByTestId } = render(<KeyDetailsSubheader {...props} />) | ||
| expect(getByText('Show TTL')).toBeInTheDocument() | ||
| expect(getByTestId('btn-add-key')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('calls onShowTtl when checkbox is clicked', () => { | ||
| const { getByLabelText } = render(<KeyDetailsSubheader {...props} />) | ||
| fireEvent.click(getByLabelText('Show TTL')) | ||
| expect(props.onShowTtl).toHaveBeenCalledWith(true) | ||
| }) | ||
|
|
||
| it('calls onAddKey when add key button is clicked', () => { | ||
| const { getByTestId } = render(<KeyDetailsSubheader {...props} />) | ||
| fireEvent.click(getByTestId('btn-add-key')) | ||
| expect(props.onAddKey).toHaveBeenCalled() | ||
| }) | ||
| }) |
59 changes: 59 additions & 0 deletions
59
...ages/browser/modules/key-details/components/key-details-subheader/KeyDetailsSubheader.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,59 @@ | ||
| import React from 'react' | ||
|
|
||
| import { EuiButton, EuiCheckbox, EuiFlexGroup, EuiFlexItem } from '@elastic/eui' | ||
| import AutoSizer from 'react-virtualized-auto-sizer' | ||
|
|
||
| import VerticalDivider from 'uiSrc/pages/rdi/statistics/components/vertical-divider' | ||
| import { KeyDetailsHeaderFormatter } from '../../../key-details-header/components/key-details-header-formatter' | ||
| import styles from './styles.module.scss' | ||
|
|
||
| interface Props { | ||
| showTtl: boolean | ||
| onShowTtl: (checked: boolean) => void | ||
| onAddKey: () => void | ||
| } | ||
|
|
||
| export const KeyDetailsSubheader = ({ | ||
| showTtl, | ||
| onShowTtl, | ||
| onAddKey | ||
| }: Props) => ( | ||
| <div className={styles.subheaderContainer}> | ||
| <AutoSizer disableHeight> | ||
| {({ width = 0 }) => ( | ||
| <div style={{ width }}> | ||
| <EuiFlexGroup justifyContent="flexEnd"> | ||
| <EuiFlexItem className={styles.keyFormatter__item}> | ||
|
||
| <KeyDetailsHeaderFormatter width={width} /> | ||
| </EuiFlexItem> | ||
| <VerticalDivider variant="half" /> | ||
| <EuiFlexItem className={styles.showTtl__item}> | ||
| <EuiCheckbox | ||
| id="showField" | ||
| name="showTtl" | ||
| label="Show TTL" | ||
| className={styles.showTtl__checkbox} | ||
| checked={showTtl} | ||
| onChange={(e) => onShowTtl(e.target.checked)} | ||
| data-testId="test-check-ttl" | ||
| /> | ||
| </EuiFlexItem> | ||
| <VerticalDivider variant="half" /> | ||
| <EuiFlexItem className={styles.addBtn__container}> | ||
| <EuiButton | ||
| fill | ||
| color="secondary" | ||
| onClick={onAddKey} | ||
| data-testid="btn-add-key" | ||
| > | ||
| + | ||
| </EuiButton> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </div> | ||
| )} | ||
| </AutoSizer> | ||
| </div> | ||
| ) | ||
|
|
||
| export default KeyDetailsSubheader | ||
55 changes: 55 additions & 0 deletions
55
...src/pages/browser/modules/key-details/components/key-details-subheader/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,55 @@ | ||
| .subheaderContainer { | ||
| padding: 12px 18px 0px 18px; | ||
|
|
||
| .keyFormatter__item { | ||
| max-width: 100px; | ||
| margin-right: 0; | ||
| } | ||
|
|
||
| .showTtl__item { | ||
| max-width: 110px; | ||
| display: 'flex'; | ||
| margin-left: 0; | ||
| .showTtl__checkbox { | ||
| font-weight: 400; | ||
| font-size: 14px; | ||
| margin: auto; | ||
|
|
||
| :global(.euiCheckbox__input) { | ||
| color: var(--controlsBorderColor) !important; | ||
| } | ||
|
|
||
| :global(.euiCheckbox__square) { | ||
| width: 18px !important; | ||
| height: 18px !important; | ||
| border: 1px solid var(--controlsBorderColor) !important; | ||
| border-radius: 4px !important; | ||
| box-shadow: none !important; | ||
| } | ||
|
|
||
| :global(.euiCheckbox__label) { | ||
| color: var(--controlsLabelColor) !important; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .addBtn__container { | ||
| max-width: 40px; | ||
| align-self: center; | ||
| margin-right: 0 !important; | ||
| :global(.euiButton) { | ||
| height: 24px !important; | ||
| width: 27px !important; | ||
| min-width: 27px !important; | ||
|
|
||
| :global(.euiButton__content) { | ||
| padding: 0 !important; | ||
| :global(.euiButton__text) { | ||
| font-size: 12px !important; | ||
| font-weight: 400 !important; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
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
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.
I do not recommend using here VerticalDivider from rdi statistics components, could you please change it to Divider from common components? Maybe add property to have an ability use vertical