diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index e990ace4abc9c..9198601ae685d 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -170,7 +170,7 @@ class Header extends React.PureComponent { componentDidMount() { const { refreshFrequency, user, dashboardInfo } = this.props; this.startPeriodicRender(refreshFrequency * 1000); - if (user && isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) { + if (this.canAddReports()) { // this is in case there is an anonymous user. this.props.fetchUISpecificReport( user.userId, @@ -197,7 +197,10 @@ class Header extends React.PureComponent { ) { this.props.setMaxUndoHistoryExceeded(); } - if (user && nextProps.dashboardInfo.id !== this.props.dashboardInfo.id) { + if ( + this.canAddReports() && + nextProps.dashboardInfo.id !== this.props.dashboardInfo.id + ) { // this is in case there is an anonymous user. this.props.fetchUISpecificReport( user.userId, @@ -399,32 +402,31 @@ class Header extends React.PureComponent { renderReportModal() { const attachedReportExists = !!Object.keys(this.props.reports).length; - const canAddReports = isFeatureEnabled(FeatureFlag.ALERT_REPORTS); - return ( - (canAddReports || null) && - (attachedReportExists ? ( - - ) : ( - <> - - - - - )) + return attachedReportExists ? ( + + ) : ( + <> + + + + ); } canAddReports() { + if (!isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) { + return false; + } const { user } = this.props; if (!user) { // this is in the case that there is an anonymous user. diff --git a/superset-frontend/src/explore/components/ExploreChartHeader.jsx b/superset-frontend/src/explore/components/ExploreChartHeader.jsx index 57632d4b9594a..5d057cabaec76 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader.jsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader.jsx @@ -117,8 +117,8 @@ export class ExploreChartHeader extends React.PureComponent { } componentDidMount() { - const { user, chart } = this.props; - if (user && isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) { + if (this.canAddReports()) { + const { user, chart } = this.props; // this is in the case that there is an anonymous user. this.props.fetchUISpecificReport( user.userId, @@ -165,33 +165,32 @@ export class ExploreChartHeader extends React.PureComponent { renderReportModal() { const attachedReportExists = !!Object.keys(this.props.reports).length; - const canAddReports = isFeatureEnabled(FeatureFlag.ALERT_REPORTS); - return ( - (canAddReports || null) && - (attachedReportExists ? ( - - ) : ( - <> - - - - - )) + return attachedReportExists ? ( + + ) : ( + <> + + + + ); } canAddReports() { + if (!isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) { + return false; + } const { user } = this.props; if (!user) { // this is in the case that there is an anonymous user.