mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-22 01:26:48 +03:00
prettier write
This commit is contained in:
parent
8fe79d2eb9
commit
eae2d5b752
|
@ -208,8 +208,8 @@ class ActionPreview<S, A extends Action<string>> extends Component<
|
|||
])
|
||||
}
|
||||
>
|
||||
{'(pin)'}
|
||||
</span>
|
||||
{'(pin)'}
|
||||
</span>
|
||||
<span
|
||||
css={(theme) => ({
|
||||
fontSize: '0.7em',
|
||||
|
@ -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);
|
||||
|
@ -235,10 +241,10 @@ class ActionPreview<S, A extends Action<string>> extends Component<
|
|||
}
|
||||
}}
|
||||
>
|
||||
{'(copy)'}
|
||||
</span>
|
||||
{'(copy)'}
|
||||
</span>
|
||||
{!expanded && ': '}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user