@@ -2,10 +2,12 @@ import React, { useCallback, useMemo, useState } from 'react';
22import { IoIosArrowDown , IoIosArrowForward } from 'react-icons/io' ;
33import { FiAlertTriangle as WarningIcon } from 'react-icons/fi' ;
44import { VscTrash as RemoveIcon } from 'react-icons/vsc' ;
5+ import { MdContentCopy as CopyIcon , MdContentPaste as PasteIcon } from 'react-icons/md' ;
56import cx from 'classnames' ;
67import { Button } from '../Button' ;
78import { InfoTooltip } from '../ui/InfoTooltip' ;
89import MoreOptionsMenu from '../EntityInspector/MoreOptionsMenu' ;
10+ import { useComponentClipboard } from '../../hooks/sdk/useComponentClipboard' ;
911
1012/**
1113 * ContainerContent is a wrapper component that allows returning both main content
@@ -79,27 +81,54 @@ const Container: React.FC<React.PropsWithChildren<Props>> = props => {
7981
8082 const finalRightContent = rightContentFromChildren || props . rightContent ;
8183
84+ const {
85+ onCopyValues,
86+ onPasteValues,
87+ enabled : clipboardEnabled ,
88+ } = useComponentClipboard ( props . entity , props . component ) ;
89+
90+ const hasMenu = ! ! props . onRemoveContainer || clipboardEnabled ;
91+
8292 const shouldRenderRightContent = useMemo ( ( ) => {
83- return finalRightContent || props . onRemoveContainer ;
84- } , [ finalRightContent , props . onRemoveContainer ] ) ;
93+ return finalRightContent || hasMenu ;
94+ } , [ finalRightContent , hasMenu ] ) ;
8595
8696 const renderRightContent = useCallback ( ( ) => {
8797 return (
8898 < div className = "RightContent" >
8999 { finalRightContent }
90- { props . onRemoveContainer && (
100+ { hasMenu && (
91101 < MoreOptionsMenu >
92- < Button
93- className = "RemoveButton"
94- onClick = { props . onRemoveContainer }
95- >
96- < RemoveIcon /> Delete Component
97- </ Button >
102+ { clipboardEnabled ? (
103+ < Button onClick = { onCopyValues } >
104+ < CopyIcon /> Copy values
105+ </ Button >
106+ ) : null }
107+ { clipboardEnabled ? (
108+ < Button onClick = { onPasteValues } >
109+ < PasteIcon /> Paste values
110+ </ Button >
111+ ) : null }
112+ { props . onRemoveContainer ? (
113+ < Button
114+ className = "RemoveButton"
115+ onClick = { props . onRemoveContainer }
116+ >
117+ < RemoveIcon /> Delete Component
118+ </ Button >
119+ ) : null }
98120 </ MoreOptionsMenu >
99121 ) }
100122 </ div >
101123 ) ;
102- } , [ finalRightContent , props . onRemoveContainer ] ) ;
124+ } , [
125+ finalRightContent ,
126+ hasMenu ,
127+ clipboardEnabled ,
128+ onCopyValues ,
129+ onPasteValues ,
130+ props . onRemoveContainer ,
131+ ] ) ;
103132
104133 return (
105134 < div
0 commit comments