geido commented on code in PR #24449:
URL: https://github.com/apache/superset/pull/24449#discussion_r1495575011


##########
superset-frontend/src/dashboard/components/RefreshIntervalModal.tsx:
##########
@@ -91,6 +99,51 @@ class RefreshIntervalModal extends React.PureComponent<
     this.setState({
       refreshFrequency: value || refreshIntervalOptions[0][0],
     });
+
+    if (value === -1) {
+      this.setState({
+        custom_block: true,
+      });
+    } else {
+      this.setState({
+        custom_block: false,
+      });
+    }
+  }
+
+  onSaveValue(value: number) {
+    this.props.onChange(value, this.props.editMode);
+    this.modalRef?.current?.close();
+    this.props.addSuccessToast(t('Refresh interval saved'));
+  }
+
+  createIntervalOptions(refreshIntervalOptions: [number, string][]) {
+    const refresh_options = [];
+    if (refreshIntervalOptions.length === 0) {
+      refresh_options.push({ value: -1, label: 'Custom interval' });
+      return refresh_options;
+    }
+    refresh_options.push({
+      value: refreshIntervalOptions[0][0],
+      label: t(refreshIntervalOptions[0][1]),
+    });
+    refresh_options.push({ value: -1, label: 'Custom interval' });
+    for (let i = 1; i < refreshIntervalOptions.length; i += 1)
+      refresh_options.push({
+        value: refreshIntervalOptions[i][0],
+        label: t(refreshIntervalOptions[i][1]),
+      });
+    return refresh_options;
+  }

Review Comment:
   Ok then please consider using `map` rather than the for loop to make the 
code more readable and concise. Thank you



-- 
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: [email protected]

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