mirror of https://github.com/buster-so/buster.git
better metric table chart updates
This commit is contained in:
parent
4d071843df
commit
0870b52f04
|
@ -1,7 +1,6 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import type { BusterTableChartConfig } from './interfaces';
|
import type { BusterTableChartConfig } from './interfaces';
|
||||||
import { formatLabel } from '@/lib/columnFormatter';
|
import { formatLabel } from '@/lib/columnFormatter';
|
||||||
import isEqual from 'lodash/isEqual';
|
|
||||||
import {
|
import {
|
||||||
type IBusterMetricChartConfig,
|
type IBusterMetricChartConfig,
|
||||||
type BusterChartPropsBase,
|
type BusterChartPropsBase,
|
||||||
|
@ -11,9 +10,8 @@ import { useMemoizedFn } from '@/hooks';
|
||||||
import { AppDataGrid } from '@/components/ui/table/AppDataGrid';
|
import { AppDataGrid } from '@/components/ui/table/AppDataGrid';
|
||||||
import './TableChart.css';
|
import './TableChart.css';
|
||||||
import { cn } from '@/lib/classMerge';
|
import { cn } from '@/lib/classMerge';
|
||||||
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import { useUpdateMetricChart } from '@/context/Metrics';
|
import { useUpdateMetricChart } from '@/context/Metrics';
|
||||||
import { useUpdateMetric } from '@/api/buster_rest/metrics';
|
|
||||||
import { useOriginalMetricStore } from '@/context/Metrics/useOriginalMetricStore';
|
|
||||||
|
|
||||||
export interface BusterTableChartProps extends BusterTableChartConfig, BusterChartPropsBase {}
|
export interface BusterTableChartProps extends BusterTableChartConfig, BusterChartPropsBase {}
|
||||||
|
|
||||||
|
@ -37,7 +35,10 @@ const BusterTableChartBase: React.FC<BusterTableChartProps> = ({
|
||||||
if (readOnly) return;
|
if (readOnly) return;
|
||||||
onUpdateMetricChartConfig({ chartConfig: config });
|
onUpdateMetricChartConfig({ chartConfig: config });
|
||||||
|
|
||||||
if (tableColumnWidths === null && !!config.tableColumnWidths) {
|
if (
|
||||||
|
(tableColumnWidths === null || isEmpty(tableColumnWidths)) &&
|
||||||
|
!isEmpty(config.tableColumnWidths)
|
||||||
|
) {
|
||||||
onInitializeTableColumnWidths(config.tableColumnWidths);
|
onInitializeTableColumnWidths(config.tableColumnWidths);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,9 +31,6 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin
|
||||||
saveToServer: true,
|
saveToServer: true,
|
||||||
updateVersion: !chatId
|
updateVersion: !chatId
|
||||||
});
|
});
|
||||||
const { mutateAsync: saveMetricToServerWithoutSideEffects } = useSaveMetric({
|
|
||||||
updateOnSave: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const getMetricMemoized = useGetMetricMemoized();
|
const getMetricMemoized = useGetMetricMemoized();
|
||||||
|
|
||||||
|
@ -145,12 +142,6 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin
|
||||||
...originalMetric,
|
...originalMetric,
|
||||||
chart_config: newChartConfig
|
chart_config: newChartConfig
|
||||||
});
|
});
|
||||||
|
|
||||||
saveMetricToServerWithoutSideEffects({
|
|
||||||
id: metricId,
|
|
||||||
chart_config: newChartConfig,
|
|
||||||
update_version: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue