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/01/06 18:59:09 UTC

[GitHub] [superset] lilykuang commented on a change in pull request #17529: feat: entry for embedded dashboard

lilykuang commented on a change in pull request #17529:
URL: https://github.com/apache/superset/pull/17529#discussion_r779784681



##########
File path: superset-frontend/src/embedded/index.tsx
##########
@@ -0,0 +1,122 @@
+/**
+ * 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, { lazy, Suspense } from 'react';
+import ReactDOM from 'react-dom';
+import { BrowserRouter as Router, Route } from 'react-router-dom';
+import { bootstrapData } from 'src/preamble';
+import setupClient from 'src/setup/setupClient';
+import { RootContextProviders } from 'src/views/RootContextProviders';
+import ErrorBoundary from 'src/components/ErrorBoundary';
+import Loading from 'src/components/Loading';
+
+const LazyDashboardPage = lazy(
+  () =>
+    import(
+      /* webpackChunkName: "DashboardPage" */ 'src/dashboard/containers/DashboardPage'
+    ),
+);
+
+const EmbeddedApp = () => (
+  <Router>
+    <Route path="/superset/dashboard/:idOrSlug/embedded">
+      <Suspense fallback={<Loading />}>
+        <RootContextProviders>
+          <ErrorBoundary>
+            <LazyDashboardPage />
+          </ErrorBoundary>
+        </RootContextProviders>
+      </Suspense>
+    </Route>
+  </Router>
+);
+
+const appMountPoint = document.getElementById('app')!;
+
+const MESSAGE_TYPE = '__embedded_comms__';
+
+if (!window.parent) {
+  appMountPoint.innerHTML =
+    'This page is intended to be embedded in an iframe, but no window.parent was found.';
+}
+
+if (!window.name) {
+  appMountPoint.innerHTML =
+    'This page is intended to be embedded by the Superset SDK, but there does not appear to be an SDK context present.';
+}
+
+// if the page is embedded in an origin that hasn't
+// been authorized by the curator, we forbid access entirely.
+// todo: check the referrer on the route serving this page instead
+const ALLOW_ORIGINS = ['http://127.0.0.1:9001', 'http://localhost:9001'];

Review comment:
       commenting it out should be better so we dont have to remove bootstrap data later




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