Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data views] Reduce deprecated api usage #124059

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pageLoadAssetSize:
uiActionsEnhanced: 38494
urlDrilldown: 30063
dataViewEditor: 12000
dataViewFieldEditor: 20000
dataViewFieldEditor: 27000
dataViewManagement: 5000
reporting: 57003
visTypeHeatmap: 25340
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export type {
export type {
IndexPatternsContract,
DataViewsContract,
IndexPatternListItem,
DataViewListItem,
} from '../../data_views/common';
export {
Expand All @@ -68,7 +67,6 @@ export {
DataViewField,
IndexPatternField,
DataViewType,
IndexPatternType,
IndexPatternsService,
DataViewsService,
IndexPattern,
Expand Down
15 changes: 1 addition & 14 deletions src/plugins/data/common/kbn_field_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@

// NOTE: trick to mark exports as deprecated (only for constants and types, but not for interfaces, classes or enums)
import {
castEsToKbnFieldTypeName as oldCastEsToKbnFieldTypeName,
getFilterableKbnTypeNames as oldGetFilterableKbnTypeNames,
getKbnFieldType as oldGetKbnFieldType,
getKbnTypeNames as oldGetKbnTypeNames,
KbnFieldType,
} from '@kbn/field-types';

/**
* @deprecated Import from the "@kbn/field-types" package directly instead.
* @removeBy 8.1
*/
const castEsToKbnFieldTypeName = oldCastEsToKbnFieldTypeName;

/**
* @deprecated Import from the "@kbn/field-types" package directly instead.
* @removeBy 8.1
Expand All @@ -39,10 +32,4 @@ const getKbnFieldType = oldGetKbnFieldType;
*/
const getKbnTypeNames = oldGetKbnTypeNames;

export {
castEsToKbnFieldTypeName,
getKbnFieldType,
getKbnTypeNames,
getFilterableKbnTypeNames,
KbnFieldType,
};
export { getKbnFieldType, getKbnTypeNames, getFilterableKbnTypeNames, KbnFieldType };
9 changes: 1 addition & 8 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ export type {
IndexPatternLoadExpressionFunctionDefinition,
GetFieldsOptions,
AggregationRestrictions,
IndexPatternListItem,
DataViewListItem,
} from '../common';
export {
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
UI_SETTINGS,
fieldList,
IndexPatternType,
DuplicateDataViewError,
} from '../common';

Expand Down Expand Up @@ -295,12 +293,7 @@ export type {

export type { AggsStart } from './search/aggs';

export {
getTime,
// kbn field types
castEsToKbnFieldTypeName,
getKbnTypeNames,
} from '../common';
export { getTime, getKbnTypeNames } from '../common';

export { isTimeRange, isQuery } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const search = {
*/

export type { TimeRange } from '../common';
export { castEsToKbnFieldTypeName, getTime, parseInterval } from '../common';
export { getTime, parseInterval } from '../common';

/**
* Static code to be shared externally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import memoizeOne from 'memoize-one';
import { DataViewField } from '../../../data_views/public';

import {
IndexPatternSpec,
DataViewSpec,
Form,
useForm,
useFormData,
Expand Down Expand Up @@ -51,7 +51,7 @@ export interface Props {
/**
* Handler for the "save" footer button
*/
onSave: (indexPatternSpec: IndexPatternSpec) => void;
onSave: (indexPatternSpec: DataViewSpec) => void;
/**
* Handler for the "cancel" footer button
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
return;
}

const indexPatternStub: IndexPatternSpec = {
const indexPatternStub: DataViewSpec = {
title: formData.title,
timeFieldName: formData.timestampField?.value,
id: formData.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { i18n } from '@kbn/i18n';

import { IndexPatternSpec, useKibana } from '../shared_imports';
import { DataViewSpec, useKibana } from '../shared_imports';
import { IndexPatternEditorFlyoutContent } from './data_view_editor_flyout_content';
import { DataViewEditorContext, DataViewEditorProps } from '../types';

Expand All @@ -23,9 +23,9 @@ const IndexPatternFlyoutContentContainer = ({
services: { dataViews, notifications },
} = useKibana<DataViewEditorContext>();

const onSaveClick = async (indexPatternSpec: IndexPatternSpec) => {
const onSaveClick = async (dataViewSpec: DataViewSpec) => {
try {
const indexPattern = await dataViews.createAndSave(indexPatternSpec);
const indexPattern = await dataViews.createAndSave(dataViewSpec);

const message = i18n.translate('indexPatternEditor.saved', {
defaultMessage: "Saved '{indexPatternTitle}'",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_view_editor/public/shared_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

export type {
DataPublicPluginStart,
IndexPatternSpec,
GetFieldsOptions,
IndexPatternAggRestrictions,
} from '../../data/public';
export { IndexPattern, IndexPatternField } from '../../data/public';
export type { DataViewSpec } from '../../data_views/public';
export { DataView } from '../../data_views/public';

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from 'src/plugins/data/public';
import type { FieldFormatInstanceType } from 'src/plugins/field_formats/common';
import { CoreStart } from 'src/core/public';
import { castEsToKbnFieldTypeName } from '../../../../data/public';
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
import { FormatEditor } from './format_editor';
import { FormatEditorServiceStart } from '../../service';
import { FieldFormatConfig } from '../../types';
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ export interface DataViewListItem {
typeMeta?: TypeMeta;
}

/**
* @deprecated Use DataViewListItem. All index pattern interfaces were renamed.
*/

export type IndexPatternListItem = DataViewListItem;

export interface DataViewsServiceDeps {
uiSettings: UiSettingsCommon;
savedObjectsClient: SavedObjectsClientCommon;
Expand Down Expand Up @@ -173,7 +167,7 @@ export class DataViewsService {
* Get list of index pattern ids with titles
* @param refresh Force refresh of index pattern list
*/
getIdsWithTitle = async (refresh: boolean = false): Promise<IndexPatternListItem[]> => {
getIdsWithTitle = async (refresh: boolean = false): Promise<DataViewListItem[]> => {
if (!this.savedObjectsCache || refresh) {
await this.refreshSavedObjectsCache();
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_views/common/fields/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FieldSpec, DataView } from '..';

/**
* @deprecated Use {@link IndexPatternField}
* @removeBy 8.1
* @removeBy 8.2
*/
export interface IFieldType extends DataViewFieldBase {
count?: number;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data_views/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export type {
IndexPatternSpec,
SourceFilter,
} from './types';
export { DataViewType, IndexPatternType } from './types';
export { DataViewType } from './types';
export type { IndexPatternsContract, DataViewsContract } from './data_views';
export { IndexPatternsService, DataViewsService } from './data_views';
export type { IndexPatternListItem, DataViewListItem, TimeBasedDataView } from './data_views';
export type { DataViewListItem, TimeBasedDataView } from './data_views';
export { IndexPattern, DataView } from './data_views';
export {
DuplicateDataViewError,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data_views/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
export { onRedirectNoIndexPattern } from './data_views';

export type { IIndexPatternFieldList, TypeMeta } from '../common';
export type { DataViewSpec } from '../common';
export { IndexPatternField, DataViewField, DataViewType, META_FIELDS } from '../common';

export type { IndexPatternsContract } from './data_views';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
RegisterDeprecationsConfig,
} from 'kibana/server';
import { i18n } from '@kbn/i18n';
import { IndexPatternAttributes } from '../../common';
import { DataViewAttributes } from '../../common';

type IndexPatternAttributesWithFields = Pick<IndexPatternAttributes, 'title' | 'fields'>;
type IndexPatternAttributesWithFields = Pick<DataViewAttributes, 'title' | 'fields'>;

export const createScriptedFieldsDeprecationsConfig: (
core: CoreSetup
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/data_views/server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { SavedObjectsClientContract } from 'kibana/server';
import {
IFieldType,
DATA_VIEW_SAVED_OBJECT_TYPE,
IndexPatternAttributes,
DataViewAttributes,
SavedObject,
} from '../common';

export const getFieldByName = (
fieldName: string,
indexPattern: SavedObject<IndexPatternAttributes>
indexPattern: SavedObject<DataViewAttributes>
): IFieldType | undefined => {
const fields: IFieldType[] = indexPattern && JSON.parse(indexPattern.attributes.fields);
const field = fields && fields.find((f) => f.name === fieldName);
Expand All @@ -27,8 +27,8 @@ export const getFieldByName = (
export const findIndexPatternById = async (
savedObjectsClient: SavedObjectsClientContract,
index: string
): Promise<SavedObject<IndexPatternAttributes> | undefined> => {
const savedObjectsResponse = await savedObjectsClient.find<IndexPatternAttributes>({
): Promise<SavedObject<DataViewAttributes> | undefined> => {
const savedObjectsResponse = await savedObjectsClient.find<DataViewAttributes>({
type: DATA_VIEW_SAVED_OBJECT_TYPE,
fields: ['fields'],
search: `"${index}"`,
Expand Down