From 40c3ebb5dc2a17119f9d0219e6247027d5ed9936 Mon Sep 17 00:00:00 2001 From: Matthew Kime Date: Mon, 2 Oct 2023 16:24:53 -0500 Subject: [PATCH] [data views mgmt] Disable spaces UI in single space mode (#166576) ## Summary In data views management - checks `hasOnlyDefaultSpace` value and renders spaces UI if value is false. Added functional test to verify this is working as expected on serverless. Closes: https://github.com/elastic/kibana/issues/165804 https://github.com/elastic/kibana/issues/165796 https://github.com/elastic/kibana/issues/165425 --- .../index_pattern_table.tsx | 11 +++-- .../mount_management_section.tsx | 2 +- .../common/management/data_view_mgmt.ts | 48 +++++++++++++++++-- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/plugins/data_view_management/public/components/index_pattern_table/index_pattern_table.tsx b/src/plugins/data_view_management/public/components/index_pattern_table/index_pattern_table.tsx index 12d9e1773e138..a64d75bf63196 100644 --- a/src/plugins/data_view_management/public/components/index_pattern_table/index_pattern_table.tsx +++ b/src/plugins/data_view_management/public/components/index_pattern_table/index_pattern_table.tsx @@ -212,7 +212,7 @@ export const IndexPatternTable = ({ name: i18n.translate('indexPatternManagement.dataViewTable.nameColumn', { defaultMessage: 'Name', }), - width: '70%', + width: spaces ? '70%' : '90%', render: (name: string, dataView: IndexPatternTableItem) => (
sort, }, - { + ]; + + if (spaces) { + columns.push({ field: 'namespaces', name: i18n.translate('indexPatternManagement.dataViewTable.spacesColumn', { defaultMessage: 'Spaces', @@ -270,8 +273,8 @@ export const IndexPatternTable = ({ <> ); }, - }, - ]; + }); + } if (dataViews.getCanSaveSync()) { columns.push(alertColumn); diff --git a/src/plugins/data_view_management/public/management_app/mount_management_section.tsx b/src/plugins/data_view_management/public/management_app/mount_management_section.tsx index 0e3c1758d2992..8bd8745f7dfd9 100644 --- a/src/plugins/data_view_management/public/management_app/mount_management_section.tsx +++ b/src/plugins/data_view_management/public/management_app/mount_management_section.tsx @@ -87,7 +87,7 @@ export async function mountManagementSection( fieldFormatEditors: dataViewFieldEditor.fieldFormatEditors, IndexPatternEditor: dataViewEditor.IndexPatternEditorComponent, fieldFormats, - spaces, + spaces: spaces?.hasOnlyDefaultSpace ? undefined : spaces, theme, savedObjectsManagement, }; diff --git a/x-pack/test_serverless/functional/test_suites/common/management/data_view_mgmt.ts b/x-pack/test_serverless/functional/test_suites/common/management/data_view_mgmt.ts index c8b004c65fb9b..e7905f6879823 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/data_view_mgmt.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/data_view_mgmt.ts @@ -14,15 +14,15 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; const archivePath = 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['settings', 'common', 'header']); + const PageObjects = getPageObjects(['settings', 'common', 'header', 'svlCommonPage']); const esArchiver = getService('esArchiver'); const supertest = getService('supertest'); const testSubjects = getService('testSubjects'); - // FLAKY: https://github.com/elastic/kibana/issues/165804 - // FLAKY: https://github.com/elastic/kibana/issues/165796 - // FLAKY: https://github.com/elastic/kibana/issues/165425 - describe.skip('Data View Management', function () { + describe('Data View Management', function () { + this.beforeAll(async () => { + await PageObjects.svlCommonPage.login(); + }); describe('disables scripted fields', function () { let dataViewId = ''; @@ -100,5 +100,43 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.missingOrFail('rollup-tag'); }); }); + + describe('when in single space mode', 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', + }, + 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 spaces UI', async () => { + await PageObjects.common.navigateToUrl('management', 'kibana/dataViews', { + shouldUseHashForSubUrl: false, + }); + await testSubjects.exists('detail-link-basic_index'); + await testSubjects.missingOrFail('tableHeaderCell_namespaces_1'); + }); + }); }); }