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 { PayloadProps as GetByErrorTypeAndServicePayload } from 'types/api/errors/getByErrorTypeAndService';
import { keyToExclude } from './config';
import { DashedContainer, EditorContainer, EventContainer } from './styles';
function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
const { idPayload } = props;
const { t } = useTranslation(['errorDetails', 'common']);
const { search } = useLocation();
const { search, pathname } = useLocation();
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 onClickErrorIdHandler = async (
@ -102,9 +91,7 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
errorId: id,
};
history.replace(
`${history.location.pathname}?${createQueryParams(queryParams)}`,
);
history.replace(`${pathname}?${createQueryParams(queryParams)}`);
} catch (error) {
notifications.error({
message: t('something_went_wrong'),

View File

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

View File

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

View File

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