2020-08-08 22:46:01 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import pkg from '../../../package.json';
|
|
|
|
import { Button, Toolbar, Spacer } from 'devui';
|
|
|
|
import getOptions from './getOptions';
|
2020-08-10 03:41:59 +03:00
|
|
|
import { push as pushRoute } from 'connected-react-router';
|
2020-08-08 22:46:01 +03:00
|
|
|
|
|
|
|
const styles = {
|
|
|
|
wrapper: {
|
|
|
|
height: '100vh',
|
|
|
|
width: '450px',
|
|
|
|
margin: 'auto',
|
2020-08-08 23:26:39 +03:00
|
|
|
textAlign: 'center',
|
2020-08-08 22:46:01 +03:00
|
|
|
},
|
|
|
|
muted: {
|
2020-08-08 23:26:39 +03:00
|
|
|
color: '#CCCCCC',
|
2020-08-08 22:46:01 +03:00
|
|
|
},
|
|
|
|
link: {
|
|
|
|
margin: '0 0.5rem',
|
|
|
|
cursor: 'pointer',
|
2020-08-08 23:26:39 +03:00
|
|
|
display: 'block',
|
|
|
|
},
|
2020-08-08 22:46:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const ROOT = '/'; // process.env.NODE_ENV === 'production' ? '/' : '/';
|
|
|
|
|
|
|
|
class DemoApp extends React.Component {
|
|
|
|
render() {
|
2020-08-10 03:41:59 +03:00
|
|
|
const options = getOptions(this.props.router.location);
|
2020-08-08 22:46:01 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={styles.wrapper}>
|
|
|
|
<h3>{pkg.name || <span style={styles.muted}>Package Name</span>}</h3>
|
|
|
|
<h5>
|
|
|
|
{pkg.description || (
|
|
|
|
<span style={styles.muted}>Package Description</span>
|
|
|
|
)}
|
|
|
|
</h5>
|
|
|
|
<Toolbar>
|
|
|
|
<Spacer />
|
|
|
|
<Button onClick={this.props.increment}>Increment</Button>
|
|
|
|
<Button onClick={this.props.push}>Push</Button>
|
|
|
|
<Button onClick={this.props.pop}>Pop</Button>
|
|
|
|
<Button onClick={this.props.replace}>Replace</Button>
|
|
|
|
<Button onClick={this.props.changeNested}>Change Nested</Button>
|
|
|
|
<Spacer />
|
|
|
|
</Toolbar>
|
|
|
|
<Toolbar>
|
|
|
|
<Spacer />
|
|
|
|
<Button onClick={this.props.pushHugeArray}>Push Huge Array</Button>
|
|
|
|
<Button onClick={this.props.addHugeObect}>Add Huge Object</Button>
|
|
|
|
<Button onClick={this.props.hugePayload}>Huge Payload</Button>
|
|
|
|
<Spacer />
|
|
|
|
</Toolbar>
|
|
|
|
<Toolbar>
|
|
|
|
<Spacer />
|
|
|
|
<Button onClick={this.props.addIterator}>Add Iterator</Button>
|
|
|
|
<Button onClick={this.props.addImmutableMap}>
|
|
|
|
Add Immutable Map
|
|
|
|
</Button>
|
|
|
|
<Button onClick={this.props.changeImmutableNested}>
|
|
|
|
Change Immutable Nested
|
|
|
|
</Button>
|
|
|
|
<Spacer />
|
|
|
|
</Toolbar>
|
|
|
|
<Toolbar>
|
|
|
|
<Spacer />
|
|
|
|
<Button onClick={this.props.addRecursive}>Add Recursive</Button>
|
|
|
|
<Button onClick={this.props.addFunction}>Add Function</Button>
|
|
|
|
<Button onClick={this.props.addSymbol}>Add Symbol</Button>
|
|
|
|
<Spacer />
|
|
|
|
</Toolbar>
|
|
|
|
<Toolbar>
|
|
|
|
<Spacer />
|
|
|
|
<Button onClick={this.toggleTimeoutUpdate}>
|
|
|
|
Timeout Update {this.props.timeoutUpdateEnabled ? 'On' : 'Off'}
|
|
|
|
</Button>
|
|
|
|
<Button onClick={this.props.shuffleArray}>Shuffle Array</Button>
|
|
|
|
<Spacer />
|
|
|
|
</Toolbar>
|
|
|
|
<div>
|
|
|
|
{options.useExtension ? (
|
|
|
|
<a href={`${ROOT}`} style={styles.link}>
|
|
|
|
Disable browser extension
|
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
<a href={`${ROOT}?ext`} style={styles.link}>
|
|
|
|
Use browser extension
|
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleTimeoutUpdate = () => {
|
|
|
|
const enabled = !this.props.timeoutUpdateEnabled;
|
|
|
|
this.props.toggleTimeoutUpdate(enabled);
|
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
this.timeout = setInterval(this.props.timeoutUpdate, 1000);
|
|
|
|
} else {
|
|
|
|
clearTimeout(this.timeout);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
export default connect((state) => state, {
|
|
|
|
toggleTimeoutUpdate: (timeoutUpdateEnabled) => ({
|
2020-08-08 22:46:01 +03:00
|
|
|
type: 'TOGGLE_TIMEOUT_UPDATE',
|
2020-08-08 23:26:39 +03:00
|
|
|
timeoutUpdateEnabled,
|
2020-08-08 22:46:01 +03:00
|
|
|
}),
|
|
|
|
timeoutUpdate: () => ({ type: 'TIMEOUT_UPDATE' }),
|
|
|
|
increment: () => ({ type: 'INCREMENT' }),
|
|
|
|
push: () => ({ type: 'PUSH' }),
|
|
|
|
pop: () => ({ type: 'POP' }),
|
|
|
|
replace: () => ({ type: 'REPLACE' }),
|
|
|
|
changeNested: () => ({ type: 'CHANGE_NESTED' }),
|
|
|
|
pushHugeArray: () => ({ type: 'PUSH_HUGE_ARRAY' }),
|
|
|
|
addIterator: () => ({ type: 'ADD_ITERATOR' }),
|
|
|
|
addHugeObect: () => ({ type: 'ADD_HUGE_OBJECT' }),
|
|
|
|
addRecursive: () => ({ type: 'ADD_RECURSIVE' }),
|
|
|
|
addImmutableMap: () => ({ type: 'ADD_IMMUTABLE_MAP' }),
|
|
|
|
changeImmutableNested: () => ({ type: 'CHANGE_IMMUTABLE_NESTED' }),
|
|
|
|
hugePayload: () => ({
|
|
|
|
type: 'HUGE_PAYLOAD',
|
2020-08-08 23:26:39 +03:00
|
|
|
payload: Array.from({ length: 10000 }).map((_, i) => i),
|
2020-08-08 22:46:01 +03:00
|
|
|
}),
|
|
|
|
addFunction: () => ({ type: 'ADD_FUNCTION' }),
|
|
|
|
addSymbol: () => ({ type: 'ADD_SYMBOL' }),
|
|
|
|
shuffleArray: () => ({ type: 'SHUFFLE_ARRAY' }),
|
2020-08-08 23:26:39 +03:00
|
|
|
pushRoute,
|
2020-08-08 22:46:01 +03:00
|
|
|
})(DemoApp);
|