Skip to content

Commit 01d6ef4

Browse files
authored
RI-7060: Replace EUI Loading Spinner with Redis Loader (#4631)
* export the loader * replace everywhere * add support for t shirt sizing for redis ui loader and conversion to pixels
1 parent 62f8a72 commit 01d6ef4

File tree

23 files changed

+98
-61
lines changed

23 files changed

+98
-61
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Loader } from './loader/Loader'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { ComponentProps } from 'react'
2+
3+
import { Loader as RedisLoader } from '@redis-ui/components'
4+
import { useTheme, theme } from '@redis-ui/styles'
5+
6+
type Space = typeof theme.core.space
7+
8+
export type RedisLoaderProps = ComponentProps<typeof RedisLoader>
9+
10+
const convertSizeToPx = (tShirtSize: string, space: Space) => {
11+
switch (tShirtSize.toLowerCase()) {
12+
case 's':
13+
return space.space050
14+
case 'm':
15+
return space.space100
16+
case 'l':
17+
return space.space250
18+
case 'xl':
19+
return space.space300
20+
default:
21+
return space.space100
22+
}
23+
}
24+
25+
export default function Loader({ size, ...rest }: RedisLoaderProps) {
26+
const theme = useTheme()
27+
const { space } = theme.core
28+
const sizeInPx = size ? convertSizeToPx(size, space) : space.space100
29+
return <RedisLoader size={sizeInPx} {...rest} />
30+
}

redisinsight/ui/src/components/database-overview/components/OverviewMetrics/OverviewMetrics.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { FunctionComponent, ReactNode } from 'react'
2-
import { EuiLoadingSpinner } from '@elastic/eui'
32
import { isArray, isUndefined, toNumber } from 'lodash'
43

