You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "justinpark (via GitHub)" <gi...@apache.org> on 2023/09/08 04:41:52 UTC

[GitHub] [superset] justinpark opened a new pull request, #25228: chore(sqllab): Typescript for SqlEditor component

justinpark opened a new pull request, #25228:
URL: https://github.com/apache/superset/pull/25228

   ### SUMMARY
   This commit migrates SqlEditor jsx to tsx along with all associated type updates.
   
   ### TESTING INSTRUCTIONS
   npm run type
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


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


[GitHub] [superset] michael-s-molina commented on a diff in pull request #25228: chore(sqllab): Typescript for SqlEditor component

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #25228:
URL: https://github.com/apache/superset/pull/25228#discussion_r1323412336


##########
superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx:
##########
@@ -30,7 +31,7 @@ type HotKey = {
   key: string;
   descr: string;
   name: string;
-  func: () => void;
+  func: (arg0: IAceEditor) => void;

Review Comment:
   ```suggestion
     func: (aceEditor: IAceEditor) => void;
   ```



##########
superset-frontend/src/SqlLab/components/SaveQuery/index.tsx:
##########
@@ -38,11 +39,11 @@ interface SaveQueryProps {
   columns: ISaveableDatasource['columns'];
   onSave: (arg0: QueryPayload, id: string) => void;
   onUpdate: (arg0: QueryPayload, id: string) => void;
-  saveQueryWarning: string | null;
-  database: Record<string, any>;
+  saveQueryWarning?: string | null;

Review Comment:
   Can this be `undefined` or `string | null` is sufficient?



##########
superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx:
##########
@@ -55,15 +55,15 @@ import {
 } from 'src/utils/localStorageHelpers';
 import TableElement from '../TableElement';
 
-interface ExtendedTable extends Table {
+export interface ExtendedTable extends Table {
   expanded: boolean;
 }
 
 interface SqlEditorLeftBarProps {
   queryEditorId: string;
   height?: number;
   tables?: ExtendedTable[];
-  database: DatabaseObject;
+  database: DatabaseObject | undefined;

Review Comment:
   ```suggestion
     database?: DatabaseObject;
   ```



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


[GitHub] [superset] justinpark commented on pull request #25228: chore(sqllab): Typescript for SqlEditor component

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark commented on PR #25228:
URL: https://github.com/apache/superset/pull/25228#issuecomment-1736257617

   @michael-s-molina could you review the update again?


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


Re: [PR] chore(sqllab): Typescript for SqlEditor component [superset]

Posted by "justinpark (via GitHub)" <gi...@apache.org>.
justinpark merged PR #25228:
URL: https://github.com/apache/superset/pull/25228


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


[GitHub] [superset] michael-s-molina commented on a diff in pull request #25228: chore(sqllab): Typescript for SqlEditor component

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #25228:
URL: https://github.com/apache/superset/pull/25228#discussion_r1323427428


##########
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx:
##########
@@ -198,19 +203,29 @@ const StyledSqlEditor = styled.div`
   `}
 `;
 
-const propTypes = {
-  tables: PropTypes.array.isRequired,
-  queryEditor: PropTypes.object.isRequired,
-  defaultQueryLimit: PropTypes.number.isRequired,
-  maxRow: PropTypes.number.isRequired,
-  displayLimit: PropTypes.number.isRequired,
-  saveQueryWarning: PropTypes.string,
-  scheduleQueryWarning: PropTypes.string,
-};
-
 const extensionsRegistry = getExtensionsRegistry();
 
-const SqlEditor = ({
+export type Props = {
+  tables: ExtendedTable[];
+  queryEditor: QueryEditor;
+  defaultQueryLimit: number;
+  maxRow: number;
+  displayLimit: number;
+  saveQueryWarning?: string;
+  scheduleQueryWarning?: string | null;

Review Comment:
   Can this be `undefined` or `string | null` is sufficient?



##########
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx:
##########
@@ -222,22 +237,26 @@ const SqlEditor = ({
   const theme = useTheme();
   const dispatch = useDispatch();
 
-  const { database, latestQuery, hideLeftBar } = useSelector(
-    ({ sqlLab: { unsavedQueryEditor, databases, queries } }) => {
-      let { dbId, latestQueryId, hideLeftBar } = queryEditor;
-      if (unsavedQueryEditor?.id === queryEditor.id) {
-        dbId = unsavedQueryEditor.dbId || dbId;
-        latestQueryId = unsavedQueryEditor.latestQueryId || latestQueryId;
-        hideLeftBar = unsavedQueryEditor.hideLeftBar || hideLeftBar;
-      }
-      return {
-        database: databases[dbId],
-        latestQuery: queries[latestQueryId],
-        hideLeftBar,
-      };
-    },
-    shallowEqual,
-  );
+  const { database, latestQuery, hideLeftBar } = useSelector<
+    SqlLabRootState,
+    {
+      database: DatabaseObject | undefined;
+      latestQuery: QueryResponse | undefined;
+      hideLeftBar: boolean | undefined;

Review Comment:
   ```suggestion
         database?: DatabaseObject;
         latestQuery?: QueryResponse;
         hideLeftBar?: boolean;
   ```



##########
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx:
##########
@@ -566,6 +584,7 @@ const SqlEditor = ({
           <AntdSwitch
             checked={autocompleteEnabled}
             onChange={handleToggleAutocompleteEnabled}
+            // @ts-ignore

Review Comment:
   This property does not exist. I think you can safely remove it as it's not being referenced anywhere. I searched for "autocomplete-switch" and I wasn't able to find anything.



##########
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx:
##########
@@ -471,10 +494,11 @@ const SqlEditor = ({
   const onResizeStart = () => {
     // Set the heights on the ace editor and the ace content area after drag starts
     // to smooth out the visual transition to the new heights when drag ends
+    // @ts-ignore
     document.getElementsByClassName('ace_content')[0].style.height = '100%';

Review Comment:
   ```suggestion
       (
         document.getElementsByClassName('ace_content')[0] as HTMLElement
       ).style.height = '100%';
   ```



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