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/07/26 16:12:46 UTC

[superset] 01/01: beginning of routing

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

aafghahi pushed a commit to branch arash.afghahi/sc-52802/create-route-for-dataset-id-and-dataset-add
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 21848cac95b4d0edd4468f58bd01664f63276029
Author: AAfghahi <ar...@gmail.com>
AuthorDate: Tue Jul 26 12:12:07 2022 -0400

    beginning of routing
---
 .../DatasetEditor/DatasetPanel/DatasetPanel.tsx    | 23 +++++++++++++
 .../data/dataset/DatasetEditor/Footer/Footer.tsx   | 23 +++++++++++++
 .../data/dataset/DatasetEditor/Header/Header.tsx   | 23 +++++++++++++
 .../dataset/DatasetEditor/LeftPanel/LeftPanel.tsx  | 23 +++++++++++++
 .../CRUD/data/dataset/DatasetEditor/index.tsx      | 40 ++++++++++++++++++++++
 superset-frontend/src/views/routes.tsx             | 16 +++++++++
 superset/initialization/__init__.py                |  4 ++-
 superset/views/datasource/views.py                 | 16 +++++++--
 8 files changed, 165 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/DatasetPanel/DatasetPanel.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/DatasetPanel/DatasetPanel.tsx
new file mode 100644
index 0000000000..9fe93b8fb5
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/DatasetPanel/DatasetPanel.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/DatasetEditor/Footer/Footer.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/Footer/Footer.tsx
new file mode 100644
index 0000000000..07c35741ee
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/Footer/Footer.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/DatasetEditor/Header/Header.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/Header/Header.tsx
new file mode 100644
index 0000000000..44f0e19f7b
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/Header/Header.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/DatasetEditor/LeftPanel/LeftPanel.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/LeftPanel/LeftPanel.tsx
new file mode 100644
index 0000000000..5ffb6a12c9
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/LeftPanel/LeftPanel.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/DatasetEditor/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/index.tsx
new file mode 100644
index 0000000000..f57e4c3c63
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/data/dataset/DatasetEditor/index.tsx
@@ -0,0 +1,40 @@
+/**
+ * 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 DatasetPanel from './DatasetPanel/DatasetPanel';
+import Footer from './Footer/Footer';
+import LeftPanel from './LeftPanel/LeftPanel';
+import Header from './Header/Header';
+
+export default function DatasetEditor() {
+  return (
+    <>
+      <div>
+        <Header />
+        <div css={{ display: 'flex' }}>
+          <LeftPanel />
+          <div>
+            <DatasetPanel />
+            <Footer />
+          </div>
+        </div>
+      </div>
+    </>
+  );
+}
diff --git a/superset-frontend/src/views/routes.tsx b/superset-frontend/src/views/routes.tsx
index dbb9ca2fab..6ab5e27eb0 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 DatasetEditor = lazy(
+  () =>
+    import(
+      /* webpackChunkName: "DatasetEditor" */ 'src/views/CRUD/data/dataset/DatasetEditor/index'
+    ),
+);
+
 const ExecutionLog = lazy(
   () =>
     import(
@@ -189,6 +197,14 @@ export const routes: Routes = [
     path: '/superset/explore/p',
     Component: ExplorePage,
   },
+  {
+    path: '/dataset/add/',
+    Component: DatasetEditor,
+  },
+  {
+    path: '/dataset/:datasetId',
+    Component: DatasetEditor,
+  },
 ];
 
 const frontEndRoutes = routes
diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py
index 588d9b66bf..77c0153026 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)
@@ -332,6 +333,7 @@ class SupersetAppInitializer:  # pylint: disable=too-many-public-methods
             category="SQL Lab",
             category_label=__("SQL Lab"),
         )
+
         appbuilder.add_link(
             __("Saved Queries"),
             href="/savedqueryview/list/",
diff --git a/superset/views/datasource/views.py b/superset/views/datasource/views.py
index 60ee4baddc..1414070aac 100644
--- a/superset/views/datasource/views.py
+++ b/superset/views/datasource/views.py
@@ -19,9 +19,9 @@ from collections import Counter
 from typing import Any
 
 from flask import request
-from flask_appbuilder import expose
+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,15 @@ 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")
+    @event_logger.log_this
+    def root(self) -> FlaskResponse:
+        return super().render_app_template()