diff --git a/lib/components/Columns.js b/lib/components/Columns.js
deleted file mode 100644
index 32abde3..0000000
--- a/lib/components/Columns.js
+++ /dev/null
@@ -1,127 +0,0 @@
-import React, { PropTypes } from 'react';
-import Column from './Column';
-import Widgets from './Widgets';
-
-/**
- * Returns a set of columns that belongs to a row.
- */
-function Columns(props) {
- const {
- columns,
- widgets,
- onRemove,
- layout,
- rowIndex,
- editable,
- frameComponent,
- editableColumnClass,
- droppableColumnClass,
- addWidgetComponentText,
- addWidgetComponent,
- onAdd,
- onMove,
- } = props;
-
- const items = columns.map((column, index) => {
- return (
-
-
-
- );
- });
-
- return
{items}
;
-}
-
-Columns.propTypes = {
- /**
- * Columns of the layout.
- */
- columns: PropTypes.array,
-
- /**
- * Widgets that should be used in the dashboard.
- */
- widgets: PropTypes.object,
-
- /**
- * Layout of the dashboard.
- */
- layout: PropTypes.object,
-
- /**
- * Index of the row where this column is in.
- */
- rowIndex: PropTypes.number,
-
- /**
- * Indicates weather the dashboard is in editable mode or not.
- */
- editable: PropTypes.bool,
-
- /**
- * Custom frame that should be used with the widget.
- */
- frameComponent: PropTypes.func,
-
- /**
- * Class to be used for columns in editable mode.
- */
- editableColumnClass: PropTypes.string,
-
- /**
- * CSS class to be used for columns when a widget is droppable.
- */
- droppableColumnClass: PropTypes.string,
-
- /**
- * Custom AddWidget component.
- */
- addWidgetComponent: PropTypes.func,
-
- /**
- * Text that should be displyed in the AddWidget component.
- */
- addWidgetComponentText: PropTypes.string,
-
- /**
- * Method that should be called when a component is added.
- */
- onAdd: PropTypes.func,
-
- /**
- * Method that should be called when a component is removed.
- */
- onRemove: PropTypes.func,
-
- /**
- * Method that should be called when a widget is moved.
- */
- onMove: PropTypes.func,
-};
-
-export default Columns;
diff --git a/lib/components/LayoutRenderer.js b/lib/components/LayoutRenderer.js
index 5754135..4b2a36c 100644
--- a/lib/components/LayoutRenderer.js
+++ b/lib/components/LayoutRenderer.js
@@ -1,6 +1,5 @@
import React, { PropTypes } from 'react';
import Row from './Row';
-import Columns from './Columns';
/**
* Renders the row, column layout based on the layout provided to the dashboard.
@@ -23,8 +22,9 @@ const LayoutRenderer = (props) => {
let rows = layout.rows.map((row, rowIndex) => {
return (
-
- {
addWidgetComponentText={addWidgetComponentText}
addWidgetComponent={addWidgetComponent}
/>
-
);
});
diff --git a/lib/components/Row.js b/lib/components/Row.js
index 43b4a3c..fdd3972 100644
--- a/lib/components/Row.js
+++ b/lib/components/Row.js
@@ -1,15 +1,66 @@
import React, { PropTypes } from 'react';
+import Column from './Column';
+import Widgets from './Widgets';
/**
- * Represents a row in the grid system.
+ * Returns a set of columns that belongs to a row.
*/
-const Row = ({ rowClass, children }) => {
+function Row(props) {
+ const {
+ rowClass,
+ columns,
+ widgets,
+ onRemove,
+ layout,
+ rowIndex,
+ editable,
+ frameComponent,
+ editableColumnClass,
+ droppableColumnClass,
+ addWidgetComponentText,
+ addWidgetComponent,
+ onAdd,
+ onMove,
+ } = props;
+
+ const items = columns.map((column, index) => {
+ return (
+
+
+
+ );
+ });
+
return (
- {children}
+ {items}
);
-};
+}
Row.propTypes = {
/**
@@ -18,9 +69,69 @@ Row.propTypes = {
rowClass: PropTypes.string,
/**
- * Children of the row component.
+ * Columns of the layout.
+ */
+ columns: PropTypes.array,
+
+ /**
+ * Widgets that should be used in the dashboard.
+ */
+ widgets: PropTypes.object,
+
+ /**
+ * Layout of the dashboard.
+ */
+ layout: PropTypes.object,
+
+ /**
+ * Index of the row where this column is in.
+ */
+ rowIndex: PropTypes.number,
+
+ /**
+ * Indicates weather the dashboard is in editable mode or not.
+ */
+ editable: PropTypes.bool,
+
+ /**
+ * Custom frame that should be used with the widget.
+ */
+ frameComponent: PropTypes.func,
+
+ /**
+ * Class to be used for columns in editable mode.
+ */
+ editableColumnClass: PropTypes.string,
+
+ /**
+ * CSS class to be used for columns when a widget is droppable.
+ */
+ droppableColumnClass: PropTypes.string,
+
+ /**
+ * Custom AddWidget component.
+ */
+ addWidgetComponent: PropTypes.func,
+
+ /**
+ * Text that should be displyed in the AddWidget component.
+ */
+ addWidgetComponentText: PropTypes.string,
+
+ /**
+ * Method that should be called when a component is added.
+ */
+ onAdd: PropTypes.func,
+
+ /**
+ * Method that should be called when a component is removed.
+ */
+ onRemove: PropTypes.func,
+
+ /**
+ * Method that should be called when a widget is moved.
*/
- children: PropTypes.node,
+ onMove: PropTypes.func,
};
Row.defaultProps = {
diff --git a/test/components/Columns.spec.js b/test/components/Columns.spec.js
deleted file mode 100644
index ce50bf7..0000000
--- a/test/components/Columns.spec.js
+++ /dev/null
@@ -1,92 +0,0 @@
-import { expect } from 'chai';
-import React from 'react';
-import { mount } from 'enzyme';
-import Column from '../../lib/components/Column';
-import Columns from '../../lib/components/Columns';
-import Widgets from '../../lib/components/Widgets';
-import TestComponent from '../fake/TestComponent';
-import TestCustomFrame from '../fake/TestCustomFrame';
-import ContainerWithDndContext from '../fake/ContainerWithDndContext';
-
-function setup() {
- const columns = [{
- className: 'col-md-4 col-sm-6 col-xs-6',
- widgets: [{key: 'HelloWorld'}],
- }, {
- className: 'col-md-4 col-sm-6 col-xs-6',
- widgets: [{key: 'HelloWorld'}],
- }, {
- className: 'col-md-4 col-sm-6 col-xs-6',
- widgets: [{key: 'HelloWorld'}],
- }];
-
- const widgets = {
- HelloWorld: {
- type: TestComponent,
- title: 'Sample Hello World App',
- },
- };
-
- return {
- columns,
- widgets,
- onAdd: () => {},
- onRemove: () => {},
- layout: {},
- rowIndex: 1,
- };
-}
-
-describe('', () => {
- it('Should render the correct number of ', () => {
- const { columns, widgets } = setup();
- const component = mount();
- expect(component.find(Column)).to.have.length(3);
- });
-
- it('Should pass the required properties to ', () => {
- const { columns, widgets, onAdd, layout, rowIndex } = setup();
- const component = mount(
-
-
-
- );
- expect(component.find(Column).first().prop('className')).to.equal('col-md-4 col-sm-6 col-xs-6');
- expect(component.find(Column).first().prop('onAdd')).to.equal(onAdd);
- expect(component.find(Column).first().prop('layout')).to.equal(layout);
- expect(component.find(Column).first().prop('rowIndex')).to.equal(rowIndex);
- expect(component.find(Column).first().prop('columnIndex')).to.equal(0);
- expect(component.find(Column).first().prop('editable')).to.equal(true);
- });
-
- it('Should pass the required properties to ', () => {
- const { columns, widgets, onAdd, onRemove, layout, rowIndex } = setup();
- const component = mount(
-
-
-
- );
- expect(component.find(Widgets).first().prop('widgets')).to.equal(columns[0].widgets);
- expect(component.find(Widgets).first().prop('widgetTypes')).to.equal(widgets);
- expect(component.find(Widgets).first().prop('onRemove')).to.equal(onRemove);
- expect(component.find(Widgets).first().prop('layout')).to.equal(layout);
- expect(component.find(Widgets).first().prop('rowIndex')).to.equal(rowIndex);
- expect(component.find(Widgets).first().prop('columnIndex')).to.equal(0);
- expect(component.find(Widgets).first().prop('editable')).to.equal(true);
- expect(component.find(Widgets).first().prop('frameComponent')).to.equal(TestCustomFrame);
- });
-});
diff --git a/test/components/Row.spec.js b/test/components/Row.spec.js
index d0b1184..d79059d 100644
--- a/test/components/Row.spec.js
+++ b/test/components/Row.spec.js
@@ -1,16 +1,109 @@
import { expect } from 'chai';
import React from 'react';
-import { shallow } from 'enzyme';
+import { mount, shallow } from 'enzyme';
+import Column from '../../lib/components/Column';
import Row from '../../lib/components/Row';
+import Widgets from '../../lib/components/Widgets';
+import TestComponent from '../fake/TestComponent';
+import TestCustomFrame from '../fake/TestCustomFrame';
+import ContainerWithDndContext from '../fake/ContainerWithDndContext';
+
+function setup() {
+ const columns = [{
+ className: 'col-md-4 col-sm-6 col-xs-6',
+ widgets: [{key: 'HelloWorld'}],
+ }, {
+ className: 'col-md-4 col-sm-6 col-xs-6',
+ widgets: [{key: 'HelloWorld'}],
+ }, {
+ className: 'col-md-4 col-sm-6 col-xs-6',
+ widgets: [{key: 'HelloWorld'}],
+ }];
+
+ const widgets = {
+ HelloWorld: {
+ type: TestComponent,
+ title: 'Sample Hello World App',
+ },
+ };
+
+ return {
+ columns,
+ widgets,
+ onAdd: () => {},
+ onRemove: () => {},
+ layout: {},
+ rowIndex: 1,
+ };
+}
describe('
', () => {
- it('Should render the children', () => {
- const component = shallow(HelloWorld
);
- expect(component.contains(HelloWorld
)).to.equal(true);
+ it('Should render the correct number of ', () => {
+ const { columns, widgets } = setup();
+ const component = mount(
);
+ expect(component.find(Column)).to.have.length(3);
});
it('Should have the row class rendered', () => {
- const component = shallow(
);
+ const { columns, widgets, onAdd, layout, rowIndex } = setup();
+
+ const component = shallow(
+
+ );
expect(component.find('.RowClass')).to.have.length(1);
});
+
+ it('Should pass the required properties to ', () => {
+ const { columns, widgets, onAdd, layout, rowIndex } = setup();
+ const component = mount(
+
+
+
+ );
+ expect(component.find(Column).first().prop('className')).to.equal('col-md-4 col-sm-6 col-xs-6');
+ expect(component.find(Column).first().prop('onAdd')).to.equal(onAdd);
+ expect(component.find(Column).first().prop('layout')).to.equal(layout);
+ expect(component.find(Column).first().prop('rowIndex')).to.equal(rowIndex);
+ expect(component.find(Column).first().prop('columnIndex')).to.equal(0);
+ expect(component.find(Column).first().prop('editable')).to.equal(true);
+ });
+
+ it('Should pass the required properties to ', () => {
+ const { columns, widgets, onAdd, onRemove, layout, rowIndex } = setup();
+ const component = mount(
+
+
+
+ );
+ expect(component.find(Widgets).first().prop('widgets')).to.equal(columns[0].widgets);
+ expect(component.find(Widgets).first().prop('widgetTypes')).to.equal(widgets);
+ expect(component.find(Widgets).first().prop('onRemove')).to.equal(onRemove);
+ expect(component.find(Widgets).first().prop('layout')).to.equal(layout);
+ expect(component.find(Widgets).first().prop('rowIndex')).to.equal(rowIndex);
+ expect(component.find(Widgets).first().prop('columnIndex')).to.equal(0);
+ expect(component.find(Widgets).first().prop('editable')).to.equal(true);
+ expect(component.find(Widgets).first().prop('frameComponent')).to.equal(TestCustomFrame);
+ });
});