Skip to content

Commit

Permalink
Merge branch 'main' into adding-api-tests-for-modules-jobs-exists-end…
Browse files Browse the repository at this point in the history
…point
  • Loading branch information
jgowdyelastic authored Sep 30, 2022
2 parents 5839fab + 874c93c commit 860c420
Show file tree
Hide file tree
Showing 182 changed files with 4,692 additions and 1,987 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pageLoadAssetSize:
dataViewEditor: 12000
dataViewFieldEditor: 27000
dataViewManagement: 5000
dataViews: 44532
dataViews: 46532
dataVisualizer: 27530
devTools: 38637
discover: 99999
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import React, { useState, useEffect, useCallback, useRef } from 'react';
import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiLoadingSpinner } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import memoizeOne from 'memoize-one';
import { DataViewField } from '@kbn/data-views-plugin/public';
import {
DataViewField,
DataViewsPublicPluginStart,
INDEX_PATTERN_TYPE,
MatchedItem,
} from '@kbn/data-views-plugin/public';

import {
DataView,
Expand All @@ -23,16 +28,14 @@ import {
UseField,
} from '../shared_imports';

import { ensureMinimumTime, getIndices, extractTimeFields, getMatchedIndices } from '../lib';
import { ensureMinimumTime, extractTimeFields, getMatchedIndices } from '../lib';
import { FlyoutPanels } from './flyout_panels';

import { removeSpaces } from '../lib';

import {
MatchedItem,
DataViewEditorContext,
RollupIndicesCapsResponse,
INDEX_PATTERN_TYPE,
IndexPatternConfig,
MatchedIndicesSet,
FormInternal,
Expand Down Expand Up @@ -176,18 +179,19 @@ const IndexPatternEditorFlyoutContentComponent = ({

// load all data sources and set initial matchedIndices
const loadSources = useCallback(() => {
getIndices({
http,
isRollupIndex: () => false,
pattern: '*',
showAllIndices: allowHidden,
}).then((dataSources) => {
setAllSources(dataSources);
const matchedSet = getMatchedIndices(dataSources, [], [], allowHidden);
setMatchedIndices(matchedSet);
setIsLoadingSources(false);
});
}, [http, allowHidden]);
dataViews
.getIndices({
isRollupIndex: () => false,
pattern: '*',
showAllIndices: allowHidden,
})
.then((dataSources) => {
setAllSources(dataSources);
const matchedSet = getMatchedIndices(dataSources, [], [], allowHidden);
setMatchedIndices(matchedSet);
setIsLoadingSources(false);
});
}, [allowHidden, dataViews]);

// loading list of index patterns
useEffect(() => {
Expand Down Expand Up @@ -271,7 +275,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
const { matchedIndicesResult, exactMatched } = !isLoadingSources
? await loadMatchedIndices(query, allowHidden, allSources, {
isRollupIndex,
http,
dataViews,
})
: {
matchedIndicesResult: {
Expand Down Expand Up @@ -302,7 +306,7 @@ const IndexPatternEditorFlyoutContentComponent = ({

return fetchIndices(newTitle);
},
[http, allowHidden, allSources, type, rollupIndicesCapabilities, isLoadingSources]
[dataViews, allowHidden, allSources, type, rollupIndicesCapabilities, isLoadingSources]
);

// If editData exists, loadSources so that MatchedIndices can be loaded for the Timestampfields
Expand Down Expand Up @@ -453,10 +457,10 @@ const loadMatchedIndices = memoizeOne(
allSources: MatchedItem[],
{
isRollupIndex,
http,
dataViews,
}: {
isRollupIndex: (index: string) => boolean;
http: DataViewEditorContext['http'];
dataViews: DataViewsPublicPluginStart;
}
): Promise<{
matchedIndicesResult: MatchedIndicesSet;
Expand All @@ -466,8 +470,7 @@ const loadMatchedIndices = memoizeOne(
const indexRequests = [];

if (query?.endsWith('*')) {
const exactMatchedQuery = getIndices({
http,
const exactMatchedQuery = dataViews.getIndices({
isRollupIndex,
pattern: query,
showAllIndices: allowHidden,
Expand All @@ -476,14 +479,12 @@ const loadMatchedIndices = memoizeOne(
// provide default value when not making a request for the partialMatchQuery
indexRequests.push(Promise.resolve([]));
} else {
const exactMatchQuery = getIndices({
http,
const exactMatchQuery = dataViews.getIndices({
isRollupIndex,
pattern: query,
showAllIndices: allowHidden,
});
const partialMatchQuery = getIndices({
http,
const partialMatchQuery = dataViews.getIndices({
isRollupIndex,
pattern: `${query}*`,
showAllIndices: allowHidden,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React, { ChangeEvent, useState, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiFieldText } from '@elastic/eui';
import { MatchedItem } from '@kbn/data-views-plugin/public';
import {
UseField,
getFieldValidityAndErrorMessage,
Expand All @@ -17,12 +18,7 @@ import {
} from '../../shared_imports';
import { canAppendWildcard, removeSpaces } from '../../lib';
import { schema } from '../form_schema';
import {
MatchedItem,
RollupIndicesCapsResponse,
IndexPatternConfig,
MatchedIndicesSet,
} from '../../types';
import { RollupIndicesCapsResponse, IndexPatternConfig, MatchedIndicesSet } from '../../types';

interface RefreshMatchedIndicesResult {
matchedIndicesResult: MatchedIndicesSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import {
EuiBadge,
} from '@elastic/eui';

import { INDEX_PATTERN_TYPE } from '@kbn/data-views-plugin/public';
import { UseField } from '../../shared_imports';

import { INDEX_PATTERN_TYPE, IndexPatternConfig } from '../../types';
import { IndexPatternConfig } from '../../types';

interface TypeFieldProps {
onChange: (type: INDEX_PATTERN_TYPE) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Side Public License, v 1.
*/

import { INDEX_PATTERN_TYPE } from '@kbn/data-views-plugin/public';
import { i18n } from '@kbn/i18n';
import { fieldValidators, ValidationFunc } from '../shared_imports';
import { INDEX_PATTERN_TYPE } from '../types';

export const singleAstriskValidator = (
...args: Parameters<ValidationFunc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { IndicesList } from '.';
import { shallow } from 'enzyme';
import { MatchedItem } from '../../../types';
import { MatchedItem } from '@kbn/data-views-plugin/public';

const indices = [
{ name: 'kibana', tags: [] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { Pager } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';
import { MatchedItem, Tag } from '../../../types';
import { MatchedItem, Tag } from '@kbn/data-views-plugin/public';

interface IndicesListProps {
indices: MatchedItem[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import React from 'react';
import { EuiSpacer } from '@elastic/eui';
import { INDEX_PATTERN_TYPE } from '@kbn/data-views-plugin/public';
import { StatusMessage } from './status_message';
import { IndicesList } from './indices_list';

import { INDEX_PATTERN_TYPE, MatchedIndicesSet } from '../../types';
import { MatchedIndicesSet } from '../../types';

interface Props {
type: INDEX_PATTERN_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { StatusMessage } from '.';
import { shallow } from 'enzyme';
import { MatchedItem } from '../../../types';
import { MatchedItem } from '@kbn/data-views-plugin/public';

const tagsPartial = {
tags: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

import { MatchedItem } from '@kbn/data-views-plugin/public';
import { Tag } from '@kbn/data-views-plugin/public/types';
import { getMatchedIndices } from './get_matched_indices';
import { Tag, MatchedItem } from '../types';

jest.mock('../constants', () => ({
MAX_NUMBER_OF_MATCHING_INDICES: 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { MatchedItem } from '@kbn/data-views-plugin/public';
import { MAX_NUMBER_OF_MATCHING_INDICES } from '../constants';

function isSystemIndex(index: string): boolean {
Expand Down Expand Up @@ -50,7 +51,7 @@ function filterSystemIndices(indices: MatchedItem[], isIncludingSystemIndices: b
We call this `exact` matches because ES is telling us exactly what it matches
*/

import { MatchedItem, MatchedIndicesSet } from '../types';
import { MatchedIndicesSet } from '../types';

export function getMatchedIndices(
unfilteredAllIndices: MatchedItem[],
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/data_view_editor/public/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export { canAppendWildcard } from './can_append_wildcard';

export { ensureMinimumTime } from './ensure_minimum_time';

export { getIndices } from './get_indices';

export { getMatchedIndices } from './get_matched_indices';

export { containsIllegalCharacters } from './contains_illegal_characters';
Expand Down
64 changes: 6 additions & 58 deletions src/plugins/data_view_editor/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import {

import { EuiComboBoxOptionOption } from '@elastic/eui';

import type { DataView, DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type {
DataView,
DataViewsPublicPluginStart,
INDEX_PATTERN_TYPE,
MatchedItem,
} from '@kbn/data-views-plugin/public';
import { DataPublicPluginStart, IndexPatternAggRestrictions } from './shared_imports';

export interface DataViewEditorContext {
Expand Down Expand Up @@ -80,51 +85,6 @@ export interface StartPlugins {

export type CloseEditor = () => void;

export interface MatchedItem {
name: string;
tags: Tag[];
item: {
name: string;
backing_indices?: string[];
timestamp_field?: string;
indices?: string[];
aliases?: string[];
attributes?: ResolveIndexResponseItemIndexAttrs[];
data_stream?: string;
};
}

// for showing index matches
export interface ResolveIndexResponse {
indices?: ResolveIndexResponseItemIndex[];
aliases?: ResolveIndexResponseItemAlias[];
data_streams?: ResolveIndexResponseItemDataStream[];
}

export interface ResolveIndexResponseItem {
name: string;
}

export interface ResolveIndexResponseItemDataStream extends ResolveIndexResponseItem {
backing_indices: string[];
timestamp_field: string;
}

export interface ResolveIndexResponseItemAlias extends ResolveIndexResponseItem {
indices: string[];
}

export interface ResolveIndexResponseItemIndex extends ResolveIndexResponseItem {
aliases?: string[];
attributes?: ResolveIndexResponseItemIndexAttrs[];
data_stream?: string;
}

export interface Tag {
name: string;
key: string;
color: string;
}
// end for index matches

export interface IndexPatternTableItem {
Expand All @@ -135,25 +95,13 @@ export interface IndexPatternTableItem {
sort: string;
}

export enum ResolveIndexResponseItemIndexAttrs {
OPEN = 'open',
CLOSED = 'closed',
HIDDEN = 'hidden',
FROZEN = 'frozen',
}

export interface RollupIndiciesCapability {
aggs: Record<string, IndexPatternAggRestrictions>;
error: string;
}

export type RollupIndicesCapsResponse = Record<string, RollupIndiciesCapability>;

export enum INDEX_PATTERN_TYPE {
ROLLUP = 'rollup',
DEFAULT = 'default',
}

export interface IndexPatternConfig {
title: string;
timestampField?: EuiComboBoxOptionOption<string>;
Expand Down
14 changes: 13 additions & 1 deletion src/plugins/data_views/public/data_views_service_public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { DataViewsService } from '.';
import { DataViewsService, MatchedItem } from '.';

import { DataViewsServiceDeps } from '../common/data_views/data_views';
import { HasDataService } from '../common';
Expand All @@ -24,6 +24,11 @@ export interface DataViewsServicePublicDeps extends DataViewsServiceDeps {
* Has data service
*/
hasData: HasDataService;
getIndices: (props: {
pattern: string;
showAllIndices?: boolean;
isRollupIndex: (indexName: string) => boolean;
}) => Promise<MatchedItem[]>;
}

/**
Expand All @@ -32,6 +37,12 @@ export interface DataViewsServicePublicDeps extends DataViewsServiceDeps {
*/
export class DataViewsServicePublic extends DataViewsService {
public getCanSaveSync: () => boolean;

public getIndices: (props: {
pattern: string;
showAllIndices?: boolean;
isRollupIndex: (indexName: string) => boolean;
}) => Promise<MatchedItem[]>;
public hasData: HasDataService;

/**
Expand All @@ -43,5 +54,6 @@ export class DataViewsServicePublic extends DataViewsService {
super(deps);
this.getCanSaveSync = deps.getCanSaveSync;
this.hasData = deps.hasData;
this.getIndices = deps.getIndices;
}
}
Loading

0 comments on commit 860c420

Please sign in to comment.