Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Jul 7, 2020
1 parent a7acdcc commit a91e33e
Show file tree
Hide file tree
Showing 130 changed files with 560 additions and 513 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('AlertsHistogram', () => {
legendItems={[]}
loading={false}
data={[]}
from={0}
to={1}
from={'0'}
to={'1'}
updateDateRange={jest.fn()}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ const DEFAULT_CHART_HEIGHT = 174;

interface AlertsHistogramProps {
chartHeight?: number;
from: number;
from: string;
legendItems: LegendItem[];
legendPosition?: Position;
loading: boolean;
to: number;
to: string;
data: HistogramData[];
updateDateRange: UpdateDateRange;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import moment from 'moment';

import { showAllOthersBucket } from '../../../../common/constants';
import { HistogramData, AlertsAggregation, AlertsBucket, AlertsGroupBucket } from './types';
Expand All @@ -28,8 +29,8 @@ export const formatAlertsData = (alertsData: AlertSearchResponse<{}, AlertsAggre

export const getAlertsHistogramQuery = (
stackByField: string,
from: number,
to: number,
from: string,
to: string,
additionalFilters: Array<{
bool: { filter: unknown[]; should: unknown[]; must_not: unknown[]; must: unknown[] };
}>
Expand All @@ -55,7 +56,7 @@ export const getAlertsHistogramQuery = (
alerts: {
date_histogram: {
field: '@timestamp',
fixed_interval: `${Math.floor((to - from) / 32)}ms`,
fixed_interval: `${Math.floor(moment(to).diff(from) / 32)}ms`,
min_doc_count: 0,
extended_bounds: {
min: from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jest.mock('../../../common/components/navigation/use_get_url_search');

describe('AlertsHistogramPanel', () => {
const defaultProps = {
from: 0,
from: '0',
signalIndexName: 'signalIndexName',
setQuery: jest.fn(),
to: 1,
to: '1',
updateDateRange: jest.fn(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface AlertsHistogramPanelProps {
defaultStackByOption?: AlertsHistogramOption;
deleteQuery?: ({ id }: { id: string }) => void;
filters?: Filter[];
from: number;
from: string;
headerChildren?: React.ReactNode;
/** Override all defaults, and only display this field */
onlyField?: string;
Expand All @@ -70,7 +70,7 @@ interface AlertsHistogramPanelProps {
showTotalAlertsCount?: boolean;
stackByOptions?: AlertsHistogramOption[];
title?: string;
to: number;
to: string;
updateDateRange: UpdateDateRange;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const determineToAndFrom = ({ ecsData }: { ecsData: Ecs }) => {

const from = moment(ecsData.timestamp ?? new Date())
.subtract(ellapsedTimeRule)
.valueOf();
const to = moment(ecsData.timestamp ?? new Date()).valueOf();
.toISOString();
const to = moment(ecsData.timestamp ?? new Date()).toISOString();

return { to, from };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ describe('AlertsTableComponent', () => {
timelineId={TimelineId.test}
canUserCRUD
hasIndexWrite
from={0}
from={'0'}
loading
signalsIndex="index"
to={1}
to={'1'}
globalQuery={{
query: 'query',
language: 'language',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ interface OwnProps {
canUserCRUD: boolean;
defaultFilters?: Filter[];
hasIndexWrite: boolean;
from: number;
from: string;
loading: boolean;
signalsIndex: string;
to: number;
to: string;
}

type AlertsTableComponentProps = OwnProps & PropsFromRedux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export interface SendAlertToTimelineActionProps {
export type UpdateTimelineLoading = ({ id, isLoading }: { id: string; isLoading: boolean }) => void;

export interface CreateTimelineProps {
from: number;
from: string;
timeline: TimelineModel;
to: number;
to: string;
ruleNote?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({
return;
}
const [min, max] = x;
setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
setAbsoluteRangeDatePicker({
id: 'global',
from: new Date(min).toISOString(),
to: new Date(max).toISOString(),
});
},
[setAbsoluteRangeDatePicker]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ export const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
return;
}
const [min, max] = x;
setAbsoluteRangeDatePicker({ id: 'global', from: min, to: max });
setAbsoluteRangeDatePicker({
id: 'global',
from: new Date(min).toISOString(),
to: new Date(max).toISOString(),
});
},
[setAbsoluteRangeDatePicker]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { getInvestigateInResolverAction } from '../../../timelines/components/ti
import * as i18n from './translations';

export interface OwnProps {
end: number;
end: string;
id: string;
start: number;
start: string;
}

const defaultAlertsFilters: Filter[] = [
Expand Down Expand Up @@ -56,8 +56,8 @@ const defaultAlertsFilters: Filter[] = [

interface Props {
timelineId: TimelineIdLiteral;
endDate: number;
startDate: number;
endDate: string;
startDate: string;
pageFilters?: Filter[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const mockUseResizeObserver: jest.Mock = useResizeObserver as jest.Mock;
jest.mock('use-resize-observer/polyfilled');
mockUseResizeObserver.mockImplementation(() => ({}));

const from = 1566943856794;
const to = 1566857456791;
const from = '2019-08-27T22:10:56.794Z';
const to = '2019-08-26T22:10:56.791Z';

describe('EventsViewer', () => {
const mount = useMountAppended();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface Props {
columns: ColumnHeaderOptions[];
dataProviders: DataProvider[];
deletedEventIds: Readonly<string[]>;
end: number;
end: string;
filters: Filter[];
headerFilterGroup?: React.ReactNode;
height?: number;
Expand All @@ -65,7 +65,7 @@ interface Props {
kqlMode: KqlMode;
onChangeItemsPerPage: OnChangeItemsPerPage;
query: Query;
start: number;
start: string;
sort: Sort;
toggleColumn: (column: ColumnHeaderOptions) => void;
utilityBar?: (refetch: inputsModel.Refetch, totalCount: number) => React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const mockUseResizeObserver: jest.Mock = useResizeObserver as jest.Mock;
jest.mock('use-resize-observer/polyfilled');
mockUseResizeObserver.mockImplementation(() => ({}));

const from = 1566943856794;
const to = 1566857456791;
const from = '2019-08-27T22:10:56.794Z';
const to = '2019-08-26T22:10:56.791Z';

describe('StatefulEventsViewer', () => {
const mount = useMountAppended();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { InspectButtonContainer } from '../inspect';
export interface OwnProps {
defaultIndices?: string[];
defaultModel: SubsetTimelineModel;
end: number;
end: string;
id: string;
start: number;
start: string;
headerFilterGroup?: React.ReactNode;
pageFilters?: Filter[];
utilityBar?: (refetch: inputsModel.Refetch, totalCount: number) => React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Matrix Histogram Component', () => {
const mockMatrixOverTimeHistogramProps = {
defaultIndex: ['defaultIndex'],
defaultStackByOption: { text: 'text', value: 'value' },
endDate: new Date('2019-07-18T20:00:00.000Z').valueOf(),
endDate: '2019-07-18T20:00:00.000Z',
errorMessage: 'error',
histogramType: HistogramType.alerts,
id: 'mockId',
Expand All @@ -64,7 +64,7 @@ describe('Matrix Histogram Component', () => {
sourceId: 'default',
stackByField: 'mockStackByField',
stackByOptions: [{ text: 'text', value: 'value' }],
startDate: new Date('2019-07-18T19:00: 00.000Z').valueOf(),
startDate: '2019-07-18T19:00: 00.000Z',
subtitle: 'mockSubtitle',
totalCount: -1,
title: 'mockTitle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,36 @@ interface MatrixHistogramBasicProps {
defaultStackByOption: MatrixHistogramOption;
dispatchSetAbsoluteRangeDatePicker: ActionCreator<{
id: InputsModelId;
from: number;
to: number;
from: string;
to: string;
}>;
endDate: number;
endDate: string;
headerChildren?: React.ReactNode;
hideHistogramIfEmpty?: boolean;
id: string;
legendPosition?: Position;
mapping?: MatrixHistogramMappingTypes;
panelHeight?: number;
setQuery: SetQuery;
startDate: number;
startDate: string;
stackByOptions: MatrixHistogramOption[];
subtitle?: string | GetSubTitle;
title?: string | GetTitle;
titleSize?: EuiTitleSize;
}

export interface MatrixHistogramQueryProps {
endDate: number;
endDate: string;
errorMessage: string;
filterQuery?: ESQuery | string | undefined;
setAbsoluteRangeDatePicker?: ActionCreator<{
id: InputsModelId;
from: number;
to: number;
from: string;
to: string;
}>;
setAbsoluteRangeDatePickerTarget?: InputsModelId;
stackByField: string;
startDate: number;
startDate: string;
indexToAdd?: string[] | null;
isInspected: boolean;
histogramType: HistogramType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe('utils', () => {
let configs: BarchartConfigs;
beforeAll(() => {
configs = getBarchartConfigs({
from: 0,
to: 0,
from: '0',
to: '0',
onBrushEnd: jest.fn() as UpdateDateRange,
});
});
Expand Down Expand Up @@ -53,8 +53,8 @@ describe('utils', () => {
beforeAll(() => {
configs = getBarchartConfigs({
chartHeight: mockChartHeight,
from: 0,
to: 0,
from: '0',
to: '0',
onBrushEnd: jest.fn() as UpdateDateRange,
yTickFormatter: mockYTickFormatter,
showLegend: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { histogramDateTimeFormatter } from '../utils';

interface GetBarchartConfigsProps {
chartHeight?: number;
from: number;
from: string;
legendPosition?: Position;
to: number;
to: string;
onBrushEnd: UpdateDateRange;
yTickFormatter?: (value: number) => string;
showLegend?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface ChildrenArgs {

interface Props {
influencers?: InfluencerInput[];
startDate: number;
endDate: number;
startDate: string;
endDate: string;
criteriaFields?: CriteriaFields[];
children: (args: ChildrenArgs) => React.ReactNode;
skip: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('create_explorer_link', () => {
test('it returns expected link', () => {
const entities = createExplorerLink(
anomalies.anomalies[0],
new Date('1970').valueOf(),
new Date('3000').valueOf()
new Date('1970').toISOString(),
new Date('3000').toISOString()
);
expect(entities).toEqual(
"#/explorer?_g=(ml:(jobIds:!(job-1)),refreshInterval:(display:Off,pause:!f,value:0),time:(from:'1970-01-01T00:00:00.000Z',mode:absolute,to:'3000-01-01T00:00:00.000Z'))&_a=(mlExplorerFilter:(),mlExplorerSwimlane:(),mlSelectLimit:(display:'10',val:10),mlShowCharts:!t)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useKibana } from '../../../lib/kibana';

interface ExplorerLinkProps {
score: Anomaly;
startDate: number;
endDate: number;
startDate: string;
endDate: string;
linkName: React.ReactNode;
}

Expand All @@ -35,7 +35,7 @@ export const ExplorerLink: React.FC<ExplorerLinkProps> = ({
);
};

export const createExplorerLink = (score: Anomaly, startDate: number, endDate: number): string => {
export const createExplorerLink = (score: Anomaly, startDate: string, endDate: string): string => {
const startDateIso = new Date(startDate).toISOString();
const endDateIso = new Date(endDate).toISOString();

Expand Down
Loading

0 comments on commit a91e33e

Please sign in to comment.