11import React from 'react' ;
2- import { Box , EditField , 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 marginTop = 'lg' 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"
@@ -64,11 +84,11 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
6484 <span className={`${styles.slider} ${styles.round}`}></span>
6585 </label>
6686 </FlexBox.Row> */ }
67- < ToggleField
68- value = { elementSchema }
69- onHandleChange = { ( ) => { } }
70- label = { titleCase ( elementName ) }
71- disabled = { true }
87+ < ToggleField
88+ value = { elementSchema }
89+ onHandleChange = { ( ) => { } }
90+ label = { titleCase ( elementName ) }
91+ disabled = { true }
7292 />
7393 </ Box >
7494 </ Box >
@@ -77,12 +97,12 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
7797 } ;
7898
7999 return (
80- < >
100+ < FlexBox . Column marginLeft = "md" >
81101 { Object . keys ( runConfiguration ) . map ( ( key , ind ) => (
82102 // <Col xs={6} key={ind}>
83103 < > { getFormElement ( key , runConfiguration [ key ] ) } </ >
84104 // </Col>
85105 ) ) }
86- </ >
106+ </ FlexBox . Column >
87107 ) ;
88108} ;
0 commit comments