mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
Change use{Suspense}APIQuery key to an array
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
9e4ffd044c
commit
5599db20cd
|
@ -1,4 +1,4 @@
|
||||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
import { QueryKey, useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { useSettings } from "../state/settingsSlice";
|
import { useSettings } from "../state/settingsSlice";
|
||||||
|
|
||||||
export const API_PATH = "api/v1";
|
export const API_PATH = "api/v1";
|
||||||
|
@ -89,7 +89,7 @@ const createQueryFn =
|
||||||
};
|
};
|
||||||
|
|
||||||
type QueryOptions = {
|
type QueryOptions = {
|
||||||
key?: string;
|
key?: QueryKey;
|
||||||
path: string;
|
path: string;
|
||||||
params?: Record<string, string>;
|
params?: Record<string, string>;
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
|
@ -106,7 +106,7 @@ export const useAPIQuery = <T>({
|
||||||
const { pathPrefix } = useSettings();
|
const { pathPrefix } = useSettings();
|
||||||
|
|
||||||
return useQuery<SuccessAPIResponse<T>>({
|
return useQuery<SuccessAPIResponse<T>>({
|
||||||
queryKey: key ? [key] : [path, params],
|
queryKey: key !== undefined ? key : [path, params],
|
||||||
retry: false,
|
retry: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
gcTime: 0,
|
gcTime: 0,
|
||||||
|
@ -119,7 +119,7 @@ export const useSuspenseAPIQuery = <T>({ key, path, params }: QueryOptions) => {
|
||||||
const { pathPrefix } = useSettings();
|
const { pathPrefix } = useSettings();
|
||||||
|
|
||||||
return useSuspenseQuery<SuccessAPIResponse<T>>({
|
return useSuspenseQuery<SuccessAPIResponse<T>>({
|
||||||
queryKey: key ? [key] : [path, params],
|
queryKey: key !== undefined ? key : [path, params],
|
||||||
retry: false,
|
retry: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
gcTime: 0,
|
gcTime: 0,
|
||||||
|
|
|
@ -15,7 +15,7 @@ const ReadinessLoader: FC = () => {
|
||||||
|
|
||||||
// Query readiness status.
|
// Query readiness status.
|
||||||
const { data: ready } = useSuspenseQuery<boolean>({
|
const { data: ready } = useSuspenseQuery<boolean>({
|
||||||
queryKey: [`ready-${queryKey}`],
|
queryKey: ["ready", queryKey],
|
||||||
retry: false,
|
retry: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
gcTime: 0,
|
gcTime: 0,
|
||||||
|
@ -46,8 +46,8 @@ const ReadinessLoader: FC = () => {
|
||||||
data: { min, max, current },
|
data: { min, max, current },
|
||||||
},
|
},
|
||||||
} = useSuspenseAPIQuery<WALReplayStatus>({
|
} = useSuspenseAPIQuery<WALReplayStatus>({
|
||||||
path: `/status/walreplay`,
|
path: "/status/walreplay",
|
||||||
key: `walreplay-${queryKey}`,
|
key: ["walreplay", queryKey],
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -144,7 +144,7 @@ const ExpressionInput: FC<ExpressionInputProps> = ({
|
||||||
isFetching: isFormatting,
|
isFetching: isFormatting,
|
||||||
refetch: formatQuery,
|
refetch: formatQuery,
|
||||||
} = useAPIQuery<string>({
|
} = useAPIQuery<string>({
|
||||||
key: expr,
|
key: [expr],
|
||||||
path: "/format_query",
|
path: "/format_query",
|
||||||
params: {
|
params: {
|
||||||
query: expr,
|
query: expr,
|
||||||
|
|
|
@ -44,7 +44,7 @@ const Graph: FC<GraphProps> = ({
|
||||||
|
|
||||||
const { data, error, isFetching, isLoading, refetch } =
|
const { data, error, isFetching, isLoading, refetch } =
|
||||||
useAPIQuery<RangeQueryResult>({
|
useAPIQuery<RangeQueryResult>({
|
||||||
key: useId(),
|
key: [useId()],
|
||||||
path: "/query_range",
|
path: "/query_range",
|
||||||
params: {
|
params: {
|
||||||
query: expr,
|
query: expr,
|
||||||
|
|
|
@ -28,7 +28,7 @@ const TableTab: FC<TableTabProps> = ({ panelIdx, retriggerIdx }) => {
|
||||||
const { endTime, range } = visualizer;
|
const { endTime, range } = visualizer;
|
||||||
|
|
||||||
const { data, error, isFetching, refetch } = useAPIQuery<InstantQueryResult>({
|
const { data, error, isFetching, refetch } = useAPIQuery<InstantQueryResult>({
|
||||||
key: useId(),
|
key: [useId()],
|
||||||
path: "/query",
|
path: "/query",
|
||||||
params: {
|
params: {
|
||||||
query: expr,
|
query: expr,
|
||||||
|
|
Loading…
Reference in a new issue