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/29 03:49:57 UTC

[GitHub] [superset] diegomedina248 opened a new pull request, #20910: chore: refactor ChartHolder to typescript + tests

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

   ### SUMMARY
   
   This PR refactors the ChartHolder into a functional component with typescript.
   It also adds more test coverage.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   --
   
   ### TESTING INSTRUCTIONS
   --
   
   ### ADDITIONAL INFORMATION
   - [ ] 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] jinghua-qa commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   Test again in the new ephemeral env and verified the reported issue is fixed. Regression test for dashboard 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


[GitHub] [superset] kgabryje merged pull request #20910: chore: refactor ChartHolder to typescript + tests

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


-- 
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] yousoph commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   /testenv up


-- 
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] diegomedina248 commented on a diff in pull request #20910: chore: refactor ChartHolder to typescript + tests

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


##########
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.tsx:
##########
@@ -0,0 +1,333 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState, useMemo, useCallback, useEffect } from 'react';
+import { ResizeCallback, ResizeStartCallback } from 're-resizable';
+import cx from 'classnames';
+import { useSelector } from 'react-redux';
+
+import { LayoutItem, RootState } from 'src/dashboard/types';
+import AnchorLink from 'src/dashboard/components/AnchorLink';
+import Chart from 'src/dashboard/containers/Chart';
+import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
+import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
+import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
+import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
+import getChartAndLabelComponentIdFromPath from 'src/dashboard/util/getChartAndLabelComponentIdFromPath';
+import useFilterFocusHighlightStyles from 'src/dashboard/util/useFilterFocusHighlightStyles';
+import { COLUMN_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes';
+import {
+  GRID_BASE_UNIT,
+  GRID_GUTTER_SIZE,
+  GRID_MIN_COLUMN_COUNT,
+  GRID_MIN_ROW_UNITS,
+} from 'src/dashboard/util/constants';
+
+export const CHART_MARGIN = 32;
+
+interface ChartHolderProps {
+  id: string;
+  parentId: string;
+  dashboardId: number;
+  component: LayoutItem;
+  parentComponent: LayoutItem;
+  getComponentById?: (id?: string) => LayoutItem | undefined;
+  index: number;
+  depth: number;
+  editMode: boolean;
+  directPathLastUpdated?: number;
+  fullSizeChartId: number | null;
+  isComponentVisible: boolean;
+
+  // grid related
+  availableColumnCount: number;
+  columnWidth: number;
+  onResizeStart: ResizeStartCallback;
+  onResize: ResizeCallback;
+  onResizeStop: ResizeCallback;
+
+  // dnd
+  deleteComponent: (id: string, parentId: string) => void;
+  updateComponents: Function;
+  handleComponentDrop: (...args: unknown[]) => unknown;
+  setFullSizeChartId: (chartId: number | null) => void;
+  postAddSliceFromDashboard?: () => void;
+}
+
+const ChartHolder: React.FC<ChartHolderProps> = ({
+  id,
+  parentId,
+  component,
+  parentComponent,
+  index,
+  depth,
+  availableColumnCount,
+  columnWidth,
+  onResizeStart,
+  onResize,
+  onResizeStop,
+  editMode,
+  isComponentVisible,
+  dashboardId,
+  fullSizeChartId,
+  getComponentById = () => undefined,
+  deleteComponent,
+  updateComponents,
+  handleComponentDrop,
+  setFullSizeChartId,
+  postAddSliceFromDashboard,
+}) => {
+  const { chartId } = component.meta;
+  const isFullSize = fullSizeChartId === chartId;
+
+  const focusHighlightStyles = useFilterFocusHighlightStyles(chartId);
+  const dashboardState = useSelector(
+    (state: RootState) => state.dashboardState,
+  );
+  const [extraControls, setExtraControls] = useState<Record<string, unknown>>(
+    {},
+  );
+  const [outlinedComponentId, setOutlinedComponentId] = useState<string>();
+  const [outlinedColumnName, setOutlinedColumnName] = useState<string>();
+  const [currentDirectPathLastUpdated, setCurrentDirectPathLastUpdated] =
+    useState(0);
+
+  const directPathToChild = useMemo(

Review Comment:
   These two are used in other hooks/callbacks below, so need to memoize those to avoid recomputing everything (even if it's just a string/etc)



-- 
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 #20910: chore: refactor ChartHolder to typescript + tests

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20910?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 [#20910](https://codecov.io/gh/apache/superset/pull/20910?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (efe387e) into [master](https://codecov.io/gh/apache/superset/commit/d50784dd808cf908567e2c7f9fa67188202c59b9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d50784d) will **increase** coverage by `0.05%`.
   > The diff coverage is `91.75%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #20910      +/-   ##
   ==========================================
   + Coverage   66.21%   66.26%   +0.05%     
   ==========================================
     Files        1758     1759       +1     
     Lines       67009    67015       +6     
     Branches     7107     7108       +1     
   ==========================================
   + Hits        44369    44410      +41     
   + Misses      20818    20793      -25     
   + Partials     1822     1812      -10     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `52.11% <91.75%> (+0.10%)` | :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/20910?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...tend/src/dashboard/components/AnchorLink/index.tsx](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL0FuY2hvckxpbmsvaW5kZXgudHN4) | `93.75% <ø> (+12.50%)` | :arrow_up: |
   | [...ashboard/components/gridComponents/ChartHolder.tsx](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0NoYXJ0SG9sZGVyLnRzeA==) | `88.88% <88.88%> (ø)` | |
   | [...end/src/dashboard/components/dnd/DragDroppable.jsx](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2RuZC9EcmFnRHJvcHBhYmxlLmpzeA==) | `76.92% <100.00%> (ø)` | |
   | [...rc/dashboard/util/useFilterFocusHighlightStyles.ts](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL3VzZUZpbHRlckZvY3VzSGlnaGxpZ2h0U3R5bGVzLnRz) | `100.00% <100.00%> (ø)` | |
   | [...-frontend/src/dashboard/reducers/dashboardState.js](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9yZWR1Y2Vycy9kYXNoYm9hcmRTdGF0ZS5qcw==) | `76.59% <0.00%> (+2.12%)` | :arrow_up: |
   | [...hboard/components/resizable/ResizableContainer.jsx](https://codecov.io/gh/apache/superset/pull/20910/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-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL3Jlc2l6YWJsZS9SZXNpemFibGVDb250YWluZXIuanN4) | `61.70% <0.00%> (+4.25%)` | :arrow_up: |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?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] jinghua-qa commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   /testenv up


-- 
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] diegomedina248 commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   > @diegomedina248 Thank you for this PR! I have a SqlEditor refactoring into FC, can I share the code with you? @michael-s-molina @kgabryje Can we merge the PR?
   
   @EugeneTorap sure thing!


-- 
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] github-actions[bot] commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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 #20910: chore: refactor ChartHolder to typescript + tests

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

   /testenv up


-- 
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] EugeneTorap commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @michael-s-molina Can you review the PR and then merge it?


-- 
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] yousoph commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   🏷️ Preset-Patch


-- 
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] Antonio-RiveroMartnez commented on a diff in pull request #20910: chore: refactor ChartHolder to typescript + tests

Posted by GitBox <gi...@apache.org>.
Antonio-RiveroMartnez commented on code in PR #20910:
URL: https://github.com/apache/superset/pull/20910#discussion_r937832782


##########
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.tsx:
##########
@@ -0,0 +1,333 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState, useMemo, useCallback, useEffect } from 'react';
+import { ResizeCallback, ResizeStartCallback } from 're-resizable';
+import cx from 'classnames';
+import { useSelector } from 'react-redux';
+
+import { LayoutItem, RootState } from 'src/dashboard/types';
+import AnchorLink from 'src/dashboard/components/AnchorLink';
+import Chart from 'src/dashboard/containers/Chart';
+import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
+import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
+import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
+import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
+import getChartAndLabelComponentIdFromPath from 'src/dashboard/util/getChartAndLabelComponentIdFromPath';
+import useFilterFocusHighlightStyles from 'src/dashboard/util/useFilterFocusHighlightStyles';
+import { COLUMN_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes';
+import {
+  GRID_BASE_UNIT,
+  GRID_GUTTER_SIZE,
+  GRID_MIN_COLUMN_COUNT,
+  GRID_MIN_ROW_UNITS,
+} from 'src/dashboard/util/constants';
+
+export const CHART_MARGIN = 32;
+
+interface ChartHolderProps {
+  id: string;
+  parentId: string;
+  dashboardId: number;
+  component: LayoutItem;
+  parentComponent: LayoutItem;
+  getComponentById?: (id?: string) => LayoutItem | undefined;
+  index: number;
+  depth: number;
+  editMode: boolean;
+  directPathLastUpdated?: number;
+  fullSizeChartId: number | null;
+  isComponentVisible: boolean;
+
+  // grid related
+  availableColumnCount: number;
+  columnWidth: number;
+  onResizeStart: ResizeStartCallback;
+  onResize: ResizeCallback;
+  onResizeStop: ResizeCallback;
+
+  // dnd
+  deleteComponent: (id: string, parentId: string) => void;
+  updateComponents: Function;
+  handleComponentDrop: (...args: unknown[]) => unknown;
+  setFullSizeChartId: (chartId: number | null) => void;
+  postAddSliceFromDashboard?: () => void;
+}
+
+const ChartHolder: React.FC<ChartHolderProps> = ({
+  id,
+  parentId,
+  component,
+  parentComponent,
+  index,
+  depth,
+  availableColumnCount,
+  columnWidth,
+  onResizeStart,
+  onResize,
+  onResizeStop,
+  editMode,
+  isComponentVisible,
+  dashboardId,
+  fullSizeChartId,
+  getComponentById = () => undefined,
+  deleteComponent,
+  updateComponents,
+  handleComponentDrop,
+  setFullSizeChartId,
+  postAddSliceFromDashboard,
+}) => {
+  const { chartId } = component.meta;
+  const isFullSize = fullSizeChartId === chartId;
+
+  const focusHighlightStyles = useFilterFocusHighlightStyles(chartId);
+  const dashboardState = useSelector(
+    (state: RootState) => state.dashboardState,
+  );
+  const [extraControls, setExtraControls] = useState<Record<string, unknown>>(
+    {},
+  );
+  const [outlinedComponentId, setOutlinedComponentId] = useState<string>();
+  const [outlinedColumnName, setOutlinedColumnName] = useState<string>();
+  const [currentDirectPathLastUpdated, setCurrentDirectPathLastUpdated] =
+    useState(0);
+
+  const directPathToChild = useMemo(

Review Comment:
   I might be mistaken, but since we are not computing an expensive function, just accessing a property inside the `dashboardState` object, could we get rid of `useMemo`? Or there is some performance implication if we remove it, that I'm not seeing. Same with `directPathLastUpdated` below.



-- 
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] github-actions[bot] commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @yousoph Ephemeral environment spinning up at http://54.202.171.173:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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 #20910: chore: refactor ChartHolder to typescript + tests

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


##########
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.tsx:
##########
@@ -0,0 +1,333 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState, useMemo, useCallback, useEffect } from 'react';
+import { ResizeCallback, ResizeStartCallback } from 're-resizable';
+import cx from 'classnames';
+import { useSelector } from 'react-redux';
+
+import { LayoutItem, RootState } from 'src/dashboard/types';
+import AnchorLink from 'src/dashboard/components/AnchorLink';
+import Chart from 'src/dashboard/containers/Chart';
+import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
+import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
+import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
+import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
+import getChartAndLabelComponentIdFromPath from 'src/dashboard/util/getChartAndLabelComponentIdFromPath';
+import useFilterFocusHighlightStyles from 'src/dashboard/util/useFilterFocusHighlightStyles';
+import { COLUMN_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes';
+import {
+  GRID_BASE_UNIT,
+  GRID_GUTTER_SIZE,
+  GRID_MIN_COLUMN_COUNT,
+  GRID_MIN_ROW_UNITS,
+} from 'src/dashboard/util/constants';
+
+export const CHART_MARGIN = 32;
+
+interface ChartHolderProps {
+  id: string;
+  parentId: string;
+  dashboardId: number;
+  component: LayoutItem;
+  parentComponent: LayoutItem;
+  getComponentById?: (id?: string) => LayoutItem | undefined;
+  index: number;
+  depth: number;
+  editMode: boolean;
+  directPathLastUpdated?: number;
+  fullSizeChartId: number | null;
+  isComponentVisible: boolean;
+
+  // grid related
+  availableColumnCount: number;
+  columnWidth: number;
+  onResizeStart: ResizeStartCallback;
+  onResize: ResizeCallback;
+  onResizeStop: ResizeCallback;
+
+  // dnd
+  deleteComponent: (id: string, parentId: string) => void;
+  updateComponents: Function;
+  handleComponentDrop: (...args: unknown[]) => unknown;
+  setFullSizeChartId: (chartId: number | null) => void;
+  postAddSliceFromDashboard?: () => void;
+}
+
+const ChartHolder: React.FC<ChartHolderProps> = ({
+  id,
+  parentId,
+  component,
+  parentComponent,
+  index,
+  depth,
+  availableColumnCount,
+  columnWidth,
+  onResizeStart,
+  onResize,
+  onResizeStop,
+  editMode,
+  isComponentVisible,
+  dashboardId,
+  fullSizeChartId,
+  getComponentById = () => undefined,
+  deleteComponent,
+  updateComponents,
+  handleComponentDrop,
+  setFullSizeChartId,
+  postAddSliceFromDashboard,
+}) => {
+  const { chartId } = component.meta;
+  const isFullSize = fullSizeChartId === chartId;
+
+  const focusHighlightStyles = useFilterFocusHighlightStyles(chartId);
+  const dashboardState = useSelector(
+    (state: RootState) => state.dashboardState,
+  );
+  const [extraControls, setExtraControls] = useState<Record<string, unknown>>(
+    {},
+  );
+  const [outlinedComponentId, setOutlinedComponentId] = useState<string>();
+  const [outlinedColumnName, setOutlinedColumnName] = useState<string>();
+  const [currentDirectPathLastUpdated, setCurrentDirectPathLastUpdated] =
+    useState(0);
+
+  const directPathToChild = useMemo(
+    () => dashboardState?.directPathToChild ?? [],
+    [dashboardState],
+  );
+
+  const directPathLastUpdated = useMemo(
+    () => dashboardState?.directPathLastUpdated ?? 0,
+    [dashboardState],
+  );
+
+  const infoFromPath = useMemo(
+    () => getChartAndLabelComponentIdFromPath(directPathToChild) as any,

Review Comment:
   Is it possible to not use `any` here?



-- 
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] EugeneTorap commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @michael-s-molina @kgabryje Can you review the PR and then merge it?


-- 
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 #20910: chore: refactor ChartHolder to typescript + tests

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

   /testenv up


-- 
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] EugeneTorap commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @diegomedina248 Thank you for this PR! I have a SqlEditor refactoring into FC, can I share the code with you?
   @michael-s-molina @kgabryje Can we merge the PR?


-- 
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] diegomedina248 commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   > I found some issues in this PR: 1, if user click on the filter indicator when chart is in fullscreen view, user will bring out to the normal view and the 3 dot menu on charts are not open. I test on superset master it seems like on master click on the filter indicator in enlarge chart view did not bring user to fullscreen view.
   > 
   >  Screen.Recording.2022-08-18.at.11.06.53.AM.mov 
   > 2, for numerical filter, it looks like the filter bar is not shown correctly when user select filter range: <img alt="Screen Shot 2022-08-18 at 11 13 27 AM" width="1792" src="https://user-images.githubusercontent.com/81597121/185465549-4974da3a-76de-4b9b-b50b-e8beba111d08.png">
   
   mm, I actually couldn't reproduce those.
   I did rebase from master, to have the branch up to date, and couldn't reproduce either that way.
   
   Here's what I'm doing:
   
   https://user-images.githubusercontent.com/17252075/185916954-9f0699d2-6808-4773-823d-2188fdfa801f.mov
   


-- 
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] github-actions[bot] commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @jinghua-qa Ephemeral environment spinning up at http://34.221.79.198:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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] github-actions[bot] commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @jinghua-qa Ephemeral environment spinning up at http://54.214.218.74:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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] github-actions[bot] commented on pull request #20910: chore: refactor ChartHolder to typescript + tests

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

   @jinghua-qa Ephemeral environment spinning up at http://54.214.218.74:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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 #20910: chore: refactor ChartHolder to typescript + tests

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

   I found an issue that if user click on the filter indicator when chart is in fullscreen view, user will bring out to the normal view and the 3 dot menu on charts are not open. I test on superset master it seems like on master click on the filter indicator in enlarge chart view did not bring user to fullscreen view.
   
   https://user-images.githubusercontent.com/81597121/185463251-0c2ffd93-8d7d-4642-93fb-02d2494c986d.mov
   
   
   


-- 
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] diegomedina248 commented on a diff in pull request #20910: chore: refactor ChartHolder to typescript + tests

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


##########
superset-frontend/src/dashboard/components/gridComponents/ChartHolder.tsx:
##########
@@ -0,0 +1,333 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState, useMemo, useCallback, useEffect } from 'react';
+import { ResizeCallback, ResizeStartCallback } from 're-resizable';
+import cx from 'classnames';
+import { useSelector } from 'react-redux';
+
+import { LayoutItem, RootState } from 'src/dashboard/types';
+import AnchorLink from 'src/dashboard/components/AnchorLink';
+import Chart from 'src/dashboard/containers/Chart';
+import DeleteComponentButton from 'src/dashboard/components/DeleteComponentButton';
+import DragDroppable from 'src/dashboard/components/dnd/DragDroppable';
+import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
+import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
+import getChartAndLabelComponentIdFromPath from 'src/dashboard/util/getChartAndLabelComponentIdFromPath';
+import useFilterFocusHighlightStyles from 'src/dashboard/util/useFilterFocusHighlightStyles';
+import { COLUMN_TYPE, ROW_TYPE } from 'src/dashboard/util/componentTypes';
+import {
+  GRID_BASE_UNIT,
+  GRID_GUTTER_SIZE,
+  GRID_MIN_COLUMN_COUNT,
+  GRID_MIN_ROW_UNITS,
+} from 'src/dashboard/util/constants';
+
+export const CHART_MARGIN = 32;
+
+interface ChartHolderProps {
+  id: string;
+  parentId: string;
+  dashboardId: number;
+  component: LayoutItem;
+  parentComponent: LayoutItem;
+  getComponentById?: (id?: string) => LayoutItem | undefined;
+  index: number;
+  depth: number;
+  editMode: boolean;
+  directPathLastUpdated?: number;
+  fullSizeChartId: number | null;
+  isComponentVisible: boolean;
+
+  // grid related
+  availableColumnCount: number;
+  columnWidth: number;
+  onResizeStart: ResizeStartCallback;
+  onResize: ResizeCallback;
+  onResizeStop: ResizeCallback;
+
+  // dnd
+  deleteComponent: (id: string, parentId: string) => void;
+  updateComponents: Function;
+  handleComponentDrop: (...args: unknown[]) => unknown;
+  setFullSizeChartId: (chartId: number | null) => void;
+  postAddSliceFromDashboard?: () => void;
+}
+
+const ChartHolder: React.FC<ChartHolderProps> = ({
+  id,
+  parentId,
+  component,
+  parentComponent,
+  index,
+  depth,
+  availableColumnCount,
+  columnWidth,
+  onResizeStart,
+  onResize,
+  onResizeStop,
+  editMode,
+  isComponentVisible,
+  dashboardId,
+  fullSizeChartId,
+  getComponentById = () => undefined,
+  deleteComponent,
+  updateComponents,
+  handleComponentDrop,
+  setFullSizeChartId,
+  postAddSliceFromDashboard,
+}) => {
+  const { chartId } = component.meta;
+  const isFullSize = fullSizeChartId === chartId;
+
+  const focusHighlightStyles = useFilterFocusHighlightStyles(chartId);
+  const dashboardState = useSelector(
+    (state: RootState) => state.dashboardState,
+  );
+  const [extraControls, setExtraControls] = useState<Record<string, unknown>>(
+    {},
+  );
+  const [outlinedComponentId, setOutlinedComponentId] = useState<string>();
+  const [outlinedColumnName, setOutlinedColumnName] = useState<string>();
+  const [currentDirectPathLastUpdated, setCurrentDirectPathLastUpdated] =
+    useState(0);
+
+  const directPathToChild = useMemo(
+    () => dashboardState?.directPathToChild ?? [],
+    [dashboardState],
+  );
+
+  const directPathLastUpdated = useMemo(
+    () => dashboardState?.directPathLastUpdated ?? 0,
+    [dashboardState],
+  );
+
+  const infoFromPath = useMemo(
+    () => getChartAndLabelComponentIdFromPath(directPathToChild) as any,

Review Comment:
   We could, but we'd need to change the file that contains that function to typescript, and there's a couple of types around the filters that are not well defined.
   Plus, changing that file should follow with tests as well, and I didn't want to make this PR bigger, since it can be addressed as a follow up



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