Skip to content

RI-7213: replace EuiImage with img tag #4760

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { RiImageProps, StyledImage } from './image.styles'

const RiImage = ({ $size, src, alt, ...rest }: RiImageProps) => (
<StyledImage src={src} alt={alt} $size={$size} {...rest} />
)

export default RiImage
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { HTMLAttributes } from 'react'
import styled, { css } from 'styled-components'

export const SIZES = ['s', 'm', 'l', 'xl', 'original', 'fullWidth'] as const

export const imageSizeStyles = {
s: css`
width: 100px;
`,
m: css`
width: 200px;
`,
l: css`
width: 360px;
`,
xl: css`
width: 600px;
`,
original: css`
width: auto;
`,
fullWidth: css`
width: 100%;
`,
}

export type RiImageSize = (typeof SIZES)[number]

export interface RiImageProps extends HTMLAttributes<HTMLImageElement> {
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface extends HTMLAttributes but overrides 'src' and 'alt' as required properties. This could cause TypeScript conflicts since HTMLImageElement attributes make these optional. Consider using Omit<HTMLAttributes, 'src' | 'alt'> to avoid conflicts.

Suggested change
export interface RiImageProps extends HTMLAttributes<HTMLImageElement> {
export interface RiImageProps extends Omit<HTMLAttributes<HTMLImageElement>, 'src' | 'alt'> {

Copilot uses AI. Check for mistakes.

$size?: RiImageSize
src: string
alt: string
}

export const StyledImage = styled.img<RiImageProps>`
${({ $size = 'original' }) => imageSizeStyles[$size]}
`
3 changes: 2 additions & 1 deletion redisinsight/ui/src/components/base/display/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Loader from './loader/Loader'
import ProgressBarLoader from './progress-bar/ProgressBarLoader'
import RiImage from './image/RiImage'

export { Loader, ProgressBarLoader }
export { Loader, ProgressBarLoader, RiImage }
export { RICollapsibleNavGroup } from './collapsible-nav-group/RICollapsibleNavGroup'

export type { RICollapsibleNavGroupProps } from './collapsible-nav-group/RICollapsibleNavGroup'
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react'
import { EuiImage } from '@elastic/eui'

import { OAuthSsoHandlerDialog } from 'uiSrc/components'

import RedisLogo from 'uiSrc/assets/img/logo_small.svg'

import { OAuthSocialAction, OAuthSocialSource } from 'uiSrc/slices/interfaces'
import { SecondaryButton } from 'uiSrc/components/base/forms/buttons'
import { RiImage } from 'uiSrc/components/base/display'
import styles from './styles.module.scss'

export interface Props {
Expand All @@ -30,7 +29,7 @@ const OAuthSignInButton = (props: Props) => {
}
data-testid="cloud-sign-in-btn"
>
<EuiImage className={styles.logo} src={RedisLogo} alt="" />
<RiImage className={styles.logo} src={RedisLogo} alt="Redis logo" />
<span>Cloud sign in</span>
</SecondaryButton>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react'
import { EuiImage } from '@elastic/eui'
import RedisLogo from 'uiSrc/assets/img/logo.svg'
import { Title } from 'uiSrc/components/base/text/Title'
import { Text } from 'uiSrc/components/base/text'
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
import { RiImage } from 'uiSrc/components/base/display'
import { OAUTH_ADVANTAGES_ITEMS } from './constants'

import styles from './styles.module.scss'

const OAuthAdvantages = () => (
<div className={styles.container} data-testid="oauth-advantages">
<EuiImage className={styles.logo} src={RedisLogo} alt="" />
<RiImage className={styles.logo} src={RedisLogo} alt="Redis logo" />
<Title size="S" className={styles.title}>
Cloud
</Title>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import { EuiImage } from '@elastic/eui'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'
import TelescopeImg from 'uiSrc/assets/img/telescope-dark.svg'
Expand All @@ -22,6 +21,7 @@ import { TutorialsIds } from 'uiSrc/constants'
import { Spacer } from 'uiSrc/components/base/layout/spacer'
import { EmptyButton } from 'uiSrc/components/base/forms/buttons'
import { Title } from 'uiSrc/components/base/text/Title'
import { RiImage } from 'uiSrc/components/base/display'
import LoadSampleData from '../load-sample-data'

import styles from './styles.module.scss'
Expand Down Expand Up @@ -59,10 +59,10 @@ const NoKeysFound = (props: Props) => {

return (
<div className={styles.container} data-testid="no-result-found-msg">
<EuiImage
<RiImage
className={styles.img}
src={TelescopeImg}
alt="no results image"
alt="no results"
/>
<Spacer />
<Title className={styles.title} size="S">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, {
import AutoSizer from 'react-virtualized-auto-sizer'
import { debounce, get, set } from 'lodash'
import { TreeWalker, TreeWalkerValue, FixedSizeTree as Tree } from 'react-vtree'
import { EuiImage } from '@elastic/eui'
import { useDispatch } from 'react-redux'

import { bufferToString, Maybe, Nullable } from 'uiSrc/utils'
Expand All @@ -21,7 +20,7 @@ import {
} from 'uiSrc/constants'
import { RedisResponseBuffer, RedisString } from 'uiSrc/slices/interfaces'
import { fetchKeysMetadataTree } from 'uiSrc/slices/browser/keys'
import { Loader, ProgressBarLoader } from 'uiSrc/components/base/display'
import { Loader, ProgressBarLoader, RiImage } from 'uiSrc/components/base/display'
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
import { GetKeyInfoResponse } from 'apiSrc/modules/browser/keys/dto'

Expand Down Expand Up @@ -307,7 +306,7 @@ const VirtualTree = (props: Props) => {
className={styles.loadingSpinner}
/>
{loadingIcon ? (
<EuiImage
<RiImage
className={styles.loadingIcon}
src={loadingIcon}
alt="loading"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EuiImage } from '@elastic/eui'
import React from 'react'

import CakeIcon from 'uiSrc/assets/img/databases/cake.svg'
Expand All @@ -11,6 +10,7 @@ import { TelemetryEvent, sendEventTelemetry } from 'uiSrc/telemetry'
import { PrimaryButton } from 'uiSrc/components/base/forms/buttons'
import { Text } from 'uiSrc/components/base/text'
import { Link } from 'uiSrc/components/base/link/Link'
import { RiImage } from 'uiSrc/components/base/display'
import styles from './styles.module.scss'

export interface Props {
Expand All @@ -22,7 +22,7 @@ const EmptyMessage = ({ onAddInstanceClick }: Props) => (
className={styles.noResultsContainer}
data-testid="empty-database-instance-list"
>
<EuiImage src={CakeIcon} className={styles.icon} alt="empty" />
<RiImage src={CakeIcon} className={styles.icon} alt="empty" />
<Text className={styles.text}>No databases yet, let&apos;s add one!</Text>
<PrimaryButton
size="m"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EuiImage } from '@elastic/eui'
import React, { useContext } from 'react'

import { EXTERNAL_LINKS, UTM_MEDIUMS } from 'uiSrc/constants/links'
Expand All @@ -14,6 +13,7 @@ import { Spacer } from 'uiSrc/components/base/layout/spacer'
import { PrimaryButton } from 'uiSrc/components/base/forms/buttons'
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
import { Link } from 'uiSrc/components/base/link/Link'
import { RiImage } from 'uiSrc/components/base/display'
import styles from './styles.module.scss'

const subTitleText =
Expand All @@ -32,7 +32,7 @@ const EmptyMessage = ({ onAddInstanceClick }: Props) => {
>
<Spacer size="xl" />
<Text className={styles.title}>Redis Data Integration</Text>
<EuiImage
<RiImage
src={theme === Theme.Dark ? EmptyListDarkIcon : EmptyListLightIcon}
className={styles.icon}
alt="empty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
font-size: 14px !important;
margin-top: 34px;
margin-bottom: 34px;
padding: 0 34px;
}

.icon {
Expand Down
4 changes: 2 additions & 2 deletions redisinsight/ui/src/pages/rdi/statistics/empty/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { EuiImage } from '@elastic/eui'
import React from 'react'
import { useHistory } from 'react-router-dom'

Expand All @@ -7,6 +6,7 @@ import { Pages } from 'uiSrc/constants'
import { Text } from 'uiSrc/components/base/text'
import { Spacer } from 'uiSrc/components/base/layout/spacer'
import { PrimaryButton } from 'uiSrc/components/base/forms/buttons'
import { RiImage } from 'uiSrc/components/base/display'
import Panel from '../components/panel'

import styles from './styles.module.scss'
Expand All @@ -21,7 +21,7 @@ const Empty = ({ rdiInstanceId }: Props) => {
return (
<Panel>
<div className={styles.emptyPipelineContainer} data-testid="empty-pipeline">
<EuiImage src={EmptyPipelineIcon} alt="empty" size="s" />
<RiImage src={EmptyPipelineIcon} alt="empty" $size="s" />
<Spacer size="xl" />
<Text>No pipeline deployed yet</Text>
<Text className={styles.subTitle}>
Expand Down
Loading