Skip to content

Commit

Permalink
Revert "[data views] Allow data views created on hidden and system in…
Browse files Browse the repository at this point in the history
…dices (#168174)"

This reverts commit 85d8231.
  • Loading branch information
mattkime authored Oct 13, 2023
1 parent 326ef31 commit 9930e70
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 87 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pageLoadAssetSize:
dataViewEditor: 28082
dataViewFieldEditor: 27000
dataViewManagement: 5000
dataViews: 48300
dataViews: 47300
dataVisualizer: 27530
devTools: 38637
discover: 99999
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const IndexPatternEditorFlyoutContentComponent = ({
timeFieldName: formData.timestampField?.value,
id: formData.id,
name: formData.name,
allowHidden: formData.allowHidden,
};

if (type === INDEX_PATTERN_TYPE.ROLLUP && rollupIndex) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/plugins/data_views/common/data_views/data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ export class DataView implements DataViewBase {
*/
public matchedIndices: string[] = [];

private allowHidden: boolean = false;

/**
* constructor
* @param config - config data and dependencies
Expand Down Expand Up @@ -189,7 +187,6 @@ export class DataView implements DataViewBase {
this.runtimeFieldMap = cloneDeep(spec.runtimeFieldMap) || {};
this.namespaces = spec.namespaces || [];
this.name = spec.name || '';
this.allowHidden = spec.allowHidden || false;
}

/**
Expand All @@ -204,8 +201,6 @@ export class DataView implements DataViewBase {

getIndexPattern = () => this.title;

getAllowHidden = () => this.allowHidden;

/**
* Set index pattern
* @param string index pattern string
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ export class DataViewsService {
allowNoIndex: true,
pattern: dataView.getIndexPattern(),
metaFields,
allowHidden: dataView.getAllowHidden(),
});
};

Expand All @@ -597,7 +596,6 @@ export class DataViewsService {
rollupIndex: options.rollupIndex,
allowNoIndex: true,
indexFilter: options.indexFilter,
allowHidden: options.allowHidden,
});
};

Expand Down Expand Up @@ -749,7 +747,6 @@ export class DataViewsService {
fieldAttrs,
allowNoIndex,
name,
allowHidden,
},
} = savedObject;

Expand Down Expand Up @@ -777,7 +774,6 @@ export class DataViewsService {
allowNoIndex,
runtimeFieldMap: parsedRuntimeFieldMap,
name,
allowHidden,
};
};

Expand Down
9 changes: 0 additions & 9 deletions src/plugins/data_views/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ export interface DataViewAttributes {
* Name of the data view. Human readable name used to differentiate data view.
*/
name?: string;
/**
* Allow hidden and system indices when loading field list
*/
allowHidden?: boolean;
}

/**
Expand Down Expand Up @@ -313,7 +309,6 @@ export interface GetFieldsOptions {
indexFilter?: QueryDslQueryContainer;
includeUnmapped?: boolean;
fields?: string[];
allowHidden?: boolean;
}

/**
Expand Down Expand Up @@ -517,10 +512,6 @@ export type DataViewSpec = {
* Name of the data view. Human readable name used to differentiate data view.
*/
name?: string;
/**
* Whether the data view is hidden from the user
*/
allowHidden?: boolean;
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
Expand Down
14 changes: 1 addition & 13 deletions src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,12 @@ export class IndexPatternsFetcher {
rollupIndex?: string;
indexFilter?: QueryDslQueryContainer;
fields?: string[];
allowHidden?: boolean;
}): Promise<{ fields: FieldDescriptor[]; indices: string[] }> {
const {
pattern,
metaFields = [],
fieldCapsOptions,
type,
rollupIndex,
indexFilter,
allowHidden,
} = options;
const { pattern, metaFields = [], fieldCapsOptions, type, rollupIndex, indexFilter } = options;
const allowNoIndices = fieldCapsOptions
? fieldCapsOptions.allow_no_indices
: this.allowNoIndices;

const expandWildcards = allowHidden ? 'all' : 'open';

const fieldCapsResponse = await getFieldCapabilities({
callCluster: this.elasticsearchClient,
indices: pattern,
Expand All @@ -96,7 +85,6 @@ export class IndexPatternsFetcher {
},
indexFilter,
fields: options.fields || ['*'],
expandWildcards,
});

if (this.rollupsEnabled && type === 'rollup' && rollupIndex) {
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/data_views/server/fetcher/lib/es_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import { ElasticsearchClient } from '@kbn/core/server';
import { ExpandWildcard } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { QueryDslQueryContainer } from '../../../common/types';
import { convertEsError } from './errors';

Expand Down Expand Up @@ -46,7 +45,6 @@ interface FieldCapsApiParams {
fieldCapsOptions?: { allow_no_indices: boolean; include_unmapped?: boolean };
indexFilter?: QueryDslQueryContainer;
fields?: string[];
expandWildcard?: ExpandWildcard;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('index_patterns/field_capabilities/field_capabilities', () => {
const fillUndefinedParams = (args) => ({
callCluster: undefined,
indices: undefined,
expandWildcard: undefined,
fieldCapsOptions: undefined,
indexFilter: undefined,
fields: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import { defaults, keyBy, sortBy } from 'lodash';

import { ElasticsearchClient } from '@kbn/core/server';
import { ExpandWildcard } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { callFieldCapsApi } from '../es_api';
import { readFieldCapsResponse } from './field_caps_response';
import { mergeOverrides } from './overrides';
Expand All @@ -23,7 +22,6 @@ interface FieldCapabilitiesParams {
fieldCapsOptions?: { allow_no_indices: boolean; include_unmapped?: boolean };
indexFilter?: QueryDslQueryContainer;
fields?: string[];
expandWildcards?: ExpandWildcard;
}

/**
Expand All @@ -44,15 +42,13 @@ export async function getFieldCapabilities(params: FieldCapabilitiesParams) {
indexFilter,
metaFields = [],
fields,
expandWildcards,
} = params;
const esFieldCaps = await callFieldCapsApi({
callCluster,
indices,
fieldCapsOptions,
indexFilter,
fields,
expandWildcard: expandWildcards,
});
const fieldCapsArr = readFieldCapsResponse(esFieldCaps.body);
const fieldsFromFieldCapsByName = keyBy(fieldCapsArr, 'name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ interface IQuery {
allow_no_index?: boolean;
include_unmapped?: boolean;
fields?: string[];
allow_hidden?: boolean;
}

const querySchema = schema.object({
Expand All @@ -63,7 +62,6 @@ const querySchema = schema.object({
allow_no_index: schema.maybe(schema.boolean()),
include_unmapped: schema.maybe(schema.boolean()),
fields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])),
allow_hidden: schema.maybe(schema.boolean()),
});

const fieldSubTypeSchema = schema.object({
Expand Down Expand Up @@ -124,7 +122,6 @@ const handler: (isRollupsEnabled: () => boolean) => RequestHandler<{}, IQuery, I
rollup_index: rollupIndex,
allow_no_index: allowNoIndex,
include_unmapped: includeUnmapped,
allow_hidden: allowHidden,
} = request.query;

// not available to get request
Expand All @@ -150,7 +147,6 @@ const handler: (isRollupsEnabled: () => boolean) => RequestHandler<{}, IQuery, I
includeUnmapped,
},
indexFilter,
allowHidden,
...(parsedFields.length > 0 ? { fields: parsedFields } : {}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const find = getService('find');
const es = getService('es');
const PageObjects = getPageObjects(['settings', 'common', 'header']);

describe('creating and deleting default data view', function describeIndexTests() {
Expand Down Expand Up @@ -251,32 +250,5 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
});

describe('hidden index support', () => {
it('can create data view against hidden index', async () => {
const pattern = 'logstash-2015.09.21';

await es.transport.request({
path: '/logstash-2015.09.21/_settings',
method: 'PUT',
body: {
index: {
hidden: true,
},
},
});

await PageObjects.settings.createIndexPattern(
pattern,
undefined,
undefined,
undefined,
undefined,
true
);
const patternName = await PageObjects.settings.getIndexPageHeading();
expect(patternName).to.be(pattern);
});
});
});
}
13 changes: 1 addition & 12 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,13 @@ export class SettingsPageObject extends FtrService {
await customDataViewIdInput.type(value);
}

async allowHiddenClick() {
await this.testSubjects.click('toggleAdvancedSetting');
await this.testSubjects.click('allowHiddenField');
}

async createIndexPattern(
indexPatternName: string,
// null to bypass default value
timefield: string | null = '@timestamp',
isStandardIndexPattern = true,
customDataViewId?: string,
dataViewName?: string,
allowHidden?: boolean
dataViewName?: string
) {
await this.retry.try(async () => {
await this.header.waitUntilLoadingHasFinished();
Expand All @@ -495,11 +489,6 @@ export class SettingsPageObject extends FtrService {
} else {
await this.clickAddNewIndexPatternButton();
}

if (allowHidden) {
await this.allowHiddenClick();
}

await this.header.waitUntilLoadingHasFinished();
if (!isStandardIndexPattern) {
await this.selectRollupIndexPatternType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ describe('LogViewsClient class', () => {
},
],
"dataViewReference": DataView {
"allowHidden": false,
"allowNoIndex": false,
"deleteFieldFormat": [Function],
"fieldAttrs": Object {},
Expand All @@ -274,7 +273,6 @@ describe('LogViewsClient class', () => {
},
"fields": FldList [],
"flattenHit": [Function],
"getAllowHidden": [Function],
"getFieldAttrs": [Function],
"getIndexPattern": [Function],
"getName": [Function],
Expand Down

0 comments on commit 9930e70

Please sign in to comment.