You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by aa...@apache.org on 2022/08/29 16:30:32 UTC

[superset] branch arash.afghahi/sc-52806/create-dataset-footer created (now 3885487099)

This is an automated email from the ASF dual-hosted git repository.

aafghahi pushed a change to branch arash.afghahi/sc-52806/create-dataset-footer
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 3885487099 rough draft of footer component

This branch includes the following new commits:

     new 3885487099 rough draft of footer component

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 01/01: rough draft of footer component

Posted by aa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aafghahi pushed a commit to branch arash.afghahi/sc-52806/create-dataset-footer
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 3885487099adae57c96c11c2edb9c39e946c2237
Author: AAfghahi <ar...@gmail.com>
AuthorDate: Mon Aug 29 12:30:06 2022 -0400

    rough draft of footer component
---
 .../CRUD/data/dataset/AddDataset/Footer/index.tsx  | 50 +++++++++++++++++++++-
 .../views/CRUD/data/dataset/AddDataset/index.tsx   | 18 +++++---
 .../src/views/CRUD/data/dataset/styles.ts          |  6 +++
 3 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx
index 07c35741ee..6e094e07cd 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx
@@ -17,7 +17,53 @@
  * under the License.
  */
 import React from 'react';
+import Button from 'src/components/Button';
+import { t } from '@superset-ui/core';
+import { useSingleViewResource } from 'src/views/CRUD/hooks';
+import { addDangerToast } from 'src/components/MessageToasts/actions';
+import { DatasetObject } from '../types';
 
-export default function Footer() {
-  return <div>Footer</div>;
+interface FooterObject {
+  url: string;
+  datasetObject?: Partial<DatasetObject> | null;
+}
+
+export default function Footer({ url, datasetObject }: FooterObject) {
+  const { createResource } = useSingleViewResource<Partial<DatasetObject>>(
+    'dataset',
+    t('dataset'),
+    addDangerToast,
+  );
+  const cancelButtonOnClick = () => {
+    // this is a placeholder url until the final feature gets implemented
+    // at that point we will be passing in the url of the previous location.
+    window.location.href = url;
+  };
+
+  const tooltipText = t('Select a database table.');
+
+  const onSave = () => {
+    if (datasetObject) {
+      createResource(datasetObject).then(response => {
+        if (!response) {
+          return;
+        }
+      });
+      cancelButtonOnClick();
+    }
+  };
+
+  return (
+    <>
+      <Button onClick={cancelButtonOnClick}>Cancel</Button>
+      <Button
+        buttonStyle="primary"
+        disabled={!datasetObject?.table_name}
+        tooltip={!datasetObject?.table_name ? tooltipText : undefined}
+        onClick={onSave}
+      >
+        Create Dataset
+      </Button>
+    </>
+  );
 }
diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx
index 677f3f52ae..4665d058f7 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/index.tsx
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
+import React, { useReducer, Reducer } from 'react';
 import Header from './Header';
 import DatasetPanel from './DatasetPanel';
 import LeftPanel from './LeftPanel';
@@ -60,19 +60,25 @@ export function datasetReducer(
   }
 }
 
-export default function AddDataset() {
+export default function AddDataset(url: string) {
   // this is commented out for now, but can be commented in as the component
   // is built up. Uncomment the useReducer in imports too
-  // const [dataset, setDataset] = useReducer<
-  //   Reducer<Partial<DatasetObject> | null, DSReducerActionType>
-  // >(datasetReducer, null);
+  const [dataset, setDataset] = useReducer<
+    Reducer<Partial<DatasetObject> | null, DSReducerActionType>
+  >(datasetReducer, null);
+  const prevUrl =
+    '/tablemodelview/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc';
+
+  const FooterComponent = () => (
+    <Footer url={prevUrl} datasetObject={dataset} />
+  );
 
   return (
     <DatasetLayout
       header={Header()}
       leftPanel={LeftPanel()}
       datasetPanel={DatasetPanel()}
-      footer={Footer()}
+      footer={FooterComponent()}
     />
   );
 }
diff --git a/superset-frontend/src/views/CRUD/data/dataset/styles.ts b/superset-frontend/src/views/CRUD/data/dataset/styles.ts
index 8d9f771dce..cbc0b33a3b 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/styles.ts
+++ b/superset-frontend/src/views/CRUD/data/dataset/styles.ts
@@ -17,6 +17,7 @@
  * under the License.
  */
 import { styled } from '@superset-ui/core';
+import Button from 'src/components/Button';
 
 export const StyledLayoutWrapper = styled.div`
   flex-grow: 1;
@@ -92,4 +93,9 @@ export const StyledFooter = styled.div`
   border-top: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
   border-bottom: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
   color: ${({ theme }) => theme.colors.info.base};
+  border-top: ${({ theme }) => theme.gridUnit / 4}px solid
+    ${({ theme }) => theme.colors.grayscale.light2};
+  padding: ${({ theme }) => theme.gridUnit * 4}px;
+  display: flex;
+  justify-content: flex-end;
 `;