Skip to content

Commit

Permalink
Merge pull request webpackmonitor#61 from roachjc/master
Browse files Browse the repository at this point in the history
utils for containers
  • Loading branch information
gordonu authored Oct 20, 2017
2 parents 91a6dca + d1e6fe4 commit ac5dcbd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions client/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class App extends React.Component {
this.handleIncrement = this.handleIncrement.bind(this);
}

// Get build data
componentDidMount() {
fetch('/getstats')
.then(res => res.json())
Expand All @@ -20,17 +21,20 @@ class App extends React.Component {
});
}

// Select build from LineChart
handleCircleClick(e) {
const len = this.state.build.length;
const index = len - e.target.getAttribute('data-build');
this.setState({ activeBuild: len - index });
}

// Select build from header dropdown
selectBuild(e) {
const index = e.target.getAttribute('data-build');
this.setState({ activeBuild: index - 1 });
}

// Select build from card
handleIncrement() {
if (this.state.activeBuild < this.state.build.length - 1) {
const activeBuild = this.state.activeBuild + 1;
Expand Down
10 changes: 2 additions & 8 deletions client/containers/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { NavDropdown, MenuItem } from 'react-bootstrap';
import { NavDropdown } from 'react-bootstrap';
import logo from './../assets/wpmlogo.png';
import { getMenuItems } from './utils';

const getMenuItems = (buildNumber, selectBuild) => {
const menuItems = [];
for (let i = buildNumber; i > 0; i -= 1) {
menuItems.push(<MenuItem onClick={selectBuild} data-build={i} key={`build${i}`}>Build {i}</MenuItem>);
}
return menuItems;
};

const Header = (props) => {
const menuItems = getMenuItems(props.build.length, props.selectBuild);
Expand Down
2 changes: 2 additions & 0 deletions client/containers/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Main extends React.Component {
);
}

// Handle routing for Main
renderApp() {
return (
<main>
Expand Down Expand Up @@ -54,6 +55,7 @@ class Main extends React.Component {
);
}

// Render spinner / loader util data loads
render() {
const build = this.props.build.length;
return (
Expand Down
11 changes: 11 additions & 0 deletions client/containers/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { MenuItem } from 'react-bootstrap';


export function getMenuItems(buildNumber, selectBuild) {
const menuItems = [];
for (let i = buildNumber; i > 0; i -= 1) {
menuItems.push(<MenuItem onClick={selectBuild} data-build={i} key={`build${i}`}>Build {i}</MenuItem>);
}
return menuItems;
}
2 changes: 2 additions & 0 deletions client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import App from './App';
const env = process.env.NODE_ENV;

if (env === 'development') {
// AppDev imports a local JSON file as demo data
render(
(
<BrowserRouter>
Expand All @@ -16,6 +17,7 @@ if (env === 'development') {
document.getElementById('root'),
);
} else {
// App retrieves data with fetch from getstats route on plugin server
render(
(
<BrowserRouter>
Expand Down
2 changes: 1 addition & 1 deletion plugin/npm-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack-monitor",
"version": "1.0.11",
"version": "1.0.12",
"description": "Monitor your production builds throughout the development process with rich analysis tool",
"homepage": "https://github.com/webpackmonitor/webpackmonitor",
"author": "Jon Roach, Gordon Yu, Balal Zuhair",
Expand Down

0 comments on commit ac5dcbd

Please sign in to comment.