2020-08-27 16:19:37 +03:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { Action } from 'redux';
|
2020-12-21 17:08:08 +03:00
|
|
|
import { PerformAction } from '@redux-devtools/core';
|
2020-08-27 16:19:37 +03:00
|
|
|
import { Base16Theme } from 'redux-devtools-themes';
|
2018-12-22 03:50:57 +03:00
|
|
|
import LogMonitorEntry from './LogMonitorEntry';
|
|
|
|
|
2023-11-05 00:04:23 +03:00
|
|
|
interface Props<S, A extends Action<string>> {
|
2020-08-27 16:19:37 +03:00
|
|
|
actionsById: { [actionId: number]: PerformAction<A> };
|
|
|
|
computedStates: { state: S; error?: string }[];
|
|
|
|
stagedActionIds: number[];
|
|
|
|
skippedActionIds: number[];
|
|
|
|
currentStateIndex: number;
|
|
|
|
consecutiveToggleStartId: number | null | undefined;
|
|
|
|
|
|
|
|
select: (state: S) => unknown;
|
|
|
|
onActionClick: (id: number) => void;
|
|
|
|
theme: Base16Theme;
|
|
|
|
expandActionRoot: boolean;
|
|
|
|
expandStateRoot: boolean;
|
|
|
|
markStateDiff: boolean;
|
|
|
|
onActionShiftClick: (id: number) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class LogMonitorEntryList<
|
|
|
|
S,
|
2023-11-05 00:04:23 +03:00
|
|
|
A extends Action<string>,
|
2020-08-27 16:19:37 +03:00
|
|
|
> extends PureComponent<Props<S, A>> {
|
2018-12-22 03:50:57 +03:00
|
|
|
render() {
|
|
|
|
const elements = [];
|
|
|
|
const {
|
|
|
|
theme,
|
|
|
|
actionsById,
|
|
|
|
computedStates,
|
|
|
|
currentStateIndex,
|
|
|
|
consecutiveToggleStartId,
|
|
|
|
select,
|
|
|
|
skippedActionIds,
|
|
|
|
stagedActionIds,
|
|
|
|
expandActionRoot,
|
|
|
|
expandStateRoot,
|
|
|
|
markStateDiff,
|
|
|
|
onActionClick,
|
2020-08-08 23:26:39 +03:00
|
|
|
onActionShiftClick,
|
2018-12-22 03:50:57 +03:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
for (let i = 0; i < stagedActionIds.length; i++) {
|
|
|
|
const actionId = stagedActionIds[i];
|
|
|
|
const action = actionsById[actionId].action;
|
|
|
|
const { state, error } = computedStates[i];
|
|
|
|
let previousState;
|
|
|
|
if (i > 0) {
|
|
|
|
previousState = computedStates[i - 1].state;
|
|
|
|
}
|
|
|
|
elements.push(
|
2019-01-10 21:51:14 +03:00
|
|
|
<LogMonitorEntry
|
|
|
|
key={actionId}
|
2018-12-22 03:50:57 +03:00
|
|
|
theme={theme}
|
|
|
|
select={select}
|
|
|
|
action={action}
|
|
|
|
actionId={actionId}
|
|
|
|
state={state}
|
|
|
|
previousState={previousState}
|
|
|
|
collapsed={skippedActionIds.indexOf(actionId) > -1}
|
|
|
|
inFuture={i > currentStateIndex}
|
|
|
|
selected={consecutiveToggleStartId === i}
|
|
|
|
error={error}
|
|
|
|
expandActionRoot={expandActionRoot}
|
|
|
|
expandStateRoot={expandStateRoot}
|
|
|
|
markStateDiff={markStateDiff}
|
|
|
|
onActionClick={onActionClick}
|
2019-01-10 21:51:14 +03:00
|
|
|
onActionShiftClick={onActionShiftClick}
|
2023-07-12 21:03:20 +03:00
|
|
|
/>,
|
2018-12-22 03:50:57 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
return <div>{elements}</div>;
|
2018-12-22 03:50:57 +03:00
|
|
|
}
|
|
|
|
}
|