You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/09/09 04:53:16 UTC

[GitHub] [superset] villebro commented on a change in pull request #16637: fix: Apply custom label colors in the Dashboard immediately

villebro commented on a change in pull request #16637:
URL: https://github.com/apache/superset/pull/16637#discussion_r704949251



##########
File path: superset-frontend/src/dashboard/containers/Chart.jsx
##########
@@ -73,6 +72,11 @@ function mapStateToProps(
     sliceId: id,
     nativeFilters,
     dataMask,
+    labelColors:
+      dashboardInfo?.metadata?.label_colors &&
+      Object.keys(dashboardInfo.metadata.label_colors).length > 0
+        ? dashboardInfo.metadata.label_colors
+        : undefined,

Review comment:
       nit: as we're already using lodash here, maybe we could simplify some more and use [size](https://lodash.com/docs/4.17.15#size) for this:
   ```
       labelColors:
         size(dashboardInfo?.metadata?.label_colors)
           ? dashboardInfo.metadata.label_colors
           : undefined,
   ```
   

##########
File path: superset-frontend/src/dashboard/actions/dashboardInfo.ts
##########
@@ -17,13 +17,30 @@
  * under the License.
  */
 import { Dispatch } from 'redux';
-import { makeApi } from '@superset-ui/core';
+import { makeApi, CategoricalColorNamespace } from '@superset-ui/core';
+import { isString } from 'lodash';
 import { ChartConfiguration, DashboardInfo } from '../reducers/types';
 
 export const DASHBOARD_INFO_UPDATED = 'DASHBOARD_INFO_UPDATED';
 
 // updates partially changed dashboard info
 export function dashboardInfoChanged(newInfo: { metadata: any }) {
+  const { metadata } = newInfo;
+
+  if (metadata?.label_colors) {
+    const scheme = metadata.color_scheme;
+    const namespace = metadata.color_namespace;

Review comment:
       nit:
   ```typescript
       const { color_scheme: scheme, color_namespace: namespace } = metadata;
   ```
   or just use the underscored names in the below code




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org