mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 07:12:00 +08:00
fix: dashboard is updated (#1240)
* fix: dashboard is updated * fix: redux is made empty when creating dashbaord Co-authored-by: Palash gupta <palash@signoz.io>
This commit is contained in:
parent
1c90e62189
commit
b7d52b8fba
@ -15,11 +15,19 @@ import ROUTES from 'constants/routes';
|
|||||||
import SearchFilter from 'container/ListOfDashboard/SearchFilter';
|
import SearchFilter from 'container/ListOfDashboard/SearchFilter';
|
||||||
import useComponentPermission from 'hooks/useComponentPermission';
|
import useComponentPermission from 'hooks/useComponentPermission';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, {
|
||||||
|
Dispatch,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { generatePath } from 'react-router-dom';
|
import { generatePath } from 'react-router-dom';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
|
import AppActions from 'types/actions';
|
||||||
|
import { GET_ALL_DASHBOARD_SUCCESS } from 'types/actions/dashboard';
|
||||||
import { Dashboard } from 'types/api/dashboard/getAll';
|
import { Dashboard } from 'types/api/dashboard/getAll';
|
||||||
import AppReducer from 'types/reducer/app';
|
import AppReducer from 'types/reducer/app';
|
||||||
import DashboardReducer from 'types/reducer/dashboards';
|
import DashboardReducer from 'types/reducer/dashboards';
|
||||||
@ -36,6 +44,7 @@ function ListOfAllDashboard(): JSX.Element {
|
|||||||
const { dashboards, loading } = useSelector<AppState, DashboardReducer>(
|
const { dashboards, loading } = useSelector<AppState, DashboardReducer>(
|
||||||
(state) => state.dashboards,
|
(state) => state.dashboards,
|
||||||
);
|
);
|
||||||
|
const dispatch = useDispatch<Dispatch<AppActions>>();
|
||||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||||
|
|
||||||
const [action, createNewDashboard, newDashboard] = useComponentPermission(
|
const [action, createNewDashboard, newDashboard] = useComponentPermission(
|
||||||
@ -131,6 +140,10 @@ function ListOfAllDashboard(): JSX.Element {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
|
dispatch({
|
||||||
|
type: GET_ALL_DASHBOARD_SUCCESS,
|
||||||
|
payload: [],
|
||||||
|
});
|
||||||
history.push(
|
history.push(
|
||||||
generatePath(ROUTES.DASHBOARD, {
|
generatePath(ROUTES.DASHBOARD, {
|
||||||
dashboardId: response.payload.uuid,
|
dashboardId: response.payload.uuid,
|
||||||
@ -151,7 +164,7 @@ function ListOfAllDashboard(): JSX.Element {
|
|||||||
errorMessage: (error as AxiosError).toString() || 'Something went Wrong',
|
errorMessage: (error as AxiosError).toString() || 'Something went Wrong',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [newDashboardState, t]);
|
}, [newDashboardState, t, dispatch]);
|
||||||
|
|
||||||
const getText = useCallback(() => {
|
const getText = useCallback(() => {
|
||||||
if (!newDashboardState.error && !newDashboardState.loading) {
|
if (!newDashboardState.error && !newDashboardState.loading) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user