chore: some tsc fix

This commit is contained in:
Palash gupta 2022-03-24 15:39:33 +05:30
parent 01bad0f18a
commit ac70240b72
No known key found for this signature in database
GPG Key ID: 8FD05AE6F9150AD6
9 changed files with 36 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import { render } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';

View File

@ -1,5 +1,5 @@
import { FlattenSimpleInterpolation } from 'styled-components';
export interface IStyledClass {
styledclass?: FlattenSimpleInterpolation[];
styledclass: FlattenSimpleInterpolation[];
}

View File

@ -33,7 +33,7 @@ function SpanLength(props: SpanLengthProps): JSX.Element {
leftOffset={leftOffset}
width={width}
/>
<SpanText leftOffset={leftOffset}>{`${toFixed(
<SpanText isDarkMode={isDarkMode} leftOffset={leftOffset}>{`${toFixed(
resolveTimeFromInterval(inMsCount, intervalUnit),
2,
)} ${intervalUnit.name}`}</SpanText>

View File

@ -157,7 +157,7 @@ function ListOfAllDashboard(): JSX.Element {
<TextToolTip
{...{
text: `More details on how to create dashboards`,
url: 'https://signoz.io/docs/userguide/metrics-dashboard',
url: 'https://signoz.io/docs/userguide/dashboards',
}}
/>

View File

@ -2,8 +2,8 @@ import { Button, Divider } from 'antd';
import Input from 'components/Input';
import TextToolTip from 'components/TextToolTip';
import { timePreferance } from 'container/NewWidget/RightContainer/timeItems';
import React, { useCallback, useState } from 'react';
import { connect } from 'react-redux';
import React, { useCallback, useMemo, useState } from 'react';
import { connect, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { bindActionCreators, Dispatch } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
@ -12,8 +12,11 @@ import {
UpdateQuery,
UpdateQueryProps,
} from 'store/actions/dashboard/updateQuery';
import { AppState } from 'store/reducers';
import AppActions from 'types/actions';
import { DeleteQueryProps } from 'types/actions/dashboard';
import { Widgets } from 'types/api/dashboard/getAll';
import DashboardReducer from 'types/reducer/dashboards';
import {
ButtonContainer,
@ -32,10 +35,27 @@ function Query({
const [promqlQuery, setPromqlQuery] = useState(preQuery);
const [legendFormat, setLegendFormat] = useState(preLegend);
const { search } = useLocation();
const { dashboards } = useSelector<AppState, DashboardReducer>(
(state) => state.dashboards,
);
const [selectedDashboards] = dashboards;
const { widgets } = selectedDashboards.data;
const query = new URLSearchParams(search);
const widgetId = query.get('widgetId') || '';
const urlQuery = useMemo(() => {
return new URLSearchParams(search);
}, [search]);
const getWidget = useCallback(() => {
const widgetId = urlQuery.get('widgetId');
return widgets?.find((e) => e.id === widgetId);
}, [widgets, urlQuery]);
const selectedWidget = getWidget() as Widgets;
const onChangeHandler = useCallback(
(setFunc: React.Dispatch<React.SetStateAction<string>>, value: string) => {
setFunc(value);
@ -49,6 +69,7 @@ function Query({
legend: legendFormat,
query: promqlQuery,
widgetId,
yAxisUnit: selectedWidget.yAxisUnit,
});
};

View File

@ -43,7 +43,7 @@ function TraceGraph(): JSX.Element {
}
return (
<Container ref={ref}>
<Container ref={ref as never}>
<Graph
animate={false}
data={ChartData}

View File

@ -56,7 +56,7 @@ function useFetch<PayloadProps, FunctionParams>(
loading: false,
success: false,
error: true,
errorMessage: error,
errorMessage: error as string,
});
}
return (): void => {

View File

@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import dayjs from 'dayjs';
import getStep, { DefaultStepSize } from 'lib/getStep';

View File

@ -74,7 +74,12 @@ function DashboardWidget({ getDashboard }: NewDashboardProps): JSX.Element {
);
}
return <NewWidget selectedGraph={selectedGraph} />;
return (
<NewWidget
yAxisUnit={selectedWidget.yAxisUnit}
selectedGraph={selectedGraph}
/>
);
}
export interface DashboardWidgetPageParams {