diff --git a/web/src/api/buster_rest/errors.ts b/web/src/api/buster_rest/errors.ts index 6de4c4078..355c88698 100644 --- a/web/src/api/buster_rest/errors.ts +++ b/web/src/api/buster_rest/errors.ts @@ -1,32 +1,34 @@ +import { AxiosError } from 'axios'; import isString from 'lodash/isString'; export const rustErrorHandler = (errors: any = {}): RustApiError => { const data = errors?.response?.data; + const status = errors?.status; if (data && isString(data)) { - return { message: String(data) }; + return { message: String(data), status }; } if (data && data?.message) { - return { message: String(data.message) }; + return { message: String(data.message), status }; } if (data && data?.detail) { if (typeof data.detail === 'string') { - return { message: String(data.detail) }; + return { message: String(data.detail), status }; } if (data.detail?.[0]) { - return { message: String(data.detail[0].msg) }; + return { message: String(data.detail[0].msg), status }; } - return { message: String(data.detail) }; + return { message: String(data.detail), status }; } if (errors?.message) { - return { message: String(errors.message) }; + return { message: String(errors.message), status }; } if (typeof errors === 'string') { - return { message: String(errors) }; + return { message: String(errors), status }; } return {}; diff --git a/web/src/api/buster_rest/metrics/queryRequests.ts b/web/src/api/buster_rest/metrics/queryRequests.ts index 4932ef632..621b45190 100644 --- a/web/src/api/buster_rest/metrics/queryRequests.ts +++ b/web/src/api/buster_rest/metrics/queryRequests.ts @@ -21,7 +21,7 @@ import { collectionQueryKeys } from '@/api/query_keys/collection'; import { useMemo } from 'react'; import { useBusterAssetsContextSelector } from '@/context/Assets/BusterAssetsProvider'; import { useGetUserFavorites } from '../users'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetricData, IBusterMetric } from '@/api/asset_interfaces/metric'; import { create } from 'mutative'; import { useAddAssetToCollection, @@ -81,7 +81,7 @@ export const useGetMetric = ( return useQuery({ ...options, queryFn, - enabled: !!id, + enabled: false, //In the year of our lord 2025, April 10, I, Nate Kelley, decided to disable this query in favor of explicityly fetching the data. May god have mercy on our souls. retry(failureCount, error) { if (error?.message !== undefined) { setAssetPasswordError(id!, error.message || 'An error occurred'); @@ -112,13 +112,19 @@ export const useGetMetricsList = ( /** * This is a hook that will use the version number from the URL params if it exists. */ -export const useGetMetricData = ({ - id, - versionNumber: versionNumberProp -}: { - id: string | undefined; - versionNumber?: number; -}) => { +export const useGetMetricData = ( + { + id, + versionNumber: versionNumberProp + }: { + id: string | undefined; + versionNumber?: number; + }, + params?: Omit, 'queryKey' | 'queryFn'> +) => { + const getAssetPassword = useBusterAssetsContextSelector((x) => x.getAssetPassword); + const { password } = getAssetPassword(id!); + const { isFetched: isFetchedMetric, error: errorMetric, @@ -141,7 +147,7 @@ export const useGetMetricData = ({ }, [versionNumberProp, versionNumberFromParams]); const queryFn = useMemoizedFn(() => { - return getMetricData({ id: id!, version_number: versionNumber }); + return getMetricData({ id: id!, version_number: versionNumber, password }); }); return useQuery({ @@ -149,7 +155,9 @@ export const useGetMetricData = ({ queryFn, enabled: () => { return !!id && isFetchedMetric && !errorMetric && !!fetchedMetricData; - } + }, + select: params?.select, + ...params }); }; diff --git a/web/src/api/buster_rest/metrics/requests.ts b/web/src/api/buster_rest/metrics/requests.ts index f96d90363..109225765 100644 --- a/web/src/api/buster_rest/metrics/requests.ts +++ b/web/src/api/buster_rest/metrics/requests.ts @@ -37,13 +37,15 @@ export const getMetric_server = async ({ id, password }: Parameters { return mainApi - .get(`/metrics/${id}/data`, { params: { version_number } }) + .get(`/metrics/${id}/data`, { params: { password, version_number } }) .then((res) => res.data); }; diff --git a/web/src/components/features/ShareMenu/ShareMenuContentPublish.tsx b/web/src/components/features/ShareMenu/ShareMenuContentPublish.tsx index 1e410c206..2c409e380 100644 --- a/web/src/components/features/ShareMenu/ShareMenuContentPublish.tsx +++ b/web/src/components/features/ShareMenu/ShareMenuContentPublish.tsx @@ -166,7 +166,6 @@ export const ShareMenuContentPublish: React.FC = Reac