2020-08-10 03:41:59 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2020-12-21 17:08:08 +03:00
|
|
|
import { createDevTools } from '@redux-devtools/core';
|
2020-09-13 07:02:24 +03:00
|
|
|
import InspectorMonitor, {
|
|
|
|
base16Themes,
|
|
|
|
Tab,
|
|
|
|
} from 'redux-devtools-inspector-monitor';
|
2020-08-10 03:41:59 +03:00
|
|
|
import DockMonitor from 'redux-devtools-dock-monitor';
|
2020-09-13 07:02:24 +03:00
|
|
|
import { Location } from 'history';
|
2020-08-10 03:41:59 +03:00
|
|
|
import getOptions from './getOptions';
|
|
|
|
import TestGenerator from '../../../src';
|
2020-09-13 07:02:24 +03:00
|
|
|
import { DemoAppState } from './reducers';
|
|
|
|
import { Action } from 'redux';
|
2020-08-10 03:41:59 +03:00
|
|
|
|
2020-09-13 07:02:24 +03:00
|
|
|
export const getDevTools = (location: { search: string }) =>
|
2020-08-10 03:41:59 +03:00
|
|
|
createDevTools(
|
|
|
|
<DockMonitor
|
|
|
|
defaultIsVisible
|
|
|
|
toggleVisibilityKey="ctrl-h"
|
|
|
|
changePositionKey="ctrl-q"
|
|
|
|
changeMonitorKey="ctrl-m"
|
|
|
|
>
|
2020-09-10 19:37:19 +03:00
|
|
|
<InspectorMonitor
|
2020-09-13 07:02:24 +03:00
|
|
|
theme={getOptions(location).theme as keyof typeof base16Themes}
|
2020-08-10 03:41:59 +03:00
|
|
|
invertTheme={!getOptions(location).dark}
|
|
|
|
supportImmutable={getOptions(location).supportImmutable}
|
2020-09-13 07:02:24 +03:00
|
|
|
tabs={(defaultTabs) =>
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: 'Test',
|
|
|
|
component: TestGenerator,
|
|
|
|
},
|
|
|
|
...defaultTabs,
|
|
|
|
] as Tab<unknown, Action<unknown>>[]
|
|
|
|
}
|
2020-08-10 03:41:59 +03:00
|
|
|
/>
|
|
|
|
</DockMonitor>
|
|
|
|
);
|
|
|
|
|
2020-09-13 07:02:24 +03:00
|
|
|
const UnconnectedDevTools = ({ location }: { location: Location }) => {
|
2020-08-10 03:41:59 +03:00
|
|
|
const DevTools = getDevTools(location);
|
|
|
|
return <DevTools />;
|
|
|
|
};
|
|
|
|
|
2020-09-13 07:02:24 +03:00
|
|
|
const mapStateToProps = (state: DemoAppState) => ({
|
2020-08-10 03:41:59 +03:00
|
|
|
location: state.router.location,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const ConnectedDevTools = connect(mapStateToProps)(UnconnectedDevTools);
|