Skip to content

Commit

Permalink
Revert "Use a real DataView reference with derivedDataView"
Browse files Browse the repository at this point in the history
This reverts commit a395d27.
  • Loading branch information
Kerry350 committed Oct 24, 2022
1 parent d0805d5 commit f2ccde9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import { createStubDataView } from '@kbn/data-views-plugin/common/stubs';
import { defaultLogViewsStaticConfig } from './defaults';
import { ResolvedLogView, resolveLogView } from './resolved_log_view';
import { LogViewAttributes } from './types';
import { DataView } from '@kbn/data-views-plugin/common';

const dataViewMock = {
id: 'log-view-data-view-mock',
title: 'log-view-data-view-mock-title',
fields: [],
} as unknown as DataView;

export const createResolvedLogViewMock = (
resolvedLogViewOverrides: Partial<ResolvedLogView> = {}
Expand Down Expand Up @@ -48,7 +41,6 @@ export const createResolvedLogViewMock = (
messageColumn: { id: 'MESSAGE_COLUMN_ID' },
},
],
dataViewReference: dataViewMock,
...resolvedLogViewOverrides,
});

Expand Down
9 changes: 0 additions & 9 deletions x-pack/plugins/infra/common/log_views/resolved_log_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface ResolvedLogView {
fields: ResolvedLogViewField[];
runtimeMappings: estypes.MappingRuntimeFields;
columns: LogViewColumnConfiguration[];
dataViewReference: DataView;
}

export const resolveLogView = async (
Expand Down Expand Up @@ -61,12 +60,6 @@ const resolveLegacyReference = async (
);
});

const dataViewReference = await dataViewsService.create({
id: '___InfraLogsLegacyLogViewReference___',
title: logViewAttributes.logIndices.indexName,
timeFieldName: TIMESTAMP_FIELD,
});

return {
indices: logViewAttributes.logIndices.indexName,
timestampField: TIMESTAMP_FIELD,
Expand All @@ -77,7 +70,6 @@ const resolveLegacyReference = async (
columns: logViewAttributes.logColumns,
name: logViewAttributes.name,
description: logViewAttributes.description,
dataViewReference,
};
};

Expand Down Expand Up @@ -105,7 +97,6 @@ const resolveDataViewReference = async (
columns: logViewAttributes.logColumns,
name: logViewAttributes.name,
description: logViewAttributes.description,
dataViewReference: dataView,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import { buildEsQuery, Filter, Query } from '@kbn/es-query';
import { JsonValue } from '@kbn/utility-types';
import { noop } from 'lodash';
import React, { useCallback, useEffect, useMemo } from 'react';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { noop } from 'lodash';
import { LogEntryCursor } from '../../../common/log_entry';
import { defaultLogViewsStaticConfig } from '../../../common/log_views';
import { BuiltEsQuery, useLogStream } from '../../containers/logs/log_stream';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const unsupportedLanguageError = i18n.translate(
}
);

export const useLogFilterState = ({ dataView }: { dataView?: DataViewBase }) => {
export const useLogFilterState = ({ dataView }: { dataView: DataViewBase }) => {
const {
notifications: { toasts },
data: {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/infra/public/hooks/use_log_view.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const defaultLogViewId = 'default';
export const createUninitializedUseLogViewMock =
(logViewId: string = defaultLogViewId) =>
(): IUseLogView => ({
derivedDataView: undefined,
derivedDataView: {
fields: [],
title: 'unknown',
},
hasFailedLoading: false,
hasFailedLoadingLogView: false,
hasFailedLoadingLogViewStatus: false,
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/infra/public/hooks/use_log_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ export const useLogView = ({
[logViews]
);

const derivedDataView = useMemo(() => {
return resolvedLogView?.dataViewReference;
}, [resolvedLogView]);
const derivedDataView = useMemo(
() => ({
fields: resolvedLogView?.fields ?? [],
title: resolvedLogView?.indices ?? 'unknown',
}),
[resolvedLogView]
);

const isLoadingLogView = loadLogViewRequest.state === 'pending';
const isResolvingLogView = resolveLogViewRequest.state === 'pending';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { DataView } from '@kbn/data-views-plugin/public';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { LogCustomizationMenu } from '../../../components/logging/log_customization_menu';
Expand Down Expand Up @@ -61,7 +62,7 @@ export const LogsToolbar = () => {
defaultMessage: 'Search for log entries… (e.g. host.name:host-1)',
})}
useDefaultBehaviors={true}
indexPatterns={derivedDataView ? [derivedDataView] : undefined}
indexPatterns={[derivedDataView as DataView]}
showQueryInput={true}
showQueryMenu={false}
showFilterBar={false}
Expand Down

0 comments on commit f2ccde9

Please sign in to comment.