etr2460 commented on a change in pull request #11951:
URL:
https://github.com/apache/incubator-superset/pull/11951#discussion_r538733937
##########
File path: superset-frontend/src/dashboard/components/SaveModal.tsx
##########
@@ -69,25 +87,25 @@ class SaveModal extends React.PureComponent {
this.onSave = this.props.onSave.bind(this);
}
- setModalRef(ref) {
+ setModalRef(ref: ModalTrigger | null) {
this.modal = ref;
}
- toggleDuplicateSlices() {
+ toggleDuplicateSlices(val?: boolean | undefined): void {
Review comment:
you don't need the `| undefined` if you already have a `?:`
Although, I wonder why you added an argument here since it seems like the
function doesn't actually use it? Is that because you pass it into a component
that expects a function with this arg?
##########
File path: superset-frontend/src/dashboard/components/SaveModal.tsx
##########
@@ -18,42 +18,60 @@
*/
/* eslint-env browser */
import React from 'react';
-import PropTypes from 'prop-types';
import { FormControl, FormGroup, Radio } from 'react-bootstrap';
import Button from 'src/components/Button';
-import { t, CategoricalColorNamespace } from '@superset-ui/core';
-
-import ModalTrigger from '../../components/ModalTrigger';
-import Checkbox from '../../components/Checkbox';
-import { SAVE_TYPE_OVERWRITE, SAVE_TYPE_NEWDASHBOARD } from
'../util/constants';
-
-const propTypes = {
- addSuccessToast: PropTypes.func.isRequired,
- addDangerToast: PropTypes.func.isRequired,
- dashboardId: PropTypes.number.isRequired,
- dashboardTitle: PropTypes.string.isRequired,
- dashboardInfo: PropTypes.object.isRequired,
- expandedSlices: PropTypes.object.isRequired,
- layout: PropTypes.object.isRequired,
- saveType: PropTypes.oneOf([SAVE_TYPE_OVERWRITE, SAVE_TYPE_NEWDASHBOARD]),
- triggerNode: PropTypes.node.isRequired,
- customCss: PropTypes.string.isRequired,
- colorNamespace: PropTypes.string,
- colorScheme: PropTypes.string,
- onSave: PropTypes.func.isRequired,
- canOverwrite: PropTypes.bool.isRequired,
- refreshFrequency: PropTypes.number.isRequired,
- lastModifiedTime: PropTypes.number.isRequired,
+import { t, CategoricalColorNamespace, JsonResponse } from '@superset-ui/core';
+
+import ModalTrigger from 'src/components/ModalTrigger';
+import Checkbox from 'src/components/Checkbox';
+import {
+ SAVE_TYPE_OVERWRITE,
+ SAVE_TYPE_NEWDASHBOARD,
+} from 'src/dashboard/util/constants';
+
+type SaveType = typeof SAVE_TYPE_OVERWRITE | typeof SAVE_TYPE_NEWDASHBOARD;
+
+type SaveModalProps = {
+ addSuccessToast: (arg: string) => void;
+ addDangerToast: (arg: string) => void;
+ dashboardId: number;
+ dashboardTitle: string;
+ dashboardInfo: Record<string, any>;
+ expandedSlices: object;
Review comment:
Could you update all instances of `object`?
##########
File path: superset-frontend/src/dashboard/components/SaveModal.tsx
##########
@@ -18,42 +18,60 @@
*/
/* eslint-env browser */
import React from 'react';
-import PropTypes from 'prop-types';
import { FormControl, FormGroup, Radio } from 'react-bootstrap';
import Button from 'src/components/Button';
-import { t, CategoricalColorNamespace } from '@superset-ui/core';
-
-import ModalTrigger from '../../components/ModalTrigger';
-import Checkbox from '../../components/Checkbox';
-import { SAVE_TYPE_OVERWRITE, SAVE_TYPE_NEWDASHBOARD } from
'../util/constants';
-
-const propTypes = {
- addSuccessToast: PropTypes.func.isRequired,
- addDangerToast: PropTypes.func.isRequired,
- dashboardId: PropTypes.number.isRequired,
- dashboardTitle: PropTypes.string.isRequired,
- dashboardInfo: PropTypes.object.isRequired,
- expandedSlices: PropTypes.object.isRequired,
- layout: PropTypes.object.isRequired,
- saveType: PropTypes.oneOf([SAVE_TYPE_OVERWRITE, SAVE_TYPE_NEWDASHBOARD]),
- triggerNode: PropTypes.node.isRequired,
- customCss: PropTypes.string.isRequired,
- colorNamespace: PropTypes.string,
- colorScheme: PropTypes.string,
- onSave: PropTypes.func.isRequired,
- canOverwrite: PropTypes.bool.isRequired,
- refreshFrequency: PropTypes.number.isRequired,
- lastModifiedTime: PropTypes.number.isRequired,
+import { t, CategoricalColorNamespace, JsonResponse } from '@superset-ui/core';
+
+import ModalTrigger from 'src/components/ModalTrigger';
+import Checkbox from 'src/components/Checkbox';
+import {
+ SAVE_TYPE_OVERWRITE,
+ SAVE_TYPE_NEWDASHBOARD,
+} from 'src/dashboard/util/constants';
+
+type SaveType = typeof SAVE_TYPE_OVERWRITE | typeof SAVE_TYPE_NEWDASHBOARD;
+
+type SaveModalProps = {
+ addSuccessToast: (arg: string) => void;
+ addDangerToast: (arg: string) => void;
+ dashboardId: number;
+ dashboardTitle: string;
+ dashboardInfo: Record<string, any>;
+ expandedSlices: object;
+ layout: object;
+ saveType: SaveType;
+ triggerNode: JSX.Element;
+ customCss: string;
+ colorNamespace?: string;
+ colorScheme?: string;
+ onSave: (data: any, id: number | string, saveType: SaveType) => void;
+ canOverwrite: boolean;
+ shouldPersistRefreshFrequency: boolean;
+ refreshFrequency: number;
+ lastModifiedTime: number;
+};
+
+type SaveModalState = {
+ saveType: SaveType;
+ newDashName: string;
+ duplicateSlices: boolean;
};
const defaultProps = {
saveType: SAVE_TYPE_OVERWRITE,
colorNamespace: undefined,
colorScheme: undefined,
+ shouldPersistRefreshFrequency: true,
};
-class SaveModal extends React.PureComponent {
- constructor(props) {
+class SaveModal extends React.PureComponent<SaveModalProps, SaveModalState> {
+ static defaultProps = defaultProps;
+
+ modal: ModalTrigger | null;
+
+ onSave: Function;
Review comment:
and all instances of `Function`? Thanks!
##########
File path: superset-frontend/src/components/Checkbox/index.tsx
##########
@@ -25,8 +25,8 @@ import {
interface CheckboxProps {
checked: boolean;
- onChange: (val?: boolean) => {};
- style: object;
+ onChange: (val?: boolean) => void;
+ style?: object;
Review comment:
are these changes intentional? I don't remember them before
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]