mirror of https://github.com/buster-so/buster.git
dashboard metrics can now be added 🐝
This commit is contained in:
parent
54ae8adc81
commit
8634cb0f79
|
@ -31,7 +31,7 @@
|
|||
"@supabase/ssr": "^0.6.1",
|
||||
"@supabase/supabase-js": "^2.49.4",
|
||||
"@tanstack/query-sync-storage-persister": "^5.74.3",
|
||||
"@tanstack/react-form": "^1.4.0",
|
||||
"@tanstack/react-form": "^1.5.0",
|
||||
"@tanstack/react-query": "^5.74.3",
|
||||
"@tanstack/react-query-devtools": "^5.74.3",
|
||||
"@tanstack/react-query-persist-client": "^5.74.3",
|
||||
|
@ -6724,9 +6724,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@tanstack/form-core": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/form-core/-/form-core-1.4.0.tgz",
|
||||
"integrity": "sha512-nZIZ6wgU5ETbamWvvnQherG5Y+kyYXUozGQpylYTFSj4aEuXUGUn35YKnupbJUjiAVFV+27n9BCKYhtNFVdRLA==",
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/form-core/-/form-core-1.5.0.tgz",
|
||||
"integrity": "sha512-7//AOAq4NbuiqbdZY16ewJhrUP9Uf+Qa3jsuP42MO2Lkmt88cWsX5MpTPj4i8Ij72Hme0e2VuxvGHPr+0D2Pow==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/store": "^0.7.0"
|
||||
|
@ -6784,12 +6784,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-form": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-form/-/react-form-1.4.0.tgz",
|
||||
"integrity": "sha512-JRFthNXDtRw7hmJ7AX8Od51bRUjLF7zj2P9G7heFUOBc1szAd0oo4EzX8pbW+BVy7fNkjGK6FlLR2c0G5dM+GQ==",
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-form/-/react-form-1.5.0.tgz",
|
||||
"integrity": "sha512-36mZXiR5v3llybH5XHEyBZ+DPGJIrHJql8VhrhX5qio6ql6VgUHDyRuPtOEMEfg6lFpUQcKPXdpXXHnS9IVuSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/form-core": "1.4.0",
|
||||
"@tanstack/form-core": "1.5.0",
|
||||
"@tanstack/react-store": "^0.7.0",
|
||||
"decode-formdata": "^0.9.0",
|
||||
"devalue": "^5.1.1"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"@supabase/ssr": "^0.6.1",
|
||||
"@supabase/supabase-js": "^2.49.4",
|
||||
"@tanstack/query-sync-storage-persister": "^5.74.3",
|
||||
"@tanstack/react-form": "^1.4.0",
|
||||
"@tanstack/react-form": "^1.5.0",
|
||||
"@tanstack/react-query": "^5.74.3",
|
||||
"@tanstack/react-query-devtools": "^5.74.3",
|
||||
"@tanstack/react-query-persist-client": "^5.74.3",
|
||||
|
|
|
@ -482,9 +482,9 @@ const useEnsureDashboardConfig = (prefetchData: boolean = true) => {
|
|||
|
||||
export const useAddAndRemoveMetricsFromDashboard = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const versionNumber = useGetDashboardVersionNumber();
|
||||
const { openErrorMessage } = useBusterNotifications();
|
||||
const ensureDashboardConfig = useEnsureDashboardConfig(false);
|
||||
const setOriginalDashboard = useOriginalDashboardStore((x) => x.setOriginalDashboard);
|
||||
|
||||
const addAndRemoveMetrics = useMemoizedFn(
|
||||
async ({ metricIds, dashboardId }: { metricIds: string[]; dashboardId: string }) => {
|
||||
|
@ -522,11 +522,16 @@ export const useAddAndRemoveMetricsFromDashboard = () => {
|
|||
mutationFn: addAndRemoveMetrics,
|
||||
onSuccess: (data, variables) => {
|
||||
if (data) {
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, undefined).queryKey,
|
||||
data
|
||||
);
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, data.dashboard.version_number)
|
||||
.queryKey,
|
||||
data
|
||||
);
|
||||
setOriginalDashboard(data.dashboard);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -536,6 +541,7 @@ export const useAddMetricsToDashboard = () => {
|
|||
const queryClient = useQueryClient();
|
||||
const { openErrorMessage } = useBusterNotifications();
|
||||
const ensureDashboardConfig = useEnsureDashboardConfig(false);
|
||||
const setOriginalDashboard = useOriginalDashboardStore((x) => x.setOriginalDashboard);
|
||||
|
||||
const addMetricToDashboard = useMemoizedFn(
|
||||
async ({ metricIds, dashboardId }: { metricIds: string[]; dashboardId: string }) => {
|
||||
|
@ -557,11 +563,16 @@ export const useAddMetricsToDashboard = () => {
|
|||
mutationFn: addMetricToDashboard,
|
||||
onSuccess: (data, variables) => {
|
||||
if (data) {
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, undefined).queryKey,
|
||||
data
|
||||
);
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, data.dashboard.version_number)
|
||||
.queryKey,
|
||||
data
|
||||
);
|
||||
setOriginalDashboard(data.dashboard);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -571,6 +582,7 @@ export const useRemoveMetricsFromDashboard = () => {
|
|||
const { openConfirmModal, openErrorMessage } = useBusterNotifications();
|
||||
const queryClient = useQueryClient();
|
||||
const ensureDashboardConfig = useEnsureDashboardConfig(false);
|
||||
const setOriginalDashboard = useOriginalDashboardStore((x) => x.setOriginalDashboard);
|
||||
|
||||
const removeMetricFromDashboard = useMemoizedFn(
|
||||
async ({
|
||||
|
@ -632,11 +644,16 @@ export const useRemoveMetricsFromDashboard = () => {
|
|||
mutationFn: removeMetricFromDashboard,
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, undefined).queryKey,
|
||||
data
|
||||
);
|
||||
queryClient.setQueryData(
|
||||
dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, data.dashboard.version_number)
|
||||
.queryKey,
|
||||
data
|
||||
);
|
||||
setOriginalDashboard(data.dashboard);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ export const useDashboardMetric = ({
|
|||
} = useGetMetric(
|
||||
{ id: metricId, versionNumber },
|
||||
{
|
||||
enabled: !!metricId,
|
||||
select: ({
|
||||
name,
|
||||
description,
|
||||
|
|
Loading…
Reference in New Issue