Merge pull request #518 from buster-so/hot-fix/dashboard-localstorage

Hot fix/dashboard localstorage
This commit is contained in:
Nate Kelley 2025-07-15 15:19:46 -06:00 committed by GitHub
commit 47f14a63f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 31 additions and 19 deletions

View File

@ -58,11 +58,7 @@ export const useGetDashboardAndInitializeMetrics = (prefetchData = true) => {
metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey
); );
const upgradedMetric = upgradeMetricToIMetric(metric, prevMetric); const upgradedMetric = upgradeMetricToIMetric(metric, prevMetric);
console.log(
'upgradedMetric',
upgradedMetric,
metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey
);
queryClient.setQueryData( queryClient.setQueryData(
metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey, metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey,
upgradedMetric upgradedMetric

View File

@ -116,6 +116,12 @@ export const useSaveDashboard = (params?: { updateOnSave?: boolean }) => {
); );
setOriginalDashboard(data.dashboard); setOriginalDashboard(data.dashboard);
onSetLatestDashboardVersion(data.dashboard.id, last(data.versions)?.version_number || 1); onSetLatestDashboardVersion(data.dashboard.id, last(data.versions)?.version_number || 1);
if (variables.restore_to_version) {
queryClient.invalidateQueries({
queryKey: dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, null).queryKey
});
}
} }
} }
}); });
@ -363,12 +369,10 @@ export const useShareDashboard = () => {
}); });
}); });
}, },
onSuccess: (data) => { onSuccess: (data, variables) => {
// queryClient.setQueryData( queryClient.invalidateQueries({
// dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, data.dashboard.version_number) queryKey: dashboardQueryKeys.dashboardGetDashboard(variables.id, null).queryKey
// .queryKey, });
// data
// );
} }
}); });
}; };

View File

