This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 5.0 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 45cf969d4b40c3781a00ba7f6cec9a3daddf0dc5 Author: Andrey Yakir <[email protected]> AuthorDate: Fri Mar 14 16:36:42 2025 +0200 fix(dashboard): Ensure `dashboardId` is included in `form_data` for embedded mode (#32646) (cherry picked from commit 777760b0966e23d24ba3c816a78b09bb36ac4176) --- .../src/dashboard/components/gridComponents/Chart.jsx | 3 +++ .../src/dashboard/components/gridComponents/Chart.test.jsx | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx index 5cc8ba6d37..2d48448815 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.jsx @@ -157,6 +157,7 @@ const Chart = props => { state.datasources[chart.form_data.datasource]) || PLACEHOLDER_DATASOURCE, ); + const dashboardInfo = useSelector(state => state.dashboardInfo); const [descriptionHeight, setDescriptionHeight] = useState(0); const [height, setHeight] = useState(props.height); @@ -304,6 +305,8 @@ const Chart = props => { ], ); + formData.dashboardId = dashboardInfo.id; + const onExploreChart = useCallback( async clickEvent => { const isOpenInNewTab = diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx index 35be0144af..3d4cb66bdc 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Chart.test.jsx @@ -74,6 +74,7 @@ const defaultState = { datasources: mockDatasource, dashboardState: { editMode: false, expandedSlices: {} }, dashboardInfo: { + id: props.dashboardId, superset_can_explore: false, superset_can_share: false, superset_can_csv: false, @@ -165,7 +166,9 @@ test('should call exportChart when exportCSV is clicked', async () => { expect(stubbedExportCSV).toHaveBeenCalledTimes(1); expect(stubbedExportCSV).toHaveBeenCalledWith( expect.objectContaining({ - formData: expect.anything(), + formData: expect.objectContaining({ + dashboardId: 111, + }), resultType: 'full', resultFormat: 'csv', }), @@ -195,6 +198,7 @@ test('should call exportChart with row_limit props.maxRows when exportFullCSV is expect.objectContaining({ formData: expect.objectContaining({ row_limit: 666, + dashboardId: 111, }), resultType: 'full', resultFormat: 'csv', @@ -249,6 +253,7 @@ test('should call exportChart with row_limit props.maxRows when exportFullXLSX i expect.objectContaining({ formData: expect.objectContaining({ row_limit: 666, + dashboardId: 111, }), resultType: 'full', resultFormat: 'xlsx',
