1
1
import React , { useContext } from 'react'
2
2
import { capitalize } from 'lodash'
3
3
4
- import cx from 'classnames'
5
4
import {
6
5
CONNECTION_TYPE_DISPLAY ,
7
6
ConnectionType ,
8
7
DATABASE_LIST_MODULES_TEXT ,
8
+ RedisDefaultModules ,
9
9
} from 'uiSrc/slices/interfaces'
10
10
import { getModule , Nullable , truncateText } from 'uiSrc/utils'
11
11
12
12
import { DEFAULT_MODULES_INFO } from 'uiSrc/constants/modules'
13
13
import { Theme } from 'uiSrc/constants'
14
14
import { ThemeContext } from 'uiSrc/contexts/themeContext'
15
- import { FlexItem , Row } from 'uiSrc/components/base/layout/flex'
15
+ import { Col , Row } from 'uiSrc/components/base/layout/flex'
16
16
import { Text } from 'uiSrc/components/base/text'
17
17
import { AllIconsType , RiIcon } from 'uiSrc/components/base/icons/RiIcon'
18
18
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
19
- import { Spacer } from 'uiSrc/components/base/layout'
20
19
import { RiImage } from 'uiSrc/components/base/display'
21
20
import MessageInfoSvg from 'uiSrc/assets/img/icons/help_illus.svg'
22
- import styles from './styles.module.scss'
21
+ import {
22
+ DbIndexInfoWrapper ,
23
+ SeparatorLine ,
24
+ WordBreakWrapper ,
25
+ } from './ShortInstanceInfo.styles'
23
26
24
27
export interface Props {
25
28
info : {
@@ -40,7 +43,7 @@ const ShortInstanceInfo = ({ info, databases, modules }: Props) => {
40
43
41
44
const getIcon = ( name : string ) => {
42
45
const icon : AllIconsType =
43
- DEFAULT_MODULES_INFO [ name ] ?. [
46
+ DEFAULT_MODULES_INFO [ name as RedisDefaultModules ] ?. [
44
47
theme === Theme . Dark ? 'iconDark' : 'iconLight'
45
48
]
46
49
if ( icon ) {
@@ -51,80 +54,86 @@ const ShortInstanceInfo = ({ info, databases, modules }: Props) => {
51
54
}
52
55
53
56
return (
54
- < div data-testid = "db-info-tooltip" >
55
- < Text color = "primary" size = "m" component = "div" variant = "semiBold" >
56
- { name }
57
- </ Text >
58
- < Spacer size = "s" />
59
- < Text color = "primary" size = "s" >
60
- { host } :{ port }
61
- </ Text >
62
- { databases > 1 && (
63
- < >
64
- < Spacer size = "s" />
65
- < Row className = { styles . dbIndexInfo } align = "center" gap = "l" >
66
- < FlexItem >
67
- < RiImage src = { MessageInfoSvg } alt = "Database Info" $size = "xs" />
68
- </ FlexItem >
69
- < FlexItem >
70
- < Text size = "m" > Logical Databases</ Text >
71
- < Spacer size = "xs" />
72
- < Text color = "primary" size = "s" >
73
- Select logical databases to work with in Browser, Workbench, and
74
- Database Analysis.
75
- </ Text >
76
- </ FlexItem >
77
- </ Row >
78
- </ >
79
- ) }
80
- < Spacer size = "xs" />
81
- < Row align = "center" >
82
- < Row align = "center" >
83
- < RiIcon type = "ConnectionIcon" />
84
- < span >
85
- { connectionType
86
- ? CONNECTION_TYPE_DISPLAY [ connectionType ]
87
- : capitalize ( connectionType ) }
88
- </ span >
57
+ < Col gap = "l" data-testid = "db-info-tooltip" >
58
+ < Col gap = "m" >
59
+ < Col gap = "m" >
60
+ < Text color = "primary" size = "L" component = "div" variant = "semiBold" >
61
+ { name }
62
+ </ Text >
63
+ < Text color = "primary" size = "s" >
64
+ { host } :{ port }
65
+ </ Text >
66
+ </ Col >
67
+ { databases > 1 && (
68
+ < DbIndexInfoWrapper align = "center" gap = "l" >
69
+ < Col >
70
+ < RiImage src = { MessageInfoSvg } alt = "Database Info" $size = "xs" />
71
+ </ Col >
72
+ < Col gap = "xs" >
73
+ < Text size = "m" > Logical databases</ Text >
74
+ < Text color = "secondary" size = "s" >
75
+ < WordBreakWrapper >
76
+ Select logical databases to work with in Browser, Workbench,
77
+ and Database Analysis.
78
+ </ WordBreakWrapper >
79
+ </ Text >
80
+ </ Col >
81
+ </ DbIndexInfoWrapper >
82
+ ) }
83
+ < Row align = "center" gap = "l" >
84
+ < Row align = "center" grow = { false } >
85
+ < RiIcon type = "ConnectionIcon" size = "M" />
86
+ < span >
87
+ { connectionType
88
+ ? CONNECTION_TYPE_DISPLAY [ connectionType ]
89
+ : capitalize ( connectionType ) }
90
+ </ span >
91
+ </ Row >
92
+ < Row align = "center" grow = { false } >
93
+ < RiIcon type = "VersionIcon" size = "M" />
94
+ < span > { version } </ span >
95
+ </ Row >
96
+ < Row align = "center" grow = { false } >
97
+ < RiIcon type = "UserIcon" size = "S" />
98
+ < span > { user || 'Default' } </ span >
99
+ </ Row >
89
100
</ Row >
90
- < Row align = "center" >
91
- < RiIcon type = "VersionIcon" />
92
- < span > { version } </ span >
93
- </ Row >
94
- < Row align = "center" >
95
- < RiIcon type = "UserIcon" />
96
- < span > { user || 'Default' } </ span >
97
- </ Row >
98
- </ Row >
101
+ </ Col >
99
102
{ ! ! modules ?. length && (
100
- < div className = { styles . modules } >
101
- < h4 className = { styles . mi_fieldName } > Database Modules</ h4 >
102
- { modules ?. map ( ( { name = '' , semanticVersion = '' , version = '' } ) => (
103
- < div
104
- key = { name }
105
- className = { cx ( styles . mi_moduleName ) }
106
- data-testid = { `module_${ name } ` }
107
- >
108
- < RiIcon type = { getIcon ( name ) } className = { styles . mi_icon } />
109
- < span >
110
- { truncateText (
111
- getModule ( name ) ?. name ||
112
- DATABASE_LIST_MODULES_TEXT [ name ] ||
113
- name ,
114
- 50 ,
115
- ) }
116
- </ span >
117
- { ! ! ( semanticVersion || version ) && (
118
- < span className = { styles . mi_version } >
119
- v.
120
- { semanticVersion || version }
121
- </ span >
122
- ) }
123
- </ div >
124
- ) ) }
125
- </ div >
103
+ < >
104
+ < SeparatorLine />
105
+ < Text color = "primary" size = "L" component = "div" variant = "semiBold" >
106
+ Database modules
107
+ </ Text >
108
+ < Col gap = "s" >
109
+ { modules ?. map (
110
+ ( { name = '' , semanticVersion = '' , version = '' } ) => (
111
+ < Row
112
+ gap = "s"
113
+ align = "center"
114
+ key = { name }
115
+ data-testid = { `module_${ name } ` }
116
+ >
117
+ < RiIcon type = { getIcon ( name ) } size = "M" />
118
+ < Text size = "S" color = "secondary" >
119
+ { truncateText (
120
+ getModule ( name ) ?. name ||
121
+ DATABASE_LIST_MODULES_TEXT [
122
+ name as RedisDefaultModules
123
+ ] ||
124
+ name ,
125
+ 50 ,
126
+ ) } { ' ' }
127
+ v.
128
+ { semanticVersion || version }
129
+ </ Text >
130
+ </ Row >
131
+ ) ,
132
+ ) }
133
+ </ Col >
134
+ </ >
126
135
) }
127
- </ div >
136
+ </ Col >
128
137
)
129
138
}
130
139
0 commit comments