Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

[WIP] Dash dev tools #64

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
eb7f935
Dash dev tools -- frontend
rmarren1 Jul 29, 2018
605b585
Eslint error fixes.
rmarren1 Jul 30, 2018
e3d4d6a
Catch Werkzueg errors in front-end and display.
rmarren1 Aug 2, 2018
3758ca2
Error boundary around each component.
rmarren1 Aug 2, 2018
43093e8
Get rid of eslint complaints
rmarren1 Aug 3, 2018
01b64ed
Werkzueg embed with console working
rmarren1 Aug 3, 2018
ffdad09
Expandable error boundaries
rmarren1 Aug 3, 2018
4409102
Error component overlay and resolve.
rmarren1 Aug 8, 2018
15e03a2
Revert changes when resolved.
rmarren1 Aug 9, 2018
9b29a74
Updates to pass testing.
rmarren1 Aug 10, 2018
09f32a6
Add 'namespace' and 'type' props to _dash_update_component payload.
rmarren1 Aug 21, 2018
11ae9b3
Merge branch 'validate' into dash-dev-tools
rmarren1 Aug 27, 2018
1653474
Rebase on master
rmarren1 Oct 3, 2018
87fd0e3
Update webpack
rmarren1 Oct 3, 2018
375fdcd
Update Dash ecosystem requirements to latest
rmarren1 Oct 3, 2018
418f46b
Fix html raw comparison test
rmarren1 Oct 3, 2018
e0486eb
Add n_clicks, n_clicks_timestamp to raw HTML comparisons
rmarren1 Oct 3, 2018
12973a3
Merge branch 'dash-dev-tools' of https://github.com/rmarren1/dash-ren…
rmarren1 Oct 3, 2018
b94c026
Add css-loader
rmarren1 Oct 4, 2018
2954c8c
Add sample werkzueg.css file
rmarren1 Oct 4, 2018
e14a259
Re-build renderer
rmarren1 Oct 4, 2018
8e80bdb
Replace werkzueg.css with default
rmarren1 Oct 4, 2018
2fec382
Add frontEnd / backEnd error state to redux.
rmarren1 Oct 5, 2018
b6e2b5f
Fix 'UNDO' error.
rmarren1 Oct 10, 2018
89c5cae
Add ComponentDisabledOverlay
rmarren1 Oct 10, 2018
e60ed0a
Include component `id` and `UID` in store.
rmarren1 Oct 10, 2018
e266c33
Remove old children from Error Overlay.
rmarren1 Oct 10, 2018
1bdb9ea
Change myId -> myUID
rmarren1 Oct 10, 2018
6c644fc
Add Global error menu.
rmarren1 Oct 10, 2018
1fc8879
Work in disabled overlay.
rmarren1 Oct 10, 2018
4785896
Re-build dev bundle.
rmarren1 Oct 10, 2018
f2bdd45
Eslint fixex.
rmarren1 Oct 10, 2018
0916d24
Add more informative `_dash-` ids to each component.
rmarren1 Oct 10, 2018
5bce957
Delete test.py
rmarren1 Oct 10, 2018
29a9ea3
Track old children state in ComponentBoundary.
rmarren1 Oct 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": ["es2015", "react"],
"presets": ["es2015", "react", "stage-2"],
"env": {
"development": {
"presets": ["es2015", "react"],
"presets": ["es2015", "react", "stage-2"],
"plugins": [
["transform-es2015-modules-commonjs-simple", {
"noMangle": true
Expand Down
6 changes: 4 additions & 2 deletions config/eslint/eslintrc-node.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"env": {
"node": true
"node": true,
"browser": true
},
"extends": [
"eslint:recommended",
Expand All @@ -15,7 +16,8 @@
"ecmaVersion": "2015",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion dash_renderer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .version import __version__
__file__

_DEFAULT_REACT_VERSION = '15.4.2'
_DEFAULT_REACT_VERSION = '16.2.0'
_REACT_VERSION_TYPES = {'15.4.2', '16.2.0'}
_REACT_VERSION_TO_URLS = {
'15.4.2': {
Expand Down
180 changes: 148 additions & 32 deletions dash_renderer/dash_renderer.dev.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dash_renderer/dash_renderer.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dash_core_components==0.12.0
dash_html_components==0.11.0rc5
dash==0.18.3
dash_core_components
dash_html_components
dash
percy
selenium
mock
Expand Down
7,016 changes: 2,664 additions & 4,352 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"dependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
Expand All @@ -33,22 +32,26 @@
"query-string": "^4.3.2",
"radium": "^0.22.0",
"ramda": "^0.23.0",
"react": "^15.6.2",
"react-dom": "^15.6.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^4.4.5",
"redux": "^3.4.0",
"redux-actions": "^0.9.1",
"redux-thunk": "^2.0.1",
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3",
"uniqid": "^5.0.3",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-partial": "^1.2.0",
"webpack-serve": "^1.0.2",
"whatwg-fetch": "^2.0.2"
},
"devDependencies": {
"babel-loader": "^7.1.5",
"babel-plugin-transform-es2015-modules-commonjs-simple": "^6.7.4",
"babel-preset-es2015-webpack": "^6.4.1",
"eslint": "^3.15.0",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^1.0.0",
"eslint": "^3.19.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.9.0",
"react-hot-loader": "^1.3.0",
Expand Down
13 changes: 8 additions & 5 deletions src/APIController.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {contains, isEmpty, isNil} from 'ramda'
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import TreeContainer from './TreeContainer';
import GlobalErrorContainer from './components/error/GlobalErrorContainer.react';
import {
computeGraphs,
computePaths,
Expand Down Expand Up @@ -97,9 +98,9 @@ class UnconnectedContainer extends Component {

else if (appLifecycle === APP_STATES('HYDRATED')) {
return (
<div id="_dash-app-content">
<TreeContainer layout={layout}/>
</div>
<GlobalErrorContainer>
<TreeContainer layout={layout}/>
</GlobalErrorContainer>
);
}

Expand All @@ -118,7 +119,8 @@ UnconnectedContainer.propTypes = {
layoutRequest: PropTypes.object,
layout: PropTypes.object,
paths: PropTypes.object,
history: PropTypes.array
history: PropTypes.array,
error: PropTypes.object
}

const Container = connect(
Expand All @@ -130,7 +132,8 @@ const Container = connect(
layout: state.layout,
graphs: state.graphs,
paths: state.paths,
history: state.history
history: state.history,
error: state.error
}),
dispatch => ({dispatch})
)(UnconnectedContainer);
Expand Down
11 changes: 8 additions & 3 deletions src/TreeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Registry from './registry';
import NotifyObservers from './components/core/NotifyObservers.react';
import ComponentErrorBoundary from './components/error/ComponentErrorBoundary.react';

export default class TreeContainer extends Component {
shouldComponentUpdate(nextProps) {
Expand Down Expand Up @@ -76,9 +77,13 @@ function render(component) {
);

return (
<NotifyObservers id={componentProps.id}>
{parent}
</NotifyObservers>
<ComponentErrorBoundary
componentType={component.type}
componentId={componentProps.id}>
<NotifyObservers id={componentProps.id}>
{parent}
</NotifyObservers>
</ComponentErrorBoundary>
);
}

Expand Down
14 changes: 8 additions & 6 deletions src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import cookie from 'cookie';
import {merge} from 'ramda';
import {urlBase} from '../utils';
import {createAction} from 'redux-actions';
import {ACTIONS} from './constants';
export const onError = createAction(ACTIONS('ON_ERROR'));

function GET(path) {
return fetch(path, {
Expand Down Expand Up @@ -69,12 +72,11 @@ function apiThunk(endpoint, method, store, id, body, headers={}) {
/* eslint-disable no-console */
console.error(err);
/* eslint-enable no-console */
dispatch({
type: store,
payload: {
id,
status: 500
}
err.text().then(text => {
dispatch(onError({
type: 'backEnd',
errorPage: text
}))
});
});
};
Expand Down
4 changes: 3 additions & 1 deletion src/actions/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export const ACTIONS = (action) => {
COMPUTE_PATHS: 'COMPUTE_PATHS',
SET_LAYOUT: 'SET_LAYOUT',
SET_APP_LIFECYCLE: 'SET_APP_LIFECYCLE',
READ_CONFIG: 'READ_CONFIG'
READ_CONFIG: 'READ_CONFIG',
ON_ERROR: 'ON_ERROR',
RESOLVE_ERROR: 'RESOLVE_ERROR'
};
if (actionList[action]) return actionList[action];
else throw new Error(`${action} is not defined.`)
Expand Down
46 changes: 45 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const computePaths = createAction(ACTIONS('COMPUTE_PATHS'));
export const setLayout = createAction(ACTIONS('SET_LAYOUT'));
export const setAppLifecycle = createAction(ACTIONS('SET_APP_LIFECYCLE'));
export const readConfig = createAction(ACTIONS('READ_CONFIG'));
export const onError = createAction(ACTIONS('ON_ERROR'));
export const resolveError = createAction(ACTIONS('RESOLVE_ERROR'));


export function hydrateInitialOutputs() {
return function (dispatch, getState) {
Expand Down Expand Up @@ -132,6 +135,26 @@ export function undo() {
}


export function revert() {
return function (dispatch, getState) {
const history = getState().history;
dispatch(createAction('REVERT')());
const previous = history.past[history.past.length - 1];

// Update props
dispatch(createAction('UNDO_PROP_CHANGE')({
itempath: getState().paths[previous.id],
props: previous.props
}));

// Notify observers
dispatch(notifyObservers({
id: previous.id,
props: previous.props
}));
}
}


function reduceInputIds(nodeIds, InputGraph) {
/*
Expand Down Expand Up @@ -403,8 +426,18 @@ function updateOutput(
* }
*
*/

const { type: outputType, namespace: outputNamespace } = view(
lensPath(paths[outputComponentId]),
layout
)
const payload = {
output: {id: outputComponentId, property: outputProp}
output: {
id: outputComponentId,
property: outputProp,
type: outputType,
namespace: outputNamespace,
}
};

if (event) {
Expand Down Expand Up @@ -479,6 +512,10 @@ function updateOutput(
body: JSON.stringify(payload)
}).then(function handleResponse(res) {

if (!res.ok) {
throw res;
}

const getThisRequestIndex = () => {
const postRequestQueue = getState().requestQueue;
const thisRequestIndex = findIndex(
Expand Down Expand Up @@ -732,6 +769,13 @@ function updateOutput(
}

});
}).catch(err => {
err.text().then(text => {
dispatch(onError({
type: 'backEnd',
errorPage: text
}))
});
});

}
Expand Down
39 changes: 39 additions & 0 deletions src/components/error/ComponentDisabledOverlay.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';

const styles = {
root: {
position: 'relative'
},
overlay: {
position: 'relative',
padding: '2px',
backgroundColor: 'rgb(0, 0, 255, .5)',
border: '1px solid black',
borderRadius: '2px',
display: 'inline-block'
},
childWrapper: {
position: 'relative',
zIndex: -1
}
}

function ComponentDisabledOverlay({ children }) {
return (
<div style={styles.root}>
<div
style={styles.overlay}>
<div style={styles.childWrapper}>
{children}
</div>
</div>
</div>
)
}

ComponentDisabledOverlay.propTypes = {
children: PropTypes.object,
}

export default ComponentDisabledOverlay;
Loading