diff --git a/packages/redux-devtools-core/src/app/actions/index.ts b/packages/redux-devtools-core/src/app/actions/index.ts index 2fe76c0e..573f6f13 100644 --- a/packages/redux-devtools-core/src/app/actions/index.ts +++ b/packages/redux-devtools-core/src/app/actions/index.ts @@ -35,6 +35,7 @@ import { SUBSCRIBE_SUCCESS, UNSUBSCRIBE, } from '../constants/socketActionTypes'; +import { Action } from 'redux'; let monitorReducer; let monitorProps = {}; @@ -65,7 +66,18 @@ export function changeTheme(data: ChangeThemeData): ChangeThemeAction { return { type: CHANGE_THEME, ...data.formData }; } -export function liftedDispatch(action) { +interface MonitorActionAction { + type: typeof MONITOR_ACTION; + action: Action; +} +interface LiftedActionAction { + type: typeof LIFTED_ACTION; + message: 'DISPATCH'; + action: Action; +} +export function liftedDispatch( + action: Action +): MonitorActionAction | LiftedActionAction { if (action.type[0] === '@') { if (action.type === '@@INIT_MONITOR') { monitorReducer = action.update; @@ -289,6 +301,8 @@ interface UnsubscribeAction { export type StoreAction = | ChangeSectionAction | ChangeThemeAction + | MonitorActionAction + | LiftedActionAction | SelectInstanceAction | SelectMonitorAction | UpdateMonitorStateAction diff --git a/packages/redux-devtools-core/src/app/components/TopButtons.tsx b/packages/redux-devtools-core/src/app/components/TopButtons.tsx index 7c2f3fc8..ddd0acde 100644 --- a/packages/redux-devtools-core/src/app/components/TopButtons.tsx +++ b/packages/redux-devtools-core/src/app/components/TopButtons.tsx @@ -1,16 +1,22 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { ActionCreators } from 'redux-devtools-instrument'; +import { ActionCreators, LiftedAction } from 'redux-devtools-instrument'; import { Button, Toolbar, Divider } from 'devui'; import RecordButton from './buttons/RecordButton'; import PersistButton from './buttons/PersistButton'; import LockButton from './buttons/LockButton'; import InstanceSelector from './InstanceSelector'; import SyncButton from './buttons/SyncButton'; +import { Action } from 'redux'; +// eslint-disable-next-line @typescript-eslint/unbound-method const { reset, rollback, commit, sweep } = ActionCreators; -export default class TopButtons extends Component { +interface Props { + dispatch: (action: LiftedAction, unknown>) => void; +} + +export default class TopButtons extends Component { static propTypes = { // shouldSync: PropTypes.bool, liftedState: PropTypes.object.isRequired, @@ -18,7 +24,7 @@ export default class TopButtons extends Component { options: PropTypes.object.isRequired, }; - shouldComponentUpdate(nextProps) { + shouldComponentUpdate(nextProps: Props) { return ( nextProps.options !== this.props.options || nextProps.liftedState !== this.props.liftedState diff --git a/packages/redux-devtools-core/src/app/containers/Actions.tsx b/packages/redux-devtools-core/src/app/containers/Actions.tsx index 3379cbec..494adfa3 100644 --- a/packages/redux-devtools-core/src/app/containers/Actions.tsx +++ b/packages/redux-devtools-core/src/app/containers/Actions.tsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; +import { connect, ResolveThunks } from 'react-redux'; import { Container } from 'devui'; import SliderMonitor from './monitors/Slider'; import { liftedDispatch as liftedDispatchAction, getReport } from '../actions'; @@ -11,7 +11,11 @@ import TopButtons from '../components/TopButtons'; import BottomButtons from '../components/BottomButtons'; import { StoreState } from '../reducers'; -class Actions extends Component { +type StateProps = ReturnType; +type DispatchProps = ResolveThunks; +type Props = StateProps & DispatchProps; + +class Actions extends Component { render() { const { monitor, diff --git a/packages/redux-devtools-core/src/app/reducers/index.ts b/packages/redux-devtools-core/src/app/reducers/index.ts index 52fb0f57..6b47effd 100644 --- a/packages/redux-devtools-core/src/app/reducers/index.ts +++ b/packages/redux-devtools-core/src/app/reducers/index.ts @@ -2,10 +2,10 @@ import { combineReducers } from 'redux'; import section, { SectionState } from './section'; import connection, { ConnectionState } from './connection'; import socket, { SocketState } from './socket'; -import monitor from './monitor'; +import monitor, { MonitorState } from './monitor'; import notification, { NotificationState } from './notification'; -import instances from './instances'; -import reports from './reports'; +import instances, { InstancesState } from './instances'; +import reports, { ReportsState } from './reports'; import theme, { ThemeState } from './theme'; import { StoreAction } from '../actions'; @@ -14,6 +14,9 @@ export interface StoreState { readonly theme: ThemeState; readonly connection: ConnectionState; readonly socket: SocketState; + readonly monitor: MonitorState; + readonly instances: InstancesState; + readonly reports: ReportsState; readonly notification: NotificationState; } diff --git a/packages/redux-devtools-core/src/app/reducers/instances.ts b/packages/redux-devtools-core/src/app/reducers/instances.ts index 5904d68c..ed209859 100644 --- a/packages/redux-devtools-core/src/app/reducers/instances.ts +++ b/packages/redux-devtools-core/src/app/reducers/instances.ts @@ -12,7 +12,7 @@ import parseJSON from '../utils/parseJSON'; import { recompute } from '../utils/updateState'; import { StoreAction } from '../actions'; -interface InstancesState { +export interface InstancesState { sync: boolean; persisted?: boolean; } diff --git a/packages/redux-devtools-core/src/app/reducers/monitor.ts b/packages/redux-devtools-core/src/app/reducers/monitor.ts index c5b31357..fe8fedbb 100644 --- a/packages/redux-devtools-core/src/app/reducers/monitor.ts +++ b/packages/redux-devtools-core/src/app/reducers/monitor.ts @@ -7,6 +7,8 @@ import { } from '../constants/actionTypes'; import { StoreAction } from '../actions'; +export interface MonitorState {} + const initialState = { selected: 'InspectorMonitor', monitorState: undefined, diff --git a/packages/redux-devtools-core/src/app/reducers/reports.ts b/packages/redux-devtools-core/src/app/reducers/reports.ts index 8f4f2bd4..cf57f100 100644 --- a/packages/redux-devtools-core/src/app/reducers/reports.ts +++ b/packages/redux-devtools-core/src/app/reducers/reports.ts @@ -3,6 +3,8 @@ import { } from '../constants/actionTypes'; import { StoreAction } from '../actions'; +export interface ReportsState {} + const initialState = { data: [], };