Skip to content

Commit b82c4e6

Browse files
committed
feat(embedded): Add setDataMask API method
1 parent 0b3fe3d commit b82c4e6

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎superset-frontend/src/embedded/api.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { DataMaskStateWithId } from '@superset-ui/core';
2020
import getBootstrapData from 'src/utils/getBootstrapData';
2121
import { store } from '../views/store';
2222
import { getDashboardPermalink as getDashboardPermalinkUtil } from '../utils/urlUtils';
23+
import { updateDataMask } from '../dataMask/actions';
2324

2425
const bootstrapData = getBootstrapData();
2526

@@ -33,6 +34,7 @@ type EmbeddedSupersetApi = {
3334
getDashboardPermalink: ({ anchor }: { anchor: string }) => Promise<string>;
3435
getActiveTabs: () => string[];
3536
getDataMask: () => DataMaskStateWithId;
37+
setDataMask: (dataMask: DataMaskStateWithId) => void;
3638
};
3739

3840
const getScrollSize = (): Size => ({
@@ -65,9 +67,16 @@ const getActiveTabs = () => store?.getState()?.dashboardState?.activeTabs || [];
6567

6668
const getDataMask = () => store?.getState()?.dataMask || {};
6769

70+
const setDataMask = (dataMask: DataMaskStateWithId) => {
71+
Object.entries(dataMask).forEach(([filterId, mask]) => {
72+
store?.dispatch(updateDataMask(filterId, mask));
73+
});
74+
};
75+
6876
export const embeddedApi: EmbeddedSupersetApi = {
6977
getScrollSize,
7078
getDashboardPermalink,
7179
getActiveTabs,
7280
getDataMask,
81+
setDataMask,
7382
};

‎superset-frontend/src/embedded/index.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ window.addEventListener('message', function embeddedPageInitializer(event) {
250250
);
251251
Switchboard.defineMethod('getActiveTabs', embeddedApi.getActiveTabs);
252252
Switchboard.defineMethod('getDataMask', embeddedApi.getDataMask);
253+
Switchboard.defineMethod('setDataMask', embeddedApi.setDataMask);
253254
Switchboard.defineMethod(
254255
'setThemeConfig',
255256
(payload: { themeConfig: SupersetThemeConfig }) => {

0 commit comments

Comments
 (0)