Skip to content

Commit b15d610

Browse files
sadpandajoeclaude
andcommitted
refactor(dashboard): remove vestigial themeId from DashboardPropertiesUpdate
themeId in DashboardPropertiesUpdate was unused by its consumer (handleOnPropertiesChange) since the full theme object is now passed instead. The save flow already derives theme_id from dashboardInfo.theme.id (Redux state). Added happy-path test verifying full theme object with json_data flows through PropertiesModal. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent d0b35ff commit b15d610

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

‎superset-frontend/src/dashboard/components/Header/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ type DashboardPropertiesUpdate = {
107107
owners?: Owner[];
108108
roles?: Role[];
109109
tags?: TagType[];
110-
themeId?: number | null;
111110
theme?: { id: number; theme_name: string; json_data: string } | null;
112111
css?: string;
113112
title?: string;

‎superset-frontend/src/dashboard/components/PropertiesModal/PropertiesModal.test.tsx‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ fetchMock.get('glob:*/api/v1/theme/*', {
152152
{
153153
id: 1,
154154
theme_name: 'Test Theme 1',
155+
json_data: '{"token":{"colorPrimary":"#ff0000"}}',
155156
},
156157
{
157158
id: 2,
158159
theme_name: 'Test Theme 2',
160+
json_data: '{"token":{"colorPrimary":"#0000ff"}}',
159161
},
160162
],
161163
},
@@ -417,6 +419,42 @@ describe('PropertiesModal', () => {
417419
});
418420
});
419421

422+
test('passes full theme object with json_data to onSubmit when theme is selected', async () => {
423+
mockedIsFeatureEnabled.mockReturnValue(false);
424+
const props = createProps();
425+
props.onlyApply = true;
426+
// Dashboard has theme id=1, which exists in the fetched themes list
427+
const propsWithTheme = {
428+
...props,
429+
dashboardInfo: {
430+
...dashboardInfo,
431+
json_metadata: mockedJsonMetadata,
432+
theme: { id: 1, theme_name: 'Test Theme 1' },
433+
},
434+
};
435+
render(<PropertiesModal {...propsWithTheme} />, {
436+
useRedux: true,
437+
});
438+
439+
expect(
440+
await screen.findByTestId('dashboard-edit-properties-form'),
441+
).toBeInTheDocument();
442+
443+
userEvent.click(screen.getByRole('button', { name: 'Apply' }));
444+
await waitFor(() => {
445+
expect(props.onSubmit).toHaveBeenCalledTimes(1);
446+
const submitCall = props.onSubmit.mock.calls[0][0];
447+
// Full theme object (including json_data) should be passed, not just the ID
448+
expect(submitCall.theme).toEqual({
449+
id: 1,
450+
theme_name: 'Test Theme 1',
451+
json_data: '{"token":{"colorPrimary":"#ff0000"}}',
452+
});
453+
// themeId removed — derived from theme.id at the save callsite
454+
expect(submitCall).not.toHaveProperty('themeId');
455+
});
456+
});
457+
420458
test('does not clear theme when selected theme is missing from fetched options', async () => {
421459
mockedIsFeatureEnabled.mockReturnValue(false);
422460
const props = createProps();
@@ -444,8 +482,8 @@ describe('PropertiesModal', () => {
444482
const submitCall = props.onSubmit.mock.calls[0][0];
445483
// theme should be undefined (not null) so Redux is not overwritten
446484
expect(submitCall.theme).toBeUndefined();
447-
// themeId should still carry the selected value for the API save path
448-
expect(submitCall.themeId).toBe(99);
485+
// themeId removed — derived from theme.id at the save callsite
486+
expect(submitCall).not.toHaveProperty('themeId');
449487
});
450488
});
451489

‎superset-frontend/src/dashboard/components/PropertiesModal/index.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ const PropertiesModal = ({
386386
colorNamespace,
387387
certifiedBy,
388388
certificationDetails,
389-
themeId: selectedThemeId,
390389
theme: selectedThemeId
391390
? themes.find(t => t.id === selectedThemeId)
392391
: null,

0 commit comments

Comments
 (0)