From 899c298c3200d3b2fb232b4a74ab3817b8840883 Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Wed, 19 Oct 2022 23:53:37 -0700 Subject: [PATCH] Fix ts errors --- .../components/datasource/datasource_component.js | 1 - .../es_data_view_select/es_data_view_select.tsx | 5 ++--- .../canvas/public/services/kibana/data_views.ts | 1 - .../canvas/public/services/stubs/data_views.ts | 13 +++++++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/canvas/public/components/datasource/datasource_component.js b/x-pack/plugins/canvas/public/components/datasource/datasource_component.js index 833db6ae536de..1a357b6722c71 100644 --- a/x-pack/plugins/canvas/public/components/datasource/datasource_component.js +++ b/x-pack/plugins/canvas/public/components/datasource/datasource_component.js @@ -71,7 +71,6 @@ export class DatasourceComponent extends PureComponent { .getServices() .dataViews.getDefaultDataView() .then((defaultDataView) => { - console.log('componnentDidMount', defaultDataView); this.setState({ defaultIndex: defaultDataView.title }); }); } diff --git a/x-pack/plugins/canvas/public/components/es_data_view_select/es_data_view_select.tsx b/x-pack/plugins/canvas/public/components/es_data_view_select/es_data_view_select.tsx index 671a713c3daca..83e21b8ba2e6f 100644 --- a/x-pack/plugins/canvas/public/components/es_data_view_select/es_data_view_select.tsx +++ b/x-pack/plugins/canvas/public/components/es_data_view_select/es_data_view_select.tsx @@ -7,7 +7,7 @@ import { DataView } from '@kbn/data-views-plugin/common'; import { sortBy } from 'lodash'; -import React, { useRef, useState } from 'react'; +import React, { FC, useRef, useState } from 'react'; import useEffectOnce from 'react-use/lib/useEffectOnce'; import { useDataViewsService } from '../../services'; import { @@ -17,7 +17,7 @@ import { type ESDataViewSelectProps = Omit; -export const ESDataViewSelect: React.FunctionComponent = (props) => { +export const ESDataViewSelect: FC = (props) => { const { value, onChange } = props; const [dataViews, setDataViews] = useState>>([]); @@ -27,7 +27,6 @@ export const ESDataViewSelect: React.FunctionComponent = useEffectOnce(() => { getDataViews().then((newDataViews) => { - console.log({ newDataViews }); if (!mounted.current) { return; } diff --git a/x-pack/plugins/canvas/public/services/kibana/data_views.ts b/x-pack/plugins/canvas/public/services/kibana/data_views.ts index 3cb0f43827a6f..99e95c2e9dc4f 100644 --- a/x-pack/plugins/canvas/public/services/kibana/data_views.ts +++ b/x-pack/plugins/canvas/public/services/kibana/data_views.ts @@ -26,7 +26,6 @@ export const dataViewsServiceFactory: DataViewsServiceFactory = ({ startPlugins getDataViews: async () => { try { const dataViews = await startPlugins.data.dataViews.getIdsWithTitle(); - console.log({ dataViews }); return dataViews.map(({ id, name, title }) => ({ id, name, title } as DataView)); } catch (e) { notify.error(e, { title: strings.getIndicesFetchErrorMessage() }); diff --git a/x-pack/plugins/canvas/public/services/stubs/data_views.ts b/x-pack/plugins/canvas/public/services/stubs/data_views.ts index 7583752ae59fd..1b1227dba4d3f 100644 --- a/x-pack/plugins/canvas/public/services/stubs/data_views.ts +++ b/x-pack/plugins/canvas/public/services/stubs/data_views.ts @@ -11,7 +11,16 @@ import { CanvasDataViewsService } from '../data_views'; type DataViewsServiceFactory = PluginServiceFactory; export const dataViewsServiceFactory: DataViewsServiceFactory = () => ({ - getDataViews: () => Promise.resolve(['dataview1', 'dataview2']), + getDataViews: () => + Promise.resolve([ + { id: 'dataview1', title: 'dataview1', name: 'Data view 1' }, + { id: 'dataview2', title: 'dataview2', name: 'Data view 2' }, + ]), getFields: () => Promise.resolve(['field1', 'field2']), - getDefaultDataView: () => Promise.resolve('defaultDataView'), + getDefaultDataView: () => + Promise.resolve({ + id: 'defaultDataViewId', + title: 'defaultDataView', + name: 'Default data view', + }), });