54
import {
@@ -27,6 +26,7 @@ import {
2726
UserDarkIcon,
2827
UserLightIcon,
2928
} from 'uiSrc/components/database-overview/components/icons'
29+
import { Loader } from 'uiSrc/components/base/display'
3030

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

@@ -103,7 +103,7 @@ function getCpuUsage(cpuUsagePercentage: number | null, theme: string) {
103103
cpuUsagePercentage === null ? (
104104
<>
105105
<div className={styles.calculationWrapper}>
106-
<EuiLoadingSpinner className={styles.spinner} size="m" />
106+
<Loader className={styles.spinner} size="m" />
107107
<span className={styles.calculation}>Calculating...</span>
108108
</div>
109109
</>

redisinsight/ui/src/components/import-file-modal/ImportFileModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
EuiFilePicker,
33
EuiIcon,
4-
EuiLoadingSpinner,
54
EuiModal,
65
EuiModalBody,
76
EuiModalFooter,
@@ -21,6 +20,7 @@ import {
2120
} from 'uiSrc/components/base/forms/buttons'
2221
import { Title } from 'uiSrc/components/base/text/Title'
2322
import { ColorText, Text } from 'uiSrc/components/base/text'
23+
import { Loader } from 'uiSrc/components/base/display'
2424
import styles from './styles.module.scss'
2525

2626
export interface Props<T> {
@@ -112,7 +112,7 @@ const ImportFileModal = <T,>({
112112
className={styles.loading}
113113
data-testid="file-loading-indicator"
114114
>
115-
<EuiLoadingSpinner size="xl" />
115+
<Loader size="xl" />
116116
<Text color="subdued" style={{ marginTop: 12 }}>
117117
Uploading...
118118
</Text>

redisinsight/ui/src/components/instance-header/components/instances-navigation-popover/components/instances-list/InstancesList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useState } from 'react'
2-
import { EuiLoadingSpinner } from '@elastic/eui'
32
import { useDispatch } from 'react-redux'
43
import { useHistory, useParams } from 'react-router-dom'
54
import { checkConnectToRdiInstanceAction } from 'uiSrc/slices/rdi/instances'
@@ -20,6 +19,7 @@ import {
2019
Item as ListGroupItem,
2120
} from 'uiSrc/components/base/layout/list'
2221
import { Text } from 'uiSrc/components/base/text'
22+
import { Loader } from 'uiSrc/components/base/display'
2323
import { InstancesTabs } from '../../InstancesNavigationPopover'
2424
import styles from '../../styles.module.scss'
2525

@@ -141,7 +141,7 @@ const InstancesList = ({
141141
component="div"
142142
>
143143
{loading && instance?.id === selected && (
144-
<EuiLoadingSpinner size="s" className={styles.loading} />
144+
<Loader size="s" className={styles.loading} />
145145
)}
146146
{instance.name} {getDbIndex(instance.db)}
147147
</Text>

redisinsight/ui/src/components/instance-header/components/user-profile/UserProfileBadge.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
3-
import { EuiIcon, EuiLoadingSpinner, EuiPopover } from '@elastic/eui'
3+
import { EuiIcon, EuiPopover } from '@elastic/eui'
44
import cx from 'classnames'
55
import { useHistory } from 'react-router-dom'
66
import { logoutUserAction } from 'uiSrc/slices/oauth/cloud'
@@ -22,6 +22,7 @@ import { FeatureFlagComponent } from 'uiSrc/components'
2222
import { getConfig } from 'uiSrc/config'
2323
import { Text } from 'uiSrc/components/base/text'
2424
import { UserProfileLink } from 'uiSrc/components/base/link/UserProfileLink'
25+
import { Loader } from 'uiSrc/components/base/display'
2526
import { CloudUser } from 'apiSrc/modules/cloud/user/models'
2627
import styles from './styles.module.scss'
2728

@@ -174,7 +175,7 @@ const UserProfileBadge = (props: UserProfileBadgeProps) => {
174175
/>
175176
)}
176177
{id === selectingAccountId && (
177-
<EuiLoadingSpinner
178+
<Loader
178179
className={styles.loadingSpinner}
179180
size="m"
180181
data-testid={`user-profile-selecting-account-${id}`}
@@ -220,7 +221,7 @@ const UserProfileBadge = (props: UserProfileBadgeProps) => {
220221
>
221222
<Text className={styles.optionTitle}>Import Cloud databases</Text>
222223
{isImportLoading ? (
223-
<EuiLoadingSpinner className={styles.loadingSpinner} size="m" />
224+
<Loader className={styles.loadingSpinner} size="m" />
224225
) : (
225226
<EuiIcon type="importAction" />
226227
)}

redisinsight/ui/src/components/main-router/components/SuspenseLoader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react'
2-
import { EuiLoadingSpinner } from '@elastic/eui'
2+
import { Loader } from 'uiSrc/components/base/display'
33
import styles from './loader.module.scss'
44

55
const SuspenseLoader = () => (
66
<div className={styles.cover} data-testid="suspense-loader">
7-
<EuiLoadingSpinner size="xl" className={styles.loader} />
7+
<Loader size="xl" className={styles.loader} />
88
</div>
99
)
1010

redisinsight/ui/src/components/notifications/components/infinite-messages/InfiniteMessages.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
22
import {
33
EuiIcon,
4-
EuiLoadingSpinner,
54
} from '@elastic/eui'
65
import { find } from 'lodash'
76
import cx from 'classnames'
@@ -29,6 +28,7 @@ import {
2928
} from 'uiSrc/components/base/forms/buttons'
3029
import { Title } from 'uiSrc/components/base/text/Title'
3130
import { Link } from 'uiSrc/components/base/link/Link'
31+
import { Loader } from 'uiSrc/components/base/display'
3232
import styles from './styles.module.scss'
3333

3434
export enum InfiniteMessagesIds {
@@ -54,7 +54,7 @@ export const INFINITE_MESSAGES = {
5454
<div role="presentation" data-testid="authenticating-notification">
5555
<Row justify="end">
5656
<FlexItem>
57-
<EuiLoadingSpinner
57+
<Loader
5858
className={cx('infiniteMessage__icon', styles.loading)}
5959
/>
6060
</FlexItem>
@@ -74,7 +74,7 @@ export const INFINITE_MESSAGES = {
7474
<div role="presentation" data-testid="pending-create-db-notification">
7575
<Row justify="end">
7676
<FlexItem grow={false}>
77-
<EuiLoadingSpinner
77+
<Loader
7878
className={cx('infiniteMessage__icon', styles.loading)}
7979
/>
8080
</FlexItem>
@@ -340,7 +340,7 @@ export const INFINITE_MESSAGES = {
340340
<div role="presentation" data-testid="pending-create-db-notification">
341341
<Row justify="end">
342342
<FlexItem>
343-
<EuiLoadingSpinner
343+
<Loader
344344
className={cx('infiniteMessage__icon', styles.loading)}
345345
/>
346346
</FlexItem>

redisinsight/ui/src/components/oauth/oauth-user-profile/OAuthUserProfile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useEffect, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
3-
import { EuiLoadingSpinner } from '@elastic/eui'
43
import cx from 'classnames'
54
import OAuthSignInButton from 'uiSrc/components/oauth/oauth-sign-in-button'
65
import {
@@ -14,6 +13,7 @@ import { OAuthSocialSource } from 'uiSrc/slices/interfaces'
1413
import { appInfoSelector } from 'uiSrc/slices/app/info'
1514
import { PackageType } from 'uiSrc/constants/env'
1615
import UserProfileBadge from 'uiSrc/components/instance-header/components/user-profile/UserProfileBadge'
16+
import { Loader } from 'uiSrc/components/base/display'
1717

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

@@ -41,7 +41,7 @@ const OAuthUserProfile = (props: Props) => {
4141
if (initialLoading) {
4242
return (
4343
<div className={styles.loadingContainer}>
44-
<EuiLoadingSpinner
44+
<Loader
4545
className={cx('infiniteMessage__icon', styles.loading)}
4646
size="l"
4747
data-testid="oath-user-profile-spinner"

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/shared/chat-history/ChatHistory.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import React, {
77
} from 'react'
88
import cx from 'classnames'
99

10-
import { EuiIcon, EuiLoadingSpinner } from '@elastic/eui'
10+
import { EuiIcon } from '@elastic/eui'
1111
import { throttle } from 'lodash'
1212
import {
1313
AiChatMessage,
1414
AiChatMessageType,
1515
} from 'uiSrc/slices/interfaces/aiAssistant'
1616
import { Nullable, scrollIntoView } from 'uiSrc/utils'
17+
import { Loader } from 'uiSrc/components/base/display'
1718
import { AdditionalRedisModule } from 'apiSrc/modules/database/models/additional.redis.module'
1819

1920
import LoadingMessage from '../loading-message'
@@ -153,7 +154,7 @@ const ChatHistory = (props: Props) => {
153154
if (isLoading) {
154155
return (
155156
<div className={cx(styles.wrapper, styles.loader)}>
156-
<EuiLoadingSpinner size="xl" data-testid="ai-loading-spinner" />
157+
<Loader size="xl" data-testid="ai-loading-spinner" />
157158
</div>
158159
)
159160
}

0 commit comments

Comments
 (0)