Skip to content

Commit

Permalink
update enzyme, fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
awitherspoon committed May 30, 2017
1 parent fe0869b commit be0cc2a
Show file tree
Hide file tree
Showing 32 changed files with 170 additions and 171 deletions.
4 changes: 2 additions & 2 deletions dist/lib.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib.js.map

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions lib/components/AddWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import PropTypes from 'prop-types';
* @param {[type]} onClick} [description]
* @return {[type]} [description]
*/
const AddWidget = ({text, onClick}) => {
return (
<div className="add-widget-button" onClick={onClick}>
<a className="add-widget-link">{text}</a>
</div>
);
};
const AddWidget = ({ text, onClick }) => (
<div className="add-widget-button" onClick={onClick}>
<a className="add-widget-link">{text}</a>
</div>
);

AddWidget.propTypes = {
/**
Expand Down
13 changes: 7 additions & 6 deletions lib/components/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { moveWidget } from '../util';

const columnTarget = {
drop(props, monitor) {
const { layout, rowIndex, columnIndex, onMove} = props;
const { layout, rowIndex, columnIndex, onMove } = props;
const item = monitor.getItem();
if (item.columnIndex !== columnIndex || item.rowIndex !== rowIndex) {
const movedLayout = moveWidget(layout, {
rowIndex: item.rowIndex,
columnIndex: item.columnIndex,
widgetIndex: item.widgetIndex,
}, {
rowIndex: rowIndex,
columnIndex: columnIndex,
rowIndex,
columnIndex,
}, item.widgetName);
onMove(movedLayout);
}
Expand Down Expand Up @@ -57,9 +57,10 @@ class Column extends Component {

let addWidgetComponentToUse = null;
if (addWidgetComponent) {
addWidgetComponentToUse = createElement(addWidgetComponent, { text: addWidgetComponentText, onClick: () => {onAdd(layout, rowIndex, columnIndex);} });
// eslint max-len=off
addWidgetComponentToUse = createElement(addWidgetComponent, { text: addWidgetComponentText, onClick: () => {onAdd(layout, rowIndex, columnIndex);} }); // eslint-disable-line
} else {
addWidgetComponentToUse = <AddWidget text={addWidgetComponentText} onClick={() => {onAdd(layout, rowIndex, columnIndex);}}/>;
addWidgetComponentToUse = <AddWidget text={addWidgetComponentText} onClick={() => {onAdd(layout, rowIndex, columnIndex);}}/>; // eslint-disable-line
}

return (
Expand Down Expand Up @@ -146,7 +147,7 @@ Column.propTypes = {
addWidgetComponent: PropTypes.func,
};

Column.defaultProps = {
Column.defaultProps = {
editableColumnClass: 'editable-column',
droppableColumnClass: 'droppable-column',
};
Expand Down
3 changes: 2 additions & 1 deletion lib/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import LayoutRenderer from './LayoutRenderer';
/**
* Main dashboard component. This is where all of this starts.
*/
@DragDropContext(HTML5Backend)
/* eslint react/prefer-stateless-function: "off" */
@DragDropContext(HTML5Backend)
class Dashboard extends Component {
render() {
return (
Expand Down
18 changes: 8 additions & 10 deletions lib/components/DefaultFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import PropTypes from 'prop-types';
/**
* Default frame that will be used with the widgets.
*/
const DefaultFrame = ({children, onRemove, editable, title}) => {
return (
<div className="defaultWidgetFrame">
<div className="defaultWidgetFrameHeader">
<span className="title">{title}</span>
{editable && <a className="remove" onClick={() => {onRemove();}}>Remove</a>}
</div>
{children}
const DefaultFrame = ({ children, onRemove, editable, title }) => (
<div className="defaultWidgetFrame">
<div className="defaultWidgetFrameHeader">
<span className="title">{title}</span>
{editable && <a className="remove" onClick={() => onRemove()}>Remove</a>}
</div>
);
};
{children}
</div>
);

DefaultFrame.propTypes = {
/**
Expand Down
4 changes: 2 additions & 2 deletions lib/components/LayoutRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const LayoutRenderer = (props) => {
addWidgetComponent,
} = props;

let rows = layout.rows.map((row, rowIndex) => {
let rows = layout.rows.map((row, rowIndex) => { // eslint-disable-line arrow-body-style
return (
<Row
key={rowIndex}
Expand All @@ -39,7 +39,7 @@ const LayoutRenderer = (props) => {
droppableColumnClass={droppableColumnClass}
addWidgetComponentText={addWidgetComponentText}
addWidgetComponent={addWidgetComponent}
/>
/>
);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/components/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Row(props) {
onMove,
} = props;

const items = columns.map((column, index) => {
const items = columns.map((column, index) => { // eslint-disable-line arrow-body-style
return (
<Column
key={index}
Expand Down
18 changes: 9 additions & 9 deletions lib/components/WidgetFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ const cardTarget = {

if (monitor.getItem().columnIndex === columnIndex) {
const newLayout = sortWidget(layout, {
rowIndex: rowIndex,
columnIndex: columnIndex,
rowIndex,
columnIndex,
widgetIndex: dragIndex,
}, {
rowIndex: rowIndex,
columnIndex: columnIndex,
rowIndex,
columnIndex,
widgetIndex: hoverIndex,
}, monitor.getItem().widgetName);
}, monitor.getItem().widgetName);

props.onMove(newLayout);

// Note: we're mutating the monitor item here!
// Generally it's better to avoid mutations,
// but it's good here for the sake of performance
// to avoid expensive index searches.
monitor.getItem().widgetIndex = hoverIndex;
monitor.getItem().widgetIndex = hoverIndex; // eslint-disable-line no-param-reassign
}
},
};
Expand All @@ -92,7 +92,7 @@ const cardTarget = {
connectDragSource: connect.dragSource(),
isDragging: monitor.isDragging(),
}))
class WidgetFrame extends Component {
class WidgetFrame extends Component {
render() {
const {
frameComponent,
Expand All @@ -108,7 +108,7 @@ class WidgetFrame extends Component {

if (frameComponent) {
// if user provided a custom frame, use it
selected = createElement(frameComponent, { children, editable, title, onRemove: this.remove });
selected = createElement(frameComponent, { children, editable, title, onRemove: this.remove }); // eslint-disable-line max-len
} else {
// else use the default frame
selected = (
Expand All @@ -130,7 +130,7 @@ class WidgetFrame extends Component {

remove = () => {
const { layout, rowIndex, columnIndex, widgetIndex } = this.props;
const newLayout = removeWidget(layout, rowIndex, columnIndex, widgetIndex);
const newLayout = removeWidget(layout, rowIndex, columnIndex, widgetIndex);
this.props.onRemove(newLayout);
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/components/Widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import WidgetFrame from './WidgetFrame';
/**
* Component that renders the widget which belongs to a column.
*/
const Widgets = ({widgets, widgetTypes, onRemove, layout, columnIndex, rowIndex, editable, frameComponent, onMove}) => {
let createdWidgets = widgets.map((widget, index)=> {
/* eslint max-len: "off" */
const Widgets = ({ widgets, widgetTypes, onRemove, layout, columnIndex, rowIndex, editable, frameComponent, onMove }) => {
let createdWidgets = widgets.map((widget, index) => { // eslint-disable-line arrow-body-style
return (
<WidgetFrame
key={index}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as default } from './components/Dashboard';
export { default as default } from './components/Dashboard';
export { addWidget } from './util';
1 change: 1 addition & 0 deletions lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function removeWidget(layout, rowIndex, columnIndex, widgetIndex) {
* Moves a widget from column to column.
*/
export function moveWidget(layout, initialLocation, destination, widgetName) {
/* eslint max-len: "off" */
const removedLayout = removeWidget(layout, initialLocation.rowIndex, initialLocation.columnIndex, initialLocation.widgetIndex);
const movedLayout = addWidget(removedLayout, destination.rowIndex, destination.columnIndex, widgetName);
return movedLayout;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"cross-env": "^1.0.7",
"css-loader": "^0.23.0",
"cz-conventional-changelog": "^1.1.5",
"enzyme": "^2.2.0",
"enzyme": "^2.8.2",
"eslint": "2.5.2",
"eslint-config-airbnb": "^6.2.0",
"eslint-loader": "^1.1.1",
Expand Down
24 changes: 12 additions & 12 deletions sample/components/AddWidgetDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-modal';

const AddWidgetDialog = ({ widgets, isModalOpen, onRequestClose, onWidgetSelect}) => {
const widgetItems = Object.keys(widgets).map(widget => {
return (
<div className="list-group">
<a href="#" className="list-group-item" onClick={() => onWidgetSelect(widget)}>
<h6 className="list-group-item-heading">{widgets[widget].title}</h6>
</a>
</div>
);
});
const AddWidgetDialog = ({ widgets, isModalOpen, onRequestClose, onWidgetSelect }) => {
const widgetItems = Object.keys(widgets).map(widget => (
<div className="list-group">
<a href="#" className="list-group-item" onClick={() => onWidgetSelect(widget)}>
<h6 className="list-group-item-heading">{widgets[widget].title}</h6>
</a>
</div>
));
return (
<Modal
className="Modal__Bootstrap modal-dialog"
isOpen={isModalOpen}>
isOpen={isModalOpen}
>
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" onClick={onRequestClose}>
Expand Down
17 changes: 8 additions & 9 deletions sample/components/Container.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

const Container = ({children}) => {
return (
<div className="container body">
<div className="main_container">
{children}
</div>
const Container = ({ children }) => (
<div className="container body">
<div className="main_container">
{children}
</div>
);
};
</div>
);

Container.propTypes = {
children: PropTypes.array,
Expand Down
15 changes: 7 additions & 8 deletions sample/components/CustomAddWidgetButton.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

const CustomAddWidgetButton = ({text, onClick}) => {
return (
<div>
<button onClick={onClick}>{text}</button>
</div>
);
};
const CustomAddWidgetButton = ({ text, onClick }) => (
<div>
<button onClick={onClick}>{text}</button>
</div>
);

CustomAddWidgetButton.propTypes = {
text: PropTypes.string,
Expand Down
23 changes: 11 additions & 12 deletions sample/components/EditBar.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

const EditBar = ({ onEdit }) => {
return (
<div className="row edit-bar">
<div className="col-sm-12 text-right">
<button type="button" className="btn btn-default btn-xs" onClick={onEdit}>
<span className="glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit
</button>
</div>
const EditBar = ({ onEdit }) => (
<div className="row edit-bar">
<div className="col-sm-12 text-right">
<button type="button" className="btn btn-default btn-xs" onClick={onEdit}>
<span className="glyphicon glyphicon-pencil" aria-hidden="true"></span>
Edit
</button>
</div>
);
};
</div>
);

EditBar.propTypes = {
onEdit: PropTypes.func,
Expand Down
20 changes: 9 additions & 11 deletions sample/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React from 'react';

const Header = () => {
return (
<div className="top_nav">
<div className="nav_menu">
<nav className="dashboardHeader">
<img src={require('../assets/Dazzle.png')} height="40px"/>
</nav>
</div>
</div>
);
};
const Header = () => (
<div className="top_nav">
<div className="nav_menu">
<nav className="dashboardHeader">
<img src={require('../assets/Dazzle.png')} height="40px" />
</nav>
</div>
</div>
);

export default Header;
Loading

0 comments on commit be0cc2a

Please sign in to comment.