Skip to content

Commit 26354e5

Browse files
committed
fix: review
1 parent 89c8c19 commit 26354e5

File tree

9 files changed

+69
-66
lines changed

9 files changed

+69
-66
lines changed

src/components/JSONTreeWithSearch/JSONTreeWithSearch.scss renamed to src/components/JSONTree/JSONTree.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@use '../../styles/mixins.scss';
22

3-
.ydb-json-tree-with-search {
3+
.ydb-json-tree {
44
position: relative;
55

66
width: 100%;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit';
2+
import JSONTreeBase 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 './JSONTree.scss';
13+
import 'react-json-inspector/json-inspector.css';
14+
15+
const b = cn('ydb-json-tree');
16+
17+
const DEBAUNCE_TIME = 300;
18+
19+
interface JSONTreeProps extends React.ComponentProps<typeof JSONTreeBase> {
20+
treeClassName?: string;
21+
}
22+
23+
export function JSONTree({treeClassName, search = true, ...rest}: JSONTreeProps) {
24+
const [caseSensitiveSearch, setCaseSensitiveSearch] = useSetting(
25+
CASE_SENSITIVE_JSON_SEARCH,
26+
false,
27+
);
28+
return (
29+
<div className={b()}>
30+
<JSONTreeBase
31+
className={b('tree', treeClassName)}
32+
filterOptions={{
33+
ignoreCase: !caseSensitiveSearch,
34+
}}
35+
searchOptions={{
36+
debounceTime: DEBAUNCE_TIME,
37+
}}
38+
search={search}
39+
{...rest}
40+
/>
41+
{search && (
42+
<ActionTooltip
43+
title={
44+
caseSensitiveSearch
45+
? i18n('context_case-sensitive-search')
46+
: i18n('context_case-sensitive-search-disabled')
47+
}
48+
>
49+
<Button
50+
view="outlined"
51+
className={b('case')}
52+
onClick={() => setCaseSensitiveSearch(!caseSensitiveSearch)}
53+
selected={caseSensitiveSearch}
54+
>
55+
<Icon data={FontCaseIcon} />
56+
</Button>
57+
</ActionTooltip>
58+
)}
59+
</div>
60+
);
61+
}

src/components/JSONTreeWithSearch/i18n/index.ts renamed to src/components/JSONTree/i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import {registerKeysets} from '../../../utils/i18n';
22

33
import en from './en.json';
44

5-
const COMPONENT = 'ydb-json-tree-with-search';
5+
const COMPONENT = 'ydb-json-tree';
66

77
export default registerKeysets(COMPONENT, {en});

src/components/JSONTreeWithSearch/JSONTreeWithSearch.tsx

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {ClipboardButton} from '@gravity-ui/uikit';
22
import {shallowEqual} from 'react-redux';
33

44
import {ResponseError} from '../../../../components/Errors/ResponseError';
5-
import {JSONTreeWithSearch} from '../../../../components/JSONTreeWithSearch/JSONTreeWithSearch';
5+
import {JSONTree} from '../../../../components/JSONTree/JSONTree';
66
import {Loader} from '../../../../components/Loader';
77
import {
88
selectSchemaMergedChildrenPaths,
@@ -71,7 +71,7 @@ const Describe = ({path, database, type}: IDescribeProps) => {
7171
{error ? <ResponseError error={error} /> : null}
7272
{preparedDescribeData ? (
7373
<div className={b('result')}>
74-
<JSONTreeWithSearch
74+
<JSONTree
7575
data={preparedDescribeData}
7676
onClick={({path}) => {
7777
const newValue = !(expandMap.get(path) || false);

src/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/IssuesViewer/IssueTree.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
}
2424

2525
&__inspector {
26-
@include mixins.json-tree-styles();
27-
2826
:not(.json-inspector__leaf_expanded).json-inspector__leaf_composite:before {
2927
content: '';
3028
}

src/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/IssuesViewer/IssueTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22

33
import _omit from 'lodash/omit';
4-
import JSONTree from 'react-json-inspector';
54
import {TreeView} from 'ydb-ui-components';
65

6+
import {JSONTree} from '../../../../../../components/JSONTree/JSONTree';
77
import type {IssuesTree} from '../../../../../../store/reducers/healthcheckInfo/types';
88
import {hcStatusToColorFlag} from '../../../../../../store/reducers/healthcheckInfo/utils';
99
import {cn} from '../../../../../../utils/cn';
@@ -32,7 +32,7 @@ const IssueTree = ({issueTree}: IssuesViewerProps) => {
3232
data={info}
3333
search={false}
3434
isExpanded={() => true}
35-
className={b('inspector')}
35+
treeClassName={b('inspector')}
3636
/>
3737
</div>
3838
);

src/containers/Tenant/Query/QueryResult/components/QueryJSONViewer/QueryJSONViewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {JSONTreeWithSearch} from '../../../../../../components/JSONTreeWithSearch/JSONTreeWithSearch';
1+
import {JSONTree} from '../../../../../../components/JSONTree/JSONTree';
22
import {cn} from '../../../../../../utils/cn';
33

44
import './QueryJSONViewer.scss';
@@ -12,7 +12,7 @@ interface QueryJSONViewerProps {
1212
export function QueryJSONViewer({data}: QueryJSONViewerProps) {
1313
return (
1414
<div className={b('inspector')}>
15-
<JSONTreeWithSearch data={data} isExpanded={() => true} />
15+
<JSONTree data={data} isExpanded={() => true} />
1616
</div>
1717
);
1818
}

0 commit comments

Comments
 (0)