Skip to content

Commit 66a4de2

Browse files
authored
RI-7056 replace eui health (#4593)
* Add Health.tsx * Replace EuiHealth
1 parent 839830c commit 66a4de2

File tree

7 files changed

+51
-27
lines changed

7 files changed

+51
-27
lines changed

redisinsight/ui/src/components/base/layout/flex/flex.styles.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,24 @@ export type FlexProps = PropsWithChildren &
174174
full?: boolean
175175
}
176176

177-
export const StyledFlex = styled.div<FlexProps>`
177+
export const StyledFlex = styled.div<
178+
Omit<FlexProps, 'direction'> & { $direction?: (typeof dirValues)[number] }
179+
>`
178180
display: flex;
179181
align-items: stretch;
180182
flex-grow: 1;
181183
${({ gap = 'none' }) => (gap ? flexGroupStyles.gapSizes[gap] : '')}
182184
${({ align = 'stretch' }) => (align ? flexGroupStyles.align[align] : '')}
183-
${({ direction = 'row' }) =>
184-
direction ? flexGroupStyles.direction[direction] : ''}
185+
${({ $direction = 'row' }) =>
186+
$direction ? flexGroupStyles.direction[$direction] : ''}
185187
${({ justify = 'start' }) =>
186188
justify ? flexGroupStyles.justify[justify] : ''}
187189
${({ centered = false }) => (centered ? flexGroupStyles.centered : '')}
188190
${({ responsive = false }) => (responsive ? flexGroupStyles.responsive : '')}
189191
${({ wrap = false }) => (wrap ? flexGroupStyles.wrap : '')}
190-
${({ full = false, direction = 'row' }) =>
192+
${({ full = false, $direction = 'row' }) =>
191193
full
192-
? direction === 'row' || direction === 'rowReverse'
194+
? $direction === 'row' || $direction === 'rowReverse'
193195
? 'width: 100%' // if it is row make it full width
194196
: 'height: 100%;' // else, make it full height
195197
: ''}

redisinsight/ui/src/components/base/layout/flex/flex.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ export const Grid = ({ children, className, ...rest }: GridProps) => {
3939
* </FlexItem>
4040
* </FlexGroup>
4141
*/
42-
export const FlexGroup = ({ children, className, ...rest }: FlexProps) => {
42+
export const FlexGroup = ({
43+
children,
44+
className,
45+
direction,
46+
...rest
47+
}: FlexProps) => {
4348
const classes = classNames('RI-flex-group', className)
4449
return (
45-
<StyledFlex {...rest} className={classes}>
50+
<StyledFlex {...rest} className={classes} $direction={direction}>
4651
{children}
4752
</StyledFlex>
4853
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react'
2+
import { Typography } from '@redis-ui/components'
3+
import styled from 'styled-components'
4+
import { Row } from 'uiSrc/components/base/layout/flex'
5+
6+
type BodyProps = React.ComponentProps<typeof Typography.Body>
7+
type ColorType = BodyProps['color'] | (string & {})
8+
export type HealthProps = Omit<BodyProps, 'color'> & {
9+
color?: ColorType
10+
}
11+
const Indicator = styled.div<{
12+
$color: ColorType
13+
}>`
14+
width: 0.8rem;
15+
height: 0.8rem;
16+
border-radius: 50%;
17+
background-color: ${({ $color }) => $color || 'inherit'};
18+
`
19+
20+
export const Health = ({ color, size = 'S', ...rest }: HealthProps) => (
21+
<Row align="center" gap="m" justify="start">
22+
<Indicator $color={color} />
23+
<Typography.Body {...rest} component="div" size={size} />
24+
</Row>
25+
)

redisinsight/ui/src/pages/browser/components/add-key/AddKey.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import cx from 'classnames'
4-
import { EuiHealth, EuiTitle, EuiToolTip, EuiButtonIcon } from '@elastic/eui'
4+
import { EuiTitle, EuiToolTip, EuiButtonIcon } from '@elastic/eui'
55
import Divider from 'uiSrc/components/divider/Divider'
66
import { KeyTypes } from 'uiSrc/constants'
77
import HelpTexts from 'uiSrc/constants/help-texts'
@@ -21,6 +21,7 @@ import { isContainJSONModule, Maybe, stringToBuffer } from 'uiSrc/utils'
2121
import { RedisResponseBuffer } from 'uiSrc/slices/interfaces'
2222

2323
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
24+
import { Health } from 'uiSrc/components/base/text/Health'
2425
import { ADD_KEY_TYPE_OPTIONS } from './constants/key-type-options'
2526
import AddKeyHash from './AddKeyHash'
2627
import AddKeyZset from './AddKeyZset'
@@ -61,13 +62,13 @@ const AddKey = (props: Props) => {
6162
return {
6263
value,
6364
inputDisplay: (
64-
<EuiHealth
65+
<Health
6566
color={color}
6667
style={{ lineHeight: 'inherit' }}
6768
data-test-subj={value}
6869
>
6970
{text}
70-
</EuiHealth>
71+
</Health>
7172
),
7273
}
7374
})

redisinsight/ui/src/pages/browser/components/create-redisearch-index/CreateRedisearchIndex.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
EuiComboBox,
44
EuiFieldText,
55
EuiFormFieldset,
6-
EuiHealth,
76
EuiLink,
87
EuiPanel,
98
EuiPopover,
@@ -34,6 +33,7 @@ import {
3433
SecondaryButton,
3534
} from 'uiSrc/components/base/forms/buttons'
3635
import { FormField } from 'uiSrc/components/base/forms/FormField'
36+
import { Health } from 'uiSrc/components/base/text/Health'
3737
import { CreateRedisearchIndexDto } from 'apiSrc/modules/browser/redisearch/dto'
3838

3939
import { KEY_TYPE_OPTIONS, RedisearchIndexKeyType } from './constants'
@@ -50,13 +50,13 @@ const keyTypeOptions = KEY_TYPE_OPTIONS.map((item) => {
5050
return {
5151
value,
5252
inputDisplay: (
53-
<EuiHealth
53+
<Health
5454
color={color}
5555
style={{ lineHeight: 'inherit' }}
5656
data-test-subj={value}
5757
>
5858
{text}
59-
</EuiHealth>
59+
</Health>
6060
),
6161
}
6262
})

redisinsight/ui/src/pages/browser/components/filter-key-type/FilterKeyType.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
EuiHealth,
32
EuiModal,
43
EuiModalBody,
54
EuiSuperSelect,
@@ -29,6 +28,7 @@ import { resetBrowserTree } from 'uiSrc/slices/app/context'
2928
import { appFeatureFlagsFeaturesSelector } from 'uiSrc/slices/app/features'
3029
import { AdditionalRedisModule } from 'uiSrc/slices/interfaces'
3130
import { OutsideClickDetector } from 'uiSrc/components/base/utils'
31+
import { Health } from 'uiSrc/components/base/text/Health'
3232
import { FILTER_KEY_TYPE_OPTIONS } from './constants'
3333

3434
import styles from './styles.module.scss'
@@ -79,14 +79,14 @@ const FilterKeyType = ({ modules }: Props) => {
7979
return {
8080
value,
8181
inputDisplay: (
82-
<EuiHealth color={color} className={styles.dropdownDisplay}>
82+
<Health color={color} className={styles.dropdownDisplay}>
8383
{text}
84-
</EuiHealth>
84+
</Health>
8585
),
8686
dropdownDisplay: (
87-
<EuiHealth color={color} className={styles.dropdownDisplay}>
87+
<Health color={color} className={styles.dropdownDisplay}>
8888
{text}
89-
</EuiHealth>
89+
</Health>
9090
),
9191
'data-test-subj': `filter-option-type-${value}`,
9292
}

redisinsight/ui/src/pages/browser/components/filter-key-type/styles.module.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,3 @@
129129
.dropdownOption {
130130
padding-left: 6px;
131131
}
132-
133-
.dropdownDisplay {
134-
:global {
135-
.euiFlexGroup {
136-
margin: 0;
137-
line-height: 1;
138-
}
139-
}
140-
}

0 commit comments

Comments
 (0)