LevisNgigi commented on code in PR #33831:
URL: https://github.com/apache/superset/pull/33831#discussion_r2339880424


##########
superset-frontend/src/dashboard/actions/dashboardInfo.ts:
##########
@@ -113,16 +165,66 @@ export function 
setCrossFiltersEnabled(crossFiltersEnabled: boolean) {
   return { type: SET_CROSS_FILTERS_ENABLED, crossFiltersEnabled };
 }
 
+export const SAVE_CHART_CUSTOMIZATION_COMPLETE =
+  'SAVE_CHART_CUSTOMIZATION_COMPLETE';
+
+export function setChartCustomization(
+  chartCustomization: ChartCustomizationItem[],
+) {
+  return { type: SAVE_CHART_CUSTOMIZATION_COMPLETE, chartCustomization };
+}
+
+export const SET_DASHBOARD_THEME = 'SET_DASHBOARD_THEME';
+
+export function setDashboardTheme(theme: { id: number; name: string } | null) {
+  return { type: SET_DASHBOARD_THEME, theme };
+}
+
+export function updateDashboardTheme(themeId: number | null) {
+  return async (dispatch: Dispatch, getState: () => RootState) => {
+    const { id } = getState().dashboardInfo;
+    const updateDashboard = createUpdateDashboardApi(id);
+
+    try {
+      const response = await updateDashboard({
+        theme_id: themeId,
+      });
+
+      // Update the dashboard info with the new theme
+      if (themeId === null) {
+        // Clearing the theme
+        dispatch(setDashboardTheme(null));
+      } else if (response.result.theme) {
+        // API returned the theme object
+        dispatch(setDashboardTheme(response.result.theme));
+      } else {
+        // API didn't return theme object, create it from the themeId
+        dispatch(setDashboardTheme({ id: themeId, name: `Theme ${themeId}` }));
+      }
+
+      const lastModifiedTime = response.last_modified_time;
+      if (lastModifiedTime) {
+        dispatch(onSave(lastModifiedTime));
+      }
+    } catch (errorObject) {
+      const { error } = await getClientErrorObject(errorObject);
+      dispatch(
+        addDangerToast(
+          t(
+            'Sorry, there was an error saving this dashboard: %s',

Review Comment:
   Yeah not in the scope for this, was include during a conflict resolution.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to