Skip to content

Commit f9a99bf

Browse files
authored
copy values (#1321)
* copy values * remove claude permissions Signed-off-by: Nicolas Earnshaw <earnshaw.nico@gmail.com> --------- Signed-off-by: Nicolas Earnshaw <earnshaw.nico@gmail.com>
1 parent dd490b5 commit f9a99bf

32 files changed

Lines changed: 266 additions & 12 deletions

File tree

packages/inspector/src/components/Container/Container.tsx

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import React, { useCallback, useMemo, useState } from 'react';
22
import { IoIosArrowDown, IoIosArrowForward } from 'react-icons/io';
33
import { FiAlertTriangle as WarningIcon } from 'react-icons/fi';
44
import { VscTrash as RemoveIcon } from 'react-icons/vsc';
5+
import { MdContentCopy as CopyIcon, MdContentPaste as PasteIcon } from 'react-icons/md';
56
import cx from 'classnames';
67
import { Button } from '../Button';
78
import { InfoTooltip } from '../ui/InfoTooltip';
89
import 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

packages/inspector/src/components/Container/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import type { Entity } from '@dcl/ecs';
2+
import type { Component } from '../../lib/sdk/components';
3+
14
export type Props = {
25
label?: string;
36
className?: string;
@@ -8,4 +11,6 @@ export type Props = {
811
gap?: boolean;
912
variant?: 'minimal';
1013
onRemoveContainer?: () => void;
14+
component?: Component<any>;
15+
entity?: Entity | Entity[];
1116
};

packages/inspector/src/components/EntityInspector/ActionInspector/ActionInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,8 @@ export default withSdk<Props>(({ sdk, entity: entityId, initialOpen = true }) =>
13141314
type="help"
13151315
/>
13161316
}
1317+
component={Actions}
1318+
entity={entityId}
13171319
onRemoveContainer={handleRemove}
13181320
>
13191321
{actions.map((action: Action, idx: number) => {

packages/inspector/src/components/EntityInspector/AnimatorInspector/AnimatorInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export default withSdk<Props>(({ sdk, entity: entityId, initialOpen = true }) =>
121121
type="help"
122122
/>
123123
}
124+
component={Animator}
125+
entity={entityId}
124126
onRemoveContainer={handleRemove}
125127
>
126128
{states.map(($, idx) => (

packages/inspector/src/components/EntityInspector/AudioSourceInspector/AudioSourceInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export default withSdk<Props>(({ sdk, entities, initialOpen = true }) => {
7272
type="help"
7373
/>
7474
}
75+
component={AudioSource}
76+
entity={entities}
7577
onRemoveContainer={handleRemove}
7678
>
7779
<Block>

packages/inspector/src/components/EntityInspector/AudioStreamInspector/AudioStreamInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export default withSdk<Props>(({ sdk, entities, initialOpen = true }) => {
5959
type="help"
6060
/>
6161
}
62+
component={AudioStream}
63+
entity={entities}
6264
onRemoveContainer={handleRemove}
6365
>
6466
<Block label="Url">

packages/inspector/src/components/EntityInspector/AvatarAttachInspector/AvatarAttachInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export default withSdk<Props>(({ sdk, entities, initialOpen = true }) => {
8686
type="help"
8787
/>
8888
}
89+
component={AvatarAttach}
90+
entity={entities}
8991
onRemoveContainer={handleRemove}
9092
>
9193
<Block>

packages/inspector/src/components/EntityInspector/BillboardInspector/BillboardInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export default withSdk<Props>(({ sdk, entities, initialOpen = true }) => {
6565
type="help"
6666
/>
6767
}
68+
component={Billboard}
69+
entity={entities}
6870
onRemoveContainer={handleRemove}
6971
>
7072
<Block>

packages/inspector/src/components/EntityInspector/CounterBarInspector/CounterBarInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export default withSdk<Props>(({ sdk, entity, initialOpen = true }) => {
4242
/>
4343
}
4444
initialOpen={initialOpen}
45+
component={CounterBar}
46+
entity={entity}
4547
onRemoveContainer={handleRemove}
4648
>
4749
<TextField

packages/inspector/src/components/EntityInspector/CounterInspector/CounterInspector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export default withSdk<Props>(({ sdk, entity, initialOpen = true }) => {
5151
type="help"
5252
/>
5353
}
54+
component={Counter}
55+
entity={entity}
5456
onRemoveContainer={handleRemove}
5557
>
5658
<TextField

0 commit comments

Comments
 (0)