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/02 18:32:53 UTC

[superset] branch arash.afghahi/sc-53583/create-redux-state-setup-listviewresource created (now 269b34749a)

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

aafghahi pushed a change to branch arash.afghahi/sc-53583/create-redux-state-setup-listviewresource
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 269b34749a beginning the reducer

This branch includes the following new commits:

     new 269b34749a beginning the reducer

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: beginning the reducer

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-53583/create-redux-state-setup-listviewresource
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 269b34749a5aa0ba34878c71dc9ec8e4c3236627
Author: AAfghahi <ar...@gmail.com>
AuthorDate: Tue Aug 2 14:32:27 2022 -0400

    beginning the reducer
---
 .../views/CRUD/data/dataset/DatasetPage/index.tsx  | 37 ++++++++++++++++
 .../dataset/DatasetPage/{index.tsx => types.tsx}   | 51 ++++++++++++++--------
 2 files changed, 70 insertions(+), 18 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
index 974091f1ef..6fa729220e 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
@@ -22,6 +22,43 @@ import DatasetPanel from './DatasetPanel';
 import LeftPanel from './LeftPanel';
 import RightPanel from './RightPanel';
 import Footer from './Footer';
+import { DatasetActionType, DatasetObject, DSReducerActionType } from './types';
+
+export function datasetReducer(
+  state: Partial<DatasetObject> | null,
+  action: DSReducerActionType,
+): Partial<DatasetObject> | null {
+  const trimmedState = {
+    ...(state || {}),
+  };
+  switch (action.type) {
+    case DatasetActionType.selectDatabase:
+      return {
+        ...trimmedState,
+        ...action.payload,
+        schema: null,
+        table_name: null,
+      };
+    case DatasetActionType.selectSchema:
+      return {
+        ...trimmedState,
+        ...action.payload,
+        table_name: null,
+      };
+    case DatasetActionType.selectTable:
+      return {
+        ...trimmedState,
+        ...action.payload,
+      };
+    case DatasetActionType.changeDataset:
+      return {
+        ...trimmedState,
+        [action.payload.name]: action.payload.value,
+      };
+    default:
+      return null;
+  }
+}
 
 export default function DatasetPage() {
   return (
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/types.tsx
similarity index 53%
copy from superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
copy to superset-frontend/src/views/CRUD/data/dataset/DatasetPage/types.tsx
index 974091f1ef..3d5d67f7e1 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/types.tsx
@@ -16,23 +16,38 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-import Header from './Header';
-import DatasetPanel from './DatasetPanel';
-import LeftPanel from './LeftPanel';
-import RightPanel from './RightPanel';
-import Footer from './Footer';
+export enum DatasetActionType {
+  selectDatabase,
+  selectSchema,
+  selectTable,
+  changeDataset,
+}
+
+export interface DatasetObject {
+  database: {
+    id: string;
+    database_name: string;
+  };
+  owners: number[];
+  schema?: string | null;
+  dataset_name: string;
+  table_name?: string | null;
+}
 
-export default function DatasetPage() {
-  return (
-    <div>
-      <Header />
-      <LeftPanel />
-      <div css={{ display: 'flex' }}>
-        <DatasetPanel />
-        <Footer />
-      </div>
-      <RightPanel />
-    </div>
-  );
+interface DatasetReducerPayloadType {
+  name: string;
+  value?: string;
 }
+
+export type DSReducerActionType =
+  | {
+      type:
+        | DatasetActionType.selectDatabase
+        | DatasetActionType.selectSchema
+        | DatasetActionType.selectTable;
+      payload: Partial<DatasetObject>;
+    }
+  | {
+      type: DatasetActionType.changeDataset;
+      payload: DatasetReducerPayloadType;
+    };