Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9c1203a
fix the footer button location and sizes
dantovska Nov 7, 2025
0f3b772
fix import text and spacing between elements
dantovska Nov 7, 2025
8eb893a
remove info icons next to submit buttons and remove unused import found
dantovska Nov 7, 2025
0f6b7a0
Fix footer button sizes and alignment
dantovska Nov 7, 2025
c0d37b2
revert the submit button info icon
dantovska Nov 10, 2025
cfeffdc
finalize styling for main import file db form and error form
dantovska Nov 12, 2025
97f7cf4
extract import table result constants
dantovska Nov 13, 2025
b53162b
replace hard coded values with defined constants; remove scss styles …
dantovska Nov 13, 2025
e7f6fa7
add sizing for table result index column; add some spacings in the co…
dantovska Nov 13, 2025
96c311b
add import db result type enum
dantovska Nov 13, 2025
a37a0f1
apply proper styling and refactor the results log component
dantovska Nov 13, 2025
3dcc0fa
Ok -> OK
dantovska Nov 14, 2025
027fbc6
add padding to the container instead changing box-shadow -> border
dantovska Nov 14, 2025
a045adc
add maxHeight to table result, beyond which a scroll will appear
dantovska Nov 14, 2025
2056b69
use rems instead of pixels
dantovska Nov 14, 2025
b114b2a
show only sections with items > 0
dantovska Nov 14, 2025
c57279e
decrease max table height
dantovska Nov 14, 2025
3384114
remove custom margin
dantovska Nov 14, 2025
8afbd11
remove unneded collapsible nav title; calculate navState once per ite…
dantovska Nov 14, 2025
56c08d1
extract the results data config in a separate file; use useMemo for t…
dantovska Nov 14, 2025
f1ce7d1
update tests since id is changed from failed-* to fail-* to match the…
dantovska Nov 14, 2025
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
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import { Nullable } from 'uiSrc/utils'
import { RiFilePicker, UploadWarning } from 'uiSrc/components'
import { Col, FlexItem } from 'uiSrc/components/base/layout/flex'
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
import { ColorText, Text } from 'uiSrc/components/base/text'
import { Loader, Modal } from 'uiSrc/components/base/display'
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
Expand Down Expand Up @@ -137,7 +137,7 @@ const ImportFileModal = <T,>({
<Modal.Content.Footer.Compose>
<Modal.Content.Footer.Group>
{isShowForm && (
<>
<Row gap="m" justify="end">
<SecondaryButton
size="l"
onClick={onClose}
Expand All @@ -153,7 +153,7 @@ const ImportFileModal = <T,>({
>
{submitBtnText || 'Import'}
</PrimaryButton>
</>
</Row>
)}
{data && <PrimaryButton onClick={onClose}>OK</PrimaryButton>}
</Modal.Content.Footer.Group>
Expand Down
20 changes: 20 additions & 0 deletions redisinsight/ui/src/constants/importDatabasesTableResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export enum ImportTableResultColumn {
Index = 'index',
Host = 'host',
Errors = 'errors',
}

export const TABLE_IMPORT_RESULT_COLUMN_ID_HEADER_MAP = new Map<
ImportTableResultColumn,
string
>([
[ImportTableResultColumn.Index, '#'],
[ImportTableResultColumn.Host, 'Host:Port'],
[ImportTableResultColumn.Errors, 'Result'],
])

export enum ImportDatabaseResultType {
Success = 'success',
Partial = 'partial',
Fail = 'fail',
}
1 change: 1 addition & 0 deletions redisinsight/ui/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export * from './datetime'
export * from './sorting'
export * from './databaseList'
export * from './rdiList'
export * from './importDatabasesTableResult'
export { ApiEndpoints, BrowserStorageItem, ApiStatusCode, apiErrors }
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
PrimaryButton,
SecondaryButton,
} from 'uiSrc/components/base/forms/buttons'
import { InfoIcon } from 'uiSrc/components/base/icons'
import {
FormField,
RiInfoIconProps,
Expand Down Expand Up @@ -163,7 +162,6 @@ const ClusterConnectionForm = (props: Props) => {
onClick={onClick}
disabled={submitIsDisabled}
loading={loading}
icon={submitIsDisabled ? InfoIcon : undefined}
data-testid="btn-submit"
>
Submit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import ReactDOM from 'react-dom'

import {
fetchInstancesAction,
importInstancesSelector,
Expand All @@ -9,22 +10,19 @@ import {
} from 'uiSrc/slices/instances/instances'
import { Nullable } from 'uiSrc/utils'
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
import { RiTooltip, UploadWarning, RiFilePicker } from 'uiSrc/components'
import { RiFilePicker, RiTooltip, UploadWarning } from 'uiSrc/components'
import { useModalHeader } from 'uiSrc/contexts/ModalTitleProvider'
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
import { Spacer } from 'uiSrc/components/base/layout/spacer'
import {
PrimaryButton,
SecondaryButton,
} from 'uiSrc/components/base/forms/buttons'
import { InfoIcon } from 'uiSrc/components/base/icons'
import { InfoIcon, RiIcon } from 'uiSrc/components/base/icons'
import { Title } from 'uiSrc/components/base/text/Title'
import { ColorText, Text } from 'uiSrc/components/base/text'
import { Loader } from 'uiSrc/components/base/display'
import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
import ResultsLog from './components/ResultsLog'

import styles from './styles.module.scss'
import { ScrollableWrapper } from '../styles.module'

export interface Props {
Expand Down Expand Up @@ -102,53 +100,47 @@ const ImportDatabase = (props: Props) => {

if (error) {
return ReactDOM.createPortal(
<div className="footerAddDatabase">
<Row justify="end" gap="m" data-testid="footer-import-database">
<PrimaryButton
size="s"
color="secondary"
onClick={onClickRetry}
data-testid="btn-retry"
>
Retry
</PrimaryButton>
</div>,
</Row>,
footerEl,
)
}

if (data) {
return ReactDOM.createPortal(
<div className="footerAddDatabase">
<Row justify="end" gap="m" data-testid="footer-import-database">
<PrimaryButton
size="s"
type="submit"
onClick={handleOnClose}
data-testid="btn-close"
>
Ok
OK
</PrimaryButton>
</div>,
</Row>,
footerEl,
)
}

return ReactDOM.createPortal(
<div className="footerAddDatabase">
<Row justify="end" gap="m" data-testid="footer-import-database">
<SecondaryButton
size="s"
className="btn-cancel"
onClick={handleOnClose}
style={{ marginRight: 12 }}
>
Cancel
</SecondaryButton>
<RiTooltip
position="top"
anchorClassName="euiToolTip__btn-disabled"
content={isSubmitDisabled ? 'Upload a file' : undefined}
>
<PrimaryButton
size="s"
type="submit"
onClick={onSubmit}
loading={loading}
Expand All @@ -159,7 +151,7 @@ const ImportDatabase = (props: Props) => {
Submit
</PrimaryButton>
</RiTooltip>
</div>,
</Row>,
footerEl,
)
}
Expand All @@ -169,70 +161,70 @@ const ImportDatabase = (props: Props) => {
return (
<>
<ScrollableWrapper data-testid="add-db_import">
<Col>
<FlexItem grow>
<Col gap="xl">
<Col grow gap="xl">
{isShowForm && (
<>
<Text color="subdued" size="s">
<Col gap="xl">
<Text>
Use a JSON file to import your database connections. Ensure
that you only use files from trusted sources to prevent the
risk of automatically executing malicious code.
</Text>
<Spacer />

<RiFilePicker
id="import-file-modal-filepicker"
initialPromptText="Select or drag and drop a file"
className={styles.fileDrop}
isInvalid={isInvalid}
onChange={onFileChange}
display="large"
data-testid="import-file-modal-filepicker"
aria-label="Select or drag and drop file"
/>

{isInvalid && (
<ColorText
color="danger"
className={styles.errorFileMsg}
data-testid="input-file-error-msg"
>
<ColorText color="danger" data-testid="input-file-error-msg">
{`File should not exceed ${MAX_MB_FILE} MB`}
</ColorText>
)}
</>
</Col>
)}
{loading && (
<div
className={styles.loading}
<Col
justify="center"
gap="l"
align="center"
data-testid="file-loading-indicator"
>
<Loader size="xl" />
<Text color="subdued" style={{ marginTop: 12 }}>
Uploading...
</Text>
</div>
<Text>Uploading...</Text>
</Col>
)}
{error && (
<div className={styles.result} data-testid="result-failed">
<RiIcon type="ToastCancelIcon" color="danger600" size="xxl" />
<Text color="subdued" style={{ marginTop: 16 }}>
Failed to add database connections
</Text>
<Text color="subdued">{error}</Text>
</div>
<Col
align="center"
gap="l"
justify="center"
data-testid="result-failed"
>
<RiIcon
type="IndicatorXIcon"
color="danger600"
customSize="5rem"
/>
<Text>Failed to add database connections</Text>
<Text>{error}</Text>
</Col>
)}
</FlexItem>
</Col>
{isShowForm && (
<FlexItem grow className={styles.uploadWarningContainer}>
<FlexItem>
<UploadWarning />
</FlexItem>
)}
</Col>
{data && (
<Row justify="center">
<FlexItem grow style={{ maxWidth: '100%' }}>
<ResultsLog data={data} />
</FlexItem>
<ResultsLog data={data} />
</Row>
)}
</ScrollableWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from 'styled-components'

import { Col } from 'uiSrc/components/base/layout/flex'

// Ideally this should not be needed, but the section component
// will not let the parent cut the border, more precisely the box-shadow,
// so we need to add padding to the parent container
export const StyledColWrapper = styled(Col)`
padding: ${({ theme }) => theme.core.space.space025};
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ImportDatabaseResultType } from 'uiSrc/constants'
import { TableResultData } from './ResultsLog'

export const RESULTS_DATA_CONFIG: TableResultData[] = [
{
type: ImportDatabaseResultType.Success,
title: 'Fully imported',
},
{
type: ImportDatabaseResultType.Partial,
title: 'Partially imported',
},
{
type: ImportDatabaseResultType.Fail,
title: 'Failed to import',
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('ResultsLog', () => {

expect(screen.getByTestId('success-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('partial-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('failed-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('fail-results-closed')).toBeInTheDocument()
})

it('should open and collapse other groups', () => {
Expand All @@ -45,12 +45,12 @@ describe('ResultsLog', () => {
expect(screen.getByTestId('success-results-open')).toBeInTheDocument()

expect(screen.getByTestId('partial-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('failed-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('fail-results-closed')).toBeInTheDocument()

fireEvent.click(
within(screen.getByTestId('failed-results-closed')).getByRole('button'),
within(screen.getByTestId('fail-results-closed')).getByRole('button'),
)
expect(screen.getByTestId('failed-results-open')).toBeInTheDocument()
expect(screen.getByTestId('fail-results-open')).toBeInTheDocument()

expect(screen.getByTestId('partial-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('success-results-closed')).toBeInTheDocument()
Expand All @@ -60,7 +60,7 @@ describe('ResultsLog', () => {
)
expect(screen.getByTestId('partial-results-open')).toBeInTheDocument()

expect(screen.getByTestId('failed-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('fail-results-closed')).toBeInTheDocument()
expect(screen.getByTestId('success-results-closed')).toBeInTheDocument()
})

Expand All @@ -87,7 +87,7 @@ describe('ResultsLog', () => {
),
).toHaveTextContent('1')
expect(
within(screen.getByTestId('failed-results-closed')).getByTestId(
within(screen.getByTestId('fail-results-closed')).getByTestId(
'number-of-dbs',
),
).toHaveTextContent('1')
Expand Down
Loading
Loading