Skip to content

Commit d82e65b

Browse files
authored
fix: fix incorrect truncate strings with popover (#567)
1 parent 187617d commit d82e65b

File tree

9 files changed

+84
-59
lines changed

9 files changed

+84
-59
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@types/lodash": "^4.14.178",
118118
"@types/numeral": "^2.0.2",
119119
"@types/qs": "^6.9.7",
120-
"@types/react": "^17.0.44",
120+
"@types/react": "^17.0.58",
121121
"@types/react-dom": "^17.0.11",
122122
"@types/react-router": "^5.1.17",
123123
"@types/react-router-dom": "^5.3.2",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.ydb-cell-with-popover {
2+
display: flex;
3+
4+
&__popover {
5+
display: inline-block;
6+
overflow: hidden;
7+
8+
max-width: 100%;
9+
10+
white-space: nowrap;
11+
text-overflow: ellipsis;
12+
}
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import cn from 'bem-cn-lite';
2+
3+
import {Popover, type PopoverProps} from '@gravity-ui/uikit';
4+
5+
import './CellWithPopover.scss';
6+
7+
const b = cn('ydb-cell-with-popover');
8+
9+
interface CellWithPopoverProps extends PopoverProps {
10+
wrapperClassName?: string;
11+
}
12+
13+
export function CellWithPopover({
14+
children,
15+
className,
16+
wrapperClassName,
17+
...props
18+
}: CellWithPopoverProps) {
19+
return (
20+
<div className={b(null, wrapperClassName)}>
21+
<Popover className={b('popover', className)} {...props}>
22+
{children}
23+
</Popover>
24+
</div>
25+
);
26+
}

src/components/NodeHostWrapper/NodeHostWrapper.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.ydb-node-host-wrapper {
2-
display: flex;
3-
42
&__host-wrapper {
53
display: flex;
64

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

3-
import {Button, Popover, PopoverBehavior} from '@gravity-ui/uikit';
3+
import {Button, PopoverBehavior} from '@gravity-ui/uikit';
44

55
import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
66
import type {NodeAddress} from '../../types/additionalProps';
@@ -10,6 +10,7 @@ import {isUnavailableNode} from '../../utils/nodes';
1010
import EntityStatus from '../EntityStatus/EntityStatus';
1111
import {NodeEndpointsTooltipContent} from '../TooltipsContent';
1212
import {IconWrapper} from '../Icon';
13+
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';
1314

1415
import './NodeHostWrapper.scss';
1516

@@ -34,33 +35,31 @@ export const NodeHostWrapper = ({node, getNodeRef}: NodeHostWrapperProps) => {
3435
: undefined;
3536

3637
return (
37-
<div className={b()}>
38-
<Popover
39-
disabled={!isNodeAvailable}
40-
content={<NodeEndpointsTooltipContent data={node} />}
41-
placement={['top', 'bottom']}
42-
behavior={PopoverBehavior.Immediate}
43-
>
44-
<div className={b('host-wrapper')}>
45-
<EntityStatus
46-
name={node.Host}
47-
status={node.SystemState}
48-
path={nodePath}
49-
hasClipboardButton
50-
className={b('host')}
51-
/>
52-
{nodeRef && (
53-
<Button
54-
size="s"
55-
href={nodeRef}
56-
className={b('external-button')}
57-
target="_blank"
58-
>
59-
<IconWrapper name="external" />
60-
</Button>
61-
)}
62-
</div>
63-
</Popover>
64-
</div>
38+
<CellWithPopover
39+
disabled={!isNodeAvailable}
40+
content={<NodeEndpointsTooltipContent data={node} />}
41+
placement={['top', 'bottom']}
42+
behavior={PopoverBehavior.Immediate}
43+
>
44+
<div className={b('host-wrapper')}>
45+
<EntityStatus
46+
name={node.Host}
47+
status={node.SystemState}
48+
path={nodePath}
49+
hasClipboardButton
50+
className={b('host')}
51+
/>
52+
{nodeRef && (
53+
<Button
54+
size="s"
55+
href={nodeRef}
56+
className={b('external-button')}
57+
target="_blank"
58+
>
59+
<IconWrapper name="external" />
60+
</Button>
61+
)}
62+
</div>
63+
</CellWithPopover>
6564
);
6665
};

src/containers/Nodes/getNodesColumns.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import DataTable, {type Column} from '@gravity-ui/react-data-table';
2-
import {Popover} from '@gravity-ui/uikit';
32

43
import {PoolsGraph} from '../../components/PoolsGraph/PoolsGraph';
54
import {ProgressViewer} from '../../components/ProgressViewer/ProgressViewer';
@@ -13,6 +12,7 @@ import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
1312
import type {GetNodeRefFunc} from '../../types/additionalProps';
1413
import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils';
1514
import {UsageLabel} from '../../components/UsageLabel/UsageLabel';
15+
import {CellWithPopover} from '../../components/CellWithPopover/CellWithPopover';
1616

1717
const NODES_COLUMNS_IDS = {
1818
NodeId: 'NodeId',
@@ -76,7 +76,7 @@ const versionColumn: Column<NodesPreparedEntity> = {
7676
width: '200px',
7777
align: DataTable.LEFT,
7878
render: ({row}) => {
79-
return <Popover content={row.Version}>{row.Version}</Popover>;
79+
return <CellWithPopover content={row.Version}>{row.Version}</CellWithPopover>;
8080
},
8181
sortable: false,
8282
};

src/containers/Storage/StorageGroups/StorageGroups.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,9 @@
2828
}
2929
}
3030
&__pool-name-wrapper {
31-
display: flex;
32-
align-items: flex-end;
33-
3431
width: 230px;
3532
}
36-
&__pool-name {
37-
display: inline-block;
38-
overflow: hidden;
3933

40-
max-width: 230px;
41-
42-
vertical-align: top;
43-
text-overflow: ellipsis;
44-
}
4534
&__usage-label {
4635
&_overload {
4736
color: var(--yc-color-text-light-primary);

src/containers/Storage/StorageGroups/getStorageGroupsColumns.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
1212
import {stringifyVdiskId} from '../../../utils/dataFormatters/dataFormatters';
1313
import EntityStatus from '../../../components/EntityStatus/EntityStatus';
1414
import {Stack} from '../../../components/Stack/Stack';
15+
import {CellWithPopover} from '../../../components/CellWithPopover/CellWithPopover';
1516
import {VDisk} from '../VDisk';
1617
import {getDegradedSeverity, getUsageSeverityForStorageGroup} from '../utils';
1718
import i18n from './i18n';
@@ -58,17 +59,16 @@ const poolNameColumn: Column<PreparedStorageGroup> = {
5859
render: ({row}) => {
5960
const splitted = row.PoolName?.split('/');
6061
return (
61-
<div className={b('pool-name-wrapper')}>
62-
{splitted && (
63-
<Popover
64-
content={row.PoolName}
65-
placement={['right']}
66-
behavior={PopoverBehavior.Immediate}
67-
>
68-
<span className={b('pool-name')}>{splitted[splitted.length - 1]}</span>
69-
</Popover>
70-
)}
71-
</div>
62+
splitted && (
63+
<CellWithPopover
64+
wrapperClassName={b('pool-name-wrapper')}
65+
content={row.PoolName}
66+
placement={['right']}
67+
behavior={PopoverBehavior.Immediate}
68+
>
69+
{splitted[splitted.length - 1]}
70+
</CellWithPopover>
71+
)
7272
);
7373
},
7474
align: DataTable.LEFT,

0 commit comments

Comments
 (0)