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 2022/07/01 14:39:55 UTC

[GitHub] [superset] geido opened a new pull request, #20589: chore: Update color scheme when deleted or changed

geido opened a new pull request, #20589:
URL: https://github.com/apache/superset/pull/20589

   ### SUMMARY
   This PR updates the color scheme for Dashboards and Charts when a color scheme in EXTRA_CATEGORICAL_COLOR_SCHEMES or EXTRA_SEQUENTIAL_COLOR_SCHEMES is deleted or changed.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   TBD
   
   ### TESTING INSTRUCTIONS
   TBD
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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


[GitHub] [superset] kgabryje commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r916160746


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   Ok thanks for explanation



-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r916101868


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   @kgabryje this isn't really an update for which the user should have any feedback whether positive or negative, since this is a fallback situation when a color scheme is deleted or changed in the `EXTRA_CATEGORICAL_COLOR_SCHEMES` or `EXTRA_SEQUENTIAL_COLOR_SCHEMES` or when the dashboard does not have the `color_scheme_domain` definition and needs it to be compatible.
   
   As for using redux, the dashboard is updated like this in the PropertiesModal and other places as well. The reason why this isn't using the available saveDashboardRequest is because that has additional logic and user feedback that we don't need here, so I believe for this scenario it makes sense to keep it as close as possible to the fallback logic



##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   @kgabryje this isn't really an update for which the user should have any feedback whether positive or negative, since this is a fallback situation when a color scheme is deleted or changed in the `EXTRA_CATEGORICAL_COLOR_SCHEMES` or `EXTRA_SEQUENTIAL_COLOR_SCHEMES` or when the dashboard does not have the `color_scheme_domain` definition and needs it to be compatible.
   
   As for using redux, the dashboard is updated like this in the PropertiesModal and other places as well. The reason why this isn't using the available `saveDashboardRequest` is because that has additional logic and user feedback that we don't need here, so I believe for this scenario it makes sense to keep it as close as possible to the fallback logic



-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r913142884


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   @stephenLYZ I tried but the color map will return empty anyway. I think the reason is that at this point we don't have all the charts rendered. I recall we had this problem before and afaik there is no way to know when all charts have finished rendering atm.



-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r913769064


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   @stephenLYZ it looks like shared_label_colors are only generated for rendered charts. See my comment in the PR description 



-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r916101868


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   @kgabryje this isn't really an update for which the user should have any feedback whether positive or negative, since this is a fallback situation when a color scheme is deleted or changed in the `EXTRA_CATEGORICAL_COLOR_SCHEMES` or `EXTRA_SEQUENTIAL_COLOR_SCHEMES` or when the dashboard is does not have the `color_scheme_domain` definition and needs it to be compatible.
   
   As for using redux, the dashboard is updated like this in the PropertiesModal and other places as well. The reason why this isn't using the available saveDashboardRequest is because that has additional logic and user feedback that we don't need here, so I believe for this scenario it makes sense to keep it as close as possible to the fallback logic



-- 
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


[GitHub] [superset] stephenLYZ commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
stephenLYZ commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r916588224


##########
superset-frontend/src/explore/actions/hydrateExplore.ts:
##########
@@ -67,6 +71,29 @@ export const hydrateExplore =
       initialExploreState,
       initialFormData,
     ) as ControlStateMapping;
