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

Commit

Permalink
format prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Oct 18, 2018
1 parent 28e67af commit c108d1d
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 123 deletions.
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.

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


function UnconnectedAppContainer() {
return (
<Authentication>
Expand Down
6 changes: 1 addition & 5 deletions src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,5 @@ export function login(oauth_token) {
}

export function getReloadHash() {
return apiThunk(
'_reload-hash',
'GET',
'reloadRequest'
)
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
46 changes: 26 additions & 20 deletions src/components/core/Reloader.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
import R from 'ramda';
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux'
import {getReloadHash} from "../../actions/api";
import {connect} from 'react-redux';
import {getReloadHash} from '../../actions/api';

class Reloader extends React.Component {
constructor(props) {
super(props);
if (props.config.hot_reload) {
const { interval, max_retry } = props.config.hot_reload;
const {interval, max_retry} = props.config.hot_reload;
this.state = {
hash: null,
interval,
disabled: false,
intervalId: null,
packages: null,
max_retry: max_retry,
}
};
} else {
this.state = {
disabled: true
}
disabled: true,
};
}
this._retry = 0;
this._head = document.querySelector('head');
Expand All @@ -33,15 +33,21 @@ class Reloader extends React.Component {
if (this.state.hash === null) {
this.setState({
hash: reloadRequest.content.reloadHash,
packages: reloadRequest.content.packages
packages: reloadRequest.content.packages,
});
return;
}
if (reloadRequest.content.reloadHash !== this.state.hash) {
if (reloadRequest.content.hard
|| reloadRequest.content.packages.length !== this.state.packages.length
|| !R.all(R.map(x => R.contains(x, this.state.packages),
reloadRequest.content.packages))
if (
reloadRequest.content.hard ||
reloadRequest.content.packages.length !==
this.state.packages.length ||
!R.all(
R.map(
x => R.contains(x, this.state.packages),
reloadRequest.content.packages
)
)
) {
// Look if it was a css file.
let was_css = false;
Expand All @@ -61,8 +67,9 @@ class Reloader extends React.Component {
nodesToDisable.push(node);
node = it.iterateNext();
}
nodesToDisable.forEach(
n => n.setAttribute('disabled', 'disabled'));
nodesToDisable.forEach(n =>
n.setAttribute('disabled', 'disabled')
);

const link = document.createElement('link');
link.href = `${a.url}?m=${a.modified}`;
Expand All @@ -83,13 +90,13 @@ class Reloader extends React.Component {
// Since it's only a css reload,
// we just change the hash.
this.setState({
hash: reloadRequest.content.reloadHash
hash: reloadRequest.content.reloadHash,
});
}
} else {
// Soft reload
window.clearInterval(this.state.intervalId);
dispatch({'type': 'RELOAD'});
dispatch({type: 'RELOAD'});
}
}
} else if (reloadRequest.status === 500) {
Expand All @@ -101,20 +108,20 @@ class Reloader extends React.Component {
Reloader failed after ${this._retry} times.
Please check your application for errors.
`
)
);
}
this._retry++;
}
}

componentDidMount() {
const { dispatch } = this.props;
const { disabled, interval } = this.state;
const {dispatch} = this.props;
const {disabled, interval} = this.state;
if (!disabled && !this.state.intervalId) {
const intervalId = setInterval(() => {
dispatch(getReloadHash());
}, interval);
this.setState({intervalId})
this.setState({intervalId});
}
}

Expand Down Expand Up @@ -146,4 +153,3 @@ export default connect(
}),
dispatch => ({dispatch})
)(Reloader);

Loading

0 comments on commit c108d1d

Please sign in to comment.