Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
prettier write
  • Loading branch information
IliyaBrook committed Mar 6, 2024
commit eae2d5b752c31195bb9399225149759e06149e59
22 changes: 14 additions & 8 deletions packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ class ActionPreview<S, A extends Action<string>> extends Component<
])
}
>
{'(pin)'}
</span>
{'(pin)'}
</span>
<span
css={(theme) => ({
fontSize: '0.7em',
Expand All @@ -220,13 +220,19 @@ class ActionPreview<S, A extends Action<string>> extends Component<
},
color: theme.PIN_COLOR,
})}
onClick={event => {
onClick={(event) => {
event.stopPropagation();
let objectForCopying;
if (this.props.tabName === 'Action') {
objectForCopying = getValueByPath(this.props.action, reversedPath);
objectForCopying = getValueByPath(
this.props.action,
reversedPath,
);
} else if (this.props.tabName === 'State') {
objectForCopying = getValueByPath(this.props.nextState, reversedPath);
objectForCopying = getValueByPath(
this.props.nextState,
reversedPath,
);
}
if (objectForCopying !== undefined) {
copyToClipboard(objectForCopying);
Expand All @@ -235,10 +241,10 @@ class ActionPreview<S, A extends Action<string>> extends Component<
}
}}
>
{'(copy)'}
</span>
{'(copy)'}
</span>
{!expanded && ': '}
</span>
</span>
);
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cloneDeep from 'lodash.clonedeep';

export function copyToClipboard(object: any){
export function copyToClipboard(object: any) {
try {
const deepCopiedObject = cloneDeep(object);
const jsonString = JSON.stringify(deepCopiedObject, null, 2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export function getValueByPath(obj: any, path: (string | number)[]){
export function getValueByPath(obj: any, path: (string | number)[]) {
let current: any = obj;
for (let i = 0; i < path.length; i++) {
const key = path[i];
const adjustedKey = typeof key === 'string' && !isNaN(Number(key)) ? parseInt(key, 10) : key;
const adjustedKey =
typeof key === 'string' && !isNaN(Number(key)) ? parseInt(key, 10) : key;
if (current[adjustedKey] === undefined) {
return undefined;
}
Expand Down