Skip to content

Commit bcc8946

Browse files
authored
RI-7243 capabilities not displayed
* provide actual icon element to IconButton * set LikeIcon as default for VoteOption.tsx
1 parent 579b31c commit bcc8946

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import React from 'react'
22
import { IconButton as RedisUiIconButton } from '@redis-ui/components'
3+
import * as Icons from 'uiSrc/components/base/icons/iconRegistry'
4+
import { AllIconsType } from 'uiSrc/components/base/icons'
35

46
export type ButtonProps = React.ComponentProps<typeof RedisUiIconButton>
57

68
export type IconType = ButtonProps['icon']
7-
export const IconButton = (props: ButtonProps) => (
8-
<RedisUiIconButton {...props} />
9-
)
9+
export type IconButtonProps = Omit<ButtonProps, 'icon'> & {
10+
icon: IconType | string
11+
}
12+
export const IconButton = ({ icon, size, ...props }: IconButtonProps) => {
13+
let buttonIcon: IconType
14+
if (typeof icon === 'string') {
15+
buttonIcon = Icons[icon as AllIconsType]
16+
} else {
17+
buttonIcon = icon
18+
}
19+
return <RedisUiIconButton icon={buttonIcon} {...props} />
20+
}

redisinsight/ui/src/components/base/icons/RiIcon.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export type IconComponentProps = Omit<IconProps, 'icon' | 'size'> &
2121

2222
export const RiIcon = ({ type, size, ...props }: IconComponentProps) => {
2323
const IconType = Icons[type]
24-
2524
if (!IconType) {
2625
console.warn(`Icon type "${type}" not found, rendering as image`)
2726
// TODO - 17.06.25 - Replace with icon

redisinsight/ui/src/components/database-list-modules/DatabaseListModules.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { ThemeContext } from 'uiSrc/contexts/themeContext'
1010
import { DEFAULT_MODULES_INFO, ModuleInfo } from 'uiSrc/constants/modules'
1111
import { IconButton } from 'uiSrc/components/base/forms/buttons'
1212
import { ColorText } from 'uiSrc/components/base/text'
13-
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
1413
import { RiTooltip } from 'uiSrc/components'
14+
import { RiIcon } from 'uiSrc/components/base/icons'
1515
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
1616

1717
import styles from './styles.module.scss'
@@ -70,7 +70,6 @@ const DatabaseListModules = React.memo((props: Props) => {
7070
}
7171
}),
7272
)
73-
7473
// set count of hidden modules
7574
if (maxViewModules && newModules.length > maxViewModules + 1) {
7675
newModules.length = maxViewModules
@@ -83,25 +82,30 @@ const DatabaseListModules = React.memo((props: Props) => {
8382
}
8483

8584
const Content = sortModules(mainContent).map(
86-
({ icon, content, abbreviation = '' }) => (
87-
<div className={styles.tooltipItem} key={content || abbreviation}>
88-
{!!icon && <RiIcon type={icon} style={{ marginRight: 10 }} />}
89-
{!icon && (
90-
<ColorText
91-
className={cx(styles.icon, styles.abbr)}
92-
style={{ marginRight: 10 }}
93-
>
94-
{abbreviation}
95-
</ColorText>
96-
)}
97-
{!!content && (
98-
<ColorText className={cx(styles.tooltipItemText)}>
99-
{content}
100-
</ColorText>
101-
)}
102-
<br />
103-
</div>
104-
),
85+
({ icon, content, abbreviation = '' }) => {
86+
const hasIcon = !!icon
87+
const hasContent = !!content
88+
const hasAbbreviation = !!abbreviation
89+
return (
90+
<div className={styles.tooltipItem} key={content || abbreviation}>
91+
{hasIcon && <RiIcon type={icon} />}
92+
{!hasIcon && hasAbbreviation && (
93+
<ColorText
94+
className={cx(styles.icon, styles.abbr)}
95+
style={{ marginRight: 10 }}
96+
>
97+
{abbreviation}
98+
</ColorText>
99+
)}
100+
{hasContent && (
101+
<ColorText className={cx(styles.tooltipItemText)}>
102+
{content}
103+
</ColorText>
104+
)}
105+
<br />
106+
</div>
107+
)
108+
},
105109
)
106110

107111
const Module = (

redisinsight/ui/src/components/recommendation/recommendation-voting/components/vote-option/VoteOption.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const VoteOption = (props: Props) => {
106106
>
107107
<IconButton
108108
disabled={!isAnalyticsEnable}
109-
icon={iconType[voteOption] ?? 'default'}
109+
icon={iconType[voteOption] ?? 'LikeIcon'}
110110
className={cx('vote__btn', { selected: vote === voteOption })}
111111
aria-label="vote useful"
112112
data-testid={`${voteOption}-vote-btn`}

redisinsight/ui/src/pages/home/components/database-list-component/DatabasesListWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
EditIcon,
2525
TagIcon,
2626
CopyIcon,
27+
RiIcon,
2728
} from 'uiSrc/components/base/icons'
2829
import DatabaseListModules from 'uiSrc/components/database-list-modules/DatabaseListModules'
2930
import ItemList from 'uiSrc/components/item-list'
@@ -80,7 +81,6 @@ import { Tag } from 'uiSrc/slices/interfaces/tag'
8081
import { FeatureFlagComponent } from 'uiSrc/components'
8182
import { RiPopover, RiTooltip } from 'uiSrc/components/base'
8283
import { EmptyButton, IconButton } from 'uiSrc/components/base/forms/buttons'
83-
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
8484
import { Link } from 'uiSrc/components/base/link/Link'
8585
import { RIResizeObserver } from 'uiSrc/components/base/utils'
8686

0 commit comments

Comments
 (0)