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/11 15:16:25 UTC

[GitHub] [superset] AAfghahi commented on a change in pull request #17926: refactor: sqleditorleftbar to typescript

AAfghahi commented on a change in pull request #17926:
URL: https://github.com/apache/superset/pull/17926#discussion_r782245845



##########
File path: superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
##########
@@ -0,0 +1,239 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import Button from 'src/components/Button';
+import { t, styled, css } from '@superset-ui/core';
+import Collapse from 'src/components/Collapse';
+import Icons from 'src/components/Icons';
+import TableSelector from 'src/components/TableSelector';
+import { IconTooltip } from 'src/components/IconTooltip';
+import { QueryEditor } from 'src/SqlLab/types';
+import { DatabaseObject } from 'src/components/DatabaseSelector';
+import TableElement from '../TableElement';
+
+// const propTypes = {
+//   queryEditor: PropTypes.object.isRequired,
+//   height: PropTypes.number,
+//   tables: PropTypes.array,
+//   actions: PropTypes.object,
+//   database: PropTypes.object,
+//   offline: PropTypes.bool,
+// };
+
+/**
+    onSchemaChange={actions.queryEditorSetSchema}
+    onSchemasLoad={actions.queryEditorSetSchemaOptions}
+    onTableChange={onTableChange}
+    onTablesLoad={actions.queryEditorSetTableOptions}
+ */
+
+// anywhere there is void or any I didnt know what to put, will look into it
+
+interface actionsTypes {
+  queryEditorSetDb: (queryEditor: QueryEditor, dbId: number) => void;
+  queryEditorSetFunctionNames: (queryEditor: QueryEditor, dbId: number) => void;
+  /*
+    Need to add:
+    addTable (X)
+    collapseTable (X)
+    expandTable (X)
+    queryEditorSetSchemaOptions (X)
+    queryEditorSetTableOptions (X)
+    resetState (X)
+  */
+
+  collapseTable: (table: tableType) => void;
+  expandTable: (table: tableType) => void;
+
+  // This came from /home/josue/superset/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx
+  addTable: (queryEditor: any, value: any, schema: any) => void;
+
+  // utilized the typing that TableSelector used for its props, which are the same functions for these two below
+  setDatabases: (arg0: any) => {};
+  addDangerToast: (msg: string) => void;
+  queryEditorSetSchema: (schema?: string) => void;
+  queryEditorSetSchemaOptions: () => void;
+  queryEditorSetTableOptions: (options: Array<any>) => void;
+  resetState: () => void;
+}
+
+// my first attempt at actionTypes:
+// interface actionsTypes {
+//   queryEditorSetDb: (queryEditor: QueryEditor, dbId: number) => void;
+//   queryEditorSetFunctionNames: (queryEditor: QueryEditor, dbId: number) => void;
+//   setDatabases: (databases: any) => object;
+//   addDangerToast: (text: string, options?: ToastOptions) => void;
+//   queryEditorSetSchema: (queryEditor: QueryEditor, schema: any) => void;
+// }
+
+type tableType = {
+  id: number;
+  expanded: boolean;
+};
+
+type dbType = {
+  id: number;
+};
+
+interface propTypes {
+  queryEditor: QueryEditor;
+  height: number;

Review comment:
       both height and tables have a default value, which make me think that they are optional. 

##########
File path: superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
##########
@@ -0,0 +1,239 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import Button from 'src/components/Button';
+import { t, styled, css } from '@superset-ui/core';
+import Collapse from 'src/components/Collapse';
+import Icons from 'src/components/Icons';
+import TableSelector from 'src/components/TableSelector';
+import { IconTooltip } from 'src/components/IconTooltip';
+import { QueryEditor } from 'src/SqlLab/types';
+import { DatabaseObject } from 'src/components/DatabaseSelector';
+import TableElement from '../TableElement';
+
+// const propTypes = {
+//   queryEditor: PropTypes.object.isRequired,
+//   height: PropTypes.number,
+//   tables: PropTypes.array,
+//   actions: PropTypes.object,
+//   database: PropTypes.object,
+//   offline: PropTypes.bool,
+// };
+
+/**
+    onSchemaChange={actions.queryEditorSetSchema}
+    onSchemasLoad={actions.queryEditorSetSchemaOptions}
+    onTableChange={onTableChange}
+    onTablesLoad={actions.queryEditorSetTableOptions}
+ */
+
+// anywhere there is void or any I didnt know what to put, will look into it
+
+interface actionsTypes {
+  queryEditorSetDb: (queryEditor: QueryEditor, dbId: number) => void;
+  queryEditorSetFunctionNames: (queryEditor: QueryEditor, dbId: number) => void;
+  /*
+    Need to add:
+    addTable (X)
+    collapseTable (X)
+    expandTable (X)
+    queryEditorSetSchemaOptions (X)
+    queryEditorSetTableOptions (X)
+    resetState (X)
+  */
+
+  collapseTable: (table: tableType) => void;
+  expandTable: (table: tableType) => void;
+
+  // This came from /home/josue/superset/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx
+  addTable: (queryEditor: any, value: any, schema: any) => void;
+
+  // utilized the typing that TableSelector used for its props, which are the same functions for these two below
+  setDatabases: (arg0: any) => {};
+  addDangerToast: (msg: string) => void;
+  queryEditorSetSchema: (schema?: string) => void;
+  queryEditorSetSchemaOptions: () => void;
+  queryEditorSetTableOptions: (options: Array<any>) => void;
+  resetState: () => void;
+}
+
+// my first attempt at actionTypes:
+// interface actionsTypes {
+//   queryEditorSetDb: (queryEditor: QueryEditor, dbId: number) => void;
+//   queryEditorSetFunctionNames: (queryEditor: QueryEditor, dbId: number) => void;
+//   setDatabases: (databases: any) => object;
+//   addDangerToast: (text: string, options?: ToastOptions) => void;
+//   queryEditorSetSchema: (queryEditor: QueryEditor, schema: any) => void;
+// }
+
+type tableType = {
+  id: number;
+  expanded: boolean;
+};
+
+type dbType = {
+  id: number;
+};
+
+interface propTypes {

Review comment:
       we should change this name to be more specific to the component that we are using. Maybe SqlEditorLeftBarProps, which is a mouthful, but I think more specific than what we have currently. 




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