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/21 13:03:17 UTC

[GitHub] [superset] ad-m commented on a change in pull request #18121: refactor: migrate QueryAndSaveBtns to TypeScript and add stories

ad-m commented on a change in pull request #18121:
URL: https://github.com/apache/superset/pull/18121#discussion_r789640253



##########
File path: superset-frontend/src/explore/components/QueryAndSaveBtns.tsx
##########
@@ -17,42 +17,37 @@
  * under the License.
  */
 import React from 'react';
-import PropTypes from 'prop-types';
 import ButtonGroup from 'src/components/ButtonGroup';
 import { t, useTheme } from '@superset-ui/core';
 
 import { Tooltip } from 'src/components/Tooltip';
-import Button from 'src/components/Button';
+import Button, { ButtonStyle, OnClickHandler } from 'src/components/Button';
 
-const propTypes = {
-  canAdd: PropTypes.bool.isRequired,
-  onQuery: PropTypes.func.isRequired,
-  onSave: PropTypes.func,
-  onStop: PropTypes.func,
-  loading: PropTypes.bool,
-  chartIsStale: PropTypes.bool,
-  errorMessage: PropTypes.node,
+export type QueryAndSaveBtnsProps = {
+  canAdd: boolean;
+  onQuery: OnClickHandler;
+  onSave: OnClickHandler;
+  onStop: OnClickHandler;
+  loading?: boolean;
+  chartIsStale?: boolean;
+  errorMessage: React.ReactElement | undefined;
 };
 
-const defaultProps = {
-  onStop: () => {},
-  onSave: () => {},
-};
-
-export default function QueryAndSaveBtns({
-  canAdd,
-  onQuery,
-  onSave,
-  onStop,
-  loading,
-  chartIsStale,
-  errorMessage,
-}) {
-  let qryButtonStyle = 'tertiary';
+export default function QueryAndSaveBtns(props: QueryAndSaveBtnsProps) {
+  const {
+    canAdd,
+    onQuery = () => {},
+    onSave = () => {},
+    onStop = () => {},
+    loading,
+    chartIsStale,
+    errorMessage,
+  } = props;
+  let qryButtonStyle = 'tertiary' as ButtonStyle;

Review comment:
       Great idea. That notation in that situation is better. I applied that as a separate commit (Is squash necessary from me?).




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