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
);
const upgradedMetric = upgradeMetricToIMetric(metric, prevMetric);
console.log(
'upgradedMetric',
upgradedMetric,
metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey
);
queryClient.setQueryData(
metricsQueryKeys.metricsGetMetric(metric.id, metric.version_number).queryKey,
upgradedMetric

View File

@ -116,6 +116,12 @@ export const useSaveDashboard = (params?: { updateOnSave?: boolean }) => {
);
setOriginalDashboard(data.dashboard);
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) => {
// queryClient.setQueryData(
// dashboardQueryKeys.dashboardGetDashboard(data.dashboard.id, data.dashboard.version_number)
// .queryKey,
// data
// );
onSuccess: (data, variables) => {
queryClient.invalidateQueries({
queryKey: dashboardQueryKeys.dashboardGetDashboard(variables.id, null).queryKey
});
}
});
};

View File

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

View File

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

View File

@ -52,7 +52,8 @@ const clientEnvSchema = z.object({
// Development/Testing credentials
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({});

View File

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

View File

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

View File

@ -30,7 +30,7 @@ export const ChatLayout: React.FC<ChatSplitterProps> = ({ children }) => {
return ['380px', 'auto'];
}, [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 leftPanelMaxSize = selectedLayout === 'both' ? MAX_CHAT_BOTH_SIDEBAR_SIZE : undefined;
const rightPanelMinSize = selectedFile ? DEFAULT_FILE_OPTION_SIDEBAR_SIZE : '0px';