etr2460 commented on a change in pull request #11997:
URL: 
https://github.com/apache/incubator-superset/pull/11997#discussion_r543504175



##########
File path: superset-frontend/src/explore/components/SaveModal.tsx
##########
@@ -55,15 +66,17 @@ class SaveModal extends React.Component {
     };
     this.onDashboardSelectChange = this.onDashboardSelectChange.bind(this);
     this.onSliceNameChange = this.onSliceNameChange.bind(this);
+    this.changeAction = this.changeAction.bind(this);
+    this.saveOrOverwrite = this.saveOrOverwrite.bind(this);
   }
 
   componentDidMount() {
     this.props.actions.fetchDashboards(this.props.userId).then(() => {
       const dashboardIds = this.props.dashboards.map(
         dashboard => dashboard.value,
       );
-      let recentDashboard = sessionStorage.getItem(SK_DASHBOARD_ID);
-      recentDashboard = recentDashboard && parseInt(recentDashboard, 10);
+      const lastDashboard = sessionStorage.getItem(SK_DASHBOARD_ID);
+      const recentDashboard = lastDashboard && parseInt(lastDashboard, 10);

Review comment:
       love the immutability! 

##########
File path: superset-frontend/src/explore/components/SaveModal.tsx
##########
@@ -227,7 +240,8 @@ class SaveModal extends React.Component {
               onChange={this.onDashboardSelectChange}
               autoSize={false}
               value={
-                this.state.saveToDashboardId || this.state.newDashboardName
+                (this.state.saveToDashboardId ||
+                  this.state.newDashboardName) as ValueType<Record<string, 
any>>

Review comment:
       i'm a bit confused by this typing, isn't this `string | number`? I 
would've expected the Select component to be fine with that

##########
File path: superset-frontend/src/explore/components/SaveModal.tsx
##########
@@ -227,7 +240,8 @@ class SaveModal extends React.Component {
               onChange={this.onDashboardSelectChange}
               autoSize={false}
               value={
-                this.state.saveToDashboardId || this.state.newDashboardName
+                (this.state.saveToDashboardId ||
+                  this.state.newDashboardName) as ValueType<Record<string, 
any>>

Review comment:
       or is it because newDashboardName can be undefined that you need to cast 
this

##########
File path: superset-frontend/src/explore/components/SaveModal.tsx
##########
@@ -75,25 +88,25 @@ class SaveModal extends React.Component {
     });
   }
 
-  onSliceNameChange(event) {
-    this.setState({ newSliceName: event.target.value });
+  onSliceNameChange(event: React.FormEvent<FormControl>) {
+    this.setState({ newSliceName: (event.target as HTMLInputElement).value });

Review comment:
       Maybe if the event is typed as `HTMLInputEvent` in the function args 
then this won't need to be cast here?

##########
File path: superset-frontend/src/explore/components/SaveModal.tsx
##########
@@ -244,17 +258,15 @@ class SaveModal extends React.Component {
   }
 }
 
-SaveModal.propTypes = propTypes;
-
-function mapStateToProps({ explore, saveModal }) {
+function mapStateToProps({ explore, saveModal }: Record<string, any>) {
   return {
     datasource: explore.datasource,
     slice: explore.slice,
     can_overwrite: explore.can_overwrite,
     userId: explore.user_id,
     dashboards: saveModal.dashboards,
     alert: saveModal.saveModalAlert,
-  };
+  } as Partial<SaveModalProps>;

Review comment:
       instead of casting the response, can we define the function to return a 
`Partial<SaveModalProps>` instead?




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

Reply via email to