kgabryje commented on code in PR #30568:
URL: https://github.com/apache/superset/pull/30568#discussion_r1806739307


##########
superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.tsx:
##########
@@ -35,97 +34,60 @@ import FilterScopeModal from 
'src/dashboard/components/filterscope/FilterScopeMo
 import getDashboardUrl from 'src/dashboard/util/getDashboardUrl';
 import { getActiveFilters } from 'src/dashboard/util/activeDashboardFilters';
 import { getUrlParam } from 'src/utils/urlUtils';
-import { MenuKeys } from 'src/dashboard/types';
+import { MenuKeys, RootState } from 'src/dashboard/types';
+import { HeaderDropdownProps } from 'src/dashboard/components/Header/types';
 
-const propTypes = {
-  addSuccessToast: PropTypes.func.isRequired,
-  addDangerToast: PropTypes.func.isRequired,
-  dashboardInfo: PropTypes.object.isRequired,
-  dashboardId: PropTypes.number,
-  dashboardTitle: PropTypes.string,
-  dataMask: PropTypes.object.isRequired,
-  customCss: PropTypes.string,
-  colorNamespace: PropTypes.string,
-  colorScheme: PropTypes.string,
-  directPathToChild: PropTypes.array,
-  onChange: PropTypes.func.isRequired,
-  updateCss: PropTypes.func.isRequired,
-  forceRefreshAllCharts: PropTypes.func.isRequired,
-  refreshFrequency: PropTypes.number,
-  shouldPersistRefreshFrequency: PropTypes.bool.isRequired,
-  setRefreshFrequency: PropTypes.func.isRequired,
-  startPeriodicRender: PropTypes.func.isRequired,
-  editMode: PropTypes.bool.isRequired,
-  userCanEdit: PropTypes.bool,
-  userCanShare: PropTypes.bool,
-  userCanSave: PropTypes.bool,
-  userCanCurate: PropTypes.bool.isRequired,
-  isLoading: PropTypes.bool.isRequired,
-  layout: PropTypes.object.isRequired,
-  expandedSlices: PropTypes.object,
-  onSave: PropTypes.func.isRequired,
-  showPropertiesModal: PropTypes.func.isRequired,
-  manageEmbedded: PropTypes.func.isRequired,
-  logEvent: PropTypes.func,
-  refreshLimit: PropTypes.number,
-  refreshWarning: PropTypes.string,
-  lastModifiedTime: PropTypes.number.isRequired,
-};
-
-const defaultProps = {
-  colorNamespace: undefined,
-  colorScheme: undefined,
-  refreshLimit: 0,
-  refreshWarning: null,
-};
-
-const mapStateToProps = state => ({
+const mapStateToProps = (state: RootState) => ({
   directPathToChild: state.dashboardState.directPathToChild,
 });
 
-export class HeaderActionsDropdown extends PureComponent {
-  static discardChanges() {
-    window.location.reload();
-  }
+interface HeaderActionsDropdownState {
+  css: string;
+  showReportSubMenu: boolean | null;
+}
 
-  constructor(props) {
+export class HeaderActionsDropdown extends PureComponent<
+  HeaderDropdownProps,
+  HeaderActionsDropdownState
+> {
+  static defaultProps = {
+    colorNamespace: undefined,
+    colorScheme: undefined,
+    refreshLimit: 0,
+    refreshWarning: null,
+  };
+
+  constructor(props: HeaderDropdownProps) {
     super(props);
     this.state = {
-      css: props.customCss,
+      css: props.customCss || '',
       showReportSubMenu: null,
     };
-
-    this.changeCss = this.changeCss.bind(this);
-    this.changeRefreshInterval = this.changeRefreshInterval.bind(this);
-    this.handleMenuClick = this.handleMenuClick.bind(this);
-    this.setShowReportSubMenu = this.setShowReportSubMenu.bind(this);
   }
 
-  UNSAFE_componentWillReceiveProps(nextProps) {
+  UNSAFE_componentWillReceiveProps(nextProps: HeaderDropdownProps) {
     if (this.props.customCss !== nextProps.customCss) {
       this.setState({ css: nextProps.customCss }, () => {
         injectCustomCss(nextProps.customCss);
       });
     }
   }
 
-  setShowReportSubMenu(show) {
-    this.setState({
-      showReportSubMenu: show,
-    });
-  }
+  setShowReportSubMenu = (show: boolean) => {
+    this.setState({ showReportSubMenu: show });
+  };
 
-  changeCss(css) {
+  changeCss = (css: string) => {
     this.props.onChange();
     this.props.updateCss(css);
-  }
+  };
 
-  changeRefreshInterval(refreshInterval, isPersistent) {
+  changeRefreshInterval = (refreshInterval: number, isPersistent: boolean) => {
     this.props.setRefreshFrequency(refreshInterval, isPersistent);
     this.props.startPeriodicRender(refreshInterval * 1000);
-  }
+  };
 
-  handleMenuClick({ key }) {
+  handleMenuClick = ({ key }: Record<string, any>) => {

Review Comment:
   nit: shouldn't the type here be sth like `{ key: MenuKeys }`?



-- 
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-unsubscr...@superset.apache.org

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


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

Reply via email to