This is an automated email from the ASF dual-hosted git repository. villebro pushed a commit to branch 1.3 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 0e7b22091737e3929c37b107ee65fd80a53940c6 Author: Elizabeth Thompson <[email protected]> AuthorDate: Fri Aug 13 20:41:03 2021 -0700 check roles before fetching reports (#16260) (cherry picked from commit 3709131089ba866de534c0f3765a8e1123df0204) --- .../src/dashboard/components/Header/index.jsx | 50 +++++++++++----------- .../src/explore/components/ExploreChartHeader.jsx | 49 +++++++++++---------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index e990ace..9198601 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 ? ( - <HeaderReportActionsDropdown - showReportModal={this.showReportModal} - toggleActive={this.props.toggleActive} - deleteActiveReport={this.props.deleteActiveReport} - /> - ) : ( - <> - <span - role="button" - title={t('Schedule email report')} - tabIndex={0} - className="action-button" - onClick={this.showReportModal} - > - <Icons.Calendar /> - </span> - </> - )) + return attachedReportExists ? ( + <HeaderReportActionsDropdown + showReportModal={this.showReportModal} + toggleActive={this.props.toggleActive} + deleteActiveReport={this.props.deleteActiveReport} + /> + ) : ( + <> + <span + role="button" + title={t('Schedule email report')} + tabIndex={0} + className="action-button" + onClick={this.showReportModal} + > + <Icons.Calendar /> + </span> + </> ); } 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 57632d4..5d057ca 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 ? ( - <HeaderReportActionsDropdown - showReportModal={this.showReportModal} - hideReportModal={this.hideReportModal} - toggleActive={this.props.toggleActive} - deleteActiveReport={this.props.deleteActiveReport} - /> - ) : ( - <> - <span - role="button" - title={t('Schedule email report')} - tabIndex={0} - className="action-button" - onClick={this.showReportModal} - > - <Icons.Calendar /> - </span> - </> - )) + return attachedReportExists ? ( + <HeaderReportActionsDropdown + showReportModal={this.showReportModal} + hideReportModal={this.hideReportModal} + toggleActive={this.props.toggleActive} + deleteActiveReport={this.props.deleteActiveReport} + /> + ) : ( + <> + <span + role="button" + title={t('Schedule email report')} + tabIndex={0} + className="action-button" + onClick={this.showReportModal} + > + <Icons.Calendar /> + </span> + </> ); } 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.
