Skip to content

Commit 89c8c19

Browse files
committed
feat(JSONTree): allow case insensitive search
1 parent dacc546 commit 89c8c19

File tree

10 files changed

+98
-30
lines changed

10 files changed

+98
-30
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@use '../../styles/mixins.scss';
2+
3+
.ydb-json-tree-with-search {
4+
position: relative;
5+
6+
width: 100%;
7+
height: 100%;
8+
&__tree {
9+
@include mixins.json-tree-styles();
10+
}
11+
&__case {
12+
position: absolute;
13+
top: 0;
14+
left: 308px;
15+
}
16+
17+
.json-inspector__search {
18+
height: 26px;
19+
}
20+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit';
2+
import JSONTree from 'react-json-inspector';
3+
4+
import {cn} from '../../utils/cn';
5+
import {CASE_SENSITIVE_JSON_SEARCH} from '../../utils/constants';
6+
import {useSetting} from '../../utils/hooks';
7+
8+
import i18n from './i18n';
9+
10+
import FontCaseIcon from '@gravity-ui/icons/svgs/font-case.svg';
11+
12+
import './JSONTreeWithSearch.scss';
13+
import 'react-json-inspector/json-inspector.css';
14+
15+
const b = cn('ydb-json-tree-with-search');
16+
17+
interface JSONTreeWithSearchProps extends React.ComponentProps<typeof JSONTree> {
18+
treeClassName?: string;
19+
}
20+
21+
export function JSONTreeWithSearch({treeClassName, ...rest}: JSONTreeWithSearchProps) {
22+
const [caseSensitiveSearch, setCaseSensitiveSearch] = useSetting(
23+
CASE_SENSITIVE_JSON_SEARCH,
24+
false,
25+
);
26+
return (
27+
<div className={b()}>
28+
<JSONTree
29+
className={b('tree', treeClassName)}
30+
filterOptions={{
31+
ignoreCase: !caseSensitiveSearch,
32+
}}
33+
searchOptions={{
34+
debounceTime: 300,
35+
}}
36+
{...rest}
37+
/>
38+
<ActionTooltip
39+
title={
40+
caseSensitiveSearch
41+
? i18n('context_case-sensitive-search')
42+
: i18n('context_case-sensitive-search-disabled')
43+
}
44+
>
45+
<Button
46+
view="outlined"
47+
className={b('case')}
48+
onClick={() => setCaseSensitiveSearch(!caseSensitiveSearch)}
49+
selected={caseSensitiveSearch}
50+
>
51+
<Icon data={FontCaseIcon} />
52+
</Button>
53+
</ActionTooltip>
54+
</div>
55+
);
56+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"context_case-sensitive-search": "Case sensitive search enadled",
3+
"context_case-sensitive-search-disabled": "Case sensitive search disabled"
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-json-tree-with-search';
6+
7+
export default registerKeysets(COMPONENT, {en});

src/containers/Tenant/Diagnostics/Describe/Describe.scss

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,8 @@
1515
padding: 0 20px 20px 0;
1616
}
1717

18-
&__tree {
19-
@include mixins.json-tree-styles();
20-
}
21-
2218
&__copy {
2319
position: absolute;
24-
left: 308px;
25-
}
26-
27-
.json-inspector__search {
28-
height: 26px;
20+
left: 340px;
2921
}
3022
}

src/containers/Tenant/Diagnostics/Describe/Describe.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {ClipboardButton} from '@gravity-ui/uikit';
2-
import JSONTree from 'react-json-inspector';
32
import {shallowEqual} from 'react-redux';
43

