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-12-21 23:46:28 +03:00
|
|
|
import DockMonitor from '@redux-devtools/dock-monitor';
|
2020-09-13 07:02:24 +03:00
|
|
|
import { Location } from 'history';
|
2021-09-25 07:12:30 +03:00
|
|
|
import DevtoolsInspector from '@redux-devtools/inspector-monitor/lib/DevtoolsInspector';
|
2020-08-10 03:41:59 +03:00
|
|
|
import getOptions from './getOptions';
|
2021-09-25 07:12:30 +03:00
|
|
|
import { base16Themes } from '@redux-devtools/inspector-monitor/lib/utils/createStylingFromTheme';
|
2020-08-31 00:49:06 +03:00
|
|
|
import { DemoAppState } from './reducers';
|
2020-08-10 03:41:59 +03:00
|
|
|
|
|
|
|
const CustomComponent = () => (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
minHeight: '20rem',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div>Custom Tab Content</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2020-08-31 00:49:06 +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"
|
|
|
|
>
|
|
|
|
<DevtoolsInspector
|
2020-08-31 00:49:06 +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}
|
|
|
|
tabs={(defaultTabs) => [
|
|
|
|
{
|
|
|
|
name: 'Custom Tab',
|
|
|
|
component: CustomComponent,
|
|
|
|
},
|
|
|
|
...defaultTabs,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</DockMonitor>
|
|
|
|
);
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
const UnconnectedDevTools = ({ location }: { location: Location }) => {
|
2020-08-10 03:41:59 +03:00
|
|
|
const DevTools = getDevTools(location);
|
|
|
|
return <DevTools />;
|
|
|
|
};
|
|
|
|
|
2020-08-31 00:49:06 +03:00
|
|
|
const mapStateToProps = (state: DemoAppState) => ({
|
2020-08-10 03:41:59 +03:00
|
|
|
location: state.router.location,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const ConnectedDevTools = connect(mapStateToProps)(UnconnectedDevTools);
|