Skip to content

Commit

Permalink
update chart name with layoutItem
Browse files Browse the repository at this point in the history
  • Loading branch information
Lily Kuang committed Mar 29, 2023
1 parent ba60278 commit 85ac0e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ export const DrillByMenuItems = ({
</div>
</Menu.SubMenu>
<DrillByModal
chartId={chartId}
column={currentColumn}
filters={filters}
formData={formData}
Expand Down
15 changes: 8 additions & 7 deletions superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import Modal from 'src/components/Modal';
import Button from 'src/components/Button';
import { useSelector } from 'react-redux';
import { Slice } from 'src/types/Chart';
import { DashboardLayout, RootState } from 'src/dashboard/types';

interface ModalFooterProps {
exploreChart: () => void;
Expand All @@ -52,7 +52,6 @@ const ModalFooter = ({ exploreChart, closeModal }: ModalFooterProps) => (
);

interface DrillByModalProps {
chartId: number;
column?: Column;
filters?: BinaryQueryObjectFilterClause[];
formData: { [key: string]: any; viz_type: string };
Expand All @@ -61,7 +60,6 @@ interface DrillByModalProps {
}

export default function DrillByModal({
chartId,
column,
formData,
filters,
Expand All @@ -72,11 +70,14 @@ export default function DrillByModal({
console.log(formData);
console.log(filters);
const theme = useTheme();
const { slice_name: chartName } = useSelector(
(state: { sliceEntities: { slices: Record<number, Slice> } }) =>
state.sliceEntities.slices[chartId],
const dashboardLayout = useSelector<RootState, DashboardLayout>(
state => state.dashboardLayout.present,
);

const chartLayoutItem = Object.values(dashboardLayout).find(
layoutItem => layoutItem.meta?.chartId === formData.slice_id,
);
const chartName =
chartLayoutItem?.meta.sliceName || chartLayoutItem?.meta.sliceNameOverride;
const exploreChart = () => {};

return (
Expand Down

0 comments on commit 85ac0e9

Please sign in to comment.