Skip to content

Commit 3ba4c25

Browse files
committed
feat: query issues displaying
1 parent 111b525 commit 3ba4c25

File tree

17 files changed

+468
-65
lines changed

17 files changed

+468
-65
lines changed
Lines changed: 1 addition & 0 deletions
Loading

src/assets/icons/circle-info.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/icons/circle-xmark.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.kv-shorty-string {
2+
&__toggle {
3+
margin-left: 2em;
4+
5+
font-size: 0.85em;
6+
}
7+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as React from 'react';
2+
import cn from 'bem-cn-lite';
3+
4+
import {Link} from '@yandex-cloud/uikit';
5+
6+
import './ShortyString.scss';
7+
8+
const block = cn('kv-shorty-string');
9+
10+
type Props = {
11+
value?: string;
12+
limit?: number;
13+
displayLength?: boolean;
14+
render?: (value: string) => React.ReactNode;
15+
onToggle?: () => void;
16+
expandLabel?: string;
17+
collapseLabel?: string;
18+
};
19+
20+
export default function ShortyString({
21+
value = '',
22+
limit = 200,
23+
displayLength = true,
24+
render = (v: string) => v,
25+
onToggle,
26+
expandLabel = 'Show more',
27+
collapseLabel = 'Show less',
28+
}: Props) {
29+
const [expanded, setExpanded] = React.useState(false);
30+
const hasToggle = value.length > limit;
31+
const length =
32+
displayLength && !expanded ? `(${value.length} symbols)` : undefined;
33+
34+
const text = expanded || value.length <= limit ? value : value.slice(0, limit - 4) + '\u00a0...';
35+
const label = expanded ? collapseLabel : expandLabel;
36+
return (
37+
<div className={block()}>
38+
{render(text)}
39+
{hasToggle ? (
40+
<Link
41+
className={block('toggle')}
42+
onClick={(e) => {
43+
e.stopPropagation();
44+
setExpanded((v) => !v);
45+
onToggle?.();
46+
}}
47+
>
48+
{label} {length}
49+
</Link>
50+
) : null}
51+
</div>
52+
);
53+
}

src/containers/Tenant/Diagnostics/HotKeys/HotKeys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function HotKeys({
105105

106106
const renderContent = () => {
107107
if (error) {
108-
return error.data;
108+
return error.data?.error?.message || error.data || error;
109109
}
110110
return data !== null ? (
111111
<div className={b('table-content')}>

src/containers/Tenant/Diagnostics/TopQueries/TopQueries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {changeUserInput} from '../../../../store/reducers/executeQuery';
88
import {sendQuery, setQueryOptions} from '../../../../store/reducers/executeTopQueries';
99
import TruncatedQuery from '../../../../components/TruncatedQuery/TruncatedQuery';
1010
import {AutoFetcher} from '../../../../utils/autofetcher';
11-
import { OLAP_STORE_TYPE, OLAP_TABLE_TYPE } from '../../Tenant';
11+
import {OLAP_STORE_TYPE, OLAP_TABLE_TYPE} from '../../Tenant';
1212

1313
import './TopQueries.scss';
1414
import {DEFAULT_TABLE_SETTINGS} from '../../../../utils/constants';
@@ -151,7 +151,7 @@ class TopQueries extends React.Component {
151151
if (type === OLAP_STORE_TYPE || type === OLAP_TABLE_TYPE) {
152152
message = 'No data';
153153
} else if (error && !error.isCancelled) {
154-
message = (error.data || error).slice(0, 300);
154+
message = (error.data?.error?.message || error.data || error).slice(0, 300);
155155
} else if (!loading && !data) {
156156
message = 'No data';
157157
}

src/containers/Tenant/Diagnostics/TopShards/TopShards.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import HistoryContext from '../../../../contexts/HistoryContext';
1414
import './TopShards.scss';
1515
import {DEFAULT_TABLE_SETTINGS} from '../../../../utils/constants';
1616
import {Loader} from '@yandex-cloud/uikit';
17-
import { OLAP_STORE_TYPE, OLAP_TABLE_TYPE } from '../../Tenant';
17+
import {OLAP_STORE_TYPE, OLAP_TABLE_TYPE} from '../../Tenant';
1818

1919
const b = cn('top-shards');
2020
const bLink = cn('yc-link');
@@ -123,7 +123,7 @@ function TopShards({
123123
return 'No data';
124124
}
125125
if (error) {
126-
return error.data || error;
126+
return error.data?.error?.message || error.data || error;
127127
}
128128

129129
return data && data.length > 0 ? (

src/containers/Tenant/Preview/Preview.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ class Preview extends React.Component {
163163
}
164164

165165
if (error) {
166-
message = <div className={b('message-container')}>{error.data || error}</div>;
166+
message = (
167+
<div className={b('message-container')}>
168+
{error.data?.error?.message || error.data || error}
169+
</div>
170+
);
167171
}
168172

169173
if (!loading && data.length === 0) {

0 commit comments

Comments
 (0)