11import React from 'react' ;
2- import { Box , EditField , FlexBox , Paragraph } from '../../components' ;
2+ import { Box , EditField , FlexBox , Paragraph , icons } from '../../components' ;
33import styles from './index.module.scss' ;
44import { titleCase } from '../../../utils' ;
55import { ToggleField } from '../common/FormElement' ;
66import JSONPretty from 'react-json-pretty' ;
7+ import { useDispatch } from '../../hooks' ;
8+ import { showToasterAction } from '../../../redux/actions' ;
9+ import { iconColors , iconSizes , toasterTypes } from '../../../constants' ;
710
811export const NonEditableRunConfig : React . FC < { runConfiguration : any } > = ( {
912 runConfiguration,
1013} ) => {
14+ const dispatch = useDispatch ( ) ;
1115 const getFormElement : any = ( elementName : any , elementSchema : any ) => {
1216 if ( typeof elementSchema === 'string' ) {
1317 return (
@@ -28,6 +32,16 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
2832 }
2933
3034 if ( typeof elementSchema === 'object' && elementSchema !== null ) {
35+ const handleCopy = ( ) => {
36+ navigator . clipboard . writeText ( JSON . stringify ( elementSchema ) ) ;
37+
38+ dispatch (
39+ showToasterAction ( {
40+ description : 'Config copied to clipboard' ,
41+ type : toasterTypes . success ,
42+ } ) ,
43+ ) ;
44+ } ;
3145 return (
3246 < Box style = { { width : '40%' } } >
3347 < Paragraph size = "body" style = { { color : 'black' } } >
@@ -38,6 +52,12 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
3852 marginVertical = { 'md' }
3953 className = { styles . JSONPretty }
4054 >
55+ < icons . copy
56+ className = { styles . copy }
57+ onClick = { handleCopy }
58+ color = { iconColors . black }
59+ size = { iconSizes . sm }
60+ />
4161 < JSONPretty
4262 style = { { fontSize : '16px' , fontFamily : 'Rubik' } }
4363 id = "json-pretty"
0 commit comments