From 7c2df81c6ad22084a8600dddf5525591b680f6fa Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Mon, 27 Feb 2017 22:48:35 -0600 Subject: [PATCH] Update to stage-3. --- bikeshop_project/.babelrc | 3 +- .../js/bikes/components/BikeForm/index.jsx | 8 ++- .../js/bikes/components/BikeModal/index.jsx | 18 +++---- .../js/bikes/components/BikeTable/index.jsx | 15 +----- .../assets/js/components/SignedInList.jsx | 18 +++---- bikeshop_project/package.json | 4 +- bikeshop_project/webpack.config.js | 50 ------------------- bikeshop_project/webpack.dev.config.js | 8 +-- 8 files changed, 34 insertions(+), 90 deletions(-) delete mode 100644 bikeshop_project/webpack.config.js diff --git a/bikeshop_project/.babelrc b/bikeshop_project/.babelrc index 7eae1a3..77e6c5c 100644 --- a/bikeshop_project/.babelrc +++ b/bikeshop_project/.babelrc @@ -1,3 +1,4 @@ { - presets: ['es2015', 'stage-0', 'react'] + "presets": ["latest", "stage-3", "react"], + "plugins": ["transform-runtime"] } \ No newline at end of file diff --git a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx index 842ab05..d71aec0 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx +++ b/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx @@ -75,7 +75,7 @@ class BikeForm extends React.Component { }); } - handleSave = () => { + handleSave() { const id = this.state.bike.id; const data = JSON.stringify(this.state.bike); const csrfToken = Cookies.get('csrftoken'); @@ -99,7 +99,7 @@ class BikeForm extends React.Component { }); } - render = () => { + render() { const timezone = moment.tz.guess(); const { claimed_at, @@ -255,4 +255,8 @@ class BikeForm extends React.Component { } } +BikeForm.propTypes = { + editing: PropTypes.bool, + handleClose: PropTypes.func, +} export default BikeForm; diff --git a/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx index 363d16a..53342c3 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx +++ b/bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx @@ -6,13 +6,7 @@ import BikeForm from '../BikeForm'; /** * A modal dialog can only be closed by selecting one of the actions. */ -export default class BikeModal extends React.Component { - static propTypes = { - open: PropTypes.bool, - bike: PropTypes.object, - editing: PropTypes.bool, - } - +class BikeModal extends React.Component { constructor(props) { super(props); @@ -23,7 +17,7 @@ export default class BikeModal extends React.Component { }; } - componentWillReceiveProps = (newProps) => { + componentWillReceiveProps(newProps) { this.setState({ ...this.state, open: newProps.open || false, @@ -32,7 +26,7 @@ export default class BikeModal extends React.Component { }); } - handleClose = () => { + handleClose() { this.setState({ open: false }); }; @@ -63,3 +57,9 @@ export default class BikeModal extends React.Component { ); } } + +export default BikeModal.propTypes = { + open: PropTypes.bool, + bike: PropTypes.object, + editing: PropTypes.bool, +}; diff --git a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx index da18bc5..58342a9 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx +++ b/bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx @@ -42,19 +42,6 @@ export default class BikeTable extends React.Component { } getBikes = () => { - fetch('/api/v1/bikes/', { - credentials: 'same-origin', - }) - .then(checkStatus) - .then(parseJSON) - .then((data) => { - this.setState({ bikes: data }); - }) - .catch((error) => { - console.log('request failed', error); - }); - } - handleEditBike(bike) { this.setState({ ...this.state, @@ -66,7 +53,7 @@ export default class BikeTable extends React.Component { }); } - handleAddBike = () => { + handleAddBike() { this.setState({ ...this.state, bikeModal: { diff --git a/bikeshop_project/assets/js/components/SignedInList.jsx b/bikeshop_project/assets/js/components/SignedInList.jsx index f4835db..f63a078 100644 --- a/bikeshop_project/assets/js/components/SignedInList.jsx +++ b/bikeshop_project/assets/js/components/SignedInList.jsx @@ -32,15 +32,7 @@ const styles = { }, }; -export default class SignedInList extends React.Component { - static propTypes = { - members: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.number, - purpose: PropTypes.string, - at: PropTypes.instanceOf(moment), - })), - } - +class SignedInList extends React.Component { constructor(props) { super(props); this.state = { tick: 0 }; @@ -117,3 +109,11 @@ export default class SignedInList extends React.Component { ); } } + +export default SignedInList.propTypes = { + members: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.number, + purpose: PropTypes.string, + at: PropTypes.instanceOf(moment), + })), +}; diff --git a/bikeshop_project/package.json b/bikeshop_project/package.json index a3a8c4f..d2caf63 100644 --- a/bikeshop_project/package.json +++ b/bikeshop_project/package.json @@ -29,9 +29,9 @@ "babel-core": "^6.9.1", "babel-loader": "^6.2.4", "babel-polyfill": "^6.22.0", - "babel-preset-es2015": "^6.9.0", + "babel-preset-latest": "^6.22.0", "babel-preset-react": "^6.5.0", - "babel-preset-stage-0": "^6.5.0", + "babel-preset-stage-3": "^6.22.0", "css-loader": "^0.23.1", "eslint": "^3.9.1", "eslint-plugin-import": "^2.1.0", diff --git a/bikeshop_project/webpack.config.js b/bikeshop_project/webpack.config.js deleted file mode 100644 index b2594cb..0000000 --- a/bikeshop_project/webpack.config.js +++ /dev/null @@ -1,50 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); -const BundleTracker = require('webpack-bundle-tracker'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const autoprefixer = require('autoprefixer'); - -module.exports = { - context: __dirname, - devtool: 'inline-source-map', - entry: { - signin: './assets/js/index', - members: './assets/js/members/index', - }, - output: { - path: path.resolve('./assets/bundles/'), - filename: '[name]-[hash].js', - }, - - plugins: [ - new BundleTracker({ filename: './webpack-stats.json' }), - new ExtractTextPlugin('react-toolbox.css', { allChunks: true }), - new webpack.NoErrorsPlugin(), - ], - - module: { - loaders: [ - { - test: /\.jsx?$/, - exclude: /node_modules/, - loader: 'babel-loader', - query: { - presets: ['es2015', 'stage-0', 'react'], - }, - }, - { - test: /(\.scss|\.css)$/, - loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox'), - }, - ], - }, - resolve: { - modulesDirectories: [ - 'node_modules', - 'bower_components', - path.resolve(__dirname, './node_modules'), - ], - extensions: ['', '.js', '.jsx', '.scss'], - }, - postcss: [autoprefixer], -}; diff --git a/bikeshop_project/webpack.dev.config.js b/bikeshop_project/webpack.dev.config.js index f5e5dcd..f6d318f 100644 --- a/bikeshop_project/webpack.dev.config.js +++ b/bikeshop_project/webpack.dev.config.js @@ -30,13 +30,15 @@ config.plugins = config.plugins.concat([ new ExtractTextPlugin('react-toolbox.css', { allChunks: true }), ]); -// Add a loader for JSX files with react-hot enabled +// Add a loader for JSX files config.module.loaders.push( { test: /\.jsx?$/, exclude: /node_modules/, - loaders: ['react-hot', 'babel-loader'], - + loader: 'babel-loader', + query: { + presets: ['latest', 'react', 'stage-3'], + }, }, { test: /(\.scss|\.css)$/,