Skip to content

Commit 14ac58a

Browse files
refactor: move LagPopover to a separate component
1 parent 2ce5ea6 commit 14ac58a

File tree

7 files changed

+38
-42
lines changed

7 files changed

+38
-42
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.ydb-lag-popover {
2+
div:nth-child(1) {
3+
margin-bottom: 10px;
4+
}
5+
6+
&_type_read {
7+
max-width: 280px;
8+
}
9+
10+
&_type_write {
11+
max-width: 220px;
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import block from 'bem-cn-lite';
2+
3+
import {ReadLagImage, WriteLagImage} from '../LagImages';
4+
5+
import './LagPopover.scss';
6+
7+
const b = block('ydb-lag-popover');
8+
9+
interface LagPopoverProps {
10+
text: string;
11+
type: 'read' | 'write';
12+
}
13+
14+
export const LagPopover = ({text, type}: LagPopoverProps) => (
15+
<div className={b({type})}>
16+
<div>{text}</div>
17+
<div>{type === 'read' ? <ReadLagImage /> : <WriteLagImage />}</div>
18+
</div>
19+
);

src/components/LagPopover/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './LagPopover';

src/containers/Tenant/Diagnostics/Consumers/Headers/Headers.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,4 @@
22
&__lags {
33
white-space: nowrap;
44
}
5-
6-
&__lags-popover-content {
7-
max-width: 300px;
8-
9-
div:nth-child(1) {
10-
margin-bottom: 10px;
11-
}
12-
}
135
}
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import block from 'bem-cn-lite';
22

3-
import {ReadLagImage} from '../../../../../components/LagImages';
43
import {LabelWithPopover} from '../../../../../components/LabelWithPopover';
4+
import {LagPopover} from '../../../../../components/LagPopover';
55

66
import {CONSUMERS_COLUMNS_IDS, CONSUMERS_COLUMNS_TITILES} from '../utils/constants';
77

@@ -15,13 +15,6 @@ export const ReadLagsHeader = () => (
1515
<LabelWithPopover
1616
className={b('lags')}
1717
text={CONSUMERS_COLUMNS_TITILES[CONSUMERS_COLUMNS_IDS.READ_LAGS]}
18-
content={
19-
<div className={b('lags-popover-content')}>
20-
<div>{i18n('lagsPopover.readLags')}</div>
21-
<div>
22-
<ReadLagImage />
23-
</div>
24-
</div>
25-
}
18+
content={<LagPopover text={i18n('lagsPopover.readLags')} type="read" />}
2619
/>
2720
);

src/containers/Tenant/Diagnostics/Partitions/Headers/Headers.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919
white-space: normal;
2020
}
2121

22-
&__lags-popover-content {
23-
max-width: 300px;
24-
25-
div:nth-child(1) {
26-
margin-bottom: 10px;
27-
}
28-
}
29-
3022
&__messages-popover-content {
3123
max-width: 200px;
3224
}

src/containers/Tenant/Diagnostics/Partitions/Headers/Headers.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import block from 'bem-cn-lite';
22

33
import {LabelWithPopover} from '../../../../../components/LabelWithPopover';
4-
import {WriteLagImage, ReadLagImage} from '../../../../../components/LagImages';
4+
import {LagPopover} from '../../../../../components/LagPopover';
55

66
import {PARTITIONS_COLUMNS_IDS, PARTITIONS_COLUMNS_TITILES} from '../utils/constants';
77

@@ -29,29 +29,15 @@ export const WriteLagsHeader = () => (
2929
<LabelWithPopover
3030
className={b('lags')}
3131
text={PARTITIONS_COLUMNS_TITILES[PARTITIONS_COLUMNS_IDS.READ_LAGS]}
32-
content={
33-
<div className={b('lags-popover-content')}>
34-
<div>{i18n('lagsPopover.writeLags')}</div>
35-
<div>
36-
<WriteLagImage />
37-
</div>
38-
</div>
39-
}
32+
content={<LagPopover text={i18n('lagsPopover.readLags')} type="read" />}
4033
/>
4134
);
4235

4336
export const ReadLagsHeader = () => (
4437
<LabelWithPopover
4538
className={b('lags')}
4639
text={PARTITIONS_COLUMNS_TITILES[PARTITIONS_COLUMNS_IDS.WRITE_LAGS]}
47-
content={
48-
<div className={b('lags-popover-content')}>
49-
<div>{i18n('lagsPopover.readLags')}</div>
50-
<div>
51-
<ReadLagImage />
52-
</div>
53-
</div>
54-
}
40+
content={<LagPopover text={i18n('lagsPopover.writeLags')} type="write" />}
5541
/>
5642
);
5743

0 commit comments

Comments
 (0)