Skip to content

Commit

Permalink
feat(embedded): fixing CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jayakrishnankarolilnlsn committed Sep 27, 2022
1 parent 84b0b7d commit 09ce85a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
27 changes: 25 additions & 2 deletions superset-frontend/src/embedded/api.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* 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 { store } from '../views/store';
import { bootstrapData } from '../preamble';
import { getDashboardPermalink as getDashboardPermalinkUtil } from '../utils/urlUtils';
Expand All @@ -18,10 +36,15 @@ const getScrollSize = (): Size => ({
height: document.body.scrollHeight,
});

const getDashboardPermalink = async ({ anchor }: { anchor: string }): Promise<string> => {
const getDashboardPermalink = async ({
anchor,
}: {
anchor: string;
}): Promise<string> => {
const state = store?.getState();
const { dashboardId, dataMask, activeTabs } = {
dashboardId: state?.dashboardInfo?.id || bootstrapData?.embedded!.dashboard_id,
dashboardId:
state?.dashboardInfo?.id || bootstrapData?.embedded!.dashboard_id,
dataMask: state?.dataMask,
activeTabs: state.dashboardState?.activeTabs,
};
Expand Down
22 changes: 14 additions & 8 deletions superset-frontend/src/embedded/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,22 @@ window.addEventListener('message', function embeddedPageInitializer(event) {

let started = false;

switchboard.defineMethod('guestToken', ({ guestToken }: { guestToken: string }) => {
setupGuestClient(guestToken);
if (!started) {
start();
started = true;
}
});
switchboard.defineMethod(
'guestToken',
({ guestToken }: { guestToken: string }) => {
setupGuestClient(guestToken);
if (!started) {
start();
started = true;
}
},
);

switchboard.defineMethod('getScrollSize', embeddedApi.getScrollSize);
switchboard.defineMethod('getDashboardPermalink', embeddedApi.getDashboardPermalink);
switchboard.defineMethod(
'getDashboardPermalink',
embeddedApi.getDashboardPermalink,
);
switchboard.defineMethod('getActiveTabs', embeddedApi.getActiveTabs);
switchboard.start();
}
Expand Down

0 comments on commit 09ce85a

Please sign in to comment.