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/01 20:59:55 UTC

[superset] branch master updated: feat: Creating dataset/add route (#20869)

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

aafghahi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 460b213057 feat: Creating dataset/add route (#20869)
460b213057 is described below

commit 460b2130577f85d1996b547fb77b69a00f4ba28e
Author: AAfghahi <48...@users.noreply.github.com>
AuthorDate: Mon Aug 1 16:59:40 2022 -0400

    feat: Creating dataset/add route (#20869)
    
    * beginning of routing
    
    * elizabeth review
    
    * changed folder layout
    
    * Update superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
    
    Co-authored-by: Lyndsi Kay Williams <55...@users.noreply.github.com>
    
    * Update superset-frontend/src/views/CRUD/data/dataset/DatasetPage/RightPanel/index.tsx
    
    Co-authored-by: Lyndsi Kay Williams <55...@users.noreply.github.com>
    
    Co-authored-by: Lyndsi Kay Williams <55...@users.noreply.github.com>
---
 .../dataset/DatasetPage/DatasetPanel/index.tsx     | 23 +++++++++++++
 .../CRUD/data/dataset/DatasetPage/Footer/index.tsx | 23 +++++++++++++
 .../CRUD/data/dataset/DatasetPage/Header/index.tsx | 23 +++++++++++++
 .../data/dataset/DatasetPage/LeftPanel/index.tsx   | 23 +++++++++++++
 .../data/dataset/DatasetPage/RightPanel/index.tsx  | 23 +++++++++++++
 .../views/CRUD/data/dataset/DatasetPage/index.tsx  | 38 ++++++++++++++++++++++
 superset-frontend/src/views/routes.tsx             | 16 +++++++++
 superset/initialization/__init__.py                |  3 +-
 superset/views/datasource/views.py                 | 30 +++++++++++++++--
 9 files changed, 198 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/DatasetPanel/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/DatasetPanel/index.tsx
new file mode 100644
index 0000000000..9fe93b8fb5
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/DatasetPanel/index.tsx
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+
+export default function DatasetPanel() {
+  return <div>Dataset Panel</div>;
+}
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Footer/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Footer/index.tsx
new file mode 100644
index 0000000000..07c35741ee
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Footer/index.tsx
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+
+export default function Footer() {
+  return <div>Footer</div>;
+}
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Header/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Header/index.tsx
new file mode 100644
index 0000000000..44f0e19f7b
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/Header/index.tsx
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+
+export default function Header() {
+  return <div>Header</div>;
+}
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/LeftPanel/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/LeftPanel/index.tsx
new file mode 100644
index 0000000000..5ffb6a12c9
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/LeftPanel/index.tsx
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+
+export default function LeftPanel() {
+  return <div>Left Panel</div>;
+}
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/RightPanel/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/RightPanel/index.tsx
new file mode 100644
index 0000000000..60f9589aad
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/RightPanel/index.tsx
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+
+export default function RightPanel() {
+  return <div>Right Panel</div>;
+}
diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
new file mode 100644
index 0000000000..974091f1ef
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetPage/index.tsx
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import Header from './Header';
+import DatasetPanel from './DatasetPanel';
+import LeftPanel from './LeftPanel';
+import RightPanel from './RightPanel';
+import Footer from './Footer';
+
+export default function DatasetPage() {
+  return (
+    <div>
+      <Header />
+      <LeftPanel />
+      <div css={{ display: 'flex' }}>
+        <DatasetPanel />
+        <Footer />
+      </div>
+      <RightPanel />
+    </div>
+  );
+}
diff --git a/superset-frontend/src/views/routes.tsx b/superset-frontend/src/views/routes.tsx
index dbb9ca2fab..732686838f 100644
--- a/superset-frontend/src/views/routes.tsx
+++ b/superset-frontend/src/views/routes.tsx
@@ -81,6 +81,14 @@ const DatasetList = lazy(
       /* webpackChunkName: "DatasetList" */ 'src/views/CRUD/data/dataset/DatasetList'
     ),
 );
+
+const DatasetPage = lazy(
+  () =>
+    import(
+      /* webpackChunkName: "DatasetEditor" */ 'src/views/CRUD/data/dataset/DatasetPage/index'
+    ),
+);
+
 const ExecutionLog = lazy(
   () =>
     import(
@@ -189,6 +197,14 @@ export const routes: Routes = [
     path: '/superset/explore/p',
     Component: ExplorePage,
   },
+  {
+    path: '/dataset/add/',
+    Component: DatasetPage,
+  },
+  {
+    path: '/dataset/:datasetId',
+    Component: DatasetPage,
+  },
 ];
 
 const frontEndRoutes = routes
diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py
index 588d9b66bf..8dfeff9942 100644
--- a/superset/initialization/__init__.py
+++ b/superset/initialization/__init__.py
@@ -169,7 +169,7 @@ class SupersetAppInitializer:  # pylint: disable=too-many-public-methods
             DatabaseView,
             ExcelToDatabaseView,
         )
-        from superset.views.datasource.views import Datasource
+        from superset.views.datasource.views import DatasetEditor, Datasource
         from superset.views.dynamic_plugins import DynamicPluginsView
         from superset.views.explore import ExplorePermalinkView, ExploreView
         from superset.views.key_value import KV
@@ -289,6 +289,7 @@ class SupersetAppInitializer:  # pylint: disable=too-many-public-methods
         appbuilder.add_view_no_menu(Dashboard)
         appbuilder.add_view_no_menu(DashboardModelViewAsync)
         appbuilder.add_view_no_menu(Datasource)
+        appbuilder.add_view_no_menu(DatasetEditor)
         appbuilder.add_view_no_menu(EmbeddedView)
         appbuilder.add_view_no_menu(ExploreView)
         appbuilder.add_view_no_menu(ExplorePermalinkView)
diff --git a/superset/views/datasource/views.py b/superset/views/datasource/views.py
index 60ee4baddc..2c137fab79 100644
--- a/superset/views/datasource/views.py
+++ b/superset/views/datasource/views.py
@@ -18,10 +18,10 @@ import json
 from collections import Counter
 from typing import Any
 
-from flask import request
-from flask_appbuilder import expose
+from flask import redirect, request
+from flask_appbuilder import expose, permission_name
 from flask_appbuilder.api import rison
-from flask_appbuilder.security.decorators import has_access_api
+from flask_appbuilder.security.decorators import has_access, has_access_api
 from flask_babel import _
 from marshmallow import ValidationError
 from sqlalchemy.exc import NoSuchTableError
@@ -203,3 +203,27 @@ class Datasource(BaseSupersetView):
             payload=payload,
         )
         return self.json_response({"result": rv})
+
+
+class DatasetEditor(BaseSupersetView):
+    route_base = "/dataset"
+    class_permission_name = "Dataset"
+
+    @expose("/add/")
+    @has_access
+    @permission_name("read")
+    def root(self) -> FlaskResponse:
+        dev = request.args.get("testing")
+        if dev is not None:
+            return super().render_app_template()
+        return redirect("/")
+
+    @expose("/<pk>", methods=["GET"])
+    @has_access
+    @permission_name("read")
+    # pylint: disable=unused-argument
+    def show(self, pk: int) -> FlaskResponse:
+        dev = request.args.get("testing")
+        if dev is not None:
+            return super().render_app_template()
+        return redirect("/")