Skip to content

Commit

Permalink
Fix typing and correct scope tree title
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed May 16, 2023
1 parent 1a281f2 commit 41a4816
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ export const ScopingTreePanel = ({
`Select the charts to which you want to apply cross-filters when interacting with this chart. You can select "All charts" to apply filters to all charts that use the same dataset or contain the same column name in the dashboard.`,
)
: t(
`Select the charts to which you want to be affected by cross-filters in this dashboard. Deselecting a chart will exclude it from being filtered when applying cross-filters from any chart on the dashboard. You can select "All charts" to apply cross-filters to all charts that use the same dataset or contain the same column name in the dashboard.`,
`Select the charts to which you want to apply cross-filters in this dashboard. Deselecting a chart will exclude it from being filtered when applying cross-filters from any chart on the dashboard. You can select "All charts" to apply cross-filters to all charts that use the same dataset or contain the same column name in the dashboard.`,
)}
</InfoText>
<ScopingTree
updateFormValues={onScopeUpdate}
initialScope={currentScope}
forceUpdate={noOp}
chartId={chartId}
title={t('All charts')}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ScopingTreeProps = {
initialScope: NativeFilterScope;
chartId?: number;
initiallyExcludedCharts?: number[];
title?: string;
};

const buildTreeLeafTitle = (
Expand Down Expand Up @@ -61,6 +62,7 @@ const ScopingTree: FC<ScopingTreeProps> = ({
updateFormValues,
chartId,
initiallyExcludedCharts = [],
title,
}) => {
const [expandedKeys, setExpandedKeys] = useState<string[]>([
DASHBOARD_ROOT_ID,
Expand All @@ -70,6 +72,7 @@ const ScopingTree: FC<ScopingTreeProps> = ({
chartId,
initiallyExcludedCharts,
buildTreeLeafTitle,
title,
);
const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import { buildTree } from './utils';

// eslint-disable-next-line import/prefer-default-export
export function useFilterScopeTree(
currentChartId?: number,
currentChartId: number | undefined,
initiallyExcludedCharts: number[] = [],
buildTreeLeafTitle: BuildTreeLeafTitle = label => label,
title = t('All panels'),
): {
treeData: [TreeItem];
layout: Layout;
Expand All @@ -46,7 +47,7 @@ export function useFilterScopeTree(
children: [],
key: DASHBOARD_ROOT_ID,
type: DASHBOARD_ROOT_TYPE,
title: t('All panels'),
title,
};

// We need to get only nodes that have charts as children or grandchildren
Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/src/hooks/useMemoCompare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { useEffect, useRef } from 'react';
import { isDefined } from '@superset-ui/core';

export const useMemoCompare = <T>(
next: T,
Expand All @@ -31,5 +32,8 @@ export const useMemoCompare = <T>(
previousRef.current = next;
}
});
if (!isDefined(previous)) {
return next;
}
return isEqual ? previous : next;
};

0 comments on commit 41a4816

Please sign in to comment.