mirror of https://github.com/buster-so/buster.git
minor structural changes
This commit is contained in:
parent
1c00f1df62
commit
0ebfd60e84
|
@ -147,6 +147,7 @@ export const useSaveMetric = (params?: { updateOnSave?: boolean }) => {
|
|||
mutationFn: updateMetric,
|
||||
onMutate: async ({ id, restore_to_version }) => {
|
||||
const isRestoringVersion = restore_to_version !== undefined;
|
||||
//set the current metric to the previous it is being restored to
|
||||
if (isRestoringVersion) {
|
||||
const oldMetric = queryClient.getQueryData(metricsQueryKeys.metricsGetMetric(id).queryKey);
|
||||
const newMetric = queryClient.getQueryData(
|
||||
|
@ -347,12 +348,18 @@ export const useUpdateMetric = (params?: {
|
|||
wait?: number;
|
||||
updateOnSave?: boolean;
|
||||
updateVersion?: boolean;
|
||||
saveToServer?: boolean;
|
||||
}) => {
|
||||
const { wait = 650, updateOnSave = false, updateVersion = true } = params || {};
|
||||
const {
|
||||
wait = 650,
|
||||
updateOnSave = false,
|
||||
updateVersion = false,
|
||||
saveToServer = true
|
||||
} = params || {};
|
||||
const queryClient = useQueryClient();
|
||||
const { mutateAsync: saveMetric } = useSaveMetric({ updateOnSave });
|
||||
|
||||
const { run: saveMetricDebounced } = useDebounceFn(
|
||||
const { run: saveMetricToServerDebounced } = useDebounceFn(
|
||||
useMemoizedFn((newMetric: IBusterMetric, prevMetric: IBusterMetric) => {
|
||||
const changedValues = prepareMetricUpdateMetric(newMetric, prevMetric);
|
||||
if (changedValues) {
|
||||
|
@ -383,8 +390,8 @@ export const useUpdateMetric = (params?: {
|
|||
async (newMetricPartial: Partial<IBusterMetric> & { id: string }) => {
|
||||
const { newMetric, prevMetric } = await combineAndSaveMetric(newMetricPartial);
|
||||
|
||||
if (newMetric && prevMetric) {
|
||||
saveMetricDebounced(newMetric, prevMetric);
|
||||
if (newMetric && prevMetric && saveToServer) {
|
||||
saveMetricToServerDebounced(newMetric, prevMetric);
|
||||
}
|
||||
|
||||
return newMetric;
|
||||
|
|
|
@ -57,7 +57,7 @@ export const MetricViewChart: React.FC<{
|
|||
const showEvaluation = !!evaluation_score && !!evaluation_summary;
|
||||
|
||||
const onSetTitle = useMemoizedFn((title: string) => {
|
||||
if (updateMetric && inputHasText(title)) {
|
||||
if (inputHasText(title)) {
|
||||
updateMetric({
|
||||
id: metricId,
|
||||
name: title
|
||||
|
|
|
@ -18,7 +18,6 @@ import type {
|
|||
ScatterAxis
|
||||
} from '@/api/asset_interfaces/metric/charts';
|
||||
import { type updateMetric } from '@/api/buster_rest/metrics';
|
||||
import { create } from 'mutative';
|
||||
import { createDefaultChartConfig } from './messageAutoChartHandler';
|
||||
|
||||
const DEFAULT_COLUMN_SETTINGS_ENTRIES = Object.entries(DEFAULT_COLUMN_SETTINGS);
|
||||
|
|
Loading…
Reference in New Issue