Copilot commented on code in PR #31495:
URL: https://github.com/apache/superset/pull/31495#discussion_r2237728377
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props:
SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
+
+ if (!columns?.length || isCurrentValueSelected) {
+ return {
+ dataMask: {
+ extraFormData: {
+ filters: [],
+ },
+ filterState: {
+ value: null,
+ selectedValues: [],
+ },
+ },
+ isCurrentValueSelected,
+ };
}
- const labels = values.map(value => labelMap[value]);
return {
dataMask: {
extraFormData: {
- filters:
- values.length === 0 || !columns
- ? []
- : columns.slice(0, treePath.length).map((col, idx) => {
- const val = labels.map(v => v[idx]);
- if (val === null || val === undefined)
- return {
- col,
- op: 'IS NULL' as const,
- };
- return {
- col,
- op: 'IN' as const,
- val: val as (string | number | boolean)[],
- };
- }),
+ filters: [
+ {
+ col: columns[treePath.length - 1],
+ op: '==' as const,
+ val: value,
+ },
+ ],
},
filterState: {
- value: labels.length ? labels : null,
- selectedValues: values.length ? values : null,
+ value,
+ selectedValues: [joinedThreePath],
Review Comment:
Variable reference contains the same typo: 'joinedThreePath' should be
'joinedTreePath'.
```suggestion
selectedValues: [joinedTreePath],
```
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props:
SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
Review Comment:
Variable name contains a typo: 'joinedThreePath' should be 'joinedTreePath'
(missing 'e' in 'tree').
```suggestion
const joinedTreePath = treePath.join(',');
const value = treePath[treePath.length - 1];
const isCurrentValueSelected =
Object.values(selectedValues).includes(joinedTreePath);
```
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props:
SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
Review Comment:
Variable reference contains the same typo: 'joinedThreePath' should be
'joinedTreePath'.
```suggestion
const joinedTreePath = treePath.join(',');
const value = treePath[treePath.length - 1];
const isCurrentValueSelected =
Object.values(selectedValues).includes(joinedTreePath);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]