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 1f191c1
Show file tree
Hide file tree
Showing 120 changed files with 522 additions and 483 deletions.
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 @@ -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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TestProviders } from '../../../mock/test_providers';
import { useMountAppended } from '../../../utils/use_mount_appended';
import { Anomalies } from '../types';

const endDate: number = new Date('3000-01-01T00:00:00.000Z').valueOf();
const endDate: string = '3000-01-01T00:00:00.000Z';
const narrowDateRange = jest.fn();

describe('anomaly_scores', () => {
Expand All @@ -28,7 +28,7 @@ describe('anomaly_scores', () => {
const wrapper = shallow(
<AnomalyScoreComponent
jobKey="job-key-1"
startDate={0}
startDate={'0'}
endDate={endDate}
score={anomalies.anomalies[0]}
interval="day"
Expand All @@ -43,7 +43,7 @@ describe('anomaly_scores', () => {
<TestProviders>
<AnomalyScoreComponent
jobKey="job-key-1"
startDate={0}
startDate={'0'}
endDate={endDate}
score={anomalies.anomalies[0]}
interval="day"
Expand All @@ -59,7 +59,7 @@ describe('anomaly_scores', () => {
<TestProviders>
<AnomalyScoreComponent
jobKey="job-key-1"
startDate={0}
startDate={'0'}
endDate={endDate}
score={anomalies.anomalies[0]}
interval="day"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { escapeDataProviderId } from '../../drag_and_drop/helpers';
import { createDescriptionList } from './create_description_list';

interface Args {
startDate: number;
endDate: number;
startDate: string;
endDate: string;
narrowDateRange: NarrowDateRange;
jobKey: string;
index?: number;
Expand Down
Loading

0 comments on commit 1f191c1

Please sign in to comment.