Skip to content

Commit fbc6c51

Browse files
fix(EntityStatus): enable component to left trim links
1 parent aa1083d commit fbc6c51

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

src/components/EntityStatus/EntityStatus.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import cn from 'bem-cn-lite';
44
import {Link} from 'react-router-dom';
5-
import {ClipboardButton, Link as ExternalLink, Button, Icon} from '@gravity-ui/uikit';
5+
import {ClipboardButton, Link as UIKitLink, Button, Icon} from '@gravity-ui/uikit';
66

77
import circleInfoIcon from '../../assets/icons/circle-info.svg';
88
import circleExclamationIcon from '../../assets/icons/circle-exclamation.svg';
@@ -35,6 +35,7 @@ class EntityStatus extends React.Component {
3535
externalLink: PropTypes.bool,
3636
className: PropTypes.string,
3737
mode: PropTypes.oneOf(['color', 'icons']),
38+
withLeftTrim: PropTypes.bool,
3839
};
3940

4041
static defaultProps = {
@@ -45,6 +46,7 @@ class EntityStatus extends React.Component {
4546
showStatus: true,
4647
externalLink: false,
4748
mode: 'color',
49+
withLeftTrim: false,
4850
};
4951
renderIcon() {
5052
const {status, size, showStatus, mode} = this.props;
@@ -56,12 +58,7 @@ class EntityStatus extends React.Component {
5658
const modifiers = {state: status.toLowerCase(), size};
5759

5860
if (mode === 'icons' && icons[status]) {
59-
return (
60-
<Icon
61-
className={b('status-icon', modifiers)}
62-
data={icons[status]}
63-
/>
64-
);
61+
return <Icon className={b('status-icon', modifiers)} data={icons[status]} />;
6562
}
6663

6764
return <div className={b('status-color', modifiers)} />;
@@ -70,21 +67,25 @@ class EntityStatus extends React.Component {
7067
const {iconPath} = this.props;
7168

7269
return (
73-
<ExternalLink target="_blank" href={iconPath}>
70+
<UIKitLink target="_blank" href={iconPath}>
7471
{this.renderIcon()}
75-
</ExternalLink>
72+
</UIKitLink>
7673
);
7774
}
7875
renderLink() {
7976
const {externalLink, name, path, onNameMouseEnter, onNameMouseLeave} = this.props;
8077

8178
if (externalLink) {
82-
return <ExternalLink href={path}>{name}</ExternalLink>;
79+
return (
80+
<UIKitLink className={b('name')} href={path}>
81+
{name}
82+
</UIKitLink>
83+
);
8384
}
8485

8586
return path ? (
8687
<Link
87-
title={name}
88+
className={b('name')}
8889
to={path}
8990
onMouseEnter={onNameMouseEnter}
9091
onMouseLeave={onNameMouseLeave}
@@ -95,7 +96,6 @@ class EntityStatus extends React.Component {
9596
name && (
9697
<span
9798
className={b('name')}
98-
title={name}
9999
onMouseEnter={onNameMouseEnter}
100100
onMouseLeave={onNameMouseLeave}
101101
>
@@ -108,14 +108,16 @@ class EntityStatus extends React.Component {
108108
const {name, label, iconPath, hasClipboardButton, className} = this.props;
109109

110110
return (
111-
<div className={b(null, className)}>
111+
<div className={b(null, className)} title={name}>
112112
{iconPath ? this.renderStatusLink() : this.renderIcon()}
113113
{label && (
114114
<span title={label} className={b('label')}>
115115
{label}
116116
</span>
117117
)}
118-
{this.renderLink()}
118+
<span className={b('link', {'with-left-trim': this.props.withLeftTrim})}>
119+
{this.renderLink()}
120+
</span>
119121
{hasClipboardButton && (
120122
<Button
121123
component="span"

src/components/EntityStatus/EntityStatus.scss

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131
}
3232

3333
a {
34-
overflow: hidden;
35-
36-
white-space: nowrap;
3734
text-decoration: none;
38-
text-overflow: ellipsis;
3935

4036
color: var(--yc-color-text-link);
4137
}
@@ -53,12 +49,25 @@
5349
color: var(--yc-color-text-complementary);
5450
}
5551

56-
&__name {
52+
&__link {
53+
overflow: hidden;
54+
5755
white-space: nowrap;
56+
text-overflow: ellipsis;
57+
}
58+
59+
&__link_with-left-trim {
60+
direction: rtl;
61+
62+
.entity-status__name {
63+
unicode-bidi: plaintext;
64+
}
5865
}
5966

6067
&__status-color,
6168
&__status-icon {
69+
flex-shrink: 0;
70+
6271
margin-right: 8px;
6372

6473
border-radius: 3px;

0 commit comments

Comments
 (0)