From c5fe152bee841aeb9ceba1c373496d5d084761fe Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 18 Jul 2025 15:38:55 -0600 Subject: [PATCH 1/2] DEFAULT must defined colors --- apps/web/src/api/buster_rest/dictionaries/queryRequests.ts | 5 ++++- .../server-shared/src/metrics/charts/chartConfigProps.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts b/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts index 084aa018e..0c5da5b34 100644 --- a/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts +++ b/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts @@ -1,11 +1,14 @@ import { useQuery, QueryClient } from '@tanstack/react-query'; import { getColorPalettes, getCurrencies } from './requests'; import { dictionariesQueryKeys } from '@/api/query_keys/dictionaries'; +import { useUserConfigContextSelector } from '../../../context/Users'; export const useColorDictionaryThemes = () => { + const isAnonymousUser = useUserConfigContextSelector((x) => x.isAnonymousUser); return useQuery({ ...dictionariesQueryKeys.colorPalettes, - queryFn: getColorPalettes + queryFn: getColorPalettes, + enabled: !isAnonymousUser }); }; diff --git a/packages/server-shared/src/metrics/charts/chartConfigProps.ts b/packages/server-shared/src/metrics/charts/chartConfigProps.ts index e8d3bd66b..146157634 100644 --- a/packages/server-shared/src/metrics/charts/chartConfigProps.ts +++ b/packages/server-shared/src/metrics/charts/chartConfigProps.ts @@ -27,7 +27,7 @@ export const ChartConfigPropsSchema = z.object({ columnSettings: z.record(z.string(), ColumnSettingsSchema).default({}), columnLabelFormats: z.record(z.string(), ColumnLabelFormatSchema).default({}), // OPTIONAL: default is the buster color palette - colors: z.array(z.string()).optional(), + colors: z.array(z.string()).default(DEFAULT_CHART_THEME), // OPTIONAL: default is null and will be true if there are multiple Y axes or if a category axis is used showLegend: z.nullable(z.boolean()).default(null), // OPTIONAL: default: true From 06f9c2e24a2c723ff7fa6454d378f6adc9d675fc Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 18 Jul 2025 15:44:17 -0600 Subject: [PATCH 2/2] check anon user --- apps/web/src/api/buster_rest/dictionaries/queryRequests.ts | 4 ++-- apps/web/src/context/Supabase/SupabaseContextProvider.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts b/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts index 0c5da5b34..cd2bdfa65 100644 --- a/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts +++ b/apps/web/src/api/buster_rest/dictionaries/queryRequests.ts @@ -1,10 +1,10 @@ import { useQuery, QueryClient } from '@tanstack/react-query'; import { getColorPalettes, getCurrencies } from './requests'; import { dictionariesQueryKeys } from '@/api/query_keys/dictionaries'; -import { useUserConfigContextSelector } from '../../../context/Users'; +import { useSupabaseContext } from '@/context/Supabase'; export const useColorDictionaryThemes = () => { - const isAnonymousUser = useUserConfigContextSelector((x) => x.isAnonymousUser); + const isAnonymousUser = useSupabaseContext((x) => x.isAnonymousUser); return useQuery({ ...dictionariesQueryKeys.colorPalettes, queryFn: getColorPalettes, diff --git a/apps/web/src/context/Supabase/SupabaseContextProvider.tsx b/apps/web/src/context/Supabase/SupabaseContextProvider.tsx index 8797a9107..78f6336b0 100644 --- a/apps/web/src/context/Supabase/SupabaseContextProvider.tsx +++ b/apps/web/src/context/Supabase/SupabaseContextProvider.tsx @@ -23,7 +23,8 @@ const useSupabaseContextInternal = ({ const { openErrorNotification, openInfoMessage } = useBusterNotifications(); const [accessToken, setAccessToken] = useState(supabaseContext.accessToken || ''); - const isAnonymousUser = !supabaseContext.user?.id || supabaseContext.user?.is_anonymous === true; + const isAnonymousUser: boolean = + !supabaseContext.user?.id || supabaseContext.user?.is_anonymous === true; const getExpiresAt = useMemoizedFn((token?: string) => { const decoded = jwtDecode(token || accessToken);