-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(JSONTree): allow case insensitive search #1735
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@use '../../styles/mixins.scss'; | ||
|
||
.ydb-json-tree-with-search { | ||
position: relative; | ||
|
||
width: 100%; | ||
height: 100%; | ||
&__tree { | ||
@include mixins.json-tree-styles(); | ||
} | ||
&__case { | ||
position: absolute; | ||
top: 0; | ||
left: 308px; | ||
} | ||
|
||
.json-inspector__search { | ||
height: 26px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit'; | ||
import JSONTree 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 './JSONTreeWithSearch.scss'; | ||
import 'react-json-inspector/json-inspector.css'; | ||
|
||
const b = cn('ydb-json-tree-with-search'); | ||
|
||
interface JSONTreeWithSearchProps extends React.ComponentProps<typeof JSONTree> { | ||
treeClassName?: string; | ||
} | ||
|
||
export function JSONTreeWithSearch({treeClassName, ...rest}: JSONTreeWithSearchProps) { | ||
const [caseSensitiveSearch, setCaseSensitiveSearch] = useSetting( | ||
CASE_SENSITIVE_JSON_SEARCH, | ||
false, | ||
); | ||
return ( | ||
<div className={b()}> | ||
<JSONTree | ||
className={b('tree', treeClassName)} | ||
filterOptions={{ | ||
Raubzeug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ignoreCase: !caseSensitiveSearch, | ||
}} | ||
searchOptions={{ | ||
debounceTime: 300, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const DEBOUNCE_TIME ? |
||
}} | ||
{...rest} | ||
/> | ||
<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> | ||
); | ||
} |
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" | ||
} |
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-with-search'; | ||
|
||
export default registerKeysets(COMPONENT, {en}); |
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(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { | |
AUTOCOMPLETE_ON_ENTER, | ||
AUTO_REFRESH_INTERVAL, | ||
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY, | ||
CASE_SENSITIVE_JSON_SEARCH, | ||
ENABLE_AUTOCOMPLETE, | ||
ENABLE_NETWORK_TABLE_KEY, | ||
INVERTED_DISKS_KEY, | ||
|
@@ -46,6 +47,7 @@ export const DEFAULT_USER_SETTINGS = { | |
[AUTOCOMPLETE_ON_ENTER]: true, | ||
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false, | ||
[AUTO_REFRESH_INTERVAL]: 0, | ||
[CASE_SENSITIVE_JSON_SEARCH]: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose case-sensitiveness should be scoped to JSONTreeWrapper (or JSONTreeSearch or whatever component it is used in) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a setting that should be saved to LS. Thats why it is among other settings. Or I didn't get you?.. |
||
[SHOW_DOMAIN_DATABASE_KEY]: false, | ||
[LAST_QUERY_EXECUTION_SETTINGS_KEY]: undefined, | ||
[QUERY_SETTINGS_BANNER_LAST_CLOSED_KEY]: undefined, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could create JSONTreeWrapper and use it everywhere with search prop?
In case we want to use search anywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense!