Skip to content

Commit ad6783b

Browse files
committed
Merge remote-tracking branch 'origin/main' into fe/RI-7712/change-rollout-mechanism
2 parents f32793b + 2c29457 commit ad6783b

File tree

65 files changed

+1942
-902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1942
-902
lines changed

.storybook/preview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Provider } from 'react-redux'
2020
import { store } from 'uiSrc/slices/store'
2121
import Router from 'uiSrc/Router'
2222
import { StyledContainer } from './helpers/styles'
23+
import { GlobalStyles } from 'uiSrc/styles/globalStyles'
2324

2425
const parameters: Parameters = {
2526
parameters: {
@@ -67,6 +68,7 @@ const preview: Preview = {
6768
<TooltipProvider>
6869
<RootStoryLayout storyContext={useStoryContext()}>
6970
<CommonStyles />
71+
<GlobalStyles />
7072
<StyledContainer>
7173
<Story />
7274
</StyledContainer>

redisinsight/ui/src/components/base/forms/buttons/EmptyButton.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ export const EmptyButton = ({
2222
...rest
2323
}: ButtonProps) => (
2424
<TextButton {...rest}>
25-
<Row justify={justify} gap="m" align="center">
26-
<ButtonIcon
27-
buttonSide="left"
28-
icon={icon}
29-
iconSide={iconSide}
30-
loading={loading}
31-
size={size}
32-
/>
33-
{children}
34-
<ButtonIcon
35-
buttonSide="right"
36-
icon={icon}
37-
iconSide={iconSide}
38-
loading={loading}
39-
size={size}
40-
/>
41-
</Row>
25+
{icon ? (
26+
<Row justify={justify} gap="m" align="center">
27+
<ButtonIcon
28+
buttonSide="left"
29+
icon={icon}
30+
iconSide={iconSide}
31+
loading={loading}
32+
size={size}
33+
/>
34+
{children}
35+
<ButtonIcon
36+
buttonSide="right"
37+
icon={icon}
38+
iconSide={iconSide}
39+
loading={loading}
40+
size={size}
41+
/>
42+
</Row>
43+
) : (
44+
children
45+
)}
4246
</TextButton>
4347
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,4 @@ export const SlowLogIcon = createIconComponent(SlowLogSvg)
305305
export const WorkbenchIcon = createIconComponent(WorkbenchSvg)
306306

307307
export const ShieldIcon = createIconComponent(ShieldSvg)
308-
export const RedisSoftwareIcon = createIconComponent(RedisSoftwareSvg)
308+
export const RedisSoftwareIcon = createIconComponent(RedisSoftwareSvg)

redisinsight/ui/src/components/base/layout/loading-content/LoadingContent.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { render } from '@testing-library/react'
2+
import { render } from 'uiSrc/utils/test-utils'
33
import LoadingContent from './LoadingContent'
44

55
describe('LoadingContent', () => {

redisinsight/ui/src/components/base/layout/loading-content/loading-content.styles.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HTMLAttributes } from 'react'
22
import styled, { keyframes } from 'styled-components'
3+
import { Theme } from 'uiSrc/components/base/theme/types'
34

45
export type LineRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
56

@@ -25,29 +26,29 @@ export const StyledLoadingContent = styled.span<
2526
`
2627

2728
export const SingleLine = styled.span<
28-
React.HtmlHTMLAttributes<HTMLSpanElement>
29+
React.HtmlHTMLAttributes<HTMLSpanElement> & { theme: Theme }
2930
>`
3031
display: block;
3132
width: 100%;
32-
height: var(--base);
33-
margin-bottom: var(--size-s);
34-
border-radius: var(--size-xs);
33+
height: ${({ theme }) => theme.core.space.space200};
34+
margin-bottom: ${({ theme }) => theme.core.space.space100};
35+
border-radius: ${({ theme }) => theme.core.space.space050};
3536
overflow: hidden;
3637
3738
&:last-child:not(:only-child) {
3839
width: 75%;
3940
}
4041
`
4142

42-
export const SingleLineBackground = styled.span`
43+
export const SingleLineBackground = styled.span<{ theme: Theme }>`
4344
display: block;
4445
width: 220%;
4546
height: 100%;
4647
background: linear-gradient(
4748
137deg,
48-
var(--loadingContentColor) 45%,
49-
var(--loadingContentLightestShade) 50%,
50-
var(--loadingContentColor) 55%
49+
${({ theme }) => theme.semantic.color.background.neutral200} 45%,
50+
${({ theme }) => theme.semantic.color.background.neutral300} 50%,
51+
${({ theme }) => theme.semantic.color.background.neutral200} 55%
5152
);
5253
animation: ${loadingAnimation} 1.5s ease-in-out infinite;
5354
`

redisinsight/ui/src/components/base/utils/pluginsThemeContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CommonStyles, themeLight, themeDark } from '@redis-ui/styles'
44
import 'modern-normalize/modern-normalize.css'
55
import '@redis-ui/styles/normalized-styles.css'
66
import '@redis-ui/styles/fonts.css'
7+
import { GlobalStyles } from 'uiSrc/styles/globalStyles'
78

89
interface Props {
910
children: React.ReactNode
@@ -31,6 +32,7 @@ export const ThemeProvider = ({ children }: Props) => {
3132
<PluginsThemeContext.Provider value={{ theme }}>
3233
<StyledThemeProvider theme={theme}>
3334
<CommonStyles />
35+
<GlobalStyles />
3436
{children}
3537
</StyledThemeProvider>
3638
</PluginsThemeContext.Provider>
Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,54 @@
1+
import React from 'react'
12
import type { Meta, StoryObj } from '@storybook/react-vite'
23

3-
import BarChart from './BarChart'
4+
import BarChart, { BarChartDataType } from './BarChart'
5+
import { formatBytes } from 'uiSrc/utils'
46

5-
const barCharMeta = {
7+
const barChartMeta: Meta<typeof BarChart> = {
68
component: BarChart,
9+
decorators: [
10+
(Story) => (
11+
<div style={{ padding: '20px' }}>
12+
<Story />
13+
</div>
14+
),
15+
],
16+
}
17+
18+
export default barChartMeta
19+
20+
type Story = StoryObj<typeof barChartMeta>
21+
22+
export const Default: Story = {
723
args: {
824
width: 600,
9-
height: 200,
10-
name: 'test',
25+
height: 300,
26+
name: 'default',
1127
data: [
12-
{ x: 1, y: 0, xlabel: 'one', ylabel: 'zero' },
13-
{ x: 5, y: 0.1, xlabel: 'five', ylabel: 'point one' },
14-
{ x: 10, y: 20, xlabel: '', ylabel: '' },
15-
{ x: 2, y: 30, xlabel: '', ylabel: '' },
16-
{ x: 30, y: 40, xlabel: '', ylabel: '' },
17-
{ x: 15, y: 500, xlabel: '', ylabel: '' },
28+
{ x: 1, y: 100, xlabel: 'A', ylabel: '' },
29+
{ x: 2, y: 200, xlabel: 'B', ylabel: '' },
30+
{ x: 3, y: 150, xlabel: 'C', ylabel: '' },
31+
{ x: 4, y: 300, xlabel: 'D', ylabel: '' },
32+
{ x: 5, y: 250, xlabel: 'E', ylabel: '' },
1833
],
1934
},
20-
} satisfies Meta<typeof BarChart>
21-
22-
export default barCharMeta
23-
24-
type Story = StoryObj<typeof barCharMeta>
35+
}
2536

26-
export const Default: Story = {}
27-
export const ThinnerBars: Story = {
37+
export const BytesDataType: Story = {
2838
args: {
29-
barWidth: 10,
39+
width: 700,
40+
height: 350,
41+
name: 'memory-usage',
42+
dataType: BarChartDataType.Bytes,
43+
data: [
44+
{ x: 3600, y: 1024 * 512, xlabel: '<1 hr', ylabel: '' },
45+
{ x: 14400, y: 1024 * 1024 * 2, xlabel: '1-4 Hrs', ylabel: '' },
46+
{ x: 43200, y: 1024 * 1024 * 5, xlabel: '4-12 Hrs', ylabel: '' },
47+
{ x: 86400, y: 1024 * 1024 * 10, xlabel: '12-24 Hrs', ylabel: '' },
48+
{ x: 604800, y: 1024 * 1024 * 3, xlabel: '1-7 Days', ylabel: '' },
49+
{ x: 2592000, y: 1024 * 1024, xlabel: '>7 Days', ylabel: '' },
50+
],
51+
tooltipValidation: (val) => formatBytes(val, 3) as string,
52+
leftAxiosValidation: (val, i) => (i % 2 ? '' : formatBytes(val, 1)),
3053
},
3154
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import styled, { createGlobalStyle } from 'styled-components'
2+
import { Theme } from 'uiSrc/components/base/theme/types'
3+
import React from 'react'
4+
5+
export const Wrapper = styled.div<React.HTMLAttributes<HTMLDivElement>>`
6+
margin: 0 auto;
7+
`
8+
9+
export const StyledSVG = styled.svg<
10+
React.SVGProps<SVGSVGElement> & {
11+
ref?: React.Ref<SVGSVGElement>
12+
theme: Theme
13+
}
14+
>`
15+
--bar-fill: ${({ theme }) => theme.semantic.color.background.notice500};
16+
--bar-stroke: ${({ theme }) =>
17+
theme.semantic.color.background.informative700};
18+
19+
width: 100%;
20+
height: 100%;
21+
/* D3-created bar elements */
22+
.bar-chart-bar {
23+
fill: rgb(from var(--bar-fill) r g b / 0.1);
24+
stroke: var(--bar-stroke);
25+
stroke-width: 1.5px;
26+
}
27+
28+
/* D3-created scatter point elements */
29+
.bar-chart-scatter-points {
30+
fill: var(--bar-stroke);
31+
cursor: pointer;
32+
}
33+
34+
/* D3-created dashed line elements */
35+
.bar-chart-dashed-line {
36+
stroke: ${({ theme }) => theme.semantic.color.text.neutral800};
37+
stroke-width: 1px;
38+
stroke-dasharray: 5, 3;
39+
}
40+
41+
/* D3-created tick lines */
42+
.tick line {
43+
stroke: ${({ theme }) => theme.semantic.color.text.neutral800};
44+
opacity: 0.1;
45+
}
46+
47+
/* D3-created domain */
48+
.domain {
49+
opacity: 0;
50+
}
51+
52+
/* D3-created text elements */
53+
text {
54+
color: ${({ theme }) => theme.semantic.color.text.neutral800};
55+
}
56+
`
57+
58+
// Tooltip is appended to body by D3, so needs global styles
59+
export const TooltipGlobalStyles = createGlobalStyle<{ theme: Theme }>`
60+
.bar-chart-tooltip {
61+
position: fixed;
62+
min-width: 50px;
63+
background: ${({ theme }) => theme.semantic.color.background.neutral600};
64+
color: ${({ theme }) => theme.semantic.color.text.primary600} !important;
65+
z-index: 10;
66+
border-radius: ${({ theme }) => theme.core.space.space100};
67+
pointer-events: none;
68+
font-weight: 400;
69+
font-size: 12px !important;
70+
box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2) !important;
71+
bottom: 0;
72+
height: 36px;
73+
min-height: 36px;
74+
padding: ${({ theme }) => theme.core.space.space100};
75+
line-height: 16px;
76+
}
77+
`

redisinsight/ui/src/components/charts/bar-chart/BarChart.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import cx from 'classnames'
44
import { curryRight, flow, toNumber } from 'lodash'
55

66
import { formatBytes, toBytes } from 'uiSrc/utils'
7-
import styles from './styles.module.scss'
7+
import {
8+
Wrapper,
9+
StyledSVG,
10+
TooltipGlobalStyles,
11+
} from './BarChart.styles'
812

913
export interface BarChartData {
1014
y: number
@@ -88,7 +92,7 @@ const BarChart = (props: IProps) => {
8892
const tooltip = d3
8993
.select('body')
9094
.append('div')
91-
.attr('class', cx(styles.tooltip, classNames?.tooltip || ''))
95+
.attr('class', cx('bar-chart-tooltip', classNames?.tooltip || ''))
9296
.style('opacity', 0)
9397

9498
d3.select(svgRef.current).select('g').remove()
@@ -143,7 +147,7 @@ const BarChart = (props: IProps) => {
143147
if (divideLastColumn) {
144148
svg
145149
.append('line')
146-
.attr('class', cx(styles.dashedLine, classNames?.dashedLine))
150+
.attr('class', cx('bar-chart-dashed-line', classNames?.dashedLine))
147151
.attr('x1', xAxis(cleanedData.length - 2.3))
148152
.attr('x2', xAxis(cleanedData.length - 2.3))
149153
.attr('y1', 0)
@@ -198,7 +202,7 @@ const BarChart = (props: IProps) => {
198202
.data(cleanedData)
199203
.enter()
200204
.append('rect')
201-
.attr('class', cx(styles.bar, classNames?.bar))
205+
.attr('class', cx('bar-chart-bar', classNames?.bar))
202206
.attr('x', (d) => xAxis(d.index))
203207
.attr('width', barWidth)
204208
// set minimal height for Bar
@@ -236,12 +240,12 @@ const BarChart = (props: IProps) => {
236240
}
237241

238242
return (
239-
<div
240-
className={styles.wrapper}
241-
style={{ width: propWidth, height: propHeight }}
242-
>
243-
<svg ref={svgRef} className={styles.svg} />
244-
</div>
243+
<>
244+
<TooltipGlobalStyles />
245+
<Wrapper style={{ width: propWidth, height: propHeight }}>
246+
<StyledSVG ref={svgRef} />
247+
</Wrapper>
248+
</>
245249
)
246250
}
247251

0 commit comments

Comments
 (0)