diff --git a/src/components/DashboardEditor/DashboardEditor.jsx b/src/components/DashboardEditor/DashboardEditor.jsx
index d4db383267..b4a6240eed 100644
--- a/src/components/DashboardEditor/DashboardEditor.jsx
+++ b/src/components/DashboardEditor/DashboardEditor.jsx
@@ -14,6 +14,7 @@ const defaultProps = {
layouts: {},
},
renderHeader: null,
+ renderCardPreview: null,
};
const propTypes = {
@@ -21,9 +22,11 @@ const propTypes = {
initialValue: PropTypes.array, // eslint-disable-line react/forbid-prop-types
/** if provided, renders header content above preview */
renderHeader: PropTypes.func,
+ /** if provided, is used to render cards in dashboard */
+ renderCardPreview: PropTypes.func,
};
-const DashboardEditor = ({ initialValue, renderHeader }) => {
+const DashboardEditor = ({ initialValue, renderHeader, renderCardPreview }) => {
const baseClassName = `${iotPrefix}--dashboard-editor`;
// show the gallery if no card is being edited
@@ -58,25 +61,29 @@ const DashboardEditor = ({ initialValue, renderHeader }) => {
})
}
>
- {dashboardData.cards.map(i => (
-
{JSON.stringify(dashboardData, null, 4)}diff --git a/src/components/DashboardEditor/DashboardEditor.story.jsx b/src/components/DashboardEditor/DashboardEditor.story.jsx index 39531936da..94e80df65a 100644 --- a/src/components/DashboardEditor/DashboardEditor.story.jsx +++ b/src/components/DashboardEditor/DashboardEditor.story.jsx @@ -3,7 +3,8 @@ import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { withKnobs, object } from '@storybook/addon-knobs'; -import { PageTitleBar, Button } from '../../index'; +import { PageTitleBar, Button, Card } from '../../index'; +import { CARD_ACTIONS } from '../../constants/LayoutConstants'; import DashboardEditor from './DashboardEditor'; @@ -20,4 +21,35 @@ storiesOf('Watson IoT Experimental/DashboardEditor', module) )} /> + )) + .add('custom card preview renderer', () => ( +