-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(JSONTree): allow case insensitive search (#1735)
- Loading branch information
Showing
12 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@use '../../styles/mixins.scss'; | ||
|
||
.ydb-json-tree { | ||
position: relative; | ||
|
||
width: 100%; | ||
height: 100%; | ||
&__tree { | ||
@include mixins.json-tree-styles(); | ||
} | ||
&__case { | ||
position: absolute; | ||
top: 0; | ||
left: 308px; | ||
} | ||
|
||
.json-inspector__search { | ||
height: 26px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit'; | ||
import JSONTreeBase from 'react-json-inspector'; | ||
|
||
import {cn} from '../../utils/cn'; | ||
import {CASE_SENSITIVE_JSON_SEARCH} from '../../utils/constants'; | ||
import {useSetting} from '../../utils/hooks'; | ||
|
||
import i18n from './i18n'; | ||
|
||
import FontCaseIcon from '@gravity-ui/icons/svgs/font-case.svg'; | ||
|
||
import './JSONTree.scss'; | ||
import 'react-json-inspector/json-inspector.css'; | ||
|
||
const b = cn('ydb-json-tree'); | ||
|
||
const DEBAUNCE_TIME = 300; | ||
|
||
interface JSONTreeProps extends React.ComponentProps<typeof JSONTreeBase> { | ||
search?: false; | ||
treeClassName?: string; | ||
} | ||
|
||
export function JSONTree({treeClassName, search, ...rest}: JSONTreeProps) { | ||
const [caseSensitiveSearch, setCaseSensitiveSearch] = useSetting( | ||
CASE_SENSITIVE_JSON_SEARCH, | ||
false, | ||
); | ||
return ( | ||
<div className={b()}> | ||
<JSONTreeBase | ||
className={b('tree', treeClassName)} | ||
filterOptions={{ | ||
ignoreCase: !caseSensitiveSearch, | ||
}} | ||
searchOptions={{ | ||
debounceTime: DEBAUNCE_TIME, | ||
}} | ||
{...rest} | ||
/> | ||
{search !== false && ( | ||
<ActionTooltip | ||
title={ | ||
caseSensitiveSearch | ||
? i18n('context_case-sensitive-search') | ||
: i18n('context_case-sensitive-search-disabled') | ||
} | ||
> | ||
<Button | ||
view="outlined" | ||
className={b('case')} | ||
onClick={() => setCaseSensitiveSearch(!caseSensitiveSearch)} | ||
selected={caseSensitiveSearch} | ||
> | ||
<Icon data={FontCaseIcon} /> | ||
</Button> | ||
</ActionTooltip> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"context_case-sensitive-search": "Case sensitive search enadled", | ||
"context_case-sensitive-search-disabled": "Case sensitive search disabled" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {registerKeysets} from '../../../utils/i18n'; | ||
|
||
import en from './en.json'; | ||
|
||
const COMPONENT = 'ydb-json-tree'; | ||
|
||
export default registerKeysets(COMPONENT, {en}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/containers/Tenant/Query/QueryResult/components/QueryJSONViewer/QueryJSONViewer.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
@use '../../../../../../styles/mixins.scss'; | ||
|
||
.ydb-query-json-viewer { | ||
&__inspector { | ||
overflow-y: auto; | ||
|
||
width: 100%; | ||
height: 100%; | ||
padding: 15px 10px; | ||
@include mixins.json-tree-styles(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters