You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2023/05/19 22:25:23 UTC
[superset] 01/01: chore(GPT4): Migrating SQL Lab from jsx to tsx
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch SQL-Lab-App-in-TS
in repository https://gitbox.apache.org/repos/asf/superset.git
commit f8763f852d6187a4da6f5e4fe16d2564ecd665d3
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Fri May 19 16:25:06 2023 -0600
chore(GPT4): Migrating SQL Lab from jsx to tsx
---
.../SqlLab/components/App/{index.jsx => index.tsx} | 39 +++++++++++++++-------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/App/index.jsx b/superset-frontend/src/SqlLab/components/App/index.tsx
similarity index 89%
rename from superset-frontend/src/SqlLab/components/App/index.jsx
rename to superset-frontend/src/SqlLab/components/App/index.tsx
index bbd1bba9ae..40471f9d65 100644
--- a/superset-frontend/src/SqlLab/components/App/index.jsx
+++ b/superset-frontend/src/SqlLab/components/App/index.tsx
@@ -17,8 +17,7 @@
* under the License.
*/
import React from 'react';
-import PropTypes from 'prop-types';
-import { bindActionCreators } from 'redux';
+import { bindActionCreators, Dispatch } from 'redux';
import { connect } from 'react-redux';
import { css, styled, t } from '@superset-ui/core';
import throttle from 'lodash/throttle';
@@ -97,15 +96,28 @@ const SqlLabStyles = styled.div`
`};
`;
-class App extends React.PureComponent {
- constructor(props) {
+interface AppProps {
+ actions: typeof Actions & {
+ logEvent: typeof logEvent;
+ };
+ common: object;
+ localStorageUsageInKilobytes: number;
+ queries: any[];
+ queriesLastUpdate: Date;
+}
+
+interface AppState {
+ hash: string;
+}
+class App extends React.PureComponent<AppProps, AppState> {
+ constructor(props: AppProps) {
super(props);
this.state = {
hash: window.location.hash,
};
this.showLocalStorageUsageWarning = throttle(
- this.showLocalStorageUsageWarning,
+ this.showLocalStorageUsageWarning.bind(this),
LOCALSTORAGE_WARNING_MESSAGE_THROTTLE_MS,
{ trailing: false },
);
@@ -185,13 +197,16 @@ class App extends React.PureComponent {
}
}
-App.propTypes = {
- actions: PropTypes.object,
- common: PropTypes.object,
- localStorageUsageInKilobytes: PropTypes.number.isRequired,
-};
+interface RootState {
+ common: object;
+ localStorageUsageInKilobytes: number;
+ sqlLab?: {
+ queries: any[];
+ queriesLastUpdate: Date;
+ };
+}
-function mapStateToProps(state) {
+function mapStateToProps(state: RootState) {
const { common, localStorageUsageInKilobytes, sqlLab } = state;
return {
common,
@@ -201,7 +216,7 @@ function mapStateToProps(state) {
};
}
-function mapDispatchToProps(dispatch) {
+function mapDispatchToProps(dispatch: Dispatch) {
return {
actions: bindActionCreators({ ...Actions, logEvent }, dispatch),
};