fix: dashboard context is updated when we update (#3718)

This commit is contained in:
Palash Gupta 2023-10-11 23:27:45 +05:30 committed by GitHub
parent a912731cc7
commit ca3283fcad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,12 @@ function GraphLayout({
onAddPanelHandler,
widgets,
}: GraphLayoutProps): JSX.Element {
const { selectedDashboard, layouts, setLayouts } = useDashboard();
const {
selectedDashboard,
layouts,
setLayouts,
setSelectedDashboard,
} = useDashboard();
const { t } = useTranslation(['dashboard']);
const { featureResponse, role } = useSelector<AppState, AppReducer>(
@ -58,12 +63,17 @@ function GraphLayout({
};
updateDashboardMutation.mutate(updatedDashboard, {
onSuccess: () => {
featureResponse.refetch();
onSuccess: (updatedDashboard) => {
if (updatedDashboard.payload) {
if (updatedDashboard.payload.data.layout)
setLayouts(updatedDashboard.payload.data.layout);
setSelectedDashboard(updatedDashboard.payload);
}
notifications.success({
message: t('dashboard:layout_saved_successfully'),
});
featureResponse.refetch();
},
onError: () => {
notifications.error({