1
1
import React from 'react' ;
2
2
3
+ import { ChevronsCollapseVertical , ChevronsExpandVertical } from '@gravity-ui/icons' ;
3
4
import type * as DT100 from '@gravity-ui/react-data-table' ;
4
5
import DataTable from '@gravity-ui/react-data-table' ;
5
6
import { ActionTooltip , Button , Flex , Icon } from '@gravity-ui/uikit' ;
6
7
7
8
import { CASE_SENSITIVE_JSON_SEARCH } from '../../utils/constants' ;
8
9
import { useSetting } from '../../utils/hooks' ;
10
+ import type { ClipboardButtonProps } from '../ClipboardButton/ClipboardButton' ;
11
+ import { ClipboardButton } from '../ClipboardButton/ClipboardButton' ;
9
12
10
13
import { Cell } from './components/Cell' ;
11
14
import { Filter } from './components/Filter' ;
@@ -22,9 +25,6 @@ import type {
22
25
} from './unipika/flattenUnipika' ;
23
26
import { unipika } from './unipika/unipika' ;
24
27
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
-
28
28
import './JsonViewer.scss' ;
29
29
30
30
interface JsonViewerCommonProps {
@@ -35,6 +35,7 @@ interface JsonViewerCommonProps {
35
35
collapsedInitially ?: boolean ;
36
36
maxValueWidth ?: number ;
37
37
toolbarClassName ?: string ;
38
+ withClipboardButton ?: Omit < ClipboardButtonProps , 'size' | 'view' > ;
38
39
}
39
40
40
41
interface JsonViewerProps extends JsonViewerCommonProps {
@@ -118,6 +119,7 @@ function JsonViewerComponent({
118
119
collapsedInitially,
119
120
maxValueWidth = 100 ,
120
121
toolbarClassName,
122
+ withClipboardButton,
121
123
} : JsonViewerComponentProps ) {
122
124
const [ caseSensitiveSearch , setCaseSensitiveSearch ] = useSetting (
123
125
CASE_SENSITIVE_JSON_SEARCH ,
@@ -300,19 +302,12 @@ function JsonViewerComponent({
300
302
301
303
const renderToolbar = ( ) => {
302
304
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
+ >
316
311
{ search && (
317
312
< Filter
318
313
onUpdate = { onFilterChange }
@@ -327,7 +322,22 @@ function JsonViewerComponent({
327
322
onUpdateCaseSensitive = { handleUpdateCaseSensitive }
328
323
/>
329
324
) }
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 >
331
341
</ Flex >
332
342
) ;
333
343
} ;
0 commit comments