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

Hot reload #73

Merged
merged 22 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ simple*

*.csv
.idea/
.vscode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐱

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

20 changes: 18 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/AppContainer.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import APIController from './APIController.react';
import DocumentTitle from './components/core/DocumentTitle.react';
import Loading from './components/core/Loading.react';
import Toolbar from './components/core/Toolbar.react';
import Reloader from './components/core/Reloader.react';

function UnconnectedAppContainer() {
return (
Expand All @@ -14,6 +15,7 @@ function UnconnectedAppContainer() {
<APIController />
<DocumentTitle />
<Loading />
<Reloader />
</div>
</Authentication>
);
Expand Down
4 changes: 4 additions & 0 deletions src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ export function login(oauth_token) {
Authorization: `Bearer ${oauth_token}`,
});
}

export function getReloadHash() {
return apiThunk('_reload-hash', 'GET', 'reloadRequest');
}
18 changes: 8 additions & 10 deletions src/components/core/DocumentTitle.react.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* global document:true */

import {connect} from 'react-redux'
import {any} from 'ramda'
import {Component} from 'react'
import {connect} from 'react-redux';
import {any} from 'ramda';
import {Component} from 'react';
import PropTypes from 'prop-types';

class DocumentTitle extends Component {
constructor(props) {
super(props);
this.state = {
initialTitle: document.title
initialTitle: document.title,
};
}

Expand All @@ -31,11 +31,9 @@ class DocumentTitle extends Component {
}

DocumentTitle.propTypes = {
requestQueue: PropTypes.array.isRequired
requestQueue: PropTypes.array.isRequired,
};

export default connect(
state => ({
requestQueue: state.requestQueue
})
)(DocumentTitle);
export default connect(state => ({
requestQueue: state.requestQueue,
}))(DocumentTitle);
25 changes: 10 additions & 15 deletions src/components/core/Loading.react.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import {connect} from 'react-redux'
import {any} from 'ramda'
import React from 'react'
import {connect} from 'react-redux';
import {any} from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';

function Loading(props) {
if (any(r => r.status === 'loading', props.requestQueue)) {
return (
<div className="_dash-loading-callback"/>
);
}
return null;

return <div className="_dash-loading-callback" />;
}
return null;
}

Loading.propTypes = {
requestQueue: PropTypes.array.isRequired
requestQueue: PropTypes.array.isRequired,
};

export default connect(
state => ({
requestQueue: state.requestQueue
})
)(Loading);
export default connect(state => ({
requestQueue: state.requestQueue,
}))(Loading);
49 changes: 24 additions & 25 deletions src/components/core/NotifyObservers.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import PropTypes from 'prop-types';
* its child as a prop
*/

function mapStateToProps (state) {
function mapStateToProps(state) {
return {
dependencies: state.dependenciesRequest.content,
paths: state.paths
paths: state.paths,
};
}

function mapDispatchToProps (dispatch) {
function mapDispatchToProps(dispatch) {
return {dispatch};
}

Expand All @@ -37,40 +37,40 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
const payload = {
props: newProps,
id: ownProps.id,
itempath: stateProps.paths[ownProps.id]
itempath: stateProps.paths[ownProps.id],
};

// Update this component's props
dispatch(updateProps(payload));

// Update output components that depend on this input
dispatch(notifyObservers({id: ownProps.id, props: newProps}));
}
}

},
};
}

function NotifyObserversComponent ({
function NotifyObserversComponent({
children,
id,
paths,

dependencies,

fireEvent,
setProps
setProps,
}) {
const thisComponentTriggersEvents = (
dependencies && dependencies.find(dependency => (
const thisComponentTriggersEvents =
dependencies &&
dependencies.find(dependency =>
dependency.events.find(event => event.id === id)
))
);
const thisComponentSharesState = (
dependencies && dependencies.find(dependency => (
dependency.inputs.find(input => input.id === id) ||
dependency.state.find(state => state.id === id)
))
);
);
const thisComponentSharesState =
dependencies &&
dependencies.find(
dependency =>
dependency.inputs.find(input => input.id === id) ||
dependency.state.find(state => state.id === id)
);
/*
* Only pass in `setProps` and `fireEvent` if they are actually
* necessary.
Expand All @@ -87,8 +87,8 @@ function NotifyObserversComponent ({
* or `subscribed_properties` instead of `fireEvent` and `setProps`.
*/
const extraProps = {};
if (thisComponentSharesState &&

if (
thisComponentSharesState &&
// there is a bug with graphs right now where
// the restyle listener gets assigned with a
// setProps function that was created before
Expand All @@ -104,15 +104,14 @@ function NotifyObserversComponent ({

if (!isEmpty(extraProps)) {
return React.cloneElement(children, extraProps);
}
return children;

}
return children;
}

NotifyObserversComponent.propTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
path: PropTypes.array.isRequired
path: PropTypes.array.isRequired,
};

export default connect(
Expand Down
Loading