11import React from 'react' ;
22
3+ import { ChevronsCollapseVertical , ChevronsExpandVertical } from '@gravity-ui/icons' ;
34import type * as DT100 from '@gravity-ui/react-data-table' ;
45import DataTable from '@gravity-ui/react-data-table' ;
56import { ActionTooltip , Button , Flex , Icon } from '@gravity-ui/uikit' ;
67
78import { CASE_SENSITIVE_JSON_SEARCH } from '../../utils/constants' ;
89import { useSetting } from '../../utils/hooks' ;
10+ import type { ClipboardButtonProps } from '../ClipboardButton/ClipboardButton' ;
11+ import { ClipboardButton } from '../ClipboardButton/ClipboardButton' ;
912
1013import { Cell } from './components/Cell' ;
1114import { Filter } from './components/Filter' ;
@@ -22,9 +25,6 @@ import type {
2225} from './unipika/flattenUnipika' ;
2326import { unipika } from './unipika/unipika' ;
2427
25- import ArrowDownToLineIcon from '@gravity-ui/icons/svgs/arrow-down-to-line.svg' ;
26- import ArrowUpFromLineIcon from '@gravity-ui/icons/svgs/arrow-up-from-line.svg' ;
27-
2828import './JsonViewer.scss' ;
2929
3030interface JsonViewerCommonProps {
@@ -35,6 +35,7 @@ interface JsonViewerCommonProps {
3535 collapsedInitially ?: boolean ;
3636 maxValueWidth ?: number ;
3737 toolbarClassName ?: string ;
38+ withClipboardButton ?: Omit < ClipboardButtonProps , 'size' | 'view' > ;
3839}
3940
4041interface JsonViewerProps extends JsonViewerCommonProps {
@@ -118,6 +119,7 @@ function JsonViewerComponent({
118119 collapsedInitially,
119120 maxValueWidth = 100 ,
120121 toolbarClassName,
122+ withClipboardButton,
121123} : JsonViewerComponentProps ) {
122124 const [ caseSensitiveSearch , setCaseSensitiveSearch ] = useSetting (
123125 CASE_SENSITIVE_JSON_SEARCH ,
@@ -300,19 +302,12 @@ function JsonViewerComponent({
300302
301303 const renderToolbar = ( ) => {
302304 return (
303- < Flex gap = { 2 } wrap = "nowrap" className = { block ( 'toolbar' , toolbarClassName ) } >
304- < Flex gap = { 1 } wrap = "nowrap" >
305- < ActionTooltip title = { i18n ( 'action_expand-all' ) } >
306- < Button onClick = { onExpandAll } view = "flat-secondary" >
307- < Icon data = { ArrowDownToLineIcon } />
308- </ Button >
309- </ ActionTooltip >
310- < ActionTooltip title = { i18n ( 'action_collapse-all' ) } >
311- < Button onClick = { onCollapseAll } view = "flat-secondary" >
312- < Icon data = { ArrowUpFromLineIcon } />
313- </ Button >
314- </ ActionTooltip >
315- </ Flex >
305+ < Flex
306+ gap = { 2 }
307+ wrap = "nowrap"
308+ className = { block ( 'toolbar' , toolbarClassName ) }
309+ justifyContent = "space-between"
310+ >
316311 { search && (
317312 < Filter
318313 onUpdate = { onFilterChange }
@@ -327,7 +322,22 @@ function JsonViewerComponent({
327322 onUpdateCaseSensitive = { handleUpdateCaseSensitive }
328323 />
329324 ) }
330- < span className = { block ( 'extra-tools' ) } > { extraTools } </ span >
325+ < Flex gap = { 2 } wrap = "nowrap" >
326+ < ActionTooltip title = { i18n ( 'action_expand-all' ) } placement = "top-start" >
327+ < Button onClick = { onExpandAll } >
328+ < Icon data = { ChevronsExpandVertical } />
329+ </ Button >
330+ </ ActionTooltip >
331+ < ActionTooltip title = { i18n ( 'action_collapse-all' ) } placement = "top-start" >
332+ < Button onClick = { onCollapseAll } >
333+ < Icon data = { ChevronsCollapseVertical } />
334+ </ Button >
335+ </ ActionTooltip >
336+ { withClipboardButton && (
337+ < ClipboardButton { ...withClipboardButton } size = "m" view = "normal" />
338+ ) }
339+ { extraTools }
340+ </ Flex >
331341 </ Flex >
332342 ) ;
333343 } ;
0 commit comments