Skip to content

Commit

Permalink
Fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cqliu1 committed Oct 20, 2022
1 parent 4ed24f6 commit 899c298
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class DatasourceComponent extends PureComponent {
.getServices()
.dataViews.getDefaultDataView()
.then((defaultDataView) => {
console.log('componnentDidMount', defaultDataView);
this.setState({ defaultIndex: defaultDataView.title });
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -17,7 +17,7 @@ import {

type ESDataViewSelectProps = Omit<Props, 'indices' | 'loading'>;

export const ESDataViewSelect: React.FunctionComponent<ESDataViewSelectProps> = (props) => {
export const ESDataViewSelect: FC<ESDataViewSelectProps> = (props) => {
const { value, onChange } = props;

const [dataViews, setDataViews] = useState<Array<Pick<DataView, 'id' | 'name' | 'title'>>>([]);
Expand All @@ -27,7 +27,6 @@ export const ESDataViewSelect: React.FunctionComponent<ESDataViewSelectProps> =

useEffectOnce(() => {
getDataViews().then((newDataViews) => {
console.log({ newDataViews });
if (!mounted.current) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/canvas/public/services/kibana/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/canvas/public/services/stubs/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ import { CanvasDataViewsService } from '../data_views';
type DataViewsServiceFactory = PluginServiceFactory<CanvasDataViewsService>;

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',
}),
});

0 comments on commit 899c298

Please sign in to comment.