Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix incorrect truncate strings with popover #567

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"@types/lodash": "^4.14.178",
"@types/numeral": "^2.0.2",
"@types/qs": "^6.9.7",
"@types/react": "^17.0.44",
"@types/react": "^17.0.58",
"@types/react-dom": "^17.0.11",
"@types/react-router": "^5.1.17",
"@types/react-router-dom": "^5.3.2",
Expand Down
13 changes: 13 additions & 0 deletions src/components/CellWithPopover/CellWithPopover.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.ydb-cell-with-popover {
display: inline-block;
overflow: hidden;

max-width: 100%;

white-space: nowrap;
text-overflow: ellipsis;

&__wrapper {
display: flex;
}
}
26 changes: 26 additions & 0 deletions src/components/CellWithPopover/CellWithPopover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import cn from 'bem-cn-lite';

import {Popover, type PopoverProps} from '@gravity-ui/uikit';

import './CellWithPopover.scss';

const b = cn('ydb-cell-with-popover');

interface CellWithPopoverProps extends PopoverProps {
wrapperClassName?: string;
}

export function CellWithPopover({
children,
className,
wrapperClassName,
...props
}: CellWithPopoverProps) {
return (
<div className={b('wrapper', wrapperClassName)}>
<Popover className={b(null, className)} {...props}>
{children}
</Popover>
</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It better to put b-style higher. So you have block__element inside block. It will be more correct in terms of BEM methodology. More specific styles should be further in components tree

);
}
2 changes: 0 additions & 2 deletions src/components/NodeHostWrapper/NodeHostWrapper.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.ydb-node-host-wrapper {
display: flex;

&__host-wrapper {
display: flex;

Expand Down
57 changes: 28 additions & 29 deletions src/components/NodeHostWrapper/NodeHostWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import block from 'bem-cn-lite';

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

import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
import type {NodeAddress} from '../../types/additionalProps';
Expand All @@ -10,6 +10,7 @@ import {isUnavailableNode} from '../../utils/nodes';
import EntityStatus from '../EntityStatus/EntityStatus';
import {NodeEndpointsTooltipContent} from '../TooltipsContent';
import {IconWrapper} from '../Icon';
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';

import './NodeHostWrapper.scss';

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

return (
<div className={b()}>
<Popover
disabled={!isNodeAvailable}
content={<NodeEndpointsTooltipContent data={node} />}
placement={['top', 'bottom']}
behavior={PopoverBehavior.Immediate}
>
<div className={b('host-wrapper')}>
<EntityStatus
name={node.Host}
status={node.SystemState}
path={nodePath}
hasClipboardButton
className={b('host')}
/>
{nodeRef && (
<Button
size="s"
href={nodeRef}
className={b('external-button')}
target="_blank"
>
<IconWrapper name="external" />
</Button>
)}
</div>
</Popover>
</div>
<CellWithPopover
disabled={!isNodeAvailable}
content={<NodeEndpointsTooltipContent data={node} />}
placement={['top', 'bottom']}
behavior={PopoverBehavior.Immediate}
>
<div className={b('host-wrapper')}>
<EntityStatus
name={node.Host}
status={node.SystemState}
path={nodePath}
hasClipboardButton
className={b('host')}
/>
{nodeRef && (
<Button
size="s"
href={nodeRef}
className={b('external-button')}
target="_blank"
>
<IconWrapper name="external" />
</Button>
)}
</div>
</CellWithPopover>
);
};
4 changes: 2 additions & 2 deletions src/containers/Nodes/getNodesColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import DataTable, {type Column} from '@gravity-ui/react-data-table';
import {Popover} from '@gravity-ui/uikit';

import {PoolsGraph} from '../../components/PoolsGraph/PoolsGraph';
import {ProgressViewer} from '../../components/ProgressViewer/ProgressViewer';
Expand All @@ -13,6 +12,7 @@ import type {NodesPreparedEntity} from '../../store/reducers/nodes/types';
import type {GetNodeRefFunc} from '../../types/additionalProps';
import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils';
import {UsageLabel} from '../../components/UsageLabel/UsageLabel';
import {CellWithPopover} from '../../components/CellWithPopover/CellWithPopover';

const NODES_COLUMNS_IDS = {
NodeId: 'NodeId',
Expand Down Expand Up @@ -76,7 +76,7 @@ const versionColumn: Column<NodesPreparedEntity> = {
width: '200px',
align: DataTable.LEFT,
render: ({row}) => {
return <Popover content={row.Version}>{row.Version}</Popover>;
return <CellWithPopover content={row.Version}>{row.Version}</CellWithPopover>;
},
sortable: false,
};
Expand Down
11 changes: 0 additions & 11 deletions src/containers/Storage/StorageGroups/StorageGroups.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@
}
}
&__pool-name-wrapper {
display: flex;
align-items: flex-end;

width: 230px;
}
&__pool-name {
display: inline-block;
overflow: hidden;

max-width: 230px;

vertical-align: top;
text-overflow: ellipsis;
}
&__usage-label {
&_overload {
color: var(--yc-color-text-light-primary);
Expand Down
22 changes: 11 additions & 11 deletions src/containers/Storage/StorageGroups/getStorageGroupsColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
import {stringifyVdiskId} from '../../../utils/dataFormatters/dataFormatters';
import EntityStatus from '../../../components/EntityStatus/EntityStatus';
import {Stack} from '../../../components/Stack/Stack';
import {CellWithPopover} from '../../../components/CellWithPopover/CellWithPopover';
import {VDisk} from '../VDisk';
import {getDegradedSeverity, getUsageSeverityForStorageGroup} from '../utils';
import i18n from './i18n';
Expand Down Expand Up @@ -58,17 +59,16 @@ const poolNameColumn: Column<PreparedStorageGroup> = {
render: ({row}) => {
const splitted = row.PoolName?.split('/');
return (
<div className={b('pool-name-wrapper')}>
{splitted && (
<Popover
content={row.PoolName}
placement={['right']}
behavior={PopoverBehavior.Immediate}
>
<span className={b('pool-name')}>{splitted[splitted.length - 1]}</span>
</Popover>
)}
</div>
splitted && (
<CellWithPopover
wrapperClassName={b('pool-name-wrapper')}
content={row.PoolName}
placement={['right']}
behavior={PopoverBehavior.Immediate}
>
{splitted[splitted.length - 1]}
</CellWithPopover>
)
);
},
align: DataTable.LEFT,
Expand Down
Loading