fix: code scanning issues is fixed (#3522)

This commit is contained in:
Palash Gupta 2023-09-11 14:02:38 +05:30 committed by GitHub
parent 41f7a7993d
commit 86c34bd87d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 26 deletions

View File

@ -0,0 +1,8 @@
export const keyToExclude = [
'exceptionStacktrace',
'exceptionType',
'errorId',
'timestamp',
'exceptionMessage',
'exceptionEscaped',
];

View File

@ -14,12 +14,13 @@ import { useQuery } from 'react-query';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { PayloadProps as GetByErrorTypeAndServicePayload } from 'types/api/errors/getByErrorTypeAndService'; import { PayloadProps as GetByErrorTypeAndServicePayload } from 'types/api/errors/getByErrorTypeAndService';
import { keyToExclude } from './config';
import { DashedContainer, EditorContainer, EventContainer } from './styles'; import { DashedContainer, EditorContainer, EventContainer } from './styles';
function ErrorDetails(props: ErrorDetailsProps): JSX.Element { function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
const { idPayload } = props; const { idPayload } = props;
const { t } = useTranslation(['errorDetails', 'common']); const { t } = useTranslation(['errorDetails', 'common']);
const { search } = useLocation(); const { search, pathname } = useLocation();
const params = useMemo(() => new URLSearchParams(search), [search]); const params = useMemo(() => new URLSearchParams(search), [search]);
@ -70,18 +71,6 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
[], [],
); );
const keyToExclude = useMemo(
() => [
'exceptionStacktrace',
'exceptionType',
'errorId',
'timestamp',
'exceptionMessage',
'exceptionEscaped',
],
[],
);
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const onClickErrorIdHandler = async ( const onClickErrorIdHandler = async (
@ -102,9 +91,7 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
errorId: id, errorId: id,
}; };
history.replace( history.replace(`${pathname}?${createQueryParams(queryParams)}`);
`${history.location.pathname}?${createQueryParams(queryParams)}`,
);
} catch (error) { } catch (error) {
notifications.error({ notifications.error({
message: t('something_went_wrong'), message: t('something_went_wrong'),

View File

@ -19,6 +19,7 @@ import {
} from 'react'; } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { connect, useSelector } from 'react-redux'; import { connect, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk'; import { ThunkDispatch } from 'redux-thunk';
import { DeleteWidget } from 'store/actions/dashboard/deleteWidget'; import { DeleteWidget } from 'store/actions/dashboard/deleteWidget';
@ -62,6 +63,7 @@ function WidgetGraphComponent({
const [hovered, setHovered] = useState(false); const [hovered, setHovered] = useState(false);
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const { t } = useTranslation(['common']); const { t } = useTranslation(['common']);
const { pathname } = useLocation();
const { graphVisibilityStates: localstoredVisibilityStates } = useMemo( const { graphVisibilityStates: localstoredVisibilityStates } = useMemo(
() => () =>
@ -195,11 +197,7 @@ function WidgetGraphComponent({
graphType: widget?.panelTypes, graphType: widget?.panelTypes,
widgetId: uuid, widgetId: uuid,
}; };
setTimeout(() => { history.push(`${pathname}/new?${createQueryParams(queryParams)}`);
history.push(
`${history.location.pathname}/new?${createQueryParams(queryParams)}`,
);
}, 1500);
}); });
} }
}; };

View File

@ -6,6 +6,7 @@ import createQueryParams from 'lib/createQueryParams';
import history from 'lib/history'; import history from 'lib/history';
import { CSSProperties, useCallback } from 'react'; import { CSSProperties, useCallback } from 'react';
import { connect, useSelector } from 'react-redux'; import { connect, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { bindActionCreators, Dispatch } from 'redux'; import { bindActionCreators, Dispatch } from 'redux';
import { ThunkDispatch } from 'redux-thunk'; import { ThunkDispatch } from 'redux-thunk';
import { import {
@ -24,6 +25,8 @@ function DashboardGraphSlider({ toggleAddWidget }: Props): JSX.Element {
(state) => state.dashboards, (state) => state.dashboards,
); );
const { pathname } = useLocation();
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const [selectedDashboard] = dashboards; const [selectedDashboard] = dashboards;
@ -51,16 +54,14 @@ function DashboardGraphSlider({ toggleAddWidget }: Props): JSX.Element {
), ),
}; };
history.push( history.push(`${pathname}/new?${createQueryParams(queryParams)}`);
`${history.location.pathname}/new?${createQueryParams(queryParams)}`,
);
} catch (error) { } catch (error) {
notifications.error({ notifications.error({
message: 'Something went wrong', message: 'Something went wrong',
}); });
} }
}, },
[data, toggleAddWidget, notifications], [data, toggleAddWidget, notifications, pathname],
); );
const isDarkMode = useIsDarkMode(); const isDarkMode = useIsDarkMode();
const fillColor: CSSProperties['color'] = isDarkMode ? 'white' : 'black'; const fillColor: CSSProperties['color'] = isDarkMode ? 'white' : 'black';

View File

@ -70,7 +70,7 @@ export const updateURL = (
userSelectedFilter: JSON.stringify(Object.fromEntries(userSelectedFilter)), userSelectedFilter: JSON.stringify(Object.fromEntries(userSelectedFilter)),
}; };
history.replace( history.replace(
`${history.location.pathname}?${createQueryParams(queryParams)}`, `${window.location.pathname}?${createQueryParams(queryParams)}`,
); );
}; };