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

 ##########
 File path: superset/assets/javascripts/dashboard/components/GridCell.jsx
 ##########
 @@ -0,0 +1,108 @@
+/* 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="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)}
+          />
+        </div>
+        <div
+          className="slice_description bs-callout bs-callout-default"
+          style={this.props.isExpanded ? {} : { display: 'none' }}
+          ref={this.getDescriptionId(slice)}
+          dangerouslySetInnerHTML={{ __html: slice.description_markeddown }}
+        />
+        <div className="row chart-container">
+          <input type="hidden" value="false" />
+          <div
+            id={'token_' + slice.slice_id}
+            className={`token col-md-12 ${this.props.isLoading ? 'is-loading' 
: ''}`}
+          >
+            <ChartContainer
 
 Review comment:
   Somewhat; if the store is injected via context, then the chart component can 
use the same global store, which can vary across apps - it definitely means, 
however, that you can't statically import the store in the leaves.

----------------------------------------------------------------
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