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 { render } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';

View File

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

View File

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

View File

@ -157,7 +157,7 @@ function ListOfAllDashboard(): JSX.Element {
<TextToolTip <TextToolTip
{...{ {...{
text: `More details on how to create dashboards`, 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 Input from 'components/Input';
import TextToolTip from 'components/TextToolTip'; import TextToolTip from 'components/TextToolTip';
import { timePreferance } from 'container/NewWidget/RightContainer/timeItems'; import { timePreferance } from 'container/NewWidget/RightContainer/timeItems';
import React, { useCallback, useState } from 'react'; import React, { useCallback, useMemo, useState } from 'react';
import { connect } from 'react-redux'; import { connect, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom'; 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';
@ -12,8 +12,11 @@ import {
UpdateQuery, UpdateQuery,
UpdateQueryProps, UpdateQueryProps,
} from 'store/actions/dashboard/updateQuery'; } from 'store/actions/dashboard/updateQuery';
import { AppState } from 'store/reducers';
import AppActions from 'types/actions'; import AppActions from 'types/actions';
import { DeleteQueryProps } from 'types/actions/dashboard'; import { DeleteQueryProps } from 'types/actions/dashboard';
import { Widgets } from 'types/api/dashboard/getAll';
import DashboardReducer from 'types/reducer/dashboards';
import { import {
ButtonContainer, ButtonContainer,
@ -32,10 +35,27 @@ function Query({
const [promqlQuery, setPromqlQuery] = useState(preQuery); const [promqlQuery, setPromqlQuery] = useState(preQuery);
const [legendFormat, setLegendFormat] = useState(preLegend); const [legendFormat, setLegendFormat] = useState(preLegend);
const { search } = useLocation(); const { search } = useLocation();
const { dashboards } = useSelector<AppState, DashboardReducer>(
(state) => state.dashboards,
);
const [selectedDashboards] = dashboards;
const { widgets } = selectedDashboards.data;
const query = new URLSearchParams(search); const query = new URLSearchParams(search);
const widgetId = query.get('widgetId') || ''; 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( const onChangeHandler = useCallback(
(setFunc: React.Dispatch<React.SetStateAction<string>>, value: string) => { (setFunc: React.Dispatch<React.SetStateAction<string>>, value: string) => {
setFunc(value); setFunc(value);
@ -49,6 +69,7 @@ function Query({
legend: legendFormat, legend: legendFormat,
query: promqlQuery, query: promqlQuery,
widgetId, widgetId,
yAxisUnit: selectedWidget.yAxisUnit,
}); });
}; };

View File

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

View File

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

View File

@ -1,3 +1,4 @@
import { expect } from '@jest/globals';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import getStep, { DefaultStepSize } from 'lib/getStep'; 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 { export interface DashboardWidgetPageParams {