54
import {ResponseError} from '../../../../components/Errors/ResponseError';
5+
import {JSONTreeWithSearch} from '../../../../components/JSONTreeWithSearch/JSONTreeWithSearch';
66
import {Loader} from '../../../../components/Loader';
77
import {
88
selectSchemaMergedChildrenPaths,
@@ -14,7 +14,6 @@ import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks'
1414
import {isEntityWithMergedImplementation} from '../../utils/schema';
1515

1616
import './Describe.scss';
17-
import 'react-json-inspector/json-inspector.css';
1817

1918
const b = cn('ydb-describe');
2019

@@ -72,16 +71,12 @@ const Describe = ({path, database, type}: IDescribeProps) => {
7271
{error ? <ResponseError error={error} /> : null}
7372
{preparedDescribeData ? (
7473
<div className={b('result')}>
75-
<JSONTree
74+
<JSONTreeWithSearch
7675
data={preparedDescribeData}
77-
className={b('tree')}
7876
onClick={({path}) => {
7977
const newValue = !(expandMap.get(path) || false);
8078
expandMap.set(path, newValue);
8179
}}
82-
searchOptions={{
83-
debounceTime: 300,
84-
}}
8580
isExpanded={(keypath) => {
8681
return expandMap.get(keypath) || false;
8782
}}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
@use '../../../../../../styles/mixins.scss';
2-
31
.ydb-query-json-viewer {
42
&__inspector {
53
overflow-y: auto;
64

75
width: 100%;
86
height: 100%;
97
padding: 15px 10px;
10-
@include mixins.json-tree-styles();
118
}
129
}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import JSONTree from 'react-json-inspector';
2-
1+
import {JSONTreeWithSearch} from '../../../../../../components/JSONTreeWithSearch/JSONTreeWithSearch';
32
import {cn} from '../../../../../../utils/cn';
43

54
import './QueryJSONViewer.scss';
6-
import 'react-json-inspector/json-inspector.css';
75

86
const b = cn('ydb-query-json-viewer');
97

@@ -13,13 +11,8 @@ interface QueryJSONViewerProps {
1311

1412
export function QueryJSONViewer({data}: QueryJSONViewerProps) {
1513
return (
16-
<JSONTree
17-
data={data}
18-
isExpanded={() => true}
19-
className={b('inspector')}
20-
searchOptions={{
21-
debounceTime: 300,
22-
}}
23-
/>
14+
<div className={b('inspector')}>
15+
<JSONTreeWithSearch data={data} isExpanded={() => true} />
16+
</div>
2417
);
2518
}

src/services/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AUTOCOMPLETE_ON_ENTER,
55
AUTO_REFRESH_INTERVAL,
66
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
7+
CASE_SENSITIVE_JSON_SEARCH,
78
ENABLE_AUTOCOMPLETE,
89
ENABLE_NETWORK_TABLE_KEY,
910
INVERTED_DISKS_KEY,
@@ -46,6 +47,7 @@ export const DEFAULT_USER_SETTINGS = {
4647
[AUTOCOMPLETE_ON_ENTER]: true,
4748
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false,
4849
[AUTO_REFRESH_INTERVAL]: 0,
50+
[CASE_SENSITIVE_JSON_SEARCH]: false,
4951
[SHOW_DOMAIN_DATABASE_KEY]: false,
5052
[LAST_QUERY_EXECUTION_SETTINGS_KEY]: undefined,
5153
[QUERY_SETTINGS_BANNER_LAST_CLOSED_KEY]: undefined,

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export const DATA_QA_TUNE_COLUMNS_POPUP = 'tune-columns-popup';
9393
export const BINARY_DATA_IN_PLAIN_TEXT_DISPLAY = 'binaryDataInPlainTextDisplay';
9494
export const AUTO_REFRESH_INTERVAL = 'auto-refresh-interval';
9595

96+
export const CASE_SENSITIVE_JSON_SEARCH = 'caseSensitiveJsonSearch';
97+
9698
export const DEFAULT_SIZE_RESULT_PANE_KEY = 'default-size-result-pane';
9799
export const DEFAULT_SIZE_TENANT_SUMMARY_KEY = 'default-size-tenant-summary-pane';
98100
export const DEFAULT_SIZE_TENANT_KEY = 'default-size-tenant-pane';

0 commit comments

Comments
 (0)