diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 86d75f0db..85450e875 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -312,6 +312,7 @@ export function setResourceView() { } export function clickNode(nodeId, label, origin) { + console.log(nodeId, label, origin); return (dispatch, getState) => { dispatch({ type: ActionTypes.CLICK_NODE, diff --git a/client/app/scripts/main.js b/client/app/scripts/main.js index 773a44cbb..be3e372c5 100644 --- a/client/app/scripts/main.js +++ b/client/app/scripts/main.js @@ -6,6 +6,7 @@ import { Provider } from 'react-redux'; import '../styles/main.scss'; import '../images/favicon.ico'; import configureStore from './stores/configureStore'; +import runDemo from './utils/demo-utils'; const store = configureStore(); @@ -22,3 +23,7 @@ renderApp(); if (module.hot) { module.hot.accept('./components/app', renderApp); } + +if (process.env.DEMO) { + runDemo(store.getState, store.dispatch); +} diff --git a/client/app/scripts/utils/demo-utils.js b/client/app/scripts/utils/demo-utils.js new file mode 100644 index 000000000..594753a96 --- /dev/null +++ b/client/app/scripts/utils/demo-utils.js @@ -0,0 +1,23 @@ +import _ from 'lodash'; +import { clickNode } from '../actions/app-actions'; + +const INTERVAL = 3000; + +function openNodeDetails(getState, dispatch) { + const action = clickNode(); + if (typeof action === 'function') { + return action(dispatch, getState); + } + + return dispatch(action); +} + +const actions = [openNodeDetails]; + +export default function runDemo(getState) { + setInterval(() => { + const state = getState().toJS(); + const fn = _.sample(actions); + + }, INTERVAL); +} diff --git a/client/webpack.local.config.js b/client/webpack.local.config.js index 8e51cb0ea..b798038ae 100644 --- a/client/webpack.local.config.js +++ b/client/webpack.local.config.js @@ -73,7 +73,10 @@ module.exports = { template: 'app/html/index.html', filename: 'index.html' }), - new ContrastStyleCompiler() + new ContrastStyleCompiler(), + new webpack.DefinePlugin({ + 'process.env': {DEMO: process.env.DEMO ? 'true' : null } + }), ], // Transform source code using Babel and React Hot Loader @@ -85,13 +88,13 @@ module.exports = { path.resolve(__dirname, 'app/scripts', 'app/styles') ], - preLoaders: [ - { - test: /\.js$/, - exclude: /node_modules|vendor/, - loader: 'eslint-loader' - } - ], + // preLoaders: [ + // { + // test: /\.js$/, + // exclude: /node_modules|vendor/, + // loader: 'eslint-loader' + // } + // ], loaders: [ { test: /\.json$/,