From 403f063ae95f673f83ee449a027872cfff773eb1 Mon Sep 17 00:00:00 2001 From: Grace Guo Date: Fri, 10 Nov 2017 16:11:50 -0800 Subject: [PATCH] [Dashboard bug] Fix Cache status and dttm information display for each slice --- .../dashboard/components/GridCell.jsx | 9 ++- .../dashboard/components/GridLayout.jsx | 73 ++++++++++--------- .../dashboard/components/SliceHeader.jsx | 6 +- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/superset/assets/javascripts/dashboard/components/GridCell.jsx b/superset/assets/javascripts/dashboard/components/GridCell.jsx index 1a59a92dd69d6..26d8eeb6eadc4 100644 --- a/superset/assets/javascripts/dashboard/components/GridCell.jsx +++ b/superset/assets/javascripts/dashboard/components/GridCell.jsx @@ -11,6 +11,8 @@ const propTypes = { timeout: PropTypes.number, datasource: PropTypes.object, isLoading: PropTypes.bool, + isCached: PropTypes.bool, + cachedDttm: PropTypes.number, isExpanded: PropTypes.bool, widgetHeight: PropTypes.number, widgetWidth: PropTypes.number, @@ -78,8 +80,9 @@ class GridCell extends React.PureComponent { render() { const { - exploreChartUrl, exportCSVUrl, isExpanded, isLoading, removeSlice, updateSliceName, - toggleExpandSlice, forceRefresh, chartKey, slice, datasource, formData, timeout, + exploreChartUrl, exportCSVUrl, isExpanded, isLoading, isCached, cachedDttm, + removeSlice, updateSliceName, toggleExpandSlice, forceRefresh, + chartKey, slice, datasource, formData, timeout, } = this.props; return (
{ + const chartKey = `slice_${slice.slice_id}`; + const currentChart = this.props.charts[chartKey]; + const queryResponse = currentChart.queryResponse || {}; + return ( +
+ +
); + }); + return ( - {this.props.dashboard.slices.map(slice => ( -
- -
- ))} + {cells}
); } diff --git a/superset/assets/javascripts/dashboard/components/SliceHeader.jsx b/superset/assets/javascripts/dashboard/components/SliceHeader.jsx index d1a2d9ec94274..8360017d44fa2 100644 --- a/superset/assets/javascripts/dashboard/components/SliceHeader.jsx +++ b/superset/assets/javascripts/dashboard/components/SliceHeader.jsx @@ -11,6 +11,8 @@ const propTypes = { exploreChartUrl: PropTypes.string, exportCSVUrl: PropTypes.string, isExpanded: PropTypes.bool, + isCached: PropTypes.bool, + cachedDttm: PropTypes.number, formDataExtra: PropTypes.object, removeSlice: PropTypes.func, updateSliceName: PropTypes.func, @@ -40,9 +42,9 @@ class SliceHeader extends React.PureComponent { render() { const slice = this.props.slice; - const isCached = slice.is_cached; + const isCached = this.props.isCached; const isExpanded = !!this.props.isExpanded; - const cachedWhen = moment.utc(slice.cached_dttm).fromNow(); + const cachedWhen = moment.utc(this.props.cachedDttm).fromNow(); const refreshTooltip = isCached ? t('Served from data cached %s . Click to force refresh.', cachedWhen) : t('Force refresh data');