@ -69,7 +69,7 @@ export const useSaveToDashboardDropdownContent = ({
> & { > & {
ModalComponent: React.ReactNode; ModalComponent: React.ReactNode;
} => { } => {
const { data: dashboardsList } = useGetDashboardsList({}); const { data: dashboardsList } = useGetDashboardsList({}, { staleTime: 60 * 1000 });
const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage); const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage);
const [openNewDashboardModal, setOpenNewDashboardModal] = useState(false); const [openNewDashboardModal, setOpenNewDashboardModal] = useState(false);

View File

@ -24,8 +24,14 @@ export const useThreeDotFavoritesOptions = ({
const { mutateAsync: removeUserFavorite } = useDeleteUserFavorite(); const { mutateAsync: removeUserFavorite } = useDeleteUserFavorite();
const { data: userFavorites } = useGetUserFavorites(); const { data: userFavorites } = useGetUserFavorites();
const { data: metricList } = useGetMetricsList({}, { enabled: false }); const { data: metricList } = useGetMetricsList({}, { enabled: false });
const { data: dashboardList } = useGetDashboardsList({}, { enabled: false }); const { data: dashboardList } = useGetDashboardsList(
const { data: collectionList } = useGetCollectionsList({}, { enabled: false }); {},
{ enabled: false, staleTime: 60 * 1000 }
);
const { data: collectionList } = useGetCollectionsList(
{},
{ enabled: false, staleTime: 60 * 1000 }
);
const nameSearchArray = useMemo(() => { const nameSearchArray = useMemo(() => {
if (assetType === 'metric' && metricList) { if (assetType === 'metric' && metricList) {

View File

@ -52,7 +52,8 @@ const clientEnvSchema = z.object({
// Development/Testing credentials // Development/Testing credentials
NEXT_PUBLIC_USER: z.string().optional(), NEXT_PUBLIC_USER: z.string().optional(),
NEXT_PUBLIC_USER_PASSWORD: z.string().optional() NEXT_PUBLIC_USER_PASSWORD: z.string().optional(),
NEXT_ENABLE_TANSTACK_PANEL: z.string().optional()
}); });
const serverEnvSchema = z.object({}); const serverEnvSchema = z.object({});

View File

@ -15,6 +15,10 @@ import { getQueryClient } from './getQueryClient';
const ENABLE_TANSTACK_PANEL = const ENABLE_TANSTACK_PANEL =
process.env.NEXT_ENABLE_TANSTACK_PANEL === 'true' || process.env.NODE_ENV === 'development'; process.env.NEXT_ENABLE_TANSTACK_PANEL === 'true' || process.env.NODE_ENV === 'development';
console.log({
ENABLE_TANSTACK_PANEL,
NEXT_ENABLE_TANSTACK_PANEL: process.env.NEXT_ENABLE_TANSTACK_PANEL
});
const ReactQueryDevtools = dynamic( const ReactQueryDevtools = dynamic(
() => () =>
@ -65,6 +69,7 @@ export const BusterReactQueryProvider = ({ children }: { children: React.ReactNo
useHotkeys( useHotkeys(
'meta+shift+i', 'meta+shift+i',
(e) => { (e) => {
console.log('meta+shift+i', isDevToolsOpen);
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
setIsDevToolsOpen((prev) => !prev); setIsDevToolsOpen((prev) => !prev);
@ -77,7 +82,7 @@ export const BusterReactQueryProvider = ({ children }: { children: React.ReactNo
{children} {children}
{isDevToolsOpen && ( {isDevToolsOpen && (
<> <>
<ReactQueryDevtools initialIsOpen={true} /> {isDev && <ReactQueryDevtools initialIsOpen={true} />}
{!isDev && <ReactQueryDevtoolsProduction />} {!isDev && <ReactQueryDevtoolsProduction />}
</> </>
)} )}

View File

@ -35,7 +35,7 @@ export const ChatResponseMessage_DashboardFile: React.FC<{
const { const {
data: dashboardResponse, data: dashboardResponse,
isError, isError,
isFetched, isFetched: isFetchedDashboard,
isLoading isLoading
} = useGetDashboard( } = useGetDashboard(
{ id, versionNumber: version_number }, { id, versionNumber: version_number },
@ -91,7 +91,7 @@ export const ChatResponseMessage_DashboardFile: React.FC<{
{!hasMetrics ? null : dashboardResponse ? ( {!hasMetrics ? null : dashboardResponse ? (
<Content <Content
dashboardResponse={dashboardResponse} dashboardResponse={dashboardResponse}
isFetched={isFetched} isFetched={isFetchedDashboard}
metricId={metricId} metricId={metricId}
dashboardId={dashboardId} dashboardId={dashboardId}
chatId={chatId} chatId={chatId}

View File

@ -30,7 +30,7 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
return ['380px', 'auto']; return ['380px', 'auto'];
}, [selectedLayout]); }, [selectedLayout]);
const autoSaveId = `chat-splitter-${chatLayoutProps.chatId || '🫥'}-${chatLayoutProps.metricId || '❌'}`; const autoSaveId = `chat-splitter-${chatLayoutProps.chatId || '🫥'}-${chatLayoutProps.dashboardId || chatLayoutProps.metricId || '❌'}`;
const leftPanelMinSize = selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : '0px'; const leftPanelMinSize = selectedFile ? DEFAULT_CHAT_OPTION_SIDEBAR_SIZE : '0px';
const leftPanelMaxSize = selectedLayout === 'both' ? MAX_CHAT_BOTH_SIDEBAR_SIZE : undefined; const leftPanelMaxSize = selectedLayout === 'both' ? MAX_CHAT_BOTH_SIDEBAR_SIZE : undefined;
const rightPanelMinSize = selectedFile ? DEFAULT_FILE_OPTION_SIDEBAR_SIZE : '0px'; const rightPanelMinSize = selectedFile ? DEFAULT_FILE_OPTION_SIDEBAR_SIZE : '0px';