Skip to content

Commit

Permalink
fix: fixed widgets not visible after saving in the dashboard detail (S…
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarRajput-7 authored and hudsongeovane committed Feb 22, 2025
1 parent 5b78447 commit b1c7dd2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion frontend/src/container/GridCardLayout/GridCardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
dashboardQueryRangeCalled,
setDashboardQueryRangeCalled,
setSelectedRowWidgetId,
isDashboardFetching,
} = useDashboard();
const { data } = selectedDashboard || {};
const { pathname } = useLocation();
Expand Down Expand Up @@ -231,7 +232,8 @@ function GraphLayout(props: GraphLayoutProps): JSX.Element {
!isEqual(layouts, dashboardLayout) &&
!isDashboardLocked &&
saveLayoutPermission &&
!updateDashboardMutation.isLoading
!updateDashboardMutation.isLoading &&
!isDashboardFetching
) {
onSaveHandler();
}
Expand Down
19 changes: 15 additions & 4 deletions frontend/src/providers/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const DashboardContext = createContext<IDashboardContext>({
setDashboardQueryRangeCalled: () => {},
selectedRowWidgetId: '',
setSelectedRowWidgetId: () => {},
isDashboardFetching: false,
});

interface Props {
Expand Down Expand Up @@ -192,6 +193,8 @@ export function DashboardProvider({
const { t } = useTranslation(['dashboard']);
const dashboardRef = useRef<Dashboard>();

const [isDashboardFetching, setIsDashboardFetching] = useState<boolean>(false);

const mergeDBWithLocalStorage = (
data: Dashboard,
localStorageVariables: any,
Expand Down Expand Up @@ -256,10 +259,16 @@ export function DashboardProvider({
[REACT_QUERY_KEY.DASHBOARD_BY_ID, isDashboardPage?.params],
{
enabled: (!!isDashboardPage || !!isDashboardWidgetPage) && isLoggedIn,
queryFn: () =>
getDashboard({
uuid: dashboardId,
}),
queryFn: async () => {
setIsDashboardFetching(true);
try {
return await getDashboard({
uuid: dashboardId,
});
} finally {
setIsDashboardFetching(false);
}
},
refetchOnWindowFocus: false,
onSuccess: (data) => {
const updatedDashboardData = transformDashboardVariables(data);
Expand Down Expand Up @@ -424,6 +433,7 @@ export function DashboardProvider({
setDashboardQueryRangeCalled,
selectedRowWidgetId,
setSelectedRowWidgetId,
isDashboardFetching,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[
Expand All @@ -445,6 +455,7 @@ export function DashboardProvider({
setDashboardQueryRangeCalled,
selectedRowWidgetId,
setSelectedRowWidgetId,
isDashboardFetching,
],
);

Expand Down
1 change: 1 addition & 0 deletions frontend/src/providers/Dashboard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export interface IDashboardContext {
setDashboardQueryRangeCalled: (value: boolean) => void;
selectedRowWidgetId: string | null;
setSelectedRowWidgetId: React.Dispatch<React.SetStateAction<string | null>>;
isDashboardFetching: boolean;
}

0 comments on commit b1c7dd2

Please sign in to comment.