Skip to content

Commit 22468f4

Browse files
added copy icon in run config
1 parent 6adb1b0 commit 22468f4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/ui/layouts/NonEditableRunConfig/index.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
background: rgba(168, 168, 168, 0.1);
1616
border: 1px solid #C9CBD0;
1717
border-radius: 4px;
18+
position: relative;
1819

1920
}
21+
.copy{
22+
right: 10px;
23+
position: absolute;
24+
cursor: pointer;
25+
}
2026

2127
.switch {
2228
position: relative;

src/ui/layouts/NonEditableRunConfig/index.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import React from 'react';
2-
import { Box, EditField, FlexBox, Paragraph } from '../../components';
2+
import { Box, EditField, FlexBox, Paragraph, icons } from '../../components';
33
import styles from './index.module.scss';
44
import { titleCase } from '../../../utils';
55
import { ToggleField } from '../common/FormElement';
66
import JSONPretty from 'react-json-pretty';
7+
import { useDispatch } from '../../hooks';
8+
import { showToasterAction } from '../../../redux/actions';
9+
import { iconColors, iconSizes, toasterTypes } from '../../../constants';
710

811
export 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

Comments
 (0)