Skip to content

Commit 371f9c4

Browse files
authored
RI-7785 Make Analysis tabs borders and action buttons consitent (#5259)
* fix(ui): integrate AnalyticsPageHeader in ClusterDetails and SlowLog pages References: #RI-7785
1 parent 2438ebb commit 371f9c4

File tree

6 files changed

+50
-75
lines changed

6 files changed

+50
-75
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import styled, { css } from 'styled-components'
2+
import { Row, Col } from 'uiSrc/components/base/layout/flex'
3+
4+
export const Container = styled(Col)`
5+
background-color: ${({ theme }) =>
6+
theme.semantic.color.background.neutral100};
7+
`
8+
9+
export const Content = styled(Row)`
10+
padding-top: ${({ theme }) => theme.core.space.space150};
11+
padding-bottom: ${({ theme }) => theme.core.space.space250};
12+
`
13+
14+
export const Item = styled(Col)<{ $borderLeft?: boolean }>`
15+
padding-right: ${({ theme }) => theme.core.space.space150};
16+
17+
${({ $borderLeft, theme }) =>
18+
$borderLeft &&
19+
css`
20+
border-left: 2px solid ${theme.semantic.color.border.neutral500};
21+
padding-left: ${theme.core.space.space150};
22+
`}
23+
`
24+
25+
export const Loading = styled.div`
26+
width: 422px;
27+
padding-top: ${({ theme }) => theme.core.space.space200};
28+
`

redisinsight/ui/src/pages/cluster-details/components/cluster-details-header/ClusterDetailsHeader.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react'
22
import { useSelector } from 'react-redux'
3-
import cx from 'classnames'
4-
import { capitalize } from 'lodash'
53

64
import { LoadingContent } from 'uiSrc/components/base/layout'
75
import {
@@ -20,7 +18,12 @@ import { Text } from 'uiSrc/components/base/text'
2018
import { RiTooltip } from 'uiSrc/components'
2119
import { AnalyticsPageHeader } from 'uiSrc/pages/database-analysis/components/analytics-page-header'
2220

23-
import styles from './styles.module.scss'
21+
import {
22+
Container,
23+
Content,
24+
Item,
25+
Loading,
26+
} from './ClusterDetailsHeader.styles'
2427

2528
interface IMetrics {
2629
label: string
@@ -55,7 +58,6 @@ const ClusterDetailsHeader = () => {
5558
username || DEFAULT_USERNAME
5659
) : (
5760
<RiTooltip
58-
className={styles.tooltip}
5961
anchorClassName="truncateText"
6062
position="bottom"
6163
content={<>{formatLongName(username || DEFAULT_USERNAME)}</>}
@@ -71,7 +73,6 @@ const ClusterDetailsHeader = () => {
7173
border: 'left',
7274
value: (
7375
<RiTooltip
74-
className={styles.tooltip}
7576
position="top"
7677
content={
7778
<>
@@ -90,33 +91,28 @@ const ClusterDetailsHeader = () => {
9091
]
9192

9293
return (
93-
<div className={styles.container} data-testid="cluster-details-header">
94+
<Container data-testid="cluster-details-header">
9495
<AnalyticsPageHeader />
9596
{loading && !data && (
96-
<div className={styles.loading} data-testid="cluster-details-loading">
97+
<Loading as="div" data-testid="cluster-details-loading">
9798
<LoadingContent lines={2} />
98-
</div>
99+
</Loading>
99100
)}
100101
{data && (
101-
<div
102-
className={cx(styles.content)}
103-
data-testid="cluster-details-content"
104-
>
102+
<Content data-testid="cluster-details-content">
105103
{metrics.map(({ value, label, border }) => (
106-
<div
107-
className={cx(styles.item, styles[`border${capitalize(border)}`])}
104+
<Item
108105
key={label}
106+
$borderLeft={border === 'left'}
109107
data-testid={`cluster-details-item-${label}`}
110108
>
111-
<Text color="subdued" className={styles.value}>
112-
{value}
113-
</Text>
114-
<Text className={styles.label}>{label}</Text>
115-
</div>
109+
<Text color="subdued">{value}</Text>
110+
<Text>{label}</Text>
111+
</Item>
116112
))}
117-
</div>
113+
</Content>
118114
)}
119-
</div>
115+
</Container>
120116
)
121117
}
122118

redisinsight/ui/src/pages/cluster-details/components/cluster-details-header/styles.module.scss

Lines changed: 0 additions & 42 deletions
This file was deleted.

redisinsight/ui/src/pages/database-analysis/components/analytics-page-header/AnalyticsPageHeader.styles.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import styled from 'styled-components'
22
import { Row } from 'uiSrc/components/base/layout/flex'
3-
import { Theme } from 'uiSrc/components/base/theme/types'
4-
5-
const getBorderColor = (theme: Theme) =>
6-
theme.name === 'dark' ? theme.color.dark600 : theme.color.dusk150
73

84
export const HeaderContainer = styled.div`
95
width: 100%;
10-
border-bottom: 4px solid
11-
${({ theme }: { theme: Theme }) => getBorderColor(theme)}; /* Mimic the tabs border width and color */
6+
border-bottom: ${({ theme }) => {
7+
const { tabsLine } = theme.components.tabs.variants.default
8+
return `${tabsLine.size} solid ${tabsLine.color}`
9+
}};
1210
`
1311

1412
export const HeaderContent = styled(Row).attrs({

redisinsight/ui/src/pages/database-analysis/components/analytics-page-header/AnalyticsPageHeader.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import {
88
TabsWrapper,
99
} from './AnalyticsPageHeader.styles'
1010

11-
export const AnalyticsPageHeader = ({
12-
actions,
13-
children,
14-
}: AnalyticsPageHeaderProps) => (
11+
export const AnalyticsPageHeader = ({ actions }: AnalyticsPageHeaderProps) => (
1512
<HeaderContainer>
1613
<HeaderContent>
1714
<FlexItem>
@@ -21,6 +18,5 @@ export const AnalyticsPageHeader = ({
2118
</FlexItem>
2219
{actions && <FlexItem>{actions}</FlexItem>}
2320
</HeaderContent>
24-
{children}
2521
</HeaderContainer>
2622
)

redisinsight/ui/src/pages/database-analysis/components/analytics-page-header/AnalyticsPageHeader.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ import { ReactNode } from 'react'
22

33
export interface AnalyticsPageHeaderProps {
44
actions?: ReactNode
5-
children?: ReactNode
65
}

0 commit comments

Comments
 (0)