+    const colorSchemeKey = initialControls.color_scheme && 'color_scheme';
+    const linearColorSchemeKey =
+      initialControls.linear_color_scheme && 'linear_color_scheme';
+    // if the color scheme does not exist anymore
+    // fallbacks to the available default key
+    const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {

Review Comment:
   Can we use an enum type here?
   ```typescript
   enum ColorSchemeType = {
     CATEGORICAL = 'CATEGORICAL',
     SEQUENTIAL = 'SEQUENTIAL'
   }
   ```



##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -288,6 +293,7 @@ const PropertiesModal = ({
   const onFinish = () => {
     const { title, slug, certifiedBy, certificationDetails } =
       form.getFieldsValue();
+    const categoricalSchemeRegistry = getCategoricalSchemeRegistry();

Review Comment:
   Call the function again looks no sense πŸ€”



-- 
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


[GitHub] [superset] sadpandajoe commented on pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
sadpandajoe commented on PR #20589:
URL: https://github.com/apache/superset/pull/20589#issuecomment-1194735866

   🏷️ preset:2022.29


-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r913142884


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   @stephenLYZ I tried but the color map will return empty anyway. I think the reason is that at this point we don't have all the charts rendered. I recall we had this problem before and afaik there is no way to know when all charts have finished rendering atm.



-- 
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


[GitHub] [superset] srinify merged pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
srinify merged PR #20589:
URL: https://github.com/apache/superset/pull/20589


-- 
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


[GitHub] [superset] stephenLYZ commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
stephenLYZ commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r912506714


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   I found `dashboardInfo.json_metadata` is not updated even though I have updated dashboard metadata, but using `dashboardInfo.metadata` is okay.



-- 
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


[GitHub] [superset] codecov[bot] commented on pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #20589:
URL: https://github.com/apache/superset/pull/20589#issuecomment-1172423671

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20589](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b8a0837) into [master](https://codecov.io/gh/apache/superset/commit/b870a21eaa9359b4cf3bd4a23fe72c77387ab7dc?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b870a21) will **decrease** coverage by `11.98%`.
   > The diff coverage is `53.22%`.
   
   > :exclamation: Current head b8a0837 differs from pull request most recent head d941abb. Consider uploading reports for the commit d941abb to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #20589       +/-   ##
   ===========================================
   - Coverage   66.79%   54.81%   -11.99%     
   ===========================================
     Files        1754     1754               
     Lines       65561    65562        +1     
     Branches     6933     6930        -3     
   ===========================================
   - Hits        43793    35936     -7857     
   - Misses      20014    27874     +7860     
   + Partials     1754     1752        -2     
   ```
   
   | Flag | Coverage Ξ” | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `53.62% <50.00%> (-0.02%)` | :arrow_down: |
   | python | `58.01% <50.00%> (-24.85%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `50.66% <50.00%> (+0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Ξ” | |
   |---|---|---|
   | [...d/packages/superset-ui-chart-controls/src/types.ts](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGFja2FnZXMvc3VwZXJzZXQtdWktY2hhcnQtY29udHJvbHMvc3JjL3R5cGVzLnRz) | `100.00% <ΓΈ> (ΓΈ)` | |
   | [superset-frontend/src/SqlLab/types.ts](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL1NxbExhYi90eXBlcy50cw==) | `57.14% <ΓΈ> (ΓΈ)` | |
   | [...rset-frontend/src/components/Chart/chartReducer.ts](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvQ2hhcnQvY2hhcnRSZWR1Y2VyLnRz) | `25.00% <0.00%> (ΓΈ)` | |
   | [...t-frontend/src/dashboard/actions/dashboardState.js](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9hY3Rpb25zL2Rhc2hib2FyZFN0YXRlLmpz) | `36.54% <ΓΈ> (ΓΈ)` | |
   | [superset-frontend/src/explore/App.jsx](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvQXBwLmpzeA==) | `0.00% <ΓΈ> (ΓΈ)` | |
   | [superset-frontend/src/explore/ExplorePage.tsx](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvRXhwbG9yZVBhZ2UudHN4) | `0.00% <0.00%> (ΓΈ)` | |
   | [...frontend/src/explore/actions/datasourcesActions.ts](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvYWN0aW9ucy9kYXRhc291cmNlc0FjdGlvbnMudHM=) | `100.00% <ΓΈ> (ΓΈ)` | |
   | [.../src/explore/components/ControlPanelsContainer.tsx](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9Db250cm9sUGFuZWxzQ29udGFpbmVyLnRzeA==) | `80.00% <ΓΈ> (ΓΈ)` | |
   | [...e/components/controls/ColorSchemeControl/index.jsx](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9Db2xvclNjaGVtZUNvbnRyb2wvaW5kZXguanN4) | `63.63% <ΓΈ> (ΓΈ)` | |
   | [...onents/controls/VizTypeControl/FastVizSwitcher.tsx](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9WaXpUeXBlQ29udHJvbC9GYXN0Vml6U3dpdGNoZXIudHN4) | `89.58% <ΓΈ> (ΓΈ)` | |
   | ... and [336 more](https://codecov.io/gh/apache/superset/pull/20589/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Ξ” = absolute <relative> (impact)`, `ΓΈ = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b870a21...d941abb](https://codecov.io/gh/apache/superset/pull/20589?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r912026191


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   @stephenLYZ I am having hard times understanding why the color map is always empty. Can you shed some light?



-- 
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


[GitHub] [superset] kgabryje commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r916079231


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   Also, shouldn't action like updating dashboard be handled in redux? Not sure what pattern we use in the rest of dashboard codebase, if we don't have a update dashboard action/thunk already, let's keep it as is



##########
superset-frontend/src/explore/components/controls/ColorSchemeControl/index.jsx:
##########
@@ -192,7 +192,7 @@ export default class ColorSchemeControl extends React.PureComponent {
       onChange: this.onChange,
       options,
       placeholder: t('Select scheme'),
-      value: currentScheme,
+      value: currentScheme && currentScheme.toString(),

Review Comment:
   ```suggestion
         value: currentScheme?.toString(),
   ```



##########
superset-frontend/src/dashboard/components/PropertiesModal/index.tsx:
##########
@@ -174,9 +174,13 @@ const PropertiesModal = ({
         delete metadata.positions;
       }
       const metaDataCopy = { ...metadata };
+
       if (metaDataCopy?.shared_label_colors) {
         delete metaDataCopy.shared_label_colors;
       }
+      if (metaDataCopy?.color_scheme_domain) {

Review Comment:
   I don't think we need that if statement. `metaDataCopy` object exists because we initialize it in line 176 and we don't need if field exists to call `delete` on it



##########
superset-frontend/src/explore/actions/hydrateExplore.ts:
##########
@@ -67,6 +71,31 @@ export const hydrateExplore =
       initialExploreState,
       initialFormData,
     ) as ControlStateMapping;
+    const colorSchemeKey = initialControls.color_scheme && 'color_scheme';
+    const linearColorSchemeKey =
+      initialControls.linear_color_scheme && 'linear_color_scheme';
+    // if the color scheme does not exist anymore
+    // fallbacks to the available default key
+    const verifyColorScheme = (type: 'CATEGORICAL' | 'SEQUENTIAL') => {
+      const schemes =
+        type === 'CATEGORICAL'
+          ? getCategoricalSchemeRegistry()
+          : getSequentialSchemeRegistry();
+      const key =
+        type === 'CATEGORICAL' ? colorSchemeKey : linearColorSchemeKey;
+      const defaultScheme = schemes.defaultKey
+        ? schemes.defaultKey
+        : type === 'CATEGORICAL'
+        ? 'supersetColors'
+        : 'superset_seq_1';

Review Comment:
   Could we simplify this expression? 



##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);

Review Comment:
   nit: `doesColorSchemeExist` or `colorSchemeExists` πŸ™‚ 



##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,10 +132,86 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  const verifyUpdateColorScheme = useCallback(() => {
+    const currentMetadata = dashboardInfo.metadata;
+    if (currentMetadata?.color_scheme) {
+      const metadata = { ...currentMetadata };
+      const colorScheme = metadata?.color_scheme;
+      const colorSchemeDomain = metadata?.color_scheme_domain || [];
+      const categoricalSchemes = getCategoricalSchemeRegistry();
+      const registryColorSchemeDomain =
+        categoricalSchemes.get(colorScheme)?.colors || [];
+      const defaultColorScheme = categoricalSchemes.defaultKey;
+      const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+      const updateDashboard = () => {
+        SupersetClient.put({
+          endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+          headers: { 'Content-Type': 'application/json' },
+          body: JSON.stringify({
+            json_metadata: jsonStringify(metadata),
+          }),
+        }).catch(e => console.log(e));

Review Comment:
   Can we add error handling? Like displaying error toast
   Also, success toast for success?



-- 
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


[GitHub] [superset] geido commented on a diff in pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #20589:
URL: https://github.com/apache/superset/pull/20589#discussion_r913769064


##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx:
##########
@@ -122,6 +132,65 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ topLevelTabs }) => {
     dispatch(setInScopeStatusOfFilters(scopes));
   }, [nativeFilterScopes, dashboardLayout, dispatch]);
 
+  useEffect(() => {
+    const currentMetadata = 
+      dashboardInfo.json_metadata?.length && JSON.parse(dashboardInfo.json_metadata);
+      if (currentMetadata?.color_scheme) {
+        const metadata = {...currentMetadata};
+        const colorScheme = metadata?.color_scheme;
+        const colorSchemeDomain = metadata?.color_scheme_domain || [];
+        const colorNamespace = metadata?.color_namespace || '';
+        const categoricalSchemes = getCategoricalSchemeRegistry();
+        const registryColorSchemeDomain = categoricalSchemes.get(colorScheme)?.colors || [];
+        const defaultColorScheme = categoricalSchemes.defaultKey;
+        const isColorSchemeExisting = !!categoricalSchemes.get(colorScheme);
+        const updateDashboard = () => {
+          SupersetClient.put({
+            endpoint: `/api/v1/dashboard/${dashboardInfo.id}`,
+            headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              json_metadata: jsonStringify(metadata),
+            }),
+          }).then(() => {
+            dispatch(dashboardInfoChanged({
+              metadata,
+            }));
+            dispatch(setColorScheme(defaultColorScheme))
+          })
+        }
+        const genColorMap = (scheme: string, update = false) => {
+          // TODO: to check why colorMap is always empty
+          const colorMap = getSharedLabelColor().getColorMap(

Review Comment:
   @stephenLYZ it looks like shared_label_colors are only generated for rendered charts



-- 
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


[GitHub] [superset] jinghua-qa commented on pull request #20589: chore: Update color scheme when deleted or changed

Posted by GitBox <gi...@apache.org>.
jinghua-qa commented on PR #20589:
URL: https://github.com/apache/superset/pull/20589#issuecomment-1181902670

   Regression test finished and did not see issues. LGTM!


-- 
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