Skip to content

Commit 9928ee2

Browse files
fix: fix status colors (#757)
* migrate EntityStatus to TS * move healthcheckInfo reducer files, rename its types * rename gray to grey color to match with EFlag * use EFlag where it's possible * use color state for tenant (previously Tenant state could be only green or grey)
1 parent ee723cd commit 9928ee2

File tree

41 files changed

+261
-244
lines changed

Some content is hidden

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

41 files changed

+261
-244
lines changed

src/components/BasicNodeViewer/BasicNodeViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cn from 'bem-cn-lite';
33
import type {AdditionalNodesProps} from '../../types/additionalProps';
44
import type {PreparedNode} from '../../store/reducers/node/types';
55

6-
import EntityStatus from '../EntityStatus/EntityStatus';
6+
import {EntityStatus} from '../EntityStatus/EntityStatus';
77
import {Tags} from '../Tags';
88
import {Icon} from '../Icon';
99

src/components/EntityStatus/EntityStatus.js

Lines changed: 0 additions & 136 deletions
This file was deleted.

src/components/EntityStatus/EntityStatus.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
}
9292

9393
&__status-color {
94-
&_state_running,
9594
&_state_green {
9695
background-color: var(--ydb-color-status-green);
9796
}
@@ -104,7 +103,6 @@
104103
&_state_red {
105104
background-color: var(--ydb-color-status-red);
106105
}
107-
&_state_gray,
108106
&_state_grey {
109107
background-color: var(--ydb-color-status-grey);
110108
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import {Link} from 'react-router-dom';
2+
import cn from 'bem-cn-lite';
3+
4+
import {Icon, Link as UIKitLink} from '@gravity-ui/uikit';
5+
6+
import {EFlag} from '../../types/api/enums';
7+
import circleExclamationIcon from '../../assets/icons/circle-exclamation.svg';
8+
import circleInfoIcon from '../../assets/icons/circle-info.svg';
9+
import circleTimesIcon from '../../assets/icons/circle-xmark.svg';
10+
import triangleExclamationIcon from '../../assets/icons/triangle-exclamation.svg';
11+
import {ClipboardButton} from '../ClipboardButton';
12+
import './EntityStatus.scss';
13+
14+
const icons = {
15+
[EFlag.Blue]: circleInfoIcon,
16+
[EFlag.Yellow]: circleExclamationIcon,
17+
[EFlag.Orange]: triangleExclamationIcon,
18+
[EFlag.Red]: circleTimesIcon,
19+
};
20+
21+
const b = cn('entity-status');
22+
23+
interface EntityStatusProps {
24+
status?: EFlag;
25+
name?: string;
26+
label?: string;
27+
path?: string;
28+
iconPath?: string;
29+
30+
size?: 'xs' | 's' | 'm' | 'l';
31+
mode?: 'color' | 'icons';
32+
33+
showStatus?: boolean;
34+
externalLink?: boolean;
35+
withLeftTrim?: boolean;
36+
37+
hasClipboardButton?: boolean;
38+
clipboardButtonAlwaysVisible?: boolean;
39+
40+
className?: string;
41+
}
42+
43+
export function EntityStatus({
44+
status = EFlag.Grey,
45+
name = '',
46+
label,
47+
path,
48+
iconPath,
49+
50+
size = 's',
51+
mode = 'color',
52+
53+
showStatus = true,
54+
externalLink = false,
55+
withLeftTrim = false,
56+
57+
hasClipboardButton,
58+
clipboardButtonAlwaysVisible = false,
59+
60+
className,
61+
}: EntityStatusProps) {
62+
const renderIcon = () => {
63+
if (!showStatus) {
64+
return null;
65+
}
66+
67+
const modifiers = {state: status.toLowerCase(), size};
68+
69+
if (mode === 'icons' && status in icons) {
70+
return (
71+
<Icon
72+
className={b('status-icon', modifiers)}
73+
data={icons[status as keyof typeof icons]}
74+
/>
75+
);
76+
}
77+
78+
return <div className={b('status-color', modifiers)} />;
79+
};
80+
const renderStatusLink = () => {
81+
return (
82+
<UIKitLink target="_blank" href={iconPath}>
83+
{renderIcon()}
84+
</UIKitLink>
85+
);
86+
};
87+
const renderLink = () => {
88+
if (externalLink) {
89+
return (
90+
<UIKitLink className={b('name')} href={path}>
91+
{name}
92+
</UIKitLink>
93+
);
94+
}
95+
96+
return path ? (
97+
<Link className={b('name')} to={path}>
98+
{name}
99+
</Link>
100+
) : (
101+
name && <span className={b('name')}>{name}</span>
102+
);
103+
};
104+
return (
105+
<div className={b(null, className)} title={name}>
106+
{iconPath ? renderStatusLink() : renderIcon()}
107+
{label && (
108+
<span title={label} className={b('label', {size, state: status.toLowerCase()})}>
109+
{label}
110+
</span>
111+
)}
112+
<span className={b('link', {'with-left-trim': withLeftTrim})}>{renderLink()}</span>
113+
{hasClipboardButton && (
114+
<ClipboardButton
115+
text={name}
116+
size="s"
117+
className={b('clipboard-button', {
118+
visible: clipboardButtonAlwaysVisible,
119+
})}
120+
/>
121+
)}
122+
</div>
123+
);
124+
}

src/components/NodeHostWrapper/NodeHostWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {NodeAddress} from '../../types/additionalProps';
77
import {getDefaultNodePath} from '../../containers/Node/NodePages';
88
import {isUnavailableNode} from '../../utils/nodes';
99

10-
import EntityStatus from '../EntityStatus/EntityStatus';
10+
import {EntityStatus} from '../EntityStatus/EntityStatus';
1111
import {NodeEndpointsTooltipContent} from '../TooltipsContent';
1212
import {Icon} from '../Icon';
1313
import {CellWithPopover} from '../CellWithPopover/CellWithPopover';

src/components/Tablet/Tablet.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
padding: 10px;
1717
}
1818

19-
&_status_gray {
19+
&_status_grey {
2020
background-color: var(--ydb-color-status-grey);
2121
}
2222
&_status_yellow {

src/components/TabletsOverall/TabletsOverall.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function TabletsOverall({tablets}: TabletsOverallProps) {
8686
value: statesForOverallProgress[key],
8787
}));
8888

89-
// sort stack to achieve order "green, orange, yellow, red, blue, gray"
89+
// sort stack to achieve order "green, orange, yellow, red, blue, grey"
9090
stack.sort((a, b) => COLORS_PRIORITY[b.colorKey] - COLORS_PRIORITY[a.colorKey]);
9191

9292
return (

src/components/TabletsStatistic/TabletsStatistic.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
color: var(--g-color-text-danger);
4040
background: var(--g-color-base-danger-light);
4141
}
42-
&_state_gray {
42+
&_state_grey {
4343
color: var(--g-color-text-secondary);
4444
border: 1px solid var(--g-color-line-generic-hover);
4545
}

src/components/VirtualTable/TableHead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const TableHead = <T,>({
170170
let newSortParams: SortParams = {};
171171

172172
// Order is changed in following order:
173-
// 1. Inactive Sort Order - gray icon of default order
173+
// 1. Inactive Sort Order - grey icon of default order
174174
// 2. Active default order
175175
// 3. Active not default order
176176
if (columnId === sortParams.columnId) {

src/containers/Cluster/Cluster.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {Tenants} from '../Tenants/Tenants';
2525
import {StorageWrapper} from '../Storage/StorageWrapper';
2626
import {NodesWrapper} from '../Nodes/NodesWrapper';
2727
import {Versions} from '../Versions/Versions';
28-
import EntityStatus from '../../components/EntityStatus/EntityStatus';
28+
import {EntityStatus} from '../../components/EntityStatus/EntityStatus';
2929
import {CLUSTER_DEFAULT_TITLE} from '../../utils/constants';
3030

3131
import {ClusterInfo} from './ClusterInfo/ClusterInfo';

0 commit comments

Comments
 (0)