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/08/12 16:36:12 UTC

[GitHub] [superset] pkdotson opened a new pull request, #21075: feat(WIP): add tableselector to dataset creation page

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

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227839714

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227837354

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1228689312

   @AAfghahi Container image not yet published for this PR. Please try again when build is complete.


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227835735

   Storybook has completed and can be viewed at 


-- 
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] AAfghahi commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1228697991

   It looks like Antonio had the same error: https://github.com/apache/superset/pull/21213#pullrequestreview-1087206807
   
   Potentially could be solved with a rebase?


-- 
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] lyndsiWilliams commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
lyndsiWilliams commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r958712154


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;

Review Comment:
   ```suggestion
       margin-top: ${theme.gridUnit * 17.5}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;

Review Comment:
   ```suggestion
       bottom: 0;
   ```
   Nit: `px` isn't needed here



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });

Review Comment:
   ```suggestion
         setDataset({
           type: DatasetActionType.selectSchema,
           payload: { name: 'schema', value: schema },
         });
   ```
   I think the state/types for this need to be adjusted so that you don't need to set `as string` for schema in the reducer, this change happens in 3 parts of the code. Here, in AddDataset, and in the types file.
   
   (1/3): This will need to be set differently so we can use it with `DatasetReducerPayloadType` in types



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx:
##########
@@ -42,7 +47,7 @@ export function datasetReducer(
     case DatasetActionType.selectSchema:
       return {
         ...trimmedState,
-        ...action.payload,
+        schema: action.payload as string,

Review Comment:
   ```suggestion
           [action.payload.name]: action.payload.value,
   ```
   (2/3): By setting this with `DatasetReducerPayloadType` in types, it'll already be defined as a `string`



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx:
##########
@@ -63,14 +64,22 @@ export function datasetReducer(
 export default function AddDataset() {
   // this is commented out for now, but can be commented in as the component

Review Comment:
   +1 on this, remove the "this is commented out for now..." comment



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,
+      );
+      getTablesList(endpoint);
+    }
+  }, [loadTables]);
+
+  useEffect(() => {
+    if (resetTables) {
+      setTableOptions([]);
+      setResetTables(false);
+    }
+  }, [resetTables]);
+
+  const search = useMemo(
+    () =>
+      debounce((value: string) => {
+        const encodeTableName =
+          value === '' ? undefined : encodeURIComponent(value);
+        const endpoint = encodeURI(
+          `/superset/tables/${dbId}/${encodedSchema}/${encodeTableName}/`,
+        );
+        getTablesList(endpoint);
+      }, FAST_DEBOUNCE),
+    [dbId, encodedSchema],
+  );
 
-export default function LeftPanel() {
   return (
-    <>
-      <EmptyStateMedium
-        image="empty-table.svg"
-        title={t('No database tables found')}
-        description={t('Try selecting a different schema')}
+    <LeftPanelStyle>
+      <p className="section-title db-schema"> Select Database & Schema</p>

Review Comment:
   ```suggestion
         <p className="section-title db-schema">Select Database & Schema</p>
   ```
   Is this space meant to be here?



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);

Review Comment:
   ```suggestion
     const encodedSchema = encodeURIComponent(schema ?? '');
   ```
   I pulled this down and it looks like TS is erroring because it doesn't like that `schema` could be undefined. I think it would be better to create a safety net in case schema comes in as not a string for some reason.
   



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/types.tsx:
##########
@@ -39,12 +37,16 @@ interface DatasetReducerPayloadType {
   value?: string;
 }
 
+export type Schema = {
+  schema?: string | null | undefined;
+};
+
 export type DSReducerActionType =

Review Comment:
   ```suggestion
   export type DSReducerActionType =
     | {
         type: DatasetActionType.selectDatabase | DatasetActionType.selectTable;
         payload: Partial<DatasetObject>;
       }
     | {
         type: DatasetActionType.changeDataset | DatasetActionType.selectSchema;
         payload: DatasetReducerPayloadType;
       };
   ```
   (3/3): If you change the `DSReducerActionType` to look like this, the other 2 parts of this state/type change should work and schema will be properly described as a string without needing `as string`



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;

Review Comment:
   ```suggestion
       top: ${theme.gridUnit * 97.5}px;
       left: ${theme.gridUnit * 3.25}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx:
