mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[data views] Disable rollup ui elements on serverless (#164098)
## Summary While rollup functionality is deprecated in serverless, its still possible to import a rollup data view. Lets hide any mention of this since it will be lacking all rollup functionality.
This commit is contained in:
parent
7db844bc66
commit
b1b9340c10
12 changed files with 128 additions and 42 deletions
|
@ -31,7 +31,7 @@ pageLoadAssetSize:
|
|||
dataViewEditor: 28082
|
||||
dataViewFieldEditor: 27000
|
||||
dataViewManagement: 5000
|
||||
dataViews: 47000
|
||||
dataViews: 47300
|
||||
dataVisualizer: 27530
|
||||
devTools: 38637
|
||||
discover: 99999
|
||||
|
|
|
@ -11,6 +11,7 @@ Array [
|
|||
"sort": "0test name",
|
||||
"tags": Array [
|
||||
Object {
|
||||
"data-test-subj": "default-tag",
|
||||
"key": "default",
|
||||
"name": "Default",
|
||||
},
|
||||
|
|
|
@ -77,7 +77,9 @@ export const EditIndexPattern = withRouter(
|
|||
indexPattern.fields.getAll().filter((field) => field.type === 'conflict')
|
||||
);
|
||||
const [defaultIndex, setDefaultIndex] = useState<string>(uiSettings.get('defaultIndex'));
|
||||
const [tags, setTags] = useState<Array<{ key: string; name: string }>>([]);
|
||||
const [tags, setTags] = useState<
|
||||
Array<{ key: string; 'data-test-subj': string; name: string }>
|
||||
>([]);
|
||||
const [showEditDialog, setShowEditDialog] = useState<boolean>(false);
|
||||
const [relationships, setRelationships] = useState<SavedObjectRelationWithTitle[]>([]);
|
||||
const [allowedTypes, setAllowedTypes] = useState<SavedObjectManagementTypeInfo[]>([]);
|
||||
|
@ -108,8 +110,10 @@ export const EditIndexPattern = withRouter(
|
|||
}, [indexPattern]);
|
||||
|
||||
useEffect(() => {
|
||||
setTags(getTags(indexPattern, indexPattern.id === defaultIndex));
|
||||
}, [defaultIndex, indexPattern]);
|
||||
setTags(
|
||||
getTags(indexPattern, indexPattern.id === defaultIndex, dataViews.getRollupsEnabled())
|
||||
);
|
||||
}, [defaultIndex, indexPattern, dataViews]);
|
||||
|
||||
const setDefaultPattern = useCallback(() => {
|
||||
uiSettings.set('defaultIndex', indexPattern.id);
|
||||
|
@ -125,7 +129,9 @@ export const EditIndexPattern = withRouter(
|
|||
},
|
||||
});
|
||||
|
||||
const isRollup = new URLSearchParams(useLocation().search).get('type') === 'rollup';
|
||||
const isRollup =
|
||||
new URLSearchParams(useLocation().search).get('type') === 'rollup' &&
|
||||
dataViews.getRollupsEnabled();
|
||||
const displayIndexPatternEditor = showEditDialog ? (
|
||||
<IndexPatternEditor
|
||||
onSave={() => {
|
||||
|
@ -237,7 +243,11 @@ export const EditIndexPattern = withRouter(
|
|||
{tags.map((tag) => (
|
||||
<EuiFlexItem grow={false} key={tag.key}>
|
||||
{tag.key === 'default' ? (
|
||||
<EuiBadge iconType="starFilled" color="default">
|
||||
<EuiBadge
|
||||
iconType="starFilled"
|
||||
color="default"
|
||||
data-test-subj={tag['data-test-subj']}
|
||||
>
|
||||
{tag.name}
|
||||
</EuiBadge>
|
||||
) : (
|
||||
|
|
|
@ -164,7 +164,9 @@ export const IndexPatternTable = ({
|
|||
|
||||
chrome.docTitle.change(title);
|
||||
|
||||
const isRollup = new URLSearchParams(useLocation().search).get('type') === 'rollup';
|
||||
const isRollup =
|
||||
new URLSearchParams(useLocation().search).get('type') === 'rollup' &&
|
||||
dataViews.getRollupsEnabled();
|
||||
|
||||
const ContextWrapper = useMemo(
|
||||
() => (spaces ? spaces.ui.components.getSpacesContextProvider : getEmptyFunctionComponent),
|
||||
|
|
|
@ -24,6 +24,7 @@ const indexPatternContractMock = {
|
|||
])
|
||||
),
|
||||
get: jest.fn().mockReturnValue(Promise.resolve({})),
|
||||
getRollupsEnabled: jest.fn().mockReturnValue(true),
|
||||
} as unknown as jest.Mocked<DataViewsContract>;
|
||||
|
||||
test('getting index patterns', async () => {
|
||||
|
|
|
@ -37,7 +37,7 @@ export async function getIndexPatterns(defaultIndex: string, dataViewsService: D
|
|||
const indexPatternsListItems = existingIndexPatterns.map((idxPattern) => {
|
||||
const { id, title, namespaces, name } = idxPattern;
|
||||
const isDefault = defaultIndex === id;
|
||||
const tags = getTags(idxPattern, isDefault);
|
||||
const tags = getTags(idxPattern, isDefault, dataViewsService.getRollupsEnabled());
|
||||
const displayName = name ? name : title;
|
||||
|
||||
return {
|
||||
|
@ -68,18 +68,24 @@ export async function getIndexPatterns(defaultIndex: string, dataViewsService: D
|
|||
);
|
||||
}
|
||||
|
||||
export const getTags = (indexPattern: DataViewListItem | DataView, isDefault: boolean) => {
|
||||
export const getTags = (
|
||||
indexPattern: DataViewListItem | DataView,
|
||||
isDefault: boolean,
|
||||
rollupsEnabled: boolean
|
||||
) => {
|
||||
const tags = [];
|
||||
if (isDefault) {
|
||||
tags.push({
|
||||
key: 'default',
|
||||
name: defaultIndexPatternListName,
|
||||
'data-test-subj': 'default-tag',
|
||||
});
|
||||
}
|
||||
if (isRollup(indexPattern.type)) {
|
||||
if (isRollup(indexPattern.type) && rollupsEnabled) {
|
||||
tags.push({
|
||||
key: 'rollup',
|
||||
name: rollupIndexPatternListName,
|
||||
'data-test-subj': 'rollup-tag',
|
||||
});
|
||||
}
|
||||
return tags;
|
||||
|
|
|
@ -29,6 +29,8 @@ export interface DataViewsServicePublicDeps extends DataViewsServiceDeps {
|
|||
showAllIndices?: boolean;
|
||||
isRollupIndex: (indexName: string) => boolean;
|
||||
}) => Promise<MatchedItem[]>;
|
||||
|
||||
getRollupsEnabled: () => boolean;
|
||||
scriptedFieldsEnabled: boolean;
|
||||
}
|
||||
|
||||
|
@ -45,6 +47,7 @@ export class DataViewsServicePublic extends DataViewsService {
|
|||
isRollupIndex: (indexName: string) => boolean;
|
||||
}) => Promise<MatchedItem[]>;
|
||||
public hasData: HasDataService;
|
||||
private rollupsEnabled: boolean = false;
|
||||
public readonly scriptedFieldsEnabled: boolean;
|
||||
|
||||
/**
|
||||
|
@ -57,6 +60,11 @@ export class DataViewsServicePublic extends DataViewsService {
|
|||
this.getCanSaveSync = deps.getCanSaveSync;
|
||||
this.hasData = deps.hasData;
|
||||
this.getIndices = deps.getIndices;
|
||||
this.rollupsEnabled = deps.getRollupsEnabled();
|
||||
this.scriptedFieldsEnabled = deps.scriptedFieldsEnabled;
|
||||
}
|
||||
|
||||
getRollupsEnabled() {
|
||||
return this.rollupsEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ import { DataViewsPlugin, DataViewsContract } from '.';
|
|||
export type Setup = jest.Mocked<ReturnType<DataViewsPlugin['setup']>>;
|
||||
export type Start = jest.Mocked<ReturnType<DataViewsPlugin['start']>>;
|
||||
|
||||
const createSetupContract = (): Setup => ({});
|
||||
const createSetupContract = (): Setup => ({
|
||||
enableRollups: jest.fn(),
|
||||
});
|
||||
|
||||
const createStartContract = (): Start => {
|
||||
return {
|
||||
|
|
|
@ -40,6 +40,7 @@ export class DataViewsPublicPlugin
|
|||
>
|
||||
{
|
||||
private readonly hasData = new HasData();
|
||||
private rollupsEnabled: boolean = false;
|
||||
|
||||
constructor(private readonly initializerContext: PluginInitializerContext) {}
|
||||
|
||||
|
@ -59,7 +60,9 @@ export class DataViewsPublicPlugin
|
|||
}),
|
||||
});
|
||||
|
||||
return {};
|
||||
return {
|
||||
enableRollups: () => (this.rollupsEnabled = true),
|
||||
};
|
||||
}
|
||||
|
||||
public start(
|
||||
|
@ -96,6 +99,7 @@ export class DataViewsPublicPlugin
|
|||
getCanSaveAdvancedSettings: () =>
|
||||
Promise.resolve(application.capabilities.advancedSettings.save === true),
|
||||
getIndices: (props) => getIndices({ ...props, http: core.http }),
|
||||
getRollupsEnabled: () => this.rollupsEnabled,
|
||||
scriptedFieldsEnabled: config.scriptedFieldsEnabled === false ? false : true, // accounting for null value
|
||||
});
|
||||
}
|
||||
|
|
|
@ -109,8 +109,9 @@ export interface DataViewsPublicStartDependencies {
|
|||
/**
|
||||
* Data plugin public Setup contract
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface DataViewsPublicPluginSetup {}
|
||||
export interface DataViewsPublicPluginSetup {
|
||||
enableRollups: () => void;
|
||||
}
|
||||
|
||||
export interface DataViewsServicePublic extends DataViewsServicePublicMethods {
|
||||
getCanSaveSync: () => boolean;
|
||||
|
@ -120,6 +121,7 @@ export interface DataViewsServicePublic extends DataViewsServicePublicMethods {
|
|||
showAllIndices?: boolean;
|
||||
isRollupIndex: (indexName: string) => boolean;
|
||||
}) => Promise<MatchedItem[]>;
|
||||
getRollupsEnabled: () => boolean;
|
||||
scriptedFieldsEnabled: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
|
|||
import { ManagementSetup } from '@kbn/management-plugin/public';
|
||||
import { IndexManagementPluginSetup } from '@kbn/index-management-plugin/public';
|
||||
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import { DataViewsPublicPluginSetup } from '@kbn/data-views-plugin/public/types';
|
||||
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
|
||||
import { UIM_APP_NAME } from '../common';
|
||||
// @ts-ignore
|
||||
|
@ -23,6 +24,7 @@ export interface RollupPluginSetupDependencies {
|
|||
management: ManagementSetup;
|
||||
indexManagement?: IndexManagementPluginSetup;
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
dataViews: DataViewsPublicPluginSetup;
|
||||
}
|
||||
|
||||
export class RollupPlugin implements Plugin {
|
||||
|
@ -30,7 +32,7 @@ export class RollupPlugin implements Plugin {
|
|||
|
||||
setup(
|
||||
core: CoreSetup,
|
||||
{ home, management, indexManagement, usageCollection }: RollupPluginSetupDependencies
|
||||
{ home, management, indexManagement, usageCollection, dataViews }: RollupPluginSetupDependencies
|
||||
) {
|
||||
const {
|
||||
ui: { enabled: isRollupUiEnabled },
|
||||
|
@ -62,6 +64,7 @@ export class RollupPlugin implements Plugin {
|
|||
}
|
||||
|
||||
if (isRollupUiEnabled) {
|
||||
dataViews.enableRollups();
|
||||
const pluginName = i18n.translate('xpack.rollupJobs.appTitle', {
|
||||
defaultMessage: 'Rollup Jobs',
|
||||
});
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
import expect from 'expect';
|
||||
import { DATA_VIEW_PATH } from '@kbn/data-views-plugin/server';
|
||||
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
||||
import { INITIAL_REST_VERSION } from '@kbn/data-views-plugin/server/constants';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
const archivePath = 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index';
|
||||
|
@ -21,37 +23,82 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/165796
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/165425
|
||||
describe.skip('Data View Management', function () {
|
||||
let dataViewId = '';
|
||||
describe('disables scripted fields', function () {
|
||||
let dataViewId = '';
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.load(archivePath);
|
||||
before(async () => {
|
||||
await esArchiver.load(archivePath);
|
||||
|
||||
const response = await supertest
|
||||
.post(DATA_VIEW_PATH)
|
||||
.set('kbn-xsrf', 'some-xsrf-token')
|
||||
.send({
|
||||
data_view: {
|
||||
title: 'basic_index',
|
||||
},
|
||||
override: true,
|
||||
});
|
||||
const response = await supertest
|
||||
.post(DATA_VIEW_PATH)
|
||||
.set('kbn-xsrf', 'some-xsrf-token')
|
||||
.send({
|
||||
data_view: {
|
||||
title: 'basic_index',
|
||||
},
|
||||
override: true,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
dataViewId = response.body.data_view.id;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload(archivePath);
|
||||
await supertest.delete(`${DATA_VIEW_PATH}/${dataViewId}`).set('kbn-xsrf', 'some-xsrf-token');
|
||||
});
|
||||
|
||||
it('Scripted fields tab is missing', async () => {
|
||||
await PageObjects.common.navigateToUrl('management', 'kibana/dataViews', {
|
||||
shouldUseHashForSubUrl: false,
|
||||
expect(response.status).toBe(200);
|
||||
dataViewId = response.body.data_view.id;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload(archivePath);
|
||||
await supertest
|
||||
.delete(`${DATA_VIEW_PATH}/${dataViewId}`)
|
||||
.set('kbn-xsrf', 'some-xsrf-token');
|
||||
});
|
||||
|
||||
it('Scripted fields tab is missing', async () => {
|
||||
await PageObjects.common.navigateToUrl('management', 'kibana/dataViews', {
|
||||
shouldUseHashForSubUrl: false,
|
||||
});
|
||||
await testSubjects.click('detail-link-basic_index');
|
||||
await testSubjects.exists('tab-indexedFields');
|
||||
await testSubjects.missingOrFail('tab-scriptedFields');
|
||||
});
|
||||
});
|
||||
|
||||
describe('disables rollups', function () {
|
||||
let dataViewId = '';
|
||||
before(async () => {
|
||||
await esArchiver.load(
|
||||
'test/api_integration/fixtures/es_archiver/index_patterns/basic_index'
|
||||
);
|
||||
|
||||
const response = await supertest
|
||||
.post(DATA_VIEW_PATH)
|
||||
.set('kbn-xsrf', 'some-xsrf-token')
|
||||
.send({
|
||||
data_view: {
|
||||
title: 'basic_index',
|
||||
type: 'rollup',
|
||||
},
|
||||
override: true,
|
||||
})
|
||||
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION);
|
||||
dataViewId = response.body.data_view.id;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload(
|
||||
'test/api_integration/fixtures/es_archiver/index_patterns/basic_index'
|
||||
);
|
||||
await supertest
|
||||
.delete(`${DATA_VIEW_PATH}/${dataViewId}`)
|
||||
.set('kbn-xsrf', 'some-xsrf-token');
|
||||
});
|
||||
|
||||
it('hides rollup UI tags', async () => {
|
||||
await PageObjects.common.navigateToUrl('management', 'kibana/dataViews', {
|
||||
shouldUseHashForSubUrl: false,
|
||||
});
|
||||
await testSubjects.exists('detail-link-basic_index');
|
||||
await testSubjects.missingOrFail('rollup-tag');
|
||||
await testSubjects.click('detail-link-basic_index');
|
||||
await testSubjects.missingOrFail('rollup-tag');
|
||||
});
|
||||
await testSubjects.click('detail-link-basic_index');
|
||||
await testSubjects.exists('tab-indexedFields');
|
||||
await testSubjects.missingOrFail('tab-scriptedFields');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue