You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/10 15:43:38 UTC

[GitHub] [superset] geido commented on a change in pull request #17970: refactor(explorechartheader): convert class to functional component

geido commented on a change in pull request #17970:
URL: https://github.com/apache/superset/pull/17970#discussion_r781305078



##########
File path: superset-frontend/src/explore/components/ExploreChartHeader/index.jsx
##########
@@ -248,134 +226,138 @@ export class ExploreChartHeader extends React.PureComponent {
       ),
     );
     return permissions[0].length > 0;
-  }
+  };
 
-  render() {
-    const { user, form_data: formData, slice } = this.props;
-    const {
-      chartStatus,
-      chartUpdateEndTime,
-      chartUpdateStartTime,
-      latestQueryFormData,
-      queriesResponse,
-    } = this.props.chart;
-    // TODO: when will get appropriate design for multi queries use all results and not first only
-    const queryResponse = queriesResponse?.[0];
-    const chartFinished = ['failed', 'rendered', 'success'].includes(
-      this.props.chart.chartStatus,
-    );
-    return (
-      <StyledHeader id="slice-header" className="panel-title-large">
-        <div className="title-panel">
-          {slice?.certified_by && (
-            <>
-              <CertifiedBadge
-                certifiedBy={slice.certified_by}
-                details={slice.certification_details}
-              />{' '}
-            </>
-          )}
-          <EditableTitle
-            title={this.getSliceName()}
-            canEdit={
-              !this.props.slice ||
-              this.props.can_overwrite ||
-              (this.props.slice?.owners || []).includes(
-                this.props?.user?.userId,
-              )
-            }
-            onSaveTitle={this.props.actions.updateChartTitle}
-          />
+  useEffect(() => {
+    const { userId } = user;

Review comment:
       This will probably fail with an anonymous user

##########
File path: superset-frontend/src/explore/components/ExploreChartHeader/index.jsx
##########
@@ -248,134 +226,138 @@ export class ExploreChartHeader extends React.PureComponent {
       ),
     );
     return permissions[0].length > 0;
-  }
+  };
 
-  render() {
-    const { user, form_data: formData, slice } = this.props;
-    const {
-      chartStatus,
-      chartUpdateEndTime,
-      chartUpdateStartTime,
-      latestQueryFormData,
-      queriesResponse,
-    } = this.props.chart;
-    // TODO: when will get appropriate design for multi queries use all results and not first only
-    const queryResponse = queriesResponse?.[0];
-    const chartFinished = ['failed', 'rendered', 'success'].includes(
-      this.props.chart.chartStatus,
-    );
-    return (
-      <StyledHeader id="slice-header" className="panel-title-large">
-        <div className="title-panel">
-          {slice?.certified_by && (
-            <>
-              <CertifiedBadge
-                certifiedBy={slice.certified_by}
-                details={slice.certification_details}
-              />{' '}
-            </>
-          )}
-          <EditableTitle
-            title={this.getSliceName()}
-            canEdit={
-              !this.props.slice ||
-              this.props.can_overwrite ||
-              (this.props.slice?.owners || []).includes(
-                this.props?.user?.userId,
-              )
-            }
-            onSaveTitle={this.props.actions.updateChartTitle}
-          />
+  useEffect(() => {
+    const { userId } = user;
+    const { id } = chart;
 
-          {this.props.slice && (
-            <StyledButtons>
-              {user.userId && (
-                <FaveStar
-                  itemId={this.props.slice.slice_id}
-                  fetchFaveStar={this.props.actions.fetchFaveStar}
-                  saveFaveStar={this.props.actions.saveFaveStar}
-                  isStarred={this.props.isStarred}
-                  showTooltip
-                />
-              )}
-              {this.state.isPropertiesModalOpen && (
-                <PropertiesModal
-                  show={this.state.isPropertiesModalOpen}
-                  onHide={this.closePropertiesModal}
-                  onSave={this.props.sliceUpdated}
-                  slice={this.props.slice}
-                />
-              )}
-              <Tooltip
-                id="edit-desc-tooltip"
-                title={t('Edit chart properties')}
+    if (canAddReports()) {
+      fetchUISpecificReport(userId, 'chart_id', 'charts', id);
+    }
+    if (dashboardId) {
+      fetchChartDashboardData();
+    }
+  }, []);

Review comment:
       It appears that some dependencies might be missing here




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org