From 3c91a23a4d9d72ed2abc037dee226c0d953acb4c Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 22 Jun 2017 13:55:23 -0700 Subject: [PATCH] Make dashboards table into a component --- .../dashboards/components/DashboardsTable.js | 73 +++++++++++++++++++ .../dashboards/containers/DashboardsPage.js | 16 ++-- 2 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 ui/src/dashboards/components/DashboardsTable.js diff --git a/ui/src/dashboards/components/DashboardsTable.js b/ui/src/dashboards/components/DashboardsTable.js new file mode 100644 index 000000000..73a739fcb --- /dev/null +++ b/ui/src/dashboards/components/DashboardsTable.js @@ -0,0 +1,73 @@ +import React, {PropTypes} from 'react' +import {Link} from 'react-router' +import _ from 'lodash' + +import DeleteConfirmTableCell from 'shared/components/DeleteConfirmTableCell' + +const DashboardsTable = ({ + dashboards, + onDeleteDashboard, + onCreateDashboard, + dashboardLink, +}) => { + return dashboards && dashboards.length + ? + + + + + + + + {_.sortBy(dashboards, d => d.name.toLowerCase()).map(dashboard => + + + + + + )} + +
NameTemplate Variables +
+ + {dashboard.name} + + + {dashboard.templates.length + ? dashboard.templates.map(tv => + + {tv.tempVar} + + ) + : + None + } +
+ :
+

+ Looks like you dont have any dashboards +

+ +
+} + +const {func, shape, string} = PropTypes + +DashboardsTable.propTypes = { + dashboards: shape.isRequired, + onDeleteDashboard: func.isRequired, + onCreateDashboard: func.isRequired, + dashboardLink: string.isRequired, +} + +export default DashboardsTable diff --git a/ui/src/dashboards/containers/DashboardsPage.js b/ui/src/dashboards/containers/DashboardsPage.js index 0ccf2cf22..d58152272 100644 --- a/ui/src/dashboards/containers/DashboardsPage.js +++ b/ui/src/dashboards/containers/DashboardsPage.js @@ -1,12 +1,10 @@ import React, {PropTypes} from 'react' -import {Link, withRouter} from 'react-router' +import {withRouter} from 'react-router' import {connect} from 'react-redux' import {bindActionCreators} from 'redux' -import _ from 'lodash' - import DashboardsHeader from 'src/dashboards/components/DashboardsHeader' -import DeleteConfirmTableCell from 'shared/components/DeleteConfirmTableCell' +import DashboardsTable from 'src/dashboards/components/DashboardsTable' import FancyScrollbar from 'shared/components/FancyScrollbar' import {createDashboard} from 'src/dashboards/apis' @@ -79,7 +77,13 @@ const DashboardsPage = React.createClass({
- {dashboards && dashboards.length + + {/* {dashboards && dashboards.length ? @@ -134,7 +138,7 @@ const DashboardsPage = React.createClass({ > Create Dashboard - } + } */}