2020-08-31 00:49:06 +03:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Base16Theme } from 'redux-devtools-themes';
|
|
|
|
import {
|
|
|
|
getBase16Theme,
|
|
|
|
invertTheme,
|
|
|
|
StylingFunction,
|
|
|
|
} from 'react-base16-styling';
|
2020-12-21 17:08:08 +03:00
|
|
|
import {
|
|
|
|
ActionCreators,
|
|
|
|
LiftedAction,
|
|
|
|
LiftedState,
|
|
|
|
} from '@redux-devtools/core';
|
2020-08-31 00:49:06 +03:00
|
|
|
import { Action, Dispatch } from 'redux';
|
|
|
|
import { Delta, DiffContext } from 'jsondiffpatch';
|
2019-01-10 21:51:14 +03:00
|
|
|
import {
|
|
|
|
createStylingFromTheme,
|
2020-08-08 23:26:39 +03:00
|
|
|
base16Themes,
|
2019-01-10 21:51:14 +03:00
|
|
|
} from './utils/createStylingFromTheme';
|
2018-12-22 03:10:49 +03:00
|
|
|
import ActionList from './ActionList';
|
2020-08-31 00:49:06 +03:00
|
|
|
import ActionPreview, { Tab } from './ActionPreview';
|
2018-12-22 03:10:49 +03:00
|
|
|
import getInspectedState from './utils/getInspectedState';
|
|
|
|
import createDiffPatcher from './createDiffPatcher';
|
2020-08-31 00:49:06 +03:00
|
|
|
import {
|
|
|
|
DevtoolsInspectorAction,
|
|
|
|
DevtoolsInspectorState,
|
|
|
|
reducer,
|
|
|
|
updateMonitorState,
|
|
|
|
} from './redux';
|
2018-12-22 03:10:49 +03:00
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
2019-01-10 21:51:14 +03:00
|
|
|
const {
|
|
|
|
commit,
|
|
|
|
sweep,
|
|
|
|
toggleAction,
|
|
|
|
jumpToAction,
|
|
|
|
jumpToState,
|
2020-08-08 23:26:39 +03:00
|
|
|
reorderAction,
|
2019-01-10 21:51:14 +03:00
|
|
|
} = ActionCreators;
|
2018-12-22 03:10:49 +03:00
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
function getLastActionId<S, A extends Action<unknown>>(
|
|
|
|
props: DevtoolsInspectorProps<S, A>
|
|
|
|
) {
|
2018-12-22 03:10:49 +03:00
|
|
|
return props.stagedActionIds[props.stagedActionIds.length - 1];
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
function getCurrentActionId<S, A extends Action<unknown>>(
|
|
|
|
props: DevtoolsInspectorProps<S, A>,
|
|
|
|
monitorState: DevtoolsInspectorState
|
|
|
|
) {
|
2019-01-10 21:51:14 +03:00
|
|
|
return monitorState.selectedActionId === null
|
|
|
|
? props.stagedActionIds[props.currentStateIndex]
|
|
|
|
: monitorState.selectedActionId;
|
2018-12-22 03:10:49 +03:00
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
function getFromState<S>(
|
|
|
|
actionIndex: number,
|
|
|
|
stagedActionIds: number[],
|
|
|
|
computedStates: { state: S; error?: string }[],
|
|
|
|
monitorState: DevtoolsInspectorState
|
2019-01-10 21:51:14 +03:00
|
|
|
) {
|
2018-12-22 03:10:49 +03:00
|
|
|
const { startActionId } = monitorState;
|
|
|
|
if (startActionId === null) {
|
|
|
|
return actionIndex > 0 ? computedStates[actionIndex - 1] : null;
|
|
|
|
}
|
|
|
|
let fromStateIdx = stagedActionIds.indexOf(startActionId - 1);
|
|
|
|
if (fromStateIdx === -1) fromStateIdx = 0;
|
|
|
|
return computedStates[fromStateIdx];
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
function createIntermediateState<S, A extends Action<unknown>>(
|
|
|
|
props: DevtoolsInspectorProps<S, A>,
|
|
|
|
monitorState: DevtoolsInspectorState
|
|
|
|
) {
|
2019-01-10 21:51:14 +03:00
|
|
|
const {
|
|
|
|
supportImmutable,
|
|
|
|
computedStates,
|
|
|
|
stagedActionIds,
|
|
|
|
actionsById: actions,
|
|
|
|
diffObjectHash,
|
2020-08-08 23:26:39 +03:00
|
|
|
diffPropertyFilter,
|
2019-01-10 21:51:14 +03:00
|
|
|
} = props;
|
2018-12-22 03:10:49 +03:00
|
|
|
const { inspectedStatePath, inspectedActionPath } = monitorState;
|
|
|
|
const currentActionId = getCurrentActionId(props, monitorState);
|
2019-01-10 21:51:14 +03:00
|
|
|
const currentAction =
|
|
|
|
actions[currentActionId] && actions[currentActionId].action;
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
const actionIndex = stagedActionIds.indexOf(currentActionId);
|
2019-01-10 21:51:14 +03:00
|
|
|
const fromState = getFromState(
|
|
|
|
actionIndex,
|
|
|
|
stagedActionIds,
|
|
|
|
computedStates,
|
|
|
|
monitorState
|
|
|
|
);
|
2018-12-22 03:10:49 +03:00
|
|
|
const toState = computedStates[actionIndex];
|
|
|
|
const error = toState && toState.error;
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
const fromInspectedState =
|
|
|
|
!error &&
|
|
|
|
fromState &&
|
2018-12-22 03:10:49 +03:00
|
|
|
getInspectedState(fromState.state, inspectedStatePath, supportImmutable);
|
|
|
|
const toInspectedState =
|
2019-01-10 21:51:14 +03:00
|
|
|
!error &&
|
|
|
|
toState &&
|
|
|
|
getInspectedState(toState.state, inspectedStatePath, supportImmutable);
|
|
|
|
const delta =
|
|
|
|
!error &&
|
|
|
|
fromState &&
|
|
|
|
toState &&
|
2018-12-22 03:10:49 +03:00
|
|
|
createDiffPatcher(diffObjectHash, diffPropertyFilter).diff(
|
|
|
|
fromInspectedState,
|
|
|
|
toInspectedState
|
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
delta,
|
2019-01-10 21:51:14 +03:00
|
|
|
nextState:
|
|
|
|
toState && getInspectedState(toState.state, inspectedStatePath, false),
|
2018-12-22 03:10:49 +03:00
|
|
|
action: getInspectedState(currentAction, inspectedActionPath, false),
|
2020-08-08 23:26:39 +03:00
|
|
|
error,
|
2018-12-22 03:10:49 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
function createThemeState<S, A extends Action<unknown>>(
|
|
|
|
props: DevtoolsInspectorProps<S, A>
|
|
|
|
) {
|
|
|
|
const base16Theme = getBase16Theme(props.theme, base16Themes)!;
|
2020-08-08 18:10:40 +03:00
|
|
|
|
|
|
|
const theme = props.invertTheme ? invertTheme(props.theme) : props.theme;
|
|
|
|
const styling = createStylingFromTheme(theme);
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
return { base16Theme, styling };
|
|
|
|
}
|
|
|
|
|
2020-10-26 02:32:04 +03:00
|
|
|
export interface ExternalProps<S, A extends Action<unknown>> {
|
2020-08-31 00:49:06 +03:00
|
|
|
dispatch: Dispatch<
|
|
|
|
DevtoolsInspectorAction | LiftedAction<S, A, DevtoolsInspectorState>
|
|
|
|
>;
|
|
|
|
preserveScrollTop?: boolean;
|
|
|
|
draggableActions: boolean;
|
|
|
|
select: (state: S) => unknown;
|
|
|
|
theme: keyof typeof base16Themes | Base16Theme;
|
|
|
|
supportImmutable: boolean;
|
|
|
|
diffObjectHash?: (item: unknown, index: number) => string;
|
|
|
|
diffPropertyFilter?: (name: string, context: DiffContext) => boolean;
|
|
|
|
hideMainButtons?: boolean;
|
|
|
|
hideActionButtons?: boolean;
|
|
|
|
invertTheme: boolean;
|
2020-10-26 02:32:04 +03:00
|
|
|
dataTypeKey?: string | symbol;
|
2020-08-31 00:49:06 +03:00
|
|
|
tabs: Tab<S, A>[] | ((tabs: Tab<S, A>[]) => Tab<S, A>[]);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface DefaultProps {
|
|
|
|
select: (state: unknown) => unknown;
|
|
|
|
supportImmutable: boolean;
|
|
|
|
draggableActions: boolean;
|
|
|
|
theme: keyof typeof base16Themes;
|
|
|
|
invertTheme: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DevtoolsInspectorProps<S, A extends Action<unknown>>
|
|
|
|
extends LiftedState<S, A, DevtoolsInspectorState> {
|
|
|
|
dispatch: Dispatch<
|
|
|
|
DevtoolsInspectorAction | LiftedAction<S, A, DevtoolsInspectorState>
|
|
|
|
>;
|
|
|
|
preserveScrollTop?: boolean;
|
|
|
|
draggableActions: boolean;
|
|
|
|
select: (state: S) => unknown;
|
|
|
|
theme: keyof typeof base16Themes | Base16Theme;
|
|
|
|
supportImmutable: boolean;
|
|
|
|
diffObjectHash?: (item: unknown, index: number) => string;
|
|
|
|
diffPropertyFilter?: (name: string, context: DiffContext) => boolean;
|
|
|
|
hideMainButtons?: boolean;
|
|
|
|
hideActionButtons?: boolean;
|
|
|
|
invertTheme: boolean;
|
2020-10-26 02:32:04 +03:00
|
|
|
dataTypeKey?: string | symbol;
|
2020-08-31 00:49:06 +03:00
|
|
|
tabs: Tab<S, A>[] | ((tabs: Tab<S, A>[]) => Tab<S, A>[]);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface State<S, A extends Action<unknown>> {
|
|
|
|
delta: Delta | null | undefined | false;
|
|
|
|
nextState: S;
|
|
|
|
action: A;
|
|
|
|
error: string | undefined;
|
|
|
|
isWideLayout: boolean;
|
|
|
|
themeState: { base16Theme: Base16Theme; styling: StylingFunction };
|
|
|
|
}
|
|
|
|
|
|
|
|
class DevtoolsInspector<S, A extends Action<unknown>> extends PureComponent<
|
|
|
|
DevtoolsInspectorProps<S, A>,
|
|
|
|
State<S, A>
|
|
|
|
> {
|
|
|
|
state: State<S, A> = {
|
|
|
|
...createIntermediateState(this.props, this.props.monitorState),
|
|
|
|
isWideLayout: false,
|
|
|
|
themeState: createThemeState(this.props),
|
|
|
|
};
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func,
|
|
|
|
computedStates: PropTypes.array,
|
|
|
|
stagedActionIds: PropTypes.array,
|
|
|
|
actionsById: PropTypes.object,
|
|
|
|
currentStateIndex: PropTypes.number,
|
|
|
|
monitorState: PropTypes.shape({
|
2020-08-08 23:26:39 +03:00
|
|
|
initialScrollTop: PropTypes.number,
|
2018-12-22 03:10:49 +03:00
|
|
|
}),
|
|
|
|
preserveScrollTop: PropTypes.bool,
|
|
|
|
draggableActions: PropTypes.bool,
|
|
|
|
select: PropTypes.func.isRequired,
|
2019-01-10 21:51:14 +03:00
|
|
|
theme: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
2018-12-22 03:10:49 +03:00
|
|
|
supportImmutable: PropTypes.bool,
|
|
|
|
diffObjectHash: PropTypes.func,
|
|
|
|
diffPropertyFilter: PropTypes.func,
|
|
|
|
hideMainButtons: PropTypes.bool,
|
2019-01-10 20:23:33 +03:00
|
|
|
hideActionButtons: PropTypes.bool,
|
|
|
|
invertTheme: PropTypes.bool,
|
|
|
|
skippedActionIds: PropTypes.array,
|
2019-01-10 21:51:14 +03:00
|
|
|
dataTypeKey: PropTypes.any,
|
2020-08-08 23:26:39 +03:00
|
|
|
tabs: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
|
2018-12-22 03:10:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static update = reducer;
|
|
|
|
|
|
|
|
static defaultProps = {
|
2020-08-31 00:49:06 +03:00
|
|
|
select: (state: unknown) => state,
|
2018-12-22 03:10:49 +03:00
|
|
|
supportImmutable: false,
|
|
|
|
draggableActions: true,
|
|
|
|
theme: 'inspector',
|
2020-08-08 23:26:39 +03:00
|
|
|
invertTheme: true,
|
2018-12-22 03:10:49 +03:00
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
updateSizeTimeout?: number;
|
|
|
|
inspectorRef?: HTMLDivElement | null;
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.updateSizeMode();
|
2020-08-31 00:49:06 +03:00
|
|
|
this.updateSizeTimeout = window.setInterval(
|
|
|
|
this.updateSizeMode.bind(this),
|
|
|
|
150
|
|
|
|
);
|
2018-12-22 03:10:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
clearTimeout(this.updateSizeTimeout);
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
updateMonitorState = (monitorState: Partial<DevtoolsInspectorState>) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.props.dispatch(updateMonitorState(monitorState));
|
|
|
|
};
|
|
|
|
|
|
|
|
updateSizeMode() {
|
2020-08-31 00:49:06 +03:00
|
|
|
const isWideLayout = this.inspectorRef!.offsetWidth > 500;
|
2018-12-22 03:10:49 +03:00
|
|
|
|
|
|
|
if (isWideLayout !== this.state.isWideLayout) {
|
|
|
|
this.setState({ isWideLayout });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
UNSAFE_componentWillReceiveProps(nextProps: DevtoolsInspectorProps<S, A>) {
|
|
|
|
const nextMonitorState = nextProps.monitorState;
|
2018-12-22 03:10:49 +03:00
|
|
|
const monitorState = this.props.monitorState;
|
|
|
|
|
|
|
|
if (
|
|
|
|
getCurrentActionId(this.props, monitorState) !==
|
2019-01-10 21:51:14 +03:00
|
|
|
getCurrentActionId(nextProps, nextMonitorState) ||
|
2018-12-22 03:10:49 +03:00
|
|
|
monitorState.startActionId !== nextMonitorState.startActionId ||
|
|
|
|
monitorState.inspectedStatePath !== nextMonitorState.inspectedStatePath ||
|
2019-01-10 21:51:14 +03:00
|
|
|
monitorState.inspectedActionPath !==
|
|
|
|
nextMonitorState.inspectedActionPath ||
|
2018-12-22 03:10:49 +03:00
|
|
|
this.props.computedStates !== nextProps.computedStates ||
|
|
|
|
this.props.stagedActionIds !== nextProps.stagedActionIds
|
|
|
|
) {
|
|
|
|
this.setState(createIntermediateState(nextProps, nextMonitorState));
|
|
|
|
}
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
if (
|
|
|
|
this.props.theme !== nextProps.theme ||
|
|
|
|
this.props.invertTheme !== nextProps.invertTheme
|
|
|
|
) {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.setState({ themeState: createThemeState(nextProps) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
inspectorCreateRef: React.RefCallback<HTMLDivElement> = (node) => {
|
2019-01-10 20:23:33 +03:00
|
|
|
this.inspectorRef = node;
|
|
|
|
};
|
|
|
|
|
2018-12-22 03:10:49 +03:00
|
|
|
render() {
|
|
|
|
const {
|
2019-01-10 21:51:14 +03:00
|
|
|
stagedActionIds: actionIds,
|
|
|
|
actionsById: actions,
|
|
|
|
computedStates,
|
|
|
|
draggableActions,
|
|
|
|
tabs,
|
|
|
|
invertTheme,
|
|
|
|
skippedActionIds,
|
|
|
|
currentStateIndex,
|
|
|
|
monitorState,
|
|
|
|
dataTypeKey,
|
|
|
|
hideMainButtons,
|
2020-08-08 23:26:39 +03:00
|
|
|
hideActionButtons,
|
2018-12-22 03:10:49 +03:00
|
|
|
} = this.props;
|
2021-06-18 06:56:36 +03:00
|
|
|
const { selectedActionId, startActionId, searchValue, tabName } =
|
|
|
|
monitorState;
|
2019-01-10 21:51:14 +03:00
|
|
|
const inspectedPathType =
|
|
|
|
tabName === 'Action' ? 'inspectedActionPath' : 'inspectedStatePath';
|
2021-06-18 06:56:36 +03:00
|
|
|
const { themeState, isWideLayout, action, nextState, delta, error } =
|
|
|
|
this.state;
|
2018-12-22 03:10:49 +03:00
|
|
|
const { base16Theme, styling } = themeState;
|
|
|
|
|
|
|
|
return (
|
2019-01-10 21:51:14 +03:00
|
|
|
<div
|
|
|
|
key="inspector"
|
2021-10-22 17:49:53 +03:00
|
|
|
data-testid="inspector"
|
2019-01-10 20:23:33 +03:00
|
|
|
ref={this.inspectorCreateRef}
|
2019-01-10 21:51:14 +03:00
|
|
|
{...styling(
|
|
|
|
['inspector', isWideLayout && 'inspectorWide'],
|
|
|
|
isWideLayout
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<ActionList
|
|
|
|
{...{
|
|
|
|
actions,
|
|
|
|
actionIds,
|
|
|
|
isWideLayout,
|
|
|
|
searchValue,
|
|
|
|
selectedActionId,
|
|
|
|
startActionId,
|
|
|
|
skippedActionIds,
|
|
|
|
draggableActions,
|
|
|
|
hideMainButtons,
|
|
|
|
hideActionButtons,
|
2020-08-08 23:26:39 +03:00
|
|
|
styling,
|
2019-01-10 21:51:14 +03:00
|
|
|
}}
|
|
|
|
onSearch={this.handleSearch}
|
|
|
|
onSelect={this.handleSelectAction}
|
|
|
|
onToggleAction={this.handleToggleAction}
|
|
|
|
onJumpToState={this.handleJumpToState}
|
|
|
|
onCommit={this.handleCommit}
|
|
|
|
onSweep={this.handleSweep}
|
|
|
|
onReorderAction={this.handleReorderAction}
|
|
|
|
currentActionId={actionIds[currentStateIndex]}
|
|
|
|
lastActionId={getLastActionId(this.props)}
|
|
|
|
/>
|
|
|
|
<ActionPreview
|
|
|
|
{...{
|
|
|
|
base16Theme,
|
|
|
|
invertTheme,
|
|
|
|
isWideLayout,
|
|
|
|
tabs,
|
|
|
|
tabName,
|
|
|
|
delta,
|
|
|
|
error,
|
|
|
|
nextState,
|
|
|
|
computedStates,
|
|
|
|
action,
|
|
|
|
actions,
|
|
|
|
selectedActionId,
|
|
|
|
startActionId,
|
2020-08-08 23:26:39 +03:00
|
|
|
dataTypeKey,
|
2019-01-10 21:51:14 +03:00
|
|
|
}}
|
|
|
|
monitorState={this.props.monitorState}
|
|
|
|
updateMonitorState={this.updateMonitorState}
|
|
|
|
styling={styling}
|
2020-08-31 00:49:06 +03:00
|
|
|
onInspectPath={(path: (string | number)[]) =>
|
|
|
|
this.handleInspectPath(inspectedPathType, path)
|
|
|
|
}
|
2019-01-10 21:51:14 +03:00
|
|
|
inspectedPath={monitorState[inspectedPathType]}
|
|
|
|
onSelectTab={this.handleSelectTab}
|
|
|
|
/>
|
2018-12-22 03:10:49 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleToggleAction = (actionId: number) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.props.dispatch(toggleAction(actionId));
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleJumpToState = (actionId: number) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
if (jumpToAction) {
|
|
|
|
this.props.dispatch(jumpToAction(actionId));
|
2019-01-10 21:51:14 +03:00
|
|
|
} else {
|
|
|
|
// Fallback for redux-devtools-instrument < 1.5
|
2018-12-22 03:10:49 +03:00
|
|
|
const index = this.props.stagedActionIds.indexOf(actionId);
|
|
|
|
if (index !== -1) this.props.dispatch(jumpToState(index));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleReorderAction = (actionId: number, beforeActionId: number) => {
|
2019-01-10 21:51:14 +03:00
|
|
|
if (reorderAction)
|
|
|
|
this.props.dispatch(reorderAction(actionId, beforeActionId));
|
2018-12-22 03:10:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
handleCommit = () => {
|
|
|
|
this.props.dispatch(commit());
|
|
|
|
};
|
|
|
|
|
|
|
|
handleSweep = () => {
|
|
|
|
this.props.dispatch(sweep());
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleSearch = (val: string) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.updateMonitorState({ searchValue: val });
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleSelectAction = (
|
|
|
|
e: React.MouseEvent<HTMLDivElement>,
|
|
|
|
actionId: number
|
|
|
|
) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
const { monitorState } = this.props;
|
|
|
|
let startActionId;
|
|
|
|
let selectedActionId;
|
|
|
|
|
|
|
|
if (e.shiftKey && monitorState.selectedActionId !== null) {
|
|
|
|
if (monitorState.startActionId !== null) {
|
|
|
|
if (actionId >= monitorState.startActionId) {
|
2019-01-10 21:51:14 +03:00
|
|
|
startActionId = Math.min(
|
|
|
|
monitorState.startActionId,
|
|
|
|
monitorState.selectedActionId
|
|
|
|
);
|
2018-12-22 03:10:49 +03:00
|
|
|
selectedActionId = actionId;
|
|
|
|
} else {
|
2019-01-10 21:51:14 +03:00
|
|
|
selectedActionId = Math.max(
|
|
|
|
monitorState.startActionId,
|
|
|
|
monitorState.selectedActionId
|
|
|
|
);
|
2018-12-22 03:10:49 +03:00
|
|
|
startActionId = actionId;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
startActionId = Math.min(actionId, monitorState.selectedActionId);
|
|
|
|
selectedActionId = Math.max(actionId, monitorState.selectedActionId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
startActionId = null;
|
2019-01-10 21:51:14 +03:00
|
|
|
if (
|
|
|
|
actionId === monitorState.selectedActionId ||
|
|
|
|
monitorState.startActionId !== null
|
|
|
|
) {
|
2018-12-22 03:10:49 +03:00
|
|
|
selectedActionId = null;
|
|
|
|
} else {
|
|
|
|
selectedActionId = actionId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateMonitorState({ startActionId, selectedActionId });
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleInspectPath = (
|
|
|
|
pathType: 'inspectedActionPath' | 'inspectedStatePath',
|
|
|
|
path: (string | number)[]
|
|
|
|
) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.updateMonitorState({ [pathType]: path });
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
handleSelectTab = (tabName: string) => {
|
2018-12-22 03:10:49 +03:00
|
|
|
this.updateMonitorState({ tabName });
|
|
|
|
};
|
|
|
|
}
|
2020-08-31 00:49:06 +03:00
|
|
|
|
2021-06-18 06:56:36 +03:00
|
|
|
export default DevtoolsInspector as unknown as React.ComponentType<
|
2020-08-31 00:49:06 +03:00
|
|
|
ExternalProps<unknown, Action<unknown>>
|
|
|
|
> & {
|
|
|
|
update(
|
|
|
|
monitorProps: ExternalProps<unknown, Action<unknown>>,
|
|
|
|
state: DevtoolsInspectorState | undefined,
|
|
|
|
action: DevtoolsInspectorAction
|
|
|
|
): DevtoolsInspectorState;
|
|
|
|
defaultProps: DefaultProps;
|
|
|
|
};
|