williaster commented on a change in pull request #3581: Dashboard refactory
URL: 
https://github.com/apache/incubator-superset/pull/3581#discussion_r147905767
 
 

 ##########
 File path: superset/assets/javascripts/dashboard/components/GridCell.jsx
 ##########
 @@ -0,0 +1,106 @@
+/* eslint-disable react/no-danger */
+import React from 'react';
+import PropTypes from 'prop-types';
+
+import SliceHeader from './SliceHeader';
+import ChartContainer from '../../chart/ChartContainer';
+
+import '../../../stylesheets/dashboard.css';
+
+const propTypes = {
+  timeout: PropTypes.number,
+  datasource: PropTypes.object,
+  isLoading: PropTypes.bool,
+  isExpanded: PropTypes.bool,
+  widgetHeight: PropTypes.number,
+  widgetWidth: PropTypes.number,
+  fetchSlice: PropTypes.func,
+  removeSlice: PropTypes.func.isRequired,
+  updateSliceName: PropTypes.func,
+  toggleExpandSlice: PropTypes.func,
+  slice: PropTypes.object,
+  chartKey: PropTypes.string,
+  formData: PropTypes.object,
+  filters: PropTypes.object,
+  addFilter: PropTypes.func,
+  clearFilter: PropTypes.func,
+  removeFilter: PropTypes.func,
+  exploreChartUrl: PropTypes.string,
+  exportCSVUrl: PropTypes.string,
+};
+
+class GridCell extends React.PureComponent {
+  getDescriptionId(slice) {
+    return 'description_' + slice.slice_id;
+  }
+
+  getHeaderId(slice) {
+    return 'header_' + slice.slice_id;
+  }
+
+  width() {
+    return this.props.widgetWidth - 10;
+  }
+
+  height(slice) {
+    const widgetHeight = this.props.widgetHeight;
+    const headerId = this.getHeaderId(slice);
+    const descriptionId = this.getDescriptionId(slice);
+    const headerHeight = this.refs[headerId] ? 
this.refs[headerId].offsetHeight : 30;
+    let descriptionHeight = 0;
+    if (this.props.isExpanded && this.refs[descriptionId]) {
+      descriptionHeight = this.refs[descriptionId].offsetHeight + 10;
+    }
+    return widgetHeight - headerHeight - descriptionHeight;
+  }
+
+  render() {
+    const slice = this.props.slice;
+    return (
+      <div
+        className={this.props.isLoading ? 'slice-cell-highlight' : 
'slice-cell'}
+        id={`${slice.slice_id}-cell`}
+      >
+        <div ref={this.getHeaderId(slice)}>
+          <SliceHeader
+            slice={slice}
+            exploreChartUrl={this.props.exploreChartUrl}
+            exportCSVUrl={this.props.exportCSVUrl}
+            isExpanded={this.props.isExpanded}
+            removeSlice={this.props.removeSlice}
+            updateSliceName={this.props.updateSliceName}
+            toggleExpandSlice={this.props.toggleExpandSlice}
+            forceRefresh={() => this.props.fetchSlice(true)}
 
 Review comment:
   shouldn't define new funcs in the render if possible

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to