##########
@@ -17,15 +17,69 @@
  * under the License.
  */
 import React from 'react';
+import { SupersetClient } from '@superset-ui/core';
 import { render, screen } from 'spec/helpers/testing-library';
 import LeftPanel from 'src/views/CRUD/data/dataset/AddDataset/LeftPanel';
 
 describe('LeftPanel', () => {
-  it('renders a blank state LeftPanel', () => {
-    render(<LeftPanel />);
+  const mockFun = jest.fn();
+
+  const SupersetClientGet = jest.spyOn(SupersetClient, 'get');
+
+  const getSchemaMockFunction = async () =>
+    ({
+      json: {
+        result: ['schema_a', 'schema_b'],
+      },
+    } as any);
+
+  const getTableMockFunction = async () =>
+    ({
+      json: {
+        options: [
+          { label: 'table_a', value: 'table_a' },
+          { label: 'table_b', value: 'table_b' },
+          { label: 'table_c', value: 'table_c' },
+          { label: 'table_d', value: 'table_d' },
+        ],
+      },
+    } as any);
+
+  it('should render', () => {
+    const { container } = render(<LeftPanel setDataset={mockFun} />, {
+      useRedux: true,
+    });
+    expect(container).toBeInTheDocument();
+  });
+
+  it('should render tableselector and databaselector container and selects', () => {
+    render(<LeftPanel setDataset={mockFun} />, { useRedux: true });
+
+    expect(screen.getByText(/select database & schema/i)).toBeVisible();
+
+    const databaseSelect = screen.getByRole('combobox', {
+      name: 'Select database or type database name',
+    });
+    const schemaSelect = screen.getByRole('combobox', {
+      name: 'Select schema or type schema name',
+    });
+    expect(databaseSelect).toBeInTheDocument();
+    expect(schemaSelect).toBeInTheDocument();
+  });
+  it('renders a blank state LeftPanel if there is no schema selected', () => {
+    render(<LeftPanel setDataset={mockFun} />, { useRedux: true });
 
     expect(screen.getByRole('img', { name: /empty/i })).toBeVisible();
     expect(screen.getByText(/no database tables found/i)).toBeVisible();
     expect(screen.getByText(/try selecting a different schema/i)).toBeVisible();
   });
+  it('renders list of options when user clicks on schema', () => {
+    render(<LeftPanel setDataset={mockFun} schema="schema_a" dbId={1} />, {
+      useRedux: true,
+    });
+    // screen.debug('container', container)

Review Comment:
   Remove this



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,
+      );
+      getTablesList(endpoint);
+    }
+  }, [loadTables]);
+
+  useEffect(() => {
+    if (resetTables) {
+      setTableOptions([]);
+      setResetTables(false);
+    }
+  }, [resetTables]);
+
+  const search = useMemo(
+    () =>
+      debounce((value: string) => {
+        const encodeTableName =
+          value === '' ? undefined : encodeURIComponent(value);
+        const endpoint = encodeURI(
+          `/superset/tables/${dbId}/${encodedSchema}/${encodeTableName}/`,
+        );
+        getTablesList(endpoint);
+      }, FAST_DEBOUNCE),
+    [dbId, encodedSchema],
+  );
 
-export default function LeftPanel() {
   return (
-    <>
-      <EmptyStateMedium
-        image="empty-table.svg"
-        title={t('No database tables found')}
-        description={t('Try selecting a different schema')}
+    <LeftPanelStyle>
+      <p className="section-title db-schema"> Select Database & Schema</p>
+      <DatabaseSelector
+        handleError={addDangerToast}
+        onDbChange={setDatabase}
+        onSchemaChange={setSchema}
       />
-    </>
+      {loadTables && (
+        <div className="loading">
+          <Loading position="inline" />
+          <p>loading schemas ...</p>

Review Comment:
   It looks like the Shortcut ticket wants this text to say "Tables loading"



-- 
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] yousoph commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
yousoph commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1234757700

   /testenv up


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1234761347

   @yousoph Ephemeral environment spinning up at http://54.218.74.130:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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] lyndsiWilliams commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
lyndsiWilliams commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r954376781


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;

Review Comment:
   ```suggestion
     max-width: ${theme.gridUnit * 87.5}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;

Review Comment:
   ```suggestion
       max-height: ${theme.gridUnit * 175}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;

Review Comment:
   ```suggestion
       bottom: ${theme.gridUnit * 95}px;
       img {
         position: absolute;
         top: -${theme.gridUnit * 13.25}px;
         right: -${theme.gridUnit * 3.75}px;
         width: ${theme.gridUnit * 17.75}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const setDatabase = (db: any) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: any) => {

Review Comment:
   Define `any`



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   

Review Comment:
   ```suggestion
       top: ${theme.gridUnit * 102.5}px;
       left: ${theme.gridUnit * 42.75}px;
       font-size: ${theme.gridUnit * 4.25}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;

Review Comment:
   Define `any`



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const setDatabase = (db: any) => {

Review Comment:
   Define `any`



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;

Review Comment:
   ```suggestion
       top: ${theme.gridUnit * 72.5}px;
       left: ${theme.gridUnit * 16.75}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;

Review Comment:
   ```suggestion
       margin-top: ${theme.gridUnit * 11}px;
       margin-bottom: ${theme.gridUnit * 11}px;
   ```
   Unit values should stay within the Superset theme



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const setDatabase = (db: any) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: any) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,
+      );
+      getTablesList(endpoint);
+    }
+  }, [loadTables]);
+
+  useEffect(() => {
+    if (resetTables) {
+      setTableOptions([]);
+      setResetTables(false);
+    }
+  }, [resetTables]);
+
+  const search = useMemo(
+    () =>
+      debounce((value: string) => {
+        const encodeTableName =
+          value === '' ? undefined : encodeURIComponent(value);
+        const endpoint = encodeURI(
+          `/superset/tables/${dbId}/${encodedSchema}/${encodeTableName}/`,
+        );
+        getTablesList(endpoint);
+      }, FAST_DEBOUNCE),
+    [dbId, encodedSchema],
+  );
 
-export default function LeftPanel() {
   return (
-    <>
-      <EmptyStateMedium
-        image="empty-table.svg"
-        title={t('No database tables found')}
-        description={t('Try selecting a different schema')}
+    <LeftPanelStyle>
+      <p className="section-title db-schema"> Select Database & Schema</p>
+      <DatabaseSelector
+        handleError={() => null}
+        onDbChange={setDatabase}
+        onSchemaChange={setSchema}
       />
-    </>
+      {loadTables && (
+        <div className="loading">
+          <Loading position="inline" />
+          <p>loading schemas ...</p>
+        </div>
+      )}
+      {!schema && !loadTables ? (
+        <>
+          <EmptyStateMedium
+            image="empty-table.svg"
+            title={t('No database tables found')}
+            description={t('Try selecting a different schema')}
+          />
+        </>

Review Comment:
   ```suggestion
             <EmptyStateMedium
               image="empty-table.svg"
               title={t('No database tables found')}
               description={t('Try selecting a different schema')}
             />
   ```
   This empty fragment can be removed



-- 
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] lyndsiWilliams commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
lyndsiWilliams commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r959043393


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);

Review Comment:
   ```suggestion
     const encodedSchema =
       !schema || schema === '' ? undefined : encodeURIComponent(schema ?? '');
   ```
   Actually, we'll need to account for all falsy values so this would be better 😁 



-- 
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] pkdotson merged pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
pkdotson merged PR #21075:
URL: https://github.com/apache/superset/pull/21075


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227840013

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1228689330

   @AAfghahi Ephemeral environment creation failed. Please check the Actions logs for details.


-- 
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] hughhhh commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r956226886


##########
superset-frontend/src/components/TableSelector/index.tsx:
##########
@@ -100,7 +100,7 @@ interface TableSelectorProps {
   tableSelectMode?: 'single' | 'multiple';
 }
 
-interface Table {
+export interface Table {

Review Comment:
   Can we have a more explicit name here like `DatabaseTable`



-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1231878790

   @AAfghahi Ephemeral environment spinning up at http://52.32.56.113:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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] pkdotson commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
pkdotson commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r959127870


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);

Review Comment:
   Easier way to do this is `const encodedSchema = schema ? encodeURIComponent(schema) : undefined;`
   
   empty string is the same as undefined.



-- 
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] AAfghahi commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1231772764

   /testenv up


-- 
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] AAfghahi commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1228688659

   /testenv up


-- 
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] AAfghahi commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r955056673


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const setDatabase = (db: any) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: any) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,
+      );
+      getTablesList(endpoint);
+    }
+  }, [loadTables]);
+
+  useEffect(() => {
+    if (resetTables) {
+      setTableOptions([]);
+      setResetTables(false);
+    }
+  }, [resetTables]);
+
+  const search = useMemo(

Review Comment:
   this looks really nice!



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: string;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: 350px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  .refresh {
+    position: absolute;
+    top: 290px;
+    left: 67px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: 44px;
+    margin-bottom: 44px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    max-height: 700px;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: 410px;
+    left: 171px;
+    font-size: 17px;   
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: 380px;
+    img {
+      position: absolute;
+      top: -53px;
+      right: -15px;
+      width: 71px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const setDatabase = (db: any) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: any) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,
+      );
+      getTablesList(endpoint);
+    }
+  }, [loadTables]);
+
+  useEffect(() => {
+    if (resetTables) {
+      setTableOptions([]);
+      setResetTables(false);
+    }
+  }, [resetTables]);
+
+  const search = useMemo(
+    () =>
+      debounce((value: string) => {
+        const encodeTableName =
+          value === '' ? undefined : encodeURIComponent(value);
+        const endpoint = encodeURI(
+          `/superset/tables/${dbId}/${encodedSchema}/${encodeTableName}/`,
+        );
+        getTablesList(endpoint);
+      }, FAST_DEBOUNCE),
+    [dbId, encodedSchema],
+  );
 
-export default function LeftPanel() {
   return (
-    <>
-      <EmptyStateMedium
-        image="empty-table.svg"
-        title={t('No database tables found')}
-        description={t('Try selecting a different schema')}
+    <LeftPanelStyle>
+      <p className="section-title db-schema"> Select Database & Schema</p>
+      <DatabaseSelector
+        handleError={() => null}

Review Comment:
   is this how the error is handled in the other DatabaseSelector?



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,204 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { DatasetActionType } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;

Review Comment:
   yeah I think that we have a DatasetObject as an interface 



##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx:
##########
@@ -63,14 +64,22 @@ export function datasetReducer(
 export default function AddDataset() {
   // this is commented out for now, but can be commented in as the component

Review Comment:
   we can delete this comment now that we are actually using the reducer :) 



-- 
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] codecov[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1231462039

   # [Codecov](https://codecov.io/gh/apache/superset/pull/21075?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21075](https://codecov.io/gh/apache/superset/pull/21075?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (aefde3f) into [master](https://codecov.io/gh/apache/superset/commit/8772e2cdb3b5a500812e7df12c133f9c9f2e6bad?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8772e2c) will **increase** coverage by `0.01%`.
   > The diff coverage is `42.10%`.
   
   > :exclamation: Current head aefde3f differs from pull request most recent head 4ce4d29. Consider uploading reports for the commit 4ce4d29 to get more accurate results
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #21075      +/-   ##
   ==========================================
   + Coverage   66.43%   66.44%   +0.01%     
   ==========================================
     Files        1784     1784              
     Lines       68163    68212      +49     
     Branches     7264     7271       +7     
   ==========================================
   + Hits        45285    45326      +41     
   - Misses      21010    21014       +4     
   - Partials     1868     1872       +4     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `52.48% <42.10%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/21075?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ols/DndColumnSelectControl/ColumnSelectPopover.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0NvbHVtblNlbGVjdFBvcG92ZXIudHN4) | `3.37% <ø> (+0.10%)` | :arrow_up: |
   | [...s/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL0NSVUQvZGF0YS9kYXRhc2V0L0FkZERhdGFzZXQvTGVmdFBhbmVsL2luZGV4LnRzeA==) | `37.50% <36.17%> (-62.50%)` | :arrow_down: |
   | [...tend/src/views/CRUD/data/database/DatabaseList.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL0NSVUQvZGF0YS9kYXRhYmFzZS9EYXRhYmFzZUxpc3QudHN4) | `66.00% <40.00%> (-2.37%)` | :arrow_down: |
   | [...et-frontend/src/components/TableSelector/index.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvVGFibGVTZWxlY3Rvci9pbmRleC50c3g=) | `78.26% <100.00%> (ø)` | |
   | [...d/src/views/CRUD/data/dataset/AddDataset/index.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL0NSVUQvZGF0YS9kYXRhc2V0L0FkZERhdGFzZXQvaW5kZXgudHN4) | `33.33% <100.00%> (+22.22%)` | :arrow_up: |
   | [...perset-frontend/src/views/components/RightMenu.tsx](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL3ZpZXdzL2NvbXBvbmVudHMvUmlnaHRNZW51LnRzeA==) | `63.33% <100.00%> (ø)` | |
   | [superset/reports/commands/execute.py](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVwb3J0cy9jb21tYW5kcy9leGVjdXRlLnB5) | `91.54% <0.00%> (+0.35%)` | :arrow_up: |
   | [superset/views/core.py](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdmlld3MvY29yZS5weQ==) | `75.60% <0.00%> (+0.45%)` | :arrow_up: |
   | [superset/common/query\_object.py](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29tbW9uL3F1ZXJ5X29iamVjdC5weQ==) | `94.38% <0.00%> (+0.51%)` | :arrow_up: |
   | [superset/models/core.py](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbW9kZWxzL2NvcmUucHk=) | `88.88% <0.00%> (+0.70%)` | :arrow_up: |
   | ... and [5 more](https://codecov.io/gh/apache/superset/pull/21075/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227834357

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat(WIP): add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1226127618

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1226716985

   Storybook has completed and can be viewed at 


-- 
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] hughhhh commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r956226414


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,221 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,

Review Comment:
   why do you have `undefined` here?



-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1239885036

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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] AAfghahi commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
AAfghahi commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227359985

   This looks really nice. Put in a couple of thoughts, one question though re: spacing. The padding in the table section looks a bit wonky, is that what it was on the figma?


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1228678823

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227838509

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227839397

   Storybook has completed and can be viewed at 


-- 
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] github-actions[bot] commented on pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21075:
URL: https://github.com/apache/superset/pull/21075#issuecomment-1227837354

   Storybook has completed and can be viewed at 


-- 
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] pkdotson commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
pkdotson commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r957879794


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,221 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,

Review Comment:
   actually we need this for the refresh. So the undefined represents the field for the search field. 



-- 
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] pkdotson commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
pkdotson commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r957571840


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,221 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, { useEffect, useState, useMemo } from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: (db: any) => void;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5}; 
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);
+
+  useEffect(() => {
+    if (loadTables) {
+      const endpoint = encodeURI(
+        `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`,

Review Comment:
   This is the search option for the api which i thought i was going to use here. I guess I can use the main  /tables/dbid/schema endpoint.



-- 
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] lyndsiWilliams commented on a diff in pull request #21075: feat: add tableselector to dataset creation page

Posted by GitBox <gi...@apache.org>.
lyndsiWilliams commented on code in PR #21075:
URL: https://github.com/apache/superset/pull/21075#discussion_r958754526


##########
superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx:
##########
@@ -16,18 +16,227 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import { t } from '@superset-ui/core';
+import React, {
+  useEffect,
+  useState,
+  useMemo,
+  SetStateAction,
+  Dispatch,
+} from 'react';
+import { SupersetClient, t, styled, FAST_DEBOUNCE } from '@superset-ui/core';
+import { Input } from 'src/components/Input';
+import { Form } from 'src/components/Form';
+import { TableOption, Table } from 'src/components/TableSelector';
+import RefreshLabel from 'src/components/RefreshLabel';
+import Loading from 'src/components/Loading';
+import DatabaseSelector from 'src/components/DatabaseSelector';
+import { debounce } from 'lodash';
 import { EmptyStateMedium } from 'src/components/EmptyState';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { DatasetActionType, DatasetObject } from '../types';
+
+interface LeftPanelProps {
+  setDataset: Dispatch<SetStateAction<object>>;
+  schema?: string | undefined | null;
+  dbId?: number;
+}
+
+const LeftPanelStyle = styled.div`
+  ${({ theme }) => `
+  max-width: ${theme.gridUnit * 87.5}px;
+  padding: ${theme.gridUnit * 4}px;
+  height: 100%;
+  background-color: ${theme.colors.grayscale.light5};
+  position: relative;
+  .emptystate {
+    height: auto;
+    margin-top: 70px;
+  }
+  .refresh {
+    position: absolute;
+    top: ${theme.gridUnit * 43.25}px;
+    left: ${theme.gridUnit * 16.75}px;
+    span[role="button"]{
+      font-size: ${theme.gridUnit * 4.25}px;
+    }
+  }
+  .section-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 11}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .table-title {
+    margin-top: ${theme.gridUnit * 11}px;
+    margin-bottom: ${theme.gridUnit * 6}px;
+    font-weight: ${theme.typography.weights.bold};
+  }
+  .options-list {
+    overflow: auto;
+    position: absolute;
+    bottom: 0px;
+    top: 390px;
+    left: 13px;
+    right: 0;
+    .options {
+      padding: ${theme.gridUnit * 1.75}px;
+      border-radius: ${theme.borderRadius}px;
+    }
+  }
+  form > span {
+    position: absolute;
+    top: ${theme.gridUnit * 73}px;
+    left: ${theme.gridUnit * 42.75}px;
+    font-size: ${theme.gridUnit * 4.25}px;
+  }
+  .table-form {
+    margin-bottom: ${theme.gridUnit * 8}px;
+  }
+  .loading {
+    position: absolute;
+    bottom: ${theme.gridUnit * 95}px;
+    img {
+      position: absolute;
+      top: -${theme.gridUnit * 13.25}px;
+      right: -${theme.gridUnit * 3.75}px;
+      width: ${theme.gridUnit * 17.75}px;
+    }
+  }
+  }
+`}
+`;
+
+export default function LeftPanel({
+  setDataset,
+  schema,
+  dbId,
+}: LeftPanelProps) {
+  const [tableOptions, setTableOptions] = useState<Array<TableOption>>([]);
+  const [resetTables, setResetTables] = useState(false);
+  const [loadTables, setLoadTables] = useState(false);
+  const [searchVal, setSearchVal] = useState('');
+  const [refresh, setRefresh] = useState(false);
+
+  const { addDangerToast } = useToasts();
+
+  const setDatabase = (db: Partial<DatasetObject>) => {
+    setDataset({ type: DatasetActionType.selectDatabase, payload: db });
+    setResetTables(true);
+  };
+
+  const getTablesList = (url: string) => {
+    SupersetClient.get({ url })
+      .then(({ json }) => {
+        const options: TableOption[] = json.options.map((table: Table) => {
+          const option: TableOption = {
+            value: table.value,
+            label: <TableOption table={table} />,
+            text: table.label,
+          };
+
+          return option;
+        });
+
+        setTableOptions(options);
+        setLoadTables(false);
+        setResetTables(false);
+        setRefresh(false);
+      })
+      .catch(e => {
+        console.log('error', e);
+      });
+  };
+
+  const setSchema = (schema: string) => {
+    if (schema) {
+      setDataset({ type: DatasetActionType.selectSchema, payload: schema });
+      setLoadTables(true);
+    }
+    setResetTables(true);
+  };
+
+  const encodedSchema = encodeURIComponent(schema as string);

Review Comment:
   I pulled this down and it looks like TS is erroring because it doesn't like that `schema` could be undefined. I think it would be better to create a safety net in case schema comes in as not a string for some reason.
   
   Edit: See second comment below for safer solution



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