diff --git a/src/plugins/advanced_settings/public/mocks.ts b/src/plugins/advanced_settings/public/mocks.ts
index e147f57101aae..b44561959cbd3 100644
--- a/src/plugins/advanced_settings/public/mocks.ts
+++ b/src/plugins/advanced_settings/public/mocks.ts
@@ -25,9 +25,9 @@ const componentType = ComponentRegistry.componentType;
export const advancedSettingsMock = {
createSetupContract() {
- return { register, componentType };
+ return { component: { register, componentType } };
},
createStartContract() {
- return { get, componentType };
+ return { component: { get, componentType } };
},
};
diff --git a/src/plugins/home/public/mocks/index.ts b/src/plugins/home/public/mocks/index.ts
new file mode 100644
index 0000000000000..dead50230ec85
--- /dev/null
+++ b/src/plugins/home/public/mocks/index.ts
@@ -0,0 +1,38 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { featureCatalogueRegistryMock } from '../services/feature_catalogue/feature_catalogue_registry.mock';
+import { environmentServiceMock } from '../services/environment/environment.mock';
+import { configSchema } from '../../config';
+
+const createSetupContract = () => ({
+ featureCatalogue: featureCatalogueRegistryMock.createSetup(),
+ environment: environmentServiceMock.createSetup(),
+ config: configSchema.validate({}),
+});
+
+const createStartContract = () => ({
+ featureCatalogue: featureCatalogueRegistryMock.createStart(),
+ environment: environmentServiceMock.createStart(),
+});
+
+export const homePluginMock = {
+ createSetupContract,
+ createStartContract,
+};
diff --git a/src/plugins/management/public/mocks/index.ts b/src/plugins/management/public/mocks/index.ts
index cc56928e8e529..6099a2cc32afc 100644
--- a/src/plugins/management/public/mocks/index.ts
+++ b/src/plugins/management/public/mocks/index.ts
@@ -17,10 +17,26 @@
* under the License.
*/
-const createStartContract = () => ({
+import { ManagementSetup, ManagementStart } from '../types';
+
+const createSetupContract = (): DeeplyMockedKeys => ({
+ sections: {
+ register: jest.fn(),
+ getSection: jest.fn(),
+ getAllSections: jest.fn(),
+ },
+});
+
+const createStartContract = (): DeeplyMockedKeys => ({
legacy: {},
+ sections: {
+ getSection: jest.fn(),
+ getAllSections: jest.fn(),
+ navigateToApp: jest.fn(),
+ },
});
export const managementPluginMock = {
+ createSetupContract,
createStartContract,
};
diff --git a/x-pack/legacy/plugins/ml/server/lib/spaces_utils.ts b/x-pack/legacy/plugins/ml/server/lib/spaces_utils.ts
index 115e7fe6ba434..92373bae4ea1d 100644
--- a/x-pack/legacy/plugins/ml/server/lib/spaces_utils.ts
+++ b/x-pack/legacy/plugins/ml/server/lib/spaces_utils.ts
@@ -5,8 +5,8 @@
*/
import { Request } from 'hapi';
+import { Space } from '../../../../../plugins/spaces/server';
import { LegacySpacesPlugin } from '../../../spaces';
-import { Space } from '../../../spaces/common/model/space';
interface GetActiveSpaceResponse {
valid: boolean;
diff --git a/x-pack/legacy/plugins/spaces/common/constants.ts b/x-pack/legacy/plugins/spaces/common/constants.ts
deleted file mode 100644
index 11882ca2f1b3a..0000000000000
--- a/x-pack/legacy/plugins/spaces/common/constants.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export const DEFAULT_SPACE_ID = `default`;
-
-/**
- * The minimum number of spaces required to show a search control.
- */
-export const SPACE_SEARCH_COUNT_THRESHOLD = 8;
-
-/**
- * The maximum number of characters allowed in the Space Avatar's initials
- */
-export const MAX_SPACE_INITIALS = 2;
-
-/**
- * The type name used within the Monitoring index to publish spaces stats.
- * @type {string}
- */
-export const KIBANA_SPACES_STATS_TYPE = 'spaces';
-
-/**
- * The path to enter a space.
- */
-export const ENTER_SPACE_PATH = '/spaces/enter';
diff --git a/x-pack/legacy/plugins/spaces/common/index.ts b/x-pack/legacy/plugins/spaces/common/index.ts
deleted file mode 100644
index 8961c9c5ccf79..0000000000000
--- a/x-pack/legacy/plugins/spaces/common/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export { isReservedSpace } from './is_reserved_space';
-export { MAX_SPACE_INITIALS } from './constants';
diff --git a/x-pack/legacy/plugins/spaces/common/is_reserved_space.test.ts b/x-pack/legacy/plugins/spaces/common/is_reserved_space.test.ts
deleted file mode 100644
index dd1372183ed8a..0000000000000
--- a/x-pack/legacy/plugins/spaces/common/is_reserved_space.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { isReservedSpace } from './is_reserved_space';
-import { Space } from './model/space';
-
-test('it returns true for reserved spaces', () => {
- const space: Space = {
- id: '',
- name: '',
- disabledFeatures: [],
- _reserved: true,
- };
-
- expect(isReservedSpace(space)).toEqual(true);
-});
-
-test('it returns false for non-reserved spaces', () => {
- const space: Space = {
- id: '',
- name: '',
- disabledFeatures: [],
- };
-
- expect(isReservedSpace(space)).toEqual(false);
-});
-
-test('it handles empty input', () => {
- // @ts-ignore
- expect(isReservedSpace()).toEqual(false);
-});
diff --git a/x-pack/legacy/plugins/spaces/common/is_reserved_space.ts b/x-pack/legacy/plugins/spaces/common/is_reserved_space.ts
deleted file mode 100644
index 788ef80c194ce..0000000000000
--- a/x-pack/legacy/plugins/spaces/common/is_reserved_space.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { get } from 'lodash';
-import { Space } from './model/space';
-
-/**
- * Returns whether the given Space is reserved or not.
- *
- * @param space the space
- * @returns boolean
- */
-export function isReservedSpace(space?: Partial | null): boolean {
- return get(space, '_reserved', false);
-}
diff --git a/x-pack/legacy/plugins/spaces/common/model/space.ts b/x-pack/legacy/plugins/spaces/common/model/space.ts
deleted file mode 100644
index c44ce41ec51c0..0000000000000
--- a/x-pack/legacy/plugins/spaces/common/model/space.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export interface Space {
- id: string;
- name: string;
- description?: string;
- color?: string;
- initials?: string;
- disabledFeatures: string[];
- _reserved?: boolean;
- imageUrl?: string;
-}
diff --git a/x-pack/legacy/plugins/spaces/index.ts b/x-pack/legacy/plugins/spaces/index.ts
index 2e6b878794777..ab3388ae96475 100644
--- a/x-pack/legacy/plugins/spaces/index.ts
+++ b/x-pack/legacy/plugins/spaces/index.ts
@@ -17,7 +17,7 @@ import { wrapError } from './server/lib/errors';
import { migrateToKibana660 } from './server/lib/migrations';
// @ts-ignore
import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize';
-import { initSpaceSelectorView, initEnterSpaceView } from './server/routes/views';
+import { initEnterSpaceView } from './server/routes/views';
export interface LegacySpacesPlugin {
getSpaceId: (request: Legacy.Request) => ReturnType;
@@ -50,15 +50,7 @@ export const spaces = (kibana: Record) =>
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
managementSections: [],
- apps: [
- {
- id: 'space_selector',
- title: 'Spaces',
- main: 'plugins/spaces/space_selector',
- url: 'space_selector',
- hidden: true,
- },
- ],
+ apps: [],
hacks: ['plugins/spaces/legacy'],
mappings,
migrations: {
@@ -131,11 +123,9 @@ export const spaces = (kibana: Record) =>
create: (pluginId: string) =>
new AuditLogger(server, pluginId, server.config(), server.plugins.xpack_main.info),
},
- xpackMain: server.plugins.xpack_main,
});
initEnterSpaceView(server);
- initSpaceSelectorView(server);
watchStatusAndLicenseToInitialize(server.plugins.xpack_main, this, async () => {
await createDefaultSpace();
diff --git a/x-pack/legacy/plugins/spaces/public/__mocks__/xpack_info.ts b/x-pack/legacy/plugins/spaces/public/__mocks__/xpack_info.ts
deleted file mode 100644
index e3467b88dbc61..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/__mocks__/xpack_info.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-jest.mock('../../../xpack_main/public/services/xpack_info', () => {
- return {
- xpackInfo: {
- get: jest.fn().mockImplementation((key: string) => {
- if (key === 'features.security.showLinks') {
- return true;
- }
- throw new Error(`unexpected key: ${key}`);
- }),
- },
- };
-});
diff --git a/x-pack/legacy/plugins/spaces/public/index.scss b/x-pack/legacy/plugins/spaces/public/index.scss
index 26269f1d31aa3..bb3481f96bc1e 100644
--- a/x-pack/legacy/plugins/spaces/public/index.scss
+++ b/x-pack/legacy/plugins/spaces/public/index.scss
@@ -1,16 +1,4 @@
// Import the EUI global scope so we can use EUI constants
@import 'src/legacy/ui/public/styles/_styling_constants';
-/* Spaces plugin styles */
-
-// Prefix all styles with "spc" to avoid conflicts.
-// Examples
-// spcChart
-// spcChart__legend
-// spcChart__legend--small
-// spcChart__legend-isLoading
-
-@import './management/index';
-@import './nav_control/index';
-@import './space_selector/index';
-@import './copy_saved_objects_to_space/index';
+@import '../../../../plugins/spaces/public/index';
\ No newline at end of file
diff --git a/x-pack/legacy/plugins/spaces/public/legacy.ts b/x-pack/legacy/plugins/spaces/public/legacy.ts
index 200cae5498595..c6740dae81717 100644
--- a/x-pack/legacy/plugins/spaces/public/legacy.ts
+++ b/x-pack/legacy/plugins/spaces/public/legacy.ts
@@ -4,23 +4,25 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { npSetup, npStart } from 'ui/new_platform';
+import { SavedObjectsManagementAction } from 'src/legacy/core_plugins/management/public';
+import { npSetup } from 'ui/new_platform';
+import routes from 'ui/routes';
+import { SpacesPluginSetup } from '../../../../plugins/spaces/public';
import { setup as managementSetup } from '../../../../../src/legacy/core_plugins/management/public/legacy';
-import { plugin } from '.';
-import { SpacesPlugin, PluginsSetup, PluginsStart } from './plugin';
-import './management/legacy_page_routes';
-const spacesPlugin: SpacesPlugin = plugin();
-
-const pluginsSetup: PluginsSetup = {
- home: npSetup.plugins.home,
- management: managementSetup,
- advancedSettings: npSetup.plugins.advancedSettings,
+const legacyAPI = {
+ registerSavedObjectsManagementAction: (action: SavedObjectsManagementAction) => {
+ managementSetup.savedObjects.registry.register(action);
+ },
};
-const pluginsStart: PluginsStart = {
- management: npStart.plugins.management,
-};
+const spaces = (npSetup.plugins as any).spaces as SpacesPluginSetup;
+if (spaces) {
+ spaces.registerLegacyAPI(legacyAPI);
-export const setup = spacesPlugin.setup(npSetup.core, pluginsSetup);
-export const start = spacesPlugin.start(npStart.core, pluginsStart);
+ routes.when('/management/spaces/list', { redirectTo: '/management/kibana/spaces' });
+ routes.when('/management/spaces/create', { redirectTo: '/management/kibana/spaces/create' });
+ routes.when('/management/spaces/edit/:spaceId', {
+ redirectTo: '/management/kibana/spaces/edit/:spaceId',
+ });
+}
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap b/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap
deleted file mode 100644
index bce57527cd55a..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/__snapshots__/secure_space_message.test.tsx.snap
+++ /dev/null
@@ -1,33 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`SecureSpaceMessage doesn't render if security is not enabled 1`] = `""`;
-
-exports[`SecureSpaceMessage renders if security is enabled 1`] = `
-
-
-
-
-
-
- ,
- }
- }
- />
-
-
-
-`;
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.test.tsx b/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.test.tsx
deleted file mode 100644
index b43010fe5f326..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.test.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import React from 'react';
-import { shallowWithIntl } from 'test_utils/enzyme_helpers';
-import { SecureSpaceMessage } from './secure_space_message';
-
-let mockShowLinks: boolean = true;
-jest.mock('../../../../../xpack_main/public/services/xpack_info', () => {
- return {
- xpackInfo: {
- get: jest.fn().mockImplementation((key: string) => {
- if (key === 'features.security.showLinks') {
- return mockShowLinks;
- }
- throw new Error(`unexpected key: ${key}`);
- }),
- },
- };
-});
-
-describe('SecureSpaceMessage', () => {
- it(`doesn't render if security is not enabled`, () => {
- mockShowLinks = false;
- expect(shallowWithIntl()).toMatchSnapshot();
- });
-
- it(`renders if security is enabled`, () => {
- mockShowLinks = true;
- expect(shallowWithIntl()).toMatchSnapshot();
- });
-});
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx b/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
deleted file mode 100644
index 746b7e2ac4c98..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { EuiHorizontalRule, EuiLink, EuiText } from '@elastic/eui';
-import { FormattedMessage } from '@kbn/i18n/react';
-import { i18n } from '@kbn/i18n';
-import React, { Fragment } from 'react';
-// @ts-ignore
-import { xpackInfo } from '../../../../../xpack_main/public/services/xpack_info';
-
-export const SecureSpaceMessage = ({}) => {
- const showSecurityLinks = xpackInfo.get('features.security.showLinks');
-
- if (showSecurityLinks) {
- const rolesLinkTextAriaLabel = i18n.translate(
- 'xpack.spaces.management.secureSpaceMessage.rolesLinkTextAriaLabel',
- { defaultMessage: 'Roles management page' }
- );
- return (
-
-
-
-
-
-
-
- ),
- }}
- />
-
-
-
- );
- }
- return null;
-};
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/__snapshots__/enabled_features.test.tsx.snap b/x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/__snapshots__/enabled_features.test.tsx.snap
deleted file mode 100644
index 5879ff621d64a..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/__snapshots__/enabled_features.test.tsx.snap
+++ /dev/null
@@ -1,324 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`EnabledFeatures renders as expected 1`] = `
-
-
-
-
-
-
-
-
-
- }
->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ,
- }
- }
- />
-
-
-
-
-
-
-
-
-`;
diff --git a/x-pack/legacy/plugins/spaces/public/management/legacy_page_routes.tsx b/x-pack/legacy/plugins/spaces/public/management/legacy_page_routes.tsx
deleted file mode 100644
index 8cf4a129e5b8f..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/legacy_page_routes.tsx
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-// @ts-ignore
-import template from 'plugins/spaces/management/template.html';
-import React from 'react';
-import { render, unmountComponentAtNode } from 'react-dom';
-import { I18nContext } from 'ui/i18n';
-// @ts-ignore
-import routes from 'ui/routes';
-import { MANAGEMENT_BREADCRUMB } from 'ui/management/breadcrumbs';
-import { npStart } from 'ui/new_platform';
-import { ManageSpacePage } from './edit_space';
-import { SpacesGridPage } from './spaces_grid';
-
-import { start as spacesNPStart } from '../legacy';
-import { Space } from '../../common/model/space';
-
-const reactRootNodeId = 'manageSpacesReactRoot';
-
-function getListBreadcrumbs() {
- return [
- MANAGEMENT_BREADCRUMB,
- {
- text: 'Spaces',
- href: '#/management/spaces/list',
- },
- ];
-}
-
-function getCreateBreadcrumbs() {
- return [
- ...getListBreadcrumbs(),
- {
- text: 'Create',
- },
- ];
-}
-
-function getEditBreadcrumbs(space?: Space) {
- return [
- ...getListBreadcrumbs(),
- {
- text: space ? space.name : '...',
- },
- ];
-}
-
-routes.when('/management/spaces/list', {
- template,
- k7Breadcrumbs: getListBreadcrumbs,
- requireUICapability: 'management.kibana.spaces',
- controller($scope: any) {
- $scope.$$postDigest(() => {
- const domNode = document.getElementById(reactRootNodeId);
-
- const { spacesManager } = spacesNPStart;
-
- render(
-
-
- ,
- domNode
- );
-
- // unmount react on controller destroy
- $scope.$on('$destroy', () => {
- if (domNode) {
- unmountComponentAtNode(domNode);
- }
- });
- });
- },
-});
-
-routes.when('/management/spaces/create', {
- template,
- k7Breadcrumbs: getCreateBreadcrumbs,
- requireUICapability: 'management.kibana.spaces',
- controller($scope: any) {
- $scope.$$postDigest(() => {
- const domNode = document.getElementById(reactRootNodeId);
-
- const { spacesManager } = spacesNPStart;
-
- render(
-
-
- ,
- domNode
- );
-
- // unmount react on controller destroy
- $scope.$on('$destroy', () => {
- if (domNode) {
- unmountComponentAtNode(domNode);
- }
- });
- });
- },
-});
-
-routes.when('/management/spaces/edit', {
- redirectTo: '/management/spaces/list',
-});
-
-routes.when('/management/spaces/edit/:spaceId', {
- template,
- k7Breadcrumbs: () => getEditBreadcrumbs(),
- requireUICapability: 'management.kibana.spaces',
- controller($scope: any, $route: any) {
- $scope.$$postDigest(async () => {
- const domNode = document.getElementById(reactRootNodeId);
-
- const { spaceId } = $route.current.params;
-
- const { spacesManager } = await spacesNPStart;
-
- render(
-
- {
- npStart.core.chrome.setBreadcrumbs(getEditBreadcrumbs(space));
- }}
- capabilities={npStart.core.application.capabilities}
- />
- ,
- domNode
- );
-
- // unmount react on controller destroy
- $scope.$on('$destroy', () => {
- if (domNode) {
- unmountComponentAtNode(domNode);
- }
- });
- });
- },
-});
diff --git a/x-pack/legacy/plugins/spaces/public/management/management_service.test.ts b/x-pack/legacy/plugins/spaces/public/management/management_service.test.ts
deleted file mode 100644
index fbd39db6969bd..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/management_service.test.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { ManagementService } from '.';
-
-const mockSections = {
- getSection: jest.fn(),
- getAllSections: jest.fn(),
- navigateToApp: jest.fn(),
-};
-
-describe('ManagementService', () => {
- describe('#start', () => {
- it('registers the spaces management page under the kibana section', () => {
- const mockKibanaSection = {
- hasItem: jest.fn().mockReturnValue(false),
- register: jest.fn(),
- };
-
- const managementStart = {
- legacy: {
- getSection: jest.fn().mockReturnValue(mockKibanaSection),
- },
- sections: mockSections,
- };
-
- const deps = {
- managementStart,
- };
-
- const service = new ManagementService();
- service.start(deps);
-
- expect(deps.managementStart.legacy.getSection).toHaveBeenCalledTimes(1);
- expect(deps.managementStart.legacy.getSection).toHaveBeenCalledWith('kibana');
-
- expect(mockKibanaSection.register).toHaveBeenCalledTimes(1);
- expect(mockKibanaSection.register).toHaveBeenCalledWith('spaces', {
- name: 'spacesManagementLink',
- order: 10,
- display: 'Spaces',
- url: `#/management/spaces/list`,
- });
- });
-
- it('will not register the spaces management page twice', () => {
- const mockKibanaSection = {
- hasItem: jest.fn().mockReturnValue(true),
- register: jest.fn(),
- };
-
- const managementStart = {
- legacy: {
- getSection: jest.fn().mockReturnValue(mockKibanaSection),
- },
- sections: mockSections,
- };
-
- const deps = {
- managementStart,
- };
-
- const service = new ManagementService();
- service.start(deps);
-
- expect(mockKibanaSection.register).toHaveBeenCalledTimes(0);
- });
-
- it('will not register the spaces management page if the kibana section is missing', () => {
- const managementStart = {
- legacy: {
- getSection: jest.fn().mockReturnValue(undefined),
- },
- sections: mockSections,
- };
-
- const deps = {
- managementStart,
- };
-
- const service = new ManagementService();
- service.start(deps);
-
- expect(deps.managementStart.legacy.getSection).toHaveBeenCalledTimes(1);
- });
- });
-
- describe('#stop', () => {
- it('deregisters the spaces management page', () => {
- const mockKibanaSection = {
- hasItem: jest
- .fn()
- .mockReturnValueOnce(false)
- .mockReturnValueOnce(true),
- register: jest.fn(),
- deregister: jest.fn(),
- };
-
- const managementStart = {
- legacy: {
- getSection: jest.fn().mockReturnValue(mockKibanaSection),
- },
- sections: mockSections,
- };
-
- const deps = {
- managementStart,
- };
-
- const service = new ManagementService();
- service.start(deps);
-
- service.stop();
-
- expect(mockKibanaSection.register).toHaveBeenCalledTimes(1);
- expect(mockKibanaSection.deregister).toHaveBeenCalledTimes(1);
- expect(mockKibanaSection.deregister).toHaveBeenCalledWith('spaces');
- });
- });
-});
diff --git a/x-pack/legacy/plugins/spaces/public/management/management_service.ts b/x-pack/legacy/plugins/spaces/public/management/management_service.ts
deleted file mode 100644
index ada38f5cf3387..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/management_service.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import { i18n } from '@kbn/i18n';
-import { ManagementStart } from 'src/plugins/management/public';
-
-interface StartDeps {
- managementStart: ManagementStart;
-}
-
-const MANAGE_SPACES_KEY = 'spaces';
-
-export class ManagementService {
- private kibanaSection!: any;
-
- public start({ managementStart }: StartDeps) {
- this.kibanaSection = managementStart.legacy.getSection('kibana');
- if (this.kibanaSection && !this.kibanaSection.hasItem(MANAGE_SPACES_KEY)) {
- this.kibanaSection.register(MANAGE_SPACES_KEY, {
- name: 'spacesManagementLink',
- order: 10,
- display: i18n.translate('xpack.spaces.displayName', {
- defaultMessage: 'Spaces',
- }),
- url: `#/management/spaces/list`,
- });
- }
- }
-
- public stop() {
- if (this.kibanaSection && this.kibanaSection.hasItem(MANAGE_SPACES_KEY)) {
- this.kibanaSection.deregister(MANAGE_SPACES_KEY);
- }
- }
-}
diff --git a/x-pack/legacy/plugins/spaces/public/management/template.html b/x-pack/legacy/plugins/spaces/public/management/template.html
deleted file mode 100644
index 3cd8e144b43fc..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/management/template.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/spaces_description.test.tsx.snap b/x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/spaces_description.test.tsx.snap
deleted file mode 100644
index 8e78f64ac59cb..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/spaces_description.test.tsx.snap
+++ /dev/null
@@ -1,43 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`SpacesDescription renders without crashing 1`] = `
-
-
-
- Organize your dashboards and other saved objects into meaningful categories.
-
-
-
-
-
-
-`;
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.test.tsx b/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.test.tsx
deleted file mode 100644
index 157dcab3e0be1..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.test.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { shallow } from 'enzyme';
-import React from 'react';
-import { SpacesDescription } from './spaces_description';
-
-describe('SpacesDescription', () => {
- it('renders without crashing', () => {
- expect(
- shallow(
-
- )
- ).toMatchSnapshot();
- });
-});
diff --git a/x-pack/legacy/plugins/spaces/public/plugin.tsx b/x-pack/legacy/plugins/spaces/public/plugin.tsx
deleted file mode 100644
index e6271ac3a0a70..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/plugin.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
-import { HomePublicPluginSetup } from 'src/plugins/home/public';
-import { ManagementSetup } from 'src/legacy/core_plugins/management/public';
-import { ManagementStart } from 'src/plugins/management/public';
-import { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public';
-import { SpacesManager } from './spaces_manager';
-import { initSpacesNavControl } from './nav_control';
-import { createSpacesFeatureCatalogueEntry } from './create_feature_catalogue_entry';
-import { CopySavedObjectsToSpaceService } from './copy_saved_objects_to_space';
-import { AdvancedSettingsService } from './advanced_settings';
-import { ManagementService } from './management';
-
-export interface SpacesPluginStart {
- spacesManager: SpacesManager | null;
-}
-
-export interface PluginsSetup {
- home?: HomePublicPluginSetup;
- management: ManagementSetup;
- advancedSettings: AdvancedSettingsSetup;
-}
-
-export interface PluginsStart {
- management: ManagementStart;
-}
-
-export class SpacesPlugin implements Plugin {
- private spacesManager!: SpacesManager;
-
- private managementService?: ManagementService;
-
- public setup(core: CoreSetup, plugins: PluginsSetup) {
- const serverBasePath = core.injectedMetadata.getInjectedVar('serverBasePath') as string;
- this.spacesManager = new SpacesManager(serverBasePath, core.http);
-
- const copySavedObjectsToSpaceService = new CopySavedObjectsToSpaceService();
- copySavedObjectsToSpaceService.setup({
- spacesManager: this.spacesManager,
- managementSetup: plugins.management,
- });
-
- const advancedSettingsService = new AdvancedSettingsService();
- advancedSettingsService.setup({
- getActiveSpace: () => this.spacesManager.getActiveSpace(),
- componentRegistry: plugins.advancedSettings.component,
- });
-
- if (plugins.home) {
- plugins.home.featureCatalogue.register(createSpacesFeatureCatalogueEntry());
- }
- }
-
- public start(core: CoreStart, plugins: PluginsStart) {
- initSpacesNavControl(this.spacesManager, core);
-
- this.managementService = new ManagementService();
- this.managementService.start({ managementStart: plugins.management });
-
- return {
- spacesManager: this.spacesManager,
- };
- }
-
- public stop() {
- if (this.managementService) {
- this.managementService.stop();
- this.managementService = undefined;
- }
- }
-}
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/index.tsx b/x-pack/legacy/plugins/spaces/public/space_selector/index.tsx
deleted file mode 100644
index c1c1b6dc3a2f3..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/space_selector/index.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-// @ts-ignore
-import template from 'plugins/spaces/space_selector/space_selector.html';
-import chrome from 'ui/chrome';
-import { I18nContext } from 'ui/i18n';
-// @ts-ignore
-import { uiModules } from 'ui/modules';
-
-import React from 'react';
-import { render, unmountComponentAtNode } from 'react-dom';
-import { SpaceSelector } from './space_selector';
-
-import { start as spacesNPStart } from '../legacy';
-
-const module = uiModules.get('spaces_selector', []);
-module.controller('spacesSelectorController', ($scope: any) => {
- $scope.$$postDigest(() => {
- const domNode = document.getElementById('spaceSelectorRoot');
-
- const { spacesManager } = spacesNPStart;
-
- render(
-
-
- ,
- domNode
- );
-
- // unmount react on controller destroy
- $scope.$on('$destroy', () => {
- if (domNode) {
- unmountComponentAtNode(domNode);
- }
- });
- });
-});
-
-chrome.setVisible(false).setRootTemplate(template);
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.html b/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.html
deleted file mode 100644
index 2dbf9fac3f68b..0000000000000
--- a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/x-pack/legacy/plugins/spaces/server/routes/views/enter_space.ts b/x-pack/legacy/plugins/spaces/server/routes/views/enter_space.ts
index e560d4278b407..337faa2a18fb6 100644
--- a/x-pack/legacy/plugins/spaces/server/routes/views/enter_space.ts
+++ b/x-pack/legacy/plugins/spaces/server/routes/views/enter_space.ts
@@ -5,7 +5,7 @@
*/
import { Legacy } from 'kibana';
-import { ENTER_SPACE_PATH } from '../../../common/constants';
+import { ENTER_SPACE_PATH } from '../../../../../../plugins/spaces/common/constants';
import { wrapError } from '../../lib/errors';
export function initEnterSpaceView(server: Legacy.Server) {
diff --git a/x-pack/legacy/plugins/spaces/server/routes/views/index.ts b/x-pack/legacy/plugins/spaces/server/routes/views/index.ts
index d7637e299652f..645e8bec48148 100644
--- a/x-pack/legacy/plugins/spaces/server/routes/views/index.ts
+++ b/x-pack/legacy/plugins/spaces/server/routes/views/index.ts
@@ -4,5 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export { initSpaceSelectorView } from './space_selector';
export { initEnterSpaceView } from './enter_space';
diff --git a/x-pack/legacy/plugins/spaces/server/routes/views/space_selector.ts b/x-pack/legacy/plugins/spaces/server/routes/views/space_selector.ts
deleted file mode 100644
index 25c4179b99542..0000000000000
--- a/x-pack/legacy/plugins/spaces/server/routes/views/space_selector.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { Legacy } from 'kibana';
-
-export function initSpaceSelectorView(server: Legacy.Server) {
- const spaceSelector = server.getHiddenUiAppById('space_selector');
-
- server.route({
- method: 'GET',
- path: '/spaces/space_selector',
- async handler(request, h) {
- return (await h.renderAppWithDefaultConfig(spaceSelector)).takeover();
- },
- });
-}
diff --git a/x-pack/plugins/security/common/licensing/index.ts b/x-pack/plugins/security/common/licensing/index.ts
index 9ddbe86167367..e8efae3dc6a6b 100644
--- a/x-pack/plugins/security/common/licensing/index.ts
+++ b/x-pack/plugins/security/common/licensing/index.ts
@@ -5,3 +5,5 @@
*/
export { SecurityLicenseService, SecurityLicense } from './license_service';
+
+export { SecurityLicenseFeatures } from './license_features';
diff --git a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx
index 4caf3d25e887b..46bbedd37c434 100644
--- a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx
+++ b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx
@@ -8,7 +8,6 @@ import { act } from '@testing-library/react';
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { AuthenticatedUser } from '../../common/model';
import { AccountManagementPage } from './account_management_page';
-
import { coreMock } from 'src/core/public/mocks';
import { mockAuthenticatedUser } from '../../common/model/authenticated_user.mock';
import { securityMock } from '../mocks';
diff --git a/x-pack/plugins/security/public/index.ts b/x-pack/plugins/security/public/index.ts
index 336ec37d76a1b..712f49afd306e 100644
--- a/x-pack/plugins/security/public/index.ts
+++ b/x-pack/plugins/security/public/index.ts
@@ -10,6 +10,7 @@ import { SecurityPlugin, SecurityPluginSetup, SecurityPluginStart } from './plug
export { SecurityPluginSetup, SecurityPluginStart };
export { SessionInfo } from './types';
export { AuthenticatedUser } from '../common/model';
+export { SecurityLicense, SecurityLicenseFeatures } from '../common/licensing';
export const plugin: PluginInitializer = () =>
new SecurityPlugin();
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
index e183eae08d1e1..23a3f327a2c5c 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
@@ -9,7 +9,6 @@ import React from 'react';
import { act } from '@testing-library/react';
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { Capabilities } from 'src/core/public';
-import { Space } from '../../../../../spaces/common/model/space';
import { Feature } from '../../../../../features/public';
// These modules should be moved into a common directory
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
@@ -28,6 +27,7 @@ import { dataPluginMock } from '../../../../../../../src/plugins/data/public/moc
import { licenseMock } from '../../../../common/licensing/index.mock';
import { userAPIClientMock } from '../../users/index.mock';
import { rolesAPIClientMock, indicesAPIClientMock, privilegesAPIClientMock } from '../index.mock';
+import { Space } from '../../../../../spaces/public';
const buildFeatures = () => {
return [
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
index 33e69a68ca896..42ec3fa419167 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
@@ -37,7 +37,7 @@ import {
NotificationsStart,
} from 'src/core/public';
import { IndexPatternsContract } from '../../../../../../../src/plugins/data/public';
-import { Space } from '../../../../../spaces/common/model/space';
+import { Space } from '../../../../../spaces/public';
import { Feature } from '../../../../../features/public';
import {
KibanaPrivileges,
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx
index 4ebe02e687159..a4e287632c764 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx
@@ -6,7 +6,7 @@
import React, { Component } from 'react';
import { Capabilities } from 'src/core/public';
-import { Space } from '../../../../../../../spaces/common/model/space';
+import { Space } from '../../../../../../../spaces/public';
import { Feature } from '../../../../../../../features/public';
import { KibanaPrivileges, Role } from '../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from './kibana_privilege_calculator';
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
index 16aad4826ae44..a01c026c1a5df 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.test.tsx
@@ -7,7 +7,7 @@
import { EuiButtonEmpty, EuiInMemoryTable } from '@elastic/eui';
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space } from '../../../../../../../../spaces/public';
import { Feature } from '../../../../../../../../features/public';
import { KibanaPrivileges, Role } from '../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../kibana_privilege_calculator';
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
index b3449e32c6c91..f0f425273e25d 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx
@@ -19,8 +19,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
-import { SpaceAvatar } from '../../../../../../../../../legacy/plugins/spaces/public/space_avatar';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space, SpaceAvatar } from '../../../../../../../../spaces/public';
import { Feature } from '../../../../../../../../features/public';
import { FeaturesPrivileges, Role } from '../../../../../../../common/model';
import { CalculatedPrivilege } from '../kibana_privilege_calculator';
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
index 6d1f5117c52e9..6f841b5d14cb3 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.tsx
@@ -24,7 +24,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space } from '../../../../../../../../spaces/public';
import { Feature } from '../../../../../../../../features/public';
import { KibanaPrivileges, Role, copyRole } from '../../../../../../../common/model';
import {
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.tsx
index 1c27ec84f50dc..1a43fb9e2683a 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.tsx
@@ -13,8 +13,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component } from 'react';
-import { getSpaceColor } from '../../../../../../../../../legacy/plugins/spaces/public/space_avatar';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space, getSpaceColor } from '../../../../../../../../spaces/public';
import {
FeaturesPrivileges,
Role,
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
index b2b92356e5126..5fc238eed0ae7 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.tsx
@@ -15,7 +15,7 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import _ from 'lodash';
import React, { Component, Fragment } from 'react';
import { Capabilities } from 'src/core/public';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space } from '../../../../../../../../spaces/public';
import { Feature } from '../../../../../../../../features/public';
import { KibanaPrivileges, Role, isReservedRole } from '../../../../../../../common/model';
import { KibanaPrivilegeCalculatorFactory } from '../kibana_privilege_calculator';
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_selector.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_selector.tsx
index cfeb5b9f37d8c..3e5ea9f146876 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_selector.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_selector.tsx
@@ -7,8 +7,7 @@
import { EuiComboBox, EuiComboBoxOptionProps, EuiHealth, EuiHighlight } from '@elastic/eui';
import { InjectedIntl } from '@kbn/i18n/react';
import React, { Component } from 'react';
-import { getSpaceColor } from '../../../../../../../../../legacy/plugins/spaces/public/space_avatar';
-import { Space } from '../../../../../../../../spaces/common/model/space';
+import { Space, getSpaceColor } from '../../../../../../../../spaces/public';
const spaceToOption = (space?: Space, currentSelection?: 'global' | 'spaces') => {
if (!space) {
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx
index bb7a6db97f7c8..f8b2991a844f7 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.tsx
@@ -14,9 +14,8 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
import React, { Component } from 'react';
-import { SpaceAvatar } from '../../../../../../../legacy/plugins/spaces/public/space_avatar';
+import { Space, SpaceAvatar } from '../../../../../../spaces/public';
import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../../../spaces/common';
-import { Space } from '../../../../../../spaces/common/model/space';
interface Props {
spaces: Space[];
diff --git a/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx b/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx
index 543d20bb92afe..7a7542909431f 100644
--- a/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx
+++ b/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx
@@ -10,7 +10,6 @@ import { EditUserPage } from './edit_user_page';
import React from 'react';
import { User, Role } from '../../../../common/model';
import { ReactWrapper } from 'enzyme';
-
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { mockAuthenticatedUser } from '../../../../common/model/authenticated_user.mock';
import { securityMock } from '../../../mocks';
diff --git a/x-pack/plugins/security/public/mocks.ts b/x-pack/plugins/security/public/mocks.ts
index 3c0c59d10abd1..33c1d1446afba 100644
--- a/x-pack/plugins/security/public/mocks.ts
+++ b/x-pack/plugins/security/public/mocks.ts
@@ -6,11 +6,13 @@
import { authenticationMock } from './authentication/index.mock';
import { createSessionTimeoutMock } from './session/session_timeout.mock';
+import { licenseMock } from '../common/licensing/index.mock';
function createSetupMock() {
return {
authc: authenticationMock.createSetup(),
sessionTimeout: createSessionTimeoutMock(),
+ license: licenseMock.create(),
};
}
diff --git a/x-pack/plugins/security/public/plugin.tsx b/x-pack/plugins/security/public/plugin.tsx
index 394e23cbbf646..f1ac2e2ecc3e2 100644
--- a/x-pack/plugins/security/public/plugin.tsx
+++ b/x-pack/plugins/security/public/plugin.tsx
@@ -107,10 +107,11 @@ export class SecurityPlugin
return {
authc: this.authc,
sessionTimeout: this.sessionTimeout,
+ license,
};
}
- public start(core: CoreStart, { data, management }: PluginStartDependencies) {
+ public start(core: CoreStart, { management }: PluginStartDependencies) {
this.sessionTimeout.start();
this.navControlService.start({ core });
diff --git a/x-pack/legacy/plugins/spaces/common/lib/dataurl.ts b/x-pack/plugins/spaces/common/lib/dataurl.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/common/lib/dataurl.ts
rename to x-pack/plugins/spaces/common/lib/dataurl.ts
diff --git a/x-pack/plugins/spaces/kibana.json b/x-pack/plugins/spaces/kibana.json
index d806aaf1807ef..4242d2f5c5d09 100644
--- a/x-pack/plugins/spaces/kibana.json
+++ b/x-pack/plugins/spaces/kibana.json
@@ -4,7 +4,7 @@
"kibanaVersion": "kibana",
"configPath": ["xpack", "spaces"],
"requiredPlugins": ["features", "licensing"],
- "optionalPlugins": ["security", "home", "usageCollection"],
+ "optionalPlugins": ["advancedSettings", "home", "management", "security", "usageCollection"],
"server": true,
- "ui": false
+ "ui": true
}
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx
similarity index 78%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx
index 3c6b2332bbbdc..08cc0a638cd78 100644
--- a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx
+++ b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.test.tsx
@@ -5,7 +5,7 @@
*/
import { AdvancedSettingsService } from './advanced_settings_service';
-import { advancedSettingsMock } from '../../../../../../src/plugins/advanced_settings/public/mocks';
+import { advancedSettingsMock } from '../../../../../src/plugins/advanced_settings/public/mocks';
const componentRegistryMock = advancedSettingsMock.createSetupContract();
@@ -14,7 +14,7 @@ describe('Advanced Settings Service', () => {
it('registers space-aware components to augment the advanced settings screen', () => {
const deps = {
getActiveSpace: jest.fn().mockResolvedValue({ id: 'foo', name: 'foo-space' }),
- componentRegistry: componentRegistryMock,
+ componentRegistry: componentRegistryMock.component,
};
const advancedSettingsService = new AdvancedSettingsService();
@@ -22,13 +22,13 @@ describe('Advanced Settings Service', () => {
expect(deps.componentRegistry.register).toHaveBeenCalledTimes(2);
expect(deps.componentRegistry.register).toHaveBeenCalledWith(
- componentRegistryMock.componentType.PAGE_TITLE_COMPONENT,
+ componentRegistryMock.component.componentType.PAGE_TITLE_COMPONENT,
expect.any(Function),
true
);
expect(deps.componentRegistry.register).toHaveBeenCalledWith(
- componentRegistryMock.componentType.PAGE_SUBTITLE_COMPONENT,
+ componentRegistryMock.component.componentType.PAGE_SUBTITLE_COMPONENT,
expect.any(Function),
true
);
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx
similarity index 91%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx
index a1552add18f2d..5dedb285014f8 100644
--- a/x-pack/legacy/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx
+++ b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
+import { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public';
import { Space } from '../../common/model/space';
import { AdvancedSettingsTitle, AdvancedSettingsSubtitle } from './components';
-import { AdvancedSettingsSetup } from '../../../../../../src/plugins/advanced_settings/public';
interface SetupDeps {
getActiveSpace: () => Promise;
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/index.ts b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/index.ts
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx
similarity index 94%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx
index b74524db81d81..413be03d08bfc 100644
--- a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx
+++ b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.tsx
@@ -7,7 +7,7 @@
import { EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { useState, useEffect } from 'react';
-import { Space } from '../../../../../../../plugins/spaces/common/model/space';
+import { Space } from '../../../../common/model/space';
import { SpaceAvatar } from '../../../space_avatar';
interface Props {
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/index.ts b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/advanced_settings_title/index.ts
rename to x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/components/index.ts b/x-pack/plugins/spaces/public/advanced_settings/components/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/components/index.ts
rename to x-pack/plugins/spaces/public/advanced_settings/components/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/advanced_settings/index.ts b/x-pack/plugins/spaces/public/advanced_settings/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/advanced_settings/index.ts
rename to x-pack/plugins/spaces/public/advanced_settings/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/constants.ts b/x-pack/plugins/spaces/public/constants.ts
similarity index 80%
rename from x-pack/legacy/plugins/spaces/public/constants.ts
rename to x-pack/plugins/spaces/public/constants.ts
index 94799f6f2b5d8..15c65722d01ef 100644
--- a/x-pack/legacy/plugins/spaces/public/constants.ts
+++ b/x-pack/plugins/spaces/public/constants.ts
@@ -5,7 +5,6 @@
*/
import { i18n } from '@kbn/i18n';
-import { npSetup } from 'ui/new_platform';
let spacesFeatureDescription: string;
@@ -19,6 +18,3 @@ export const getSpacesFeatureDescription = () => {
return spacesFeatureDescription;
};
-
-export const getManageSpacesUrl = () =>
- npSetup.core.http.basePath.prepend(`/app/kibana#/management/spaces/list`);
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/_index.scss b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/_index.scss
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/_copy_to_space.scss b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_copy_to_space.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/_copy_to_space.scss
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_copy_to_space.scss
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/_index.scss b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/_index.scss
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_indicator.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_indicator.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_indicator.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_indicator.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx
similarity index 97%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx
index 28011911e212e..7809b511adda4 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import Boom from 'boom';
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
-import { mockManagementPlugin } from '../../../../../../../src/legacy/core_plugins/management/public/np_ready/mocks';
+import { mockManagementPlugin } from '../../../../../../src/legacy/core_plugins/management/public/np_ready/mocks';
import { CopySavedObjectsToSpaceFlyout } from './copy_to_space_flyout';
import { CopyToSpaceForm } from './copy_to_space_form';
import { EuiLoadingSpinner, EuiEmptyPrompt } from '@elastic/eui';
@@ -17,9 +17,9 @@ import { act } from '@testing-library/react';
import { ProcessingCopyToSpace } from './processing_copy_to_space';
import { spacesManagerMock } from '../../spaces_manager/mocks';
import { SpacesManager } from '../../spaces_manager';
-import { ToastNotifications } from 'ui/notify/toasts/toast_notifications';
+import { ToastsApi } from 'src/core/public';
-jest.mock('../../../../../../../src/legacy/core_plugins/management/public/legacy', () => ({
+jest.mock('../../../../../../src/legacy/core_plugins/management/public/legacy', () => ({
setup: mockManagementPlugin.createSetupContract(),
start: mockManagementPlugin.createStartContract(),
}));
@@ -86,7 +86,7 @@ const setup = async (opts: SetupOpts = {}) => {
);
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx
similarity index 96%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx
index f486f2f24f13d..cd2f3986600ff 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.tsx
@@ -21,12 +21,12 @@ import {
import { mapValues } from 'lodash';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import { ToastNotifications } from 'ui/notify/toasts/toast_notifications';
-import { SavedObjectsManagementRecord } from '../../../../../../../src/legacy/core_plugins/management/public';
+import { ToastsStart } from 'src/core/public';
import {
+ SavedObjectsManagementRecord,
ProcessedImportResponse,
processImportResponse,
-} from '../../../../../../../src/legacy/core_plugins/management/public';
+} from '../../../../../../src/legacy/core_plugins/management/public';
import { Space } from '../../../common/model/space';
import { SpacesManager } from '../../spaces_manager';
import { ProcessingCopyToSpace } from './processing_copy_to_space';
@@ -38,7 +38,7 @@ interface Props {
onClose: () => void;
savedObject: SavedObjectsManagementRecord;
spacesManager: SpacesManager;
- toastNotifications: ToastNotifications;
+ toastNotifications: ToastsStart;
}
export const CopySavedObjectsToSpaceFlyout = (props: Props) => {
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx
similarity index 98%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx
index 56f39ce3ed4fb..b22cec0af5ea8 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_footer.tsx
@@ -8,7 +8,7 @@ import React, { Fragment } from 'react';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiStat, EuiHorizontalRule } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import { ProcessedImportResponse } from '../../../../../../../src/legacy/core_plugins/management/public';
+import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/management/public';
import { ImportRetry } from '../types';
interface Props {
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_form.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx
similarity index 94%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx
index 285abb828a011..2735218fdd370 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/processing_copy_to_space.tsx
@@ -13,8 +13,10 @@ import {
EuiHorizontalRule,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { SavedObjectsManagementRecord } from '../../../../../../../src/legacy/core_plugins/management/public';
-import { ProcessedImportResponse } from '../../../../../../../src/legacy/core_plugins/management/public';
+import {
+ SavedObjectsManagementRecord,
+ ProcessedImportResponse,
+} from '../../../../../../src/legacy/core_plugins/management/public';
import { Space } from '../../../common/model/space';
import { CopyOptions, ImportRetry } from '../types';
import { SpaceResult } from './space_result';
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx
similarity index 98%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx
index 22f0767ba196e..b667ec2a6e11d 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { EuiAccordion, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui';
-import { SavedObjectsManagementRecord } from '../../../../../../../src/legacy/core_plugins/management/public';
+import { SavedObjectsManagementRecord } from '../../../../../../src/legacy/core_plugins/management/public';
import { SummarizedCopyToSpaceResult } from '../index';
import { SpaceAvatar } from '../../space_avatar';
import { Space } from '../../../common/model/space';
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx
similarity index 98%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx
index d3ab406b87c3e..cae72bb1e75e9 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/space_result_details.tsx
@@ -8,7 +8,7 @@ import React from 'react';
import { EuiText, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { SummarizedCopyToSpaceResult } from '../index';
-import { SavedObjectsManagementRecord } from '../../../../../../../src/legacy/core_plugins/management/public';
+import { SavedObjectsManagementRecord } from '../../../../../../src/legacy/core_plugins/management/public';
import { Space } from '../../../common/model/space';
import { CopyStatusIndicator } from './copy_status_indicator';
import { ImportRetry } from '../types';
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx
similarity index 83%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx
index c016494a4cdf9..c9297ed97f09b 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_action.tsx
@@ -5,11 +5,11 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
-import { toastNotifications } from 'ui/notify';
+import { NotificationsStart } from 'src/core/public';
import {
SavedObjectsManagementAction,
SavedObjectsManagementRecord,
-} from '../../../../../../src/legacy/core_plugins/management/public';
+} from '../../../../../src/legacy/core_plugins/management/public';
import { CopySavedObjectsToSpaceFlyout } from './components';
import { SpacesManager } from '../spaces_manager';
@@ -30,7 +30,10 @@ export class CopyToSpaceSavedObjectsManagementAction extends SavedObjectsManagem
},
};
- constructor(private readonly spacesManager: SpacesManager) {
+ constructor(
+ private readonly spacesManager: SpacesManager,
+ private readonly notifications: NotificationsStart
+ ) {
super();
}
@@ -43,7 +46,7 @@ export class CopyToSpaceSavedObjectsManagementAction extends SavedObjectsManagem
onClose={this.onClose}
savedObject={this.record}
spacesManager={this.spacesManager}
- toastNotifications={toastNotifications}
+ toastNotifications={this.notifications.toasts}
/>
);
};
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts
similarity index 90%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts
index 63a59344dfe5d..2603f80a19520 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.test.ts
@@ -8,12 +8,14 @@ import { ManagementSetup } from 'src/legacy/core_plugins/management/public';
import { CopyToSpaceSavedObjectsManagementAction } from './copy_saved_objects_to_space_action';
import { spacesManagerMock } from '../spaces_manager/mocks';
import { CopySavedObjectsToSpaceService } from '.';
+import { notificationServiceMock } from 'src/core/public/mocks';
describe('CopySavedObjectsToSpaceService', () => {
describe('#setup', () => {
it('registers the CopyToSpaceSavedObjectsManagementAction', () => {
const deps = {
spacesManager: spacesManagerMock.create(),
+ notificationsSetup: notificationServiceMock.createSetupContract(),
// we don't have a proper NP mock for this yet
managementSetup: ({
savedObjects: {
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts
similarity index 71%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts
index 37354f985a2fc..2db3d4b319acb 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/copy_saved_objects_to_space_service.ts
@@ -5,17 +5,19 @@
*/
import { ManagementSetup } from 'src/legacy/core_plugins/management/public';
+import { NotificationsSetup } from 'src/core/public';
import { CopyToSpaceSavedObjectsManagementAction } from './copy_saved_objects_to_space_action';
import { SpacesManager } from '../spaces_manager';
interface SetupDeps {
spacesManager: SpacesManager;
- managementSetup: ManagementSetup;
+ managementSetup: Pick;
+ notificationsSetup: NotificationsSetup;
}
export class CopySavedObjectsToSpaceService {
- public setup({ spacesManager, managementSetup }: SetupDeps) {
- const action = new CopyToSpaceSavedObjectsManagementAction(spacesManager);
+ public setup({ spacesManager, managementSetup, notificationsSetup }: SetupDeps) {
+ const action = new CopyToSpaceSavedObjectsManagementAction(spacesManager, notificationsSetup);
managementSetup.savedObjects.registry.register(action);
}
}
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/index.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/index.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts
similarity index 98%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts
index 0244a35711e6f..fb2616619c644 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.test.ts
@@ -5,7 +5,7 @@
*/
import { summarizeCopyResult } from './summarize_copy_result';
-import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/management/public';
+import { ProcessedImportResponse } from 'src/legacy/core_plugins/management/public';
const createSavedObjectsManagementRecord = () => ({
type: 'dashboard',
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts
similarity index 94%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts
index 7bc47d35efc6c..5ad4fe2cad3ab 100644
--- a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts
+++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/summarize_copy_result.ts
@@ -4,8 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { SavedObjectsManagementRecord } from '../../../../../../src/legacy/core_plugins/management/public';
-import { ProcessedImportResponse } from '../../../../../../src/legacy/core_plugins/management/public';
+import {
+ ProcessedImportResponse,
+ SavedObjectsManagementRecord,
+} from 'src/legacy/core_plugins/management/public';
export interface SummarizedSavedObjectResult {
type: string;
diff --git a/x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/types.ts b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/copy_saved_objects_to_space/types.ts
rename to x-pack/plugins/spaces/public/copy_saved_objects_to_space/types.ts
diff --git a/x-pack/legacy/plugins/spaces/public/create_feature_catalogue_entry.ts b/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
similarity index 88%
rename from x-pack/legacy/plugins/spaces/public/create_feature_catalogue_entry.ts
rename to x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
index 464066d2221de..2cf34e842ce33 100644
--- a/x-pack/legacy/plugins/spaces/public/create_feature_catalogue_entry.ts
+++ b/x-pack/plugins/spaces/public/create_feature_catalogue_entry.ts
@@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n';
import {
FeatureCatalogueEntry,
FeatureCatalogueCategory,
-} from '../../../../../src/plugins/home/public';
+} from '../../../../src/plugins/home/public';
import { getSpacesFeatureDescription } from './constants';
export const createSpacesFeatureCatalogueEntry = (): FeatureCatalogueEntry => {
@@ -19,7 +19,7 @@ export const createSpacesFeatureCatalogueEntry = (): FeatureCatalogueEntry => {
}),
description: getSpacesFeatureDescription(),
icon: 'spacesApp',
- path: '/app/kibana#/management/spaces/list',
+ path: '/app/kibana#/management/kibana/spaces',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
};
diff --git a/x-pack/plugins/spaces/public/index.scss b/x-pack/plugins/spaces/public/index.scss
new file mode 100644
index 0000000000000..26269f1d31aa3
--- /dev/null
+++ b/x-pack/plugins/spaces/public/index.scss
@@ -0,0 +1,16 @@
+// Import the EUI global scope so we can use EUI constants
+@import 'src/legacy/ui/public/styles/_styling_constants';
+
+/* Spaces plugin styles */
+
+// Prefix all styles with "spc" to avoid conflicts.
+// Examples
+// spcChart
+// spcChart__legend
+// spcChart__legend--small
+// spcChart__legend-isLoading
+
+@import './management/index';
+@import './nav_control/index';
+@import './space_selector/index';
+@import './copy_saved_objects_to_space/index';
diff --git a/x-pack/legacy/plugins/spaces/public/index.ts b/x-pack/plugins/spaces/public/index.ts
similarity index 62%
rename from x-pack/legacy/plugins/spaces/public/index.ts
rename to x-pack/plugins/spaces/public/index.ts
index 53cb906a619d3..9abf05cab2786 100644
--- a/x-pack/legacy/plugins/spaces/public/index.ts
+++ b/x-pack/plugins/spaces/public/index.ts
@@ -5,7 +5,11 @@
*/
import { SpacesPlugin } from './plugin';
-export { SpaceAvatar } from './space_avatar';
+export { Space } from '../common/model/space';
+
+export { SpaceAvatar, getSpaceColor, getSpaceImageUrl, getSpaceInitials } from './space_avatar';
+
+export { SpacesPluginSetup, SpacesPluginStart } from './plugin';
export const plugin = () => {
return new SpacesPlugin();
diff --git a/x-pack/legacy/plugins/spaces/public/management/_index.scss b/x-pack/plugins/spaces/public/management/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/_index.scss
rename to x-pack/plugins/spaces/public/management/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/__snapshots__/confirm_delete_modal.test.tsx.snap b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/__snapshots__/confirm_delete_modal.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/__snapshots__/confirm_delete_modal.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/components/confirm_delete_modal/__snapshots__/confirm_delete_modal.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/_confirm_delete_modal.scss b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/_confirm_delete_modal.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/_confirm_delete_modal.scss
rename to x-pack/plugins/spaces/public/management/components/confirm_delete_modal/_confirm_delete_modal.scss
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx
rename to x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx
rename to x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/index.ts b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/confirm_delete_modal/index.ts
rename to x-pack/plugins/spaces/public/management/components/confirm_delete_modal/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/index.ts b/x-pack/plugins/spaces/public/management/components/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/index.ts
rename to x-pack/plugins/spaces/public/management/components/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/index.ts b/x-pack/plugins/spaces/public/management/components/secure_space_message/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/secure_space_message/index.ts
rename to x-pack/plugins/spaces/public/management/components/secure_space_message/index.ts
diff --git a/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx b/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
new file mode 100644
index 0000000000000..38d8451b658a8
--- /dev/null
+++ b/x-pack/plugins/spaces/public/management/components/secure_space_message/secure_space_message.tsx
@@ -0,0 +1,40 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { EuiHorizontalRule, EuiLink, EuiText } from '@elastic/eui';
+import { FormattedMessage } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
+import React, { Fragment } from 'react';
+
+export const SecureSpaceMessage = () => {
+ const rolesLinkTextAriaLabel = i18n.translate(
+ 'xpack.spaces.management.secureSpaceMessage.rolesLinkTextAriaLabel',
+ { defaultMessage: 'Roles management page' }
+ );
+ return (
+
+
+
+
+
+
+
+ ),
+ }}
+ />
+
+
+
+ );
+};
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/__snapshots__/unauthorized_prompt.test.tsx.snap b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/__snapshots__/unauthorized_prompt.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/__snapshots__/unauthorized_prompt.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/components/unauthorized_prompt/__snapshots__/unauthorized_prompt.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/index.ts b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/index.ts
rename to x-pack/plugins/spaces/public/management/components/unauthorized_prompt/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx
rename to x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.tsx b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.tsx
rename to x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/__snapshots__/delete_spaces_button.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/__snapshots__/delete_spaces_button.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/__snapshots__/delete_spaces_button.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/edit_space/__snapshots__/delete_spaces_button.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/__snapshots__/confirm_alter_active_space_modal.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/__snapshots__/confirm_alter_active_space_modal.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/__snapshots__/confirm_alter_active_space_modal.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/__snapshots__/confirm_alter_active_space_modal.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.tsx b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/index.ts b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/index.ts
rename to x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space_avatar.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space_avatar.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space_avatar.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space_avatar.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/space_identifier.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/space_identifier.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/space_identifier.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/space_identifier.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx
similarity index 77%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx
index b0d74afaa90aa..d581ac22650e3 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.tsx
@@ -16,7 +16,8 @@ import {
EuiTextArea,
EuiTitle,
} from '@elastic/eui';
-import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
+import { FormattedMessage } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
import React, { ChangeEvent, Component, Fragment } from 'react';
import { isReservedSpace } from '../../../../common';
import { Space } from '../../../../common/model/space';
@@ -30,7 +31,6 @@ interface Props {
validator: SpaceValidator;
space: Partial;
editingExistingSpace: boolean;
- intl: InjectedIntl;
onChange: (space: Partial) => void;
}
@@ -46,24 +46,21 @@ export class CustomizeSpace extends Component {
};
public render() {
- const { validator, editingExistingSpace, intl } = this.props;
+ const { validator, editingExistingSpace } = this.props;
const { name = '', description = '' } = this.props.space;
- const panelTitle = intl.formatMessage({
- id: 'xpack.spaces.management.manageSpacePage.customizeSpaceTitle',
- defaultMessage: 'Customize your space',
- });
+ const panelTitle = i18n.translate(
+ 'xpack.spaces.management.manageSpacePage.customizeSpaceTitle',
+ {
+ defaultMessage: 'Customize your space',
+ }
+ );
const extraPopoverProps: Partial = {
initialFocus: 'input[name="spaceInitials"]',
};
return (
-
+
@@ -81,8 +78,7 @@ export class CustomizeSpace extends Component {
{
>
{
@@ -147,14 +149,18 @@ export class CustomizeSpace extends Component {
)}
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx
similarity index 91%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx
index 642f2f0013222..dc20a375ada1e 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx
@@ -15,9 +15,7 @@ const space = {
};
test('renders without crashing', () => {
- const wrapper = shallowWithIntl(
-
- );
+ const wrapper = shallowWithIntl();
expect(wrapper).toMatchSnapshot();
});
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx
similarity index 83%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx
index c3207c82bf95e..55fea3671645b 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.tsx
@@ -16,16 +16,14 @@ import {
EuiSpacer,
isValidHex,
} from '@elastic/eui';
-import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
+import { Space } from '../../../../common/model/space';
import { imageTypes, encode } from '../../../../common/lib/dataurl';
import { getSpaceColor, getSpaceInitials } from '../../../space_avatar';
-import { Space } from '../../../../../../../plugins/spaces/common/model/space';
-import { MAX_SPACE_INITIALS } from '../../../../../../../plugins/spaces/common';
-
+import { MAX_SPACE_INITIALS } from '../../../../common';
interface Props {
space: Partial;
onChange: (space: Partial) => void;
- intl: InjectedIntl;
}
interface State {
@@ -33,7 +31,7 @@ interface State {
pendingInitials?: string | null;
}
-class CustomizeSpaceAvatarUI extends Component {
+export class CustomizeSpaceAvatar extends Component {
private initialsRef: HTMLInputElement | null = null;
constructor(props: Props) {
@@ -101,7 +99,7 @@ class CustomizeSpaceAvatarUI extends Component {
};
public render() {
- const { space, intl } = this.props;
+ const { space } = this.props;
const { initialsHasFocus, pendingInitials } = this.state;
@@ -111,10 +109,12 @@ class CustomizeSpaceAvatarUI extends Component {
return (
@@ -130,7 +129,7 @@ export class EnabledFeatures extends Component {
defaultMessage="The feature is hidden in the UI, but is not disabled."
/>
- {this.props.capabilities.spaces.manage && (
+ {this.props.securityEnabled && (
;
features: Feature[];
- intl: InjectedIntl;
onChange: (space: Partial) => void;
}
@@ -66,8 +66,7 @@ export class FeatureTable extends Component {
private getColumns = () => [
{
field: 'feature',
- name: this.props.intl.formatMessage({
- id: 'xpack.spaces.management.enabledSpaceFeaturesFeatureColumnTitle',
+ name: i18n.translate('xpack.spaces.management.enabledSpaceFeaturesFeatureColumnTitle', {
defaultMessage: 'Feature',
}),
render: (feature: Feature, _item: { feature: Feature; space: Props['space'] }) => {
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/index.ts b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/index.ts
rename to x-pack/plugins/spaces/public/management/edit_space/enabled_features/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/toggle_all_features.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/toggle_all_features.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/enabled_features/toggle_all_features.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/enabled_features/toggle_all_features.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/index.ts b/x-pack/plugins/spaces/public/management/edit_space/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/index.ts
rename to x-pack/plugins/spaces/public/management/edit_space/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx
similarity index 84%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx
index d24e932bce112..2aba1522a7e3f 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx
@@ -3,10 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-jest.mock('ui/kfetch', () => ({
- kfetch: () => Promise.resolve([{ id: 'feature-1', name: 'feature 1', icon: 'spacesApp' }]),
-}));
-import '../../__mocks__/xpack_info';
+
import { EuiButton, EuiLink, EuiSwitch } from '@elastic/eui';
import { ReactWrapper } from 'enzyme';
import React from 'react';
@@ -16,6 +13,7 @@ import { ManageSpacePage } from './manage_space_page';
import { SectionPanel } from './section_panel';
import { spacesManagerMock } from '../../spaces_manager/mocks';
import { SpacesManager } from '../../spaces_manager';
+import { httpServiceMock, notificationServiceMock } from 'src/core/public/mocks';
const space = {
id: 'my-space',
@@ -29,10 +27,15 @@ describe('ManageSpacePage', () => {
spacesManager.createSpace = jest.fn(spacesManager.createSpace);
spacesManager.getActiveSpace = jest.fn().mockResolvedValue(space);
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([{ id: 'feature-1', name: 'feature 1', icon: 'spacesApp' }]);
+
const wrapper = mountWithIntl(
- {
});
spacesManager.getActiveSpace = jest.fn().mockResolvedValue(space);
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([{ id: 'feature-1', name: 'feature 1', icon: 'spacesApp' }]);
+
const onLoadSpace = jest.fn();
const wrapper = mountWithIntl(
- {
});
spacesManager.getActiveSpace = jest.fn().mockResolvedValue(space);
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([{ id: 'feature-1', name: 'feature 1', icon: 'spacesApp' }]);
+
const wrapper = mountWithIntl(
- {
});
spacesManager.getActiveSpace = jest.fn().mockResolvedValue(space);
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([{ id: 'feature-1', name: 'feature 1', icon: 'spacesApp' }]);
+
const wrapper = mountWithIntl(
- void;
capabilities: Capabilities;
+ securityEnabled: boolean;
}
interface State {
@@ -54,7 +55,7 @@ interface State {
};
}
-class ManageSpacePageUI extends Component {
+export class ManageSpacePage extends Component {
private readonly validator: SpaceValidator;
constructor(props: Props) {
@@ -74,47 +75,24 @@ class ManageSpacePageUI extends Component {
return;
}
- const { spaceId, spacesManager, intl, onLoadSpace } = this.props;
+ const { spaceId, http } = this.props;
- const getFeatures = kfetch({ method: 'get', pathname: '/api/features' });
+ const getFeatures = http.get('/api/features');
if (spaceId) {
- try {
- const [space, features] = await Promise.all([spacesManager.getSpace(spaceId), getFeatures]);
- if (space) {
- if (onLoadSpace) {
- onLoadSpace(space);
- }
-
- this.setState({
- space,
- features: await features,
- originalSpace: space,
- isLoading: false,
- });
- }
- } catch (error) {
- const { message = '' } = error.data || {};
-
- toastNotifications.addDanger(
- intl.formatMessage(
- {
- id: 'xpack.spaces.management.manageSpacePage.errorLoadingSpaceTitle',
- defaultMessage: 'Error loading space: {message}',
- },
- {
- message,
- }
- )
- );
- this.backToSpacesList();
- }
+ await this.loadSpace(spaceId, getFeatures);
} else {
const features = await getFeatures;
this.setState({ isLoading: false, features });
}
}
+ public async componentDidUpdate(previousProps: Props) {
+ if (this.props.spaceId !== previousProps.spaceId && this.props.spaceId) {
+ await this.loadSpace(this.props.spaceId, Promise.resolve(this.state.features));
+ }
+ }
+
public render() {
const content = this.state.isLoading ? this.getLoadingIndicator() : this.getForm();
@@ -162,7 +140,6 @@ class ManageSpacePageUI extends Component {
onChange={this.onSpaceChange}
editingExistingSpace={this.editingExistingSpace()}
validator={this.validator}
- intl={this.props.intl}
/>
@@ -170,9 +147,8 @@ class ManageSpacePageUI extends Component {
@@ -212,27 +188,33 @@ class ManageSpacePageUI extends Component {
};
public maybeGetSecureSpacesMessage = () => {
- if (this.editingExistingSpace()) {
+ if (this.editingExistingSpace() && this.props.securityEnabled) {
return ;
}
return null;
};
public getFormButtons = () => {
- const createSpaceText = this.props.intl.formatMessage({
- id: 'xpack.spaces.management.manageSpacePage.createSpaceButton',
- defaultMessage: 'Create space',
- });
+ const createSpaceText = i18n.translate(
+ 'xpack.spaces.management.manageSpacePage.createSpaceButton',
+ {
+ defaultMessage: 'Create space',
+ }
+ );
- const updateSpaceText = this.props.intl.formatMessage({
- id: 'xpack.spaces.management.manageSpacePage.updateSpaceButton',
- defaultMessage: 'Update space',
- });
+ const updateSpaceText = i18n.translate(
+ 'xpack.spaces.management.manageSpacePage.updateSpaceButton',
+ {
+ defaultMessage: 'Update space',
+ }
+ );
- const cancelButtonText = this.props.intl.formatMessage({
- id: 'xpack.spaces.management.manageSpacePage.cancelSpaceButton',
- defaultMessage: 'Cancel',
- });
+ const cancelButtonText = i18n.translate(
+ 'xpack.spaces.management.manageSpacePage.cancelSpaceButton',
+ {
+ defaultMessage: 'Cancel',
+ }
+ );
const saveText = this.editingExistingSpace() ? updateSpaceText : createSpaceText;
return (
@@ -267,6 +249,7 @@ class ManageSpacePageUI extends Component {
space={this.state.space as Space}
spacesManager={this.props.spacesManager}
onDelete={this.backToSpacesList}
+ notifications={this.props.notifications}
/>
);
@@ -320,8 +303,40 @@ class ManageSpacePageUI extends Component {
}
};
+ private loadSpace = async (spaceId: string, featuresPromise: Promise) => {
+ const { spacesManager, onLoadSpace } = this.props;
+
+ try {
+ const [space, features] = await Promise.all([
+ spacesManager.getSpace(spaceId),
+ featuresPromise,
+ ]);
+ if (space) {
+ if (onLoadSpace) {
+ onLoadSpace(space);
+ }
+
+ this.setState({
+ space,
+ features: await features,
+ originalSpace: space,
+ isLoading: false,
+ });
+ }
+ } catch (error) {
+ const message = error?.body?.message ?? '';
+
+ this.props.notifications.toasts.addDanger(
+ i18n.translate('xpack.spaces.management.manageSpacePage.errorLoadingSpaceTitle', {
+ defaultMessage: 'Error loading space: {message}',
+ values: { message },
+ })
+ );
+ this.backToSpacesList();
+ }
+ };
+
private performSave = (requireRefresh = false) => {
- const { intl } = this.props;
if (!this.state.space) {
return;
}
@@ -357,19 +372,16 @@ class ManageSpacePageUI extends Component {
action
.then(() => {
- toastNotifications.addSuccess(
- intl.formatMessage(
+ this.props.notifications.toasts.addSuccess(
+ i18n.translate(
+ 'xpack.spaces.management.manageSpacePage.spaceSuccessfullySavedNotificationMessage',
{
- id:
- 'xpack.spaces.management.manageSpacePage.spaceSuccessfullySavedNotificationMessage',
defaultMessage: `Space {name} was saved.`,
- },
- {
- name: `'${name}'`,
+ values: { name: `'${name}'` },
}
)
);
- window.location.hash = `#/management/spaces/list`;
+ window.location.hash = `#/management/kibana/spaces`;
if (requireRefresh) {
setTimeout(() => {
window.location.reload();
@@ -377,29 +389,22 @@ class ManageSpacePageUI extends Component {
}
})
.catch(error => {
- const { message = '' } = error.data || {};
+ const message = error?.body?.message ?? '';
this.setState({ saveInProgress: false });
- toastNotifications.addDanger(
- intl.formatMessage(
- {
- id: 'xpack.spaces.management.manageSpacePage.errorSavingSpaceTitle',
- defaultMessage: 'Error saving space: {message}',
- },
- {
- message,
- }
- )
+ this.props.notifications.toasts.addDanger(
+ i18n.translate('xpack.spaces.management.manageSpacePage.errorSavingSpaceTitle', {
+ defaultMessage: 'Error saving space: {message}',
+ values: { message },
+ })
);
});
};
private backToSpacesList = () => {
- window.location.hash = `#/management/spaces/list`;
+ window.location.hash = `#/management/kibana/spaces`;
};
private editingExistingSpace = () => !!this.props.spaceId;
}
-
-export const ManageSpacePage = injectI18n(ManageSpacePageUI);
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/__snapshots__/section_panel.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/section_panel/__snapshots__/section_panel.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/__snapshots__/section_panel.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/edit_space/section_panel/__snapshots__/section_panel.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/_section_panel.scss b/x-pack/plugins/spaces/public/management/edit_space/section_panel/_section_panel.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/_section_panel.scss
rename to x-pack/plugins/spaces/public/management/edit_space/section_panel/_section_panel.scss
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/index.ts b/x-pack/plugins/spaces/public/management/edit_space/section_panel/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/index.ts
rename to x-pack/plugins/spaces/public/management/edit_space/section_panel/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx
similarity index 73%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx
index 9b736c98d1f0c..0b8085ff1ad16 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx
@@ -11,13 +11,7 @@ import { SectionPanel } from './section_panel';
test('it renders without blowing up', () => {
const wrapper = shallowWithIntl(
-
+
child
);
@@ -27,13 +21,7 @@ test('it renders without blowing up', () => {
test('it renders children by default', () => {
const wrapper = mountWithIntl(
-
+
child 1
child 2
@@ -45,13 +33,7 @@ test('it renders children by default', () => {
test('it hides children when the "hide" link is clicked', () => {
const wrapper = mountWithIntl(
-
+
child 1
child 2
diff --git a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx
similarity index 77%
rename from x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx
rename to x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx
index a205130d2d765..a0a6bc5a89d33 100644
--- a/x-pack/legacy/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx
+++ b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.tsx
@@ -14,7 +14,7 @@ import {
EuiTitle,
IconType,
} from '@elastic/eui';
-import { InjectedIntl } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
import React, { Component, Fragment, ReactNode } from 'react';
interface Props {
@@ -22,7 +22,6 @@ interface Props {
title: string | ReactNode;
description: string;
collapsible: boolean;
- intl: InjectedIntl;
initiallyCollapsed?: boolean;
}
@@ -52,38 +51,31 @@ export class SectionPanel extends Component {
}
public getTitle = () => {
- const showLinkText = this.props.intl.formatMessage({
- id: 'xpack.spaces.management.collapsiblePanel.showLinkText',
+ const showLinkText = i18n.translate('xpack.spaces.management.collapsiblePanel.showLinkText', {
defaultMessage: 'show',
});
- const hideLinkText = this.props.intl.formatMessage({
- id: 'xpack.spaces.management.collapsiblePanel.hideLinkText',
+ const hideLinkText = i18n.translate('xpack.spaces.management.collapsiblePanel.hideLinkText', {
defaultMessage: 'hide',
});
- const showLinkDescription = this.props.intl.formatMessage(
+ const showLinkDescription = i18n.translate(
+ 'xpack.spaces.management.collapsiblePanel.showLinkDescription',
{
- id: 'xpack.spaces.management.collapsiblePanel.showLinkDescription',
defaultMessage: 'show {title}',
- },
- {
- title: this.props.description,
+ values: { title: this.props.description },
}
);
- const hideLinkDescription = this.props.intl.formatMessage(
+ const hideLinkDescription = i18n.translate(
+ 'xpack.spaces.management.collapsiblePanel.hideLinkDescription',
{
- id: 'xpack.spaces.management.collapsiblePanel.hideLinkDescription',
defaultMessage: 'hide {title}',
- },
- {
- title: this.props.description,
+ values: { title: this.props.description },
}
);
return (
- // @ts-ignore
diff --git a/x-pack/legacy/plugins/spaces/public/management/index.ts b/x-pack/plugins/spaces/public/management/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/index.ts
rename to x-pack/plugins/spaces/public/management/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.test.ts b/x-pack/plugins/spaces/public/management/lib/feature_utils.test.ts
similarity index 95%
rename from x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.test.ts
rename to x-pack/plugins/spaces/public/management/lib/feature_utils.test.ts
index ce874956d0ef2..a3360969fb3f2 100644
--- a/x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.test.ts
+++ b/x-pack/plugins/spaces/public/management/lib/feature_utils.test.ts
@@ -5,7 +5,7 @@
*/
import { getEnabledFeatures } from './feature_utils';
-import { Feature } from '../../../../../../plugins/features/public';
+import { Feature } from '../../../../features/public';
const buildFeatures = () =>
[
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.ts b/x-pack/plugins/spaces/public/management/lib/feature_utils.ts
similarity index 74%
rename from x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.ts
rename to x-pack/plugins/spaces/public/management/lib/feature_utils.ts
index ff1688637ef73..a1b64eb954403 100644
--- a/x-pack/legacy/plugins/spaces/public/management/lib/feature_utils.ts
+++ b/x-pack/plugins/spaces/public/management/lib/feature_utils.ts
@@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Feature } from '../../../../../../plugins/features/common';
+import { Feature } from '../../../../features/common';
-import { Space } from '../../../../../../plugins/spaces/common/model/space';
+import { Space } from '../..';
export function getEnabledFeatures(features: Feature[], space: Partial) {
return features.filter(feature => !(space.disabledFeatures || []).includes(feature.id));
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/index.ts b/x-pack/plugins/spaces/public/management/lib/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/lib/index.ts
rename to x-pack/plugins/spaces/public/management/lib/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/space_identifier_utils.test.ts b/x-pack/plugins/spaces/public/management/lib/space_identifier_utils.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/lib/space_identifier_utils.test.ts
rename to x-pack/plugins/spaces/public/management/lib/space_identifier_utils.test.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/space_identifier_utils.ts b/x-pack/plugins/spaces/public/management/lib/space_identifier_utils.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/lib/space_identifier_utils.ts
rename to x-pack/plugins/spaces/public/management/lib/space_identifier_utils.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/validate_space.test.ts b/x-pack/plugins/spaces/public/management/lib/validate_space.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/lib/validate_space.test.ts
rename to x-pack/plugins/spaces/public/management/lib/validate_space.test.ts
diff --git a/x-pack/legacy/plugins/spaces/public/management/lib/validate_space.ts b/x-pack/plugins/spaces/public/management/lib/validate_space.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/management/lib/validate_space.ts
rename to x-pack/plugins/spaces/public/management/lib/validate_space.ts
diff --git a/x-pack/plugins/spaces/public/management/management_service.test.ts b/x-pack/plugins/spaces/public/management/management_service.test.ts
new file mode 100644
index 0000000000000..d4c6bdaea2776
--- /dev/null
+++ b/x-pack/plugins/spaces/public/management/management_service.test.ts
@@ -0,0 +1,138 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { ManagementService } from '.';
+import { coreMock } from 'src/core/public/mocks';
+import { spacesManagerMock } from '../spaces_manager/mocks';
+import { managementPluginMock } from '../../../../../src/plugins/management/public/mocks';
+import { ManagementSection } from 'src/plugins/management/public';
+import { Capabilities } from 'kibana/public';
+
+describe('ManagementService', () => {
+ describe('#setup', () => {
+ it('registers the spaces management page under the kibana section', () => {
+ const mockKibanaSection = ({
+ registerApp: jest.fn(),
+ } as unknown) as ManagementSection;
+ const deps = {
+ management: managementPluginMock.createSetupContract(),
+ getStartServices: coreMock.createSetup().getStartServices,
+ spacesManager: spacesManagerMock.create(),
+ };
+
+ deps.management.sections.getSection.mockReturnValue(mockKibanaSection);
+
+ const service = new ManagementService();
+ service.setup(deps);
+
+ expect(deps.management.sections.getSection).toHaveBeenCalledTimes(1);
+ expect(deps.management.sections.getSection).toHaveBeenCalledWith('kibana');
+
+ expect(mockKibanaSection.registerApp).toHaveBeenCalledTimes(1);
+ expect(mockKibanaSection.registerApp).toHaveBeenCalledWith({
+ id: 'spaces',
+ title: 'Spaces',
+ order: 10,
+ mount: expect.any(Function),
+ });
+ });
+
+ it('will not crash if the kibana section is missing', () => {
+ const deps = {
+ management: managementPluginMock.createSetupContract(),
+ getStartServices: coreMock.createSetup().getStartServices,
+ spacesManager: spacesManagerMock.create(),
+ };
+
+ const service = new ManagementService();
+ service.setup(deps);
+ });
+ });
+
+ describe('#start', () => {
+ it('disables the spaces management page if the user is not authorized', () => {
+ const mockSpacesManagementPage = { disable: jest.fn() };
+ const mockKibanaSection = ({
+ registerApp: jest.fn().mockReturnValue(mockSpacesManagementPage),
+ } as unknown) as ManagementSection;
+
+ const deps = {
+ management: managementPluginMock.createSetupContract(),
+ getStartServices: coreMock.createSetup().getStartServices,
+ spacesManager: spacesManagerMock.create(),
+ };
+
+ deps.management.sections.getSection.mockImplementation(id => {
+ if (id === 'kibana') return mockKibanaSection;
+ throw new Error(`unexpected getSection call: ${id}`);
+ });
+
+ const service = new ManagementService();
+ service.setup(deps);
+
+ const capabilities = ({ spaces: { manage: false } } as unknown) as Capabilities;
+ service.start({ capabilities });
+
+ expect(mockKibanaSection.registerApp).toHaveBeenCalledTimes(1);
+ expect(mockSpacesManagementPage.disable).toHaveBeenCalledTimes(1);
+ });
+
+ it('does not disable the spaces management page if the user is authorized', () => {
+ const mockSpacesManagementPage = { disable: jest.fn() };
+ const mockKibanaSection = ({
+ registerApp: jest.fn().mockReturnValue(mockSpacesManagementPage),
+ } as unknown) as ManagementSection;
+
+ const deps = {
+ management: managementPluginMock.createSetupContract(),
+ getStartServices: coreMock.createSetup().getStartServices,
+ spacesManager: spacesManagerMock.create(),
+ };
+
+ deps.management.sections.getSection.mockImplementation(id => {
+ if (id === 'kibana') return mockKibanaSection;
+ throw new Error(`unexpected getSection call: ${id}`);
+ });
+
+ const service = new ManagementService();
+ service.setup(deps);
+
+ const capabilities = ({ spaces: { manage: true } } as unknown) as Capabilities;
+ service.start({ capabilities });
+
+ expect(mockKibanaSection.registerApp).toHaveBeenCalledTimes(1);
+ expect(mockSpacesManagementPage.disable).toHaveBeenCalledTimes(0);
+ });
+ });
+
+ describe('#stop', () => {
+ it('disables the spaces management page', () => {
+ const mockSpacesManagementPage = { disable: jest.fn() };
+ const mockKibanaSection = ({
+ registerApp: jest.fn().mockReturnValue(mockSpacesManagementPage),
+ } as unknown) as ManagementSection;
+
+ const deps = {
+ management: managementPluginMock.createSetupContract(),
+ getStartServices: coreMock.createSetup().getStartServices,
+ spacesManager: spacesManagerMock.create(),
+ };
+
+ deps.management.sections.getSection.mockImplementation(id => {
+ if (id === 'kibana') return mockKibanaSection;
+ throw new Error(`unexpected getSection call: ${id}`);
+ });
+
+ const service = new ManagementService();
+ service.setup(deps);
+
+ service.stop();
+
+ expect(mockKibanaSection.registerApp).toHaveBeenCalledTimes(1);
+ expect(mockSpacesManagementPage.disable).toHaveBeenCalledTimes(1);
+ });
+ });
+});
diff --git a/x-pack/plugins/spaces/public/management/management_service.tsx b/x-pack/plugins/spaces/public/management/management_service.tsx
new file mode 100644
index 0000000000000..c81a3497762a5
--- /dev/null
+++ b/x-pack/plugins/spaces/public/management/management_service.tsx
@@ -0,0 +1,51 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { ManagementSetup, ManagementApp } from 'src/plugins/management/public';
+import { CoreSetup, Capabilities } from 'src/core/public';
+import { SecurityLicense } from '../../../security/public';
+import { SpacesManager } from '../spaces_manager';
+import { PluginsStart } from '../plugin';
+import { spacesManagementApp } from './spaces_management_app';
+
+interface SetupDeps {
+ management: ManagementSetup;
+ getStartServices: CoreSetup['getStartServices'];
+ spacesManager: SpacesManager;
+ securityLicense?: SecurityLicense;
+}
+
+interface StartDeps {
+ capabilities: Capabilities;
+}
+export class ManagementService {
+ private registeredSpacesManagementApp?: ManagementApp;
+
+ public setup({ getStartServices, management, spacesManager, securityLicense }: SetupDeps) {
+ const kibanaSection = management.sections.getSection('kibana');
+ if (kibanaSection) {
+ this.registeredSpacesManagementApp = kibanaSection.registerApp(
+ spacesManagementApp.create({ getStartServices, spacesManager, securityLicense })
+ );
+ }
+ }
+
+ public start({ capabilities }: StartDeps) {
+ if (!capabilities.spaces.manage) {
+ this.disableSpacesApp();
+ }
+ }
+
+ public stop() {
+ this.disableSpacesApp();
+ }
+
+ private disableSpacesApp() {
+ if (this.registeredSpacesManagementApp) {
+ this.registeredSpacesManagementApp.disable();
+ }
+ }
+}
diff --git a/x-pack/legacy/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap b/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
similarity index 99%
rename from x-pack/legacy/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
rename to x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
index 02dbca28c7b66..aa6db7e22fd5d 100644
--- a/x-pack/legacy/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
+++ b/x-pack/plugins/spaces/public/management/spaces_grid/__snapshots__/spaces_grid_pages.test.tsx.snap
@@ -39,7 +39,7 @@ exports[`SpacesGridPage renders as expected 1`] = `
>
{
+export class SpacesGridPage extends Component {
constructor(props: Props) {
super(props);
this.state = {
@@ -72,15 +73,13 @@ class SpacesGridPageUI extends Component {
return (
{this.getPageContent()}
-
+ {this.props.securityEnabled && }
{this.getConfirmDeleteModal()}
);
}
public getPageContent() {
- const { intl } = this.props;
-
if (!this.props.capabilities.spaces.manage) {
return ;
}
@@ -114,10 +113,12 @@ class SpacesGridPageUI extends Component {
sorting={true}
search={{
box: {
- placeholder: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.searchPlaceholder',
- defaultMessage: 'Search',
- }),
+ placeholder: i18n.translate(
+ 'xpack.spaces.management.spacesGridPage.searchPlaceholder',
+ {
+ defaultMessage: 'Search',
+ }
+ ),
},
}}
loading={this.state.loading}
@@ -138,12 +139,7 @@ class SpacesGridPageUI extends Component {
public getPrimaryActionButton() {
return (
- {
- window.location.hash = `#/management/spaces/create`;
- }}
- >
+
{
};
public deleteSpace = async () => {
- const { intl } = this.props;
const { spacesManager } = this.props;
const space = this.state.selectedSpace;
@@ -188,16 +183,13 @@ class SpacesGridPageUI extends Component {
} catch (error) {
const { message: errorMessage = '' } = error.data || {};
- toastNotifications.addDanger(
- intl.formatMessage(
- {
- id: 'xpack.spaces.management.spacesGridPage.errorDeletingSpaceErrorMessage',
- defaultMessage: 'Error deleting space: {errorMessage}',
- },
- {
+ this.props.notifications.toasts.addDanger(
+ i18n.translate('xpack.spaces.management.spacesGridPage.errorDeletingSpaceErrorMessage', {
+ defaultMessage: 'Error deleting space: {errorMessage}',
+ values: {
errorMessage,
- }
- )
+ },
+ })
);
}
@@ -207,21 +199,19 @@ class SpacesGridPageUI extends Component {
this.loadGrid();
- const message = intl.formatMessage(
+ const message = i18n.translate(
+ 'xpack.spaces.management.spacesGridPage.spaceSuccessfullyDeletedNotificationMessage',
{
- id: 'xpack.spaces.management.spacesGridPage.spaceSuccessfullyDeletedNotificationMessage',
defaultMessage: 'Deleted "{spaceName}" space.',
- },
- {
- spaceName: space.name,
+ values: { spaceName: space.name },
}
);
- toastNotifications.addSuccess(message);
+ this.props.notifications.toasts.addSuccess(message);
};
public loadGrid = async () => {
- const { spacesManager } = this.props;
+ const { spacesManager, http } = this.props;
this.setState({
loading: true,
@@ -230,7 +220,7 @@ class SpacesGridPageUI extends Component {
});
const getSpaces = spacesManager.getSpaces();
- const getFeatures = kfetch({ method: 'get', pathname: '/api/features' });
+ const getFeatures = http.get('/api/features');
try {
const [spaces, features] = await Promise.all([getSpaces, getFeatures]);
@@ -248,51 +238,37 @@ class SpacesGridPageUI extends Component {
};
public getColumnConfig() {
- const { intl } = this.props;
return [
{
field: 'initials',
name: '',
width: '50px',
render: (value: string, record: Space) => (
- {
- this.onEditSpaceClick(record);
- }}
- >
+
),
},
{
field: 'name',
- name: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.spaceColumnName',
+ name: i18n.translate('xpack.spaces.management.spacesGridPage.spaceColumnName', {
defaultMessage: 'Space',
}),
sortable: true,
render: (value: string, record: Space) => (
- {
- this.onEditSpaceClick(record);
- }}
- >
- {value}
-
+ {value}
),
},
{
field: 'description',
- name: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.descriptionColumnName',
+ name: i18n.translate('xpack.spaces.management.spacesGridPage.descriptionColumnName', {
defaultMessage: 'Description',
}),
sortable: true,
},
{
field: 'disabledFeatures',
- name: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.featuresColumnName',
+ name: i18n.translate('xpack.spaces.management.spacesGridPage.featuresColumnName', {
defaultMessage: 'Features',
}),
sortable: (space: Space) => {
@@ -332,8 +308,7 @@ class SpacesGridPageUI extends Component {
},
{
field: 'id',
- name: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.identifierColumnName',
+ name: i18n.translate('xpack.spaces.management.spacesGridPage.identifierColumnName', {
defaultMessage: 'Identifier',
}),
sortable: true,
@@ -345,26 +320,23 @@ class SpacesGridPageUI extends Component {
},
},
{
- name: intl.formatMessage({
- id: 'xpack.spaces.management.spacesGridPage.actionsColumnName',
+ name: i18n.translate('xpack.spaces.management.spacesGridPage.actionsColumnName', {
defaultMessage: 'Actions',
}),
actions: [
{
render: (record: Space) => (
this.onEditSpaceClick(record)}
+ href={this.getEditSpacePath(record)}
/>
),
},
@@ -372,13 +344,11 @@ class SpacesGridPageUI extends Component {
available: (record: Space) => !isReservedSpace(record),
render: (record: Space) => (
{
];
}
- private onEditSpaceClick = (space: Space) => {
- window.location.hash = `#/management/spaces/edit/${encodeURIComponent(space.id)}`;
+ private getEditSpacePath = (space: Space) => {
+ return `#/management/kibana/spaces/edit/${encodeURIComponent(space.id)}`;
};
private onDeleteSpaceClick = (space: Space) => {
@@ -403,5 +373,3 @@ class SpacesGridPageUI extends Component {
});
};
}
-
-export const SpacesGridPage = injectI18n(SpacesGridPageUI);
diff --git a/x-pack/legacy/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
similarity index 71%
rename from x-pack/legacy/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
rename to x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
index 7856d2e7bee01..90c7aba65e3d6 100644
--- a/x-pack/legacy/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
+++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx
@@ -3,16 +3,15 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-jest.mock('ui/kfetch', () => ({
- kfetch: () => Promise.resolve([]),
-}));
-import '../../__mocks__/xpack_info';
+
import React from 'react';
-import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
+import { mountWithIntl, shallowWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { SpaceAvatar } from '../../space_avatar';
import { spacesManagerMock } from '../../spaces_manager/mocks';
import { SpacesManager } from '../../spaces_manager';
import { SpacesGridPage } from './spaces_grid_page';
+import { httpServiceMock } from 'src/core/public/mocks';
+import { notificationServiceMock } from 'src/core/public/mocks';
const spaces = [
{
@@ -41,11 +40,16 @@ spacesManager.getSpaces = jest.fn().mockResolvedValue(spaces);
describe('SpacesGridPage', () => {
it('renders as expected', () => {
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([]);
+
expect(
shallowWithIntl(
- {
});
it('renders the list of spaces', async () => {
+ const httpStart = httpServiceMock.createStartContract();
+ httpStart.get.mockResolvedValue([]);
+
const wrapper = mountWithIntl(
- {
);
// allow spacesManager to load spaces
- await Promise.resolve();
- wrapper.update();
- await Promise.resolve();
+ await nextTick();
wrapper.update();
expect(wrapper.find(SpaceAvatar)).toHaveLength(spaces.length);
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
new file mode 100644
index 0000000000000..b19ef995283da
--- /dev/null
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx
@@ -0,0 +1,137 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+jest.mock('./spaces_grid', () => ({
+ SpacesGridPage: (props: any) => `Spaces Page: ${JSON.stringify(props)}`,
+}));
+
+jest.mock('./edit_space', () => ({
+ ManageSpacePage: (props: any) => {
+ if (props.spacesManager && props.onLoadSpace) {
+ props.spacesManager.getSpace().then((space: any) => props.onLoadSpace(space));
+ }
+ return `Spaces Edit Page: ${JSON.stringify(props)}`;
+ },
+}));
+
+import { spacesManagementApp } from './spaces_management_app';
+
+import { coreMock } from '../../../../../src/core/public/mocks';
+import { securityMock } from '../../../security/public/mocks';
+import { spacesManagerMock } from '../spaces_manager/mocks';
+import { SecurityLicenseFeatures } from '../../../security/public';
+
+async function mountApp(basePath: string, spaceId?: string) {
+ const container = document.createElement('div');
+ const setBreadcrumbs = jest.fn();
+
+ const spacesManager = spacesManagerMock.create();
+ if (spaceId) {
+ spacesManager.getSpace.mockResolvedValue({
+ id: spaceId,
+ name: `space with id ${spaceId}`,
+ disabledFeatures: [],
+ });
+ }
+
+ const securityLicense = securityMock.createSetup().license;
+ securityLicense.getFeatures.mockReturnValue({
+ showLinks: true,
+ } as SecurityLicenseFeatures);
+
+ const unmount = await spacesManagementApp
+ .create({
+ spacesManager,
+ securityLicense,
+ getStartServices: coreMock.createSetup().getStartServices as any,
+ })
+ .mount({ basePath, element: container, setBreadcrumbs });
+
+ return { unmount, container, setBreadcrumbs };
+}
+
+describe('spacesManagementApp', () => {
+ it('create() returns proper management app descriptor', () => {
+ expect(
+ spacesManagementApp.create({
+ spacesManager: spacesManagerMock.create(),
+ securityLicense: securityMock.createSetup().license,
+ getStartServices: coreMock.createSetup().getStartServices as any,
+ })
+ ).toMatchInlineSnapshot(`
+ Object {
+ "id": "spaces",
+ "mount": [Function],
+ "order": 10,
+ "title": "Spaces",
+ }
+ `);
+ });
+
+ it('mount() works for the `grid` page', async () => {
+ const basePath = '/some-base-path/spaces';
+ window.location.hash = basePath;
+
+ const { setBreadcrumbs, container, unmount } = await mountApp(basePath);
+
+ expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
+ expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: `#${basePath}`, text: 'Spaces' }]);
+ expect(container).toMatchInlineSnapshot(`
+
+ Spaces Page: {"capabilities":{"catalogue":{},"management":{},"navLinks":{}},"http":{"basePath":{"basePath":""},"anonymousPaths":{}},"notifications":{"toasts":{}},"spacesManager":{"onActiveSpaceChange$":{"_isScalar":false}},"securityEnabled":true}
+
+ `);
+
+ unmount();
+
+ expect(container).toMatchInlineSnapshot(``);
+ });
+
+ it('mount() works for the `create space` page', async () => {
+ const basePath = '/some-base-path/spaces';
+ window.location.hash = `${basePath}/create`;
+
+ const { setBreadcrumbs, container, unmount } = await mountApp(basePath);
+
+ expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
+ expect(setBreadcrumbs).toHaveBeenCalledWith([
+ { href: `#${basePath}`, text: 'Spaces' },
+ { text: 'Create' },
+ ]);
+ expect(container).toMatchInlineSnapshot(`
+
+ Spaces Edit Page: {"capabilities":{"catalogue":{},"management":{},"navLinks":{}},"http":{"basePath":{"basePath":""},"anonymousPaths":{}},"notifications":{"toasts":{}},"spacesManager":{"onActiveSpaceChange$":{"_isScalar":false}},"securityEnabled":true}
+
+ `);
+
+ unmount();
+
+ expect(container).toMatchInlineSnapshot(``);
+ });
+
+ it('mount() works for the `edit space` page', async () => {
+ const basePath = '/some-base-path/spaces';
+ const spaceId = 'some-space';
+ window.location.hash = `${basePath}/edit/${spaceId}`;
+
+ const { setBreadcrumbs, container, unmount } = await mountApp(basePath, spaceId);
+
+ expect(setBreadcrumbs).toHaveBeenCalledTimes(1);
+ expect(setBreadcrumbs).toHaveBeenCalledWith([
+ { href: `#${basePath}`, text: 'Spaces' },
+ { href: `#/some-base-path/spaces/edit/${spaceId}`, text: `space with id some-space` },
+ ]);
+ expect(container).toMatchInlineSnapshot(`
+
+ Spaces Edit Page: {"capabilities":{"catalogue":{},"management":{},"navLinks":{}},"http":{"basePath":{"basePath":""},"anonymousPaths":{}},"notifications":{"toasts":{}},"spacesManager":{"onActiveSpaceChange$":{"_isScalar":false}},"spaceId":"some-space","securityEnabled":true}
+
+ `);
+
+ unmount();
+
+ expect(container).toMatchInlineSnapshot(``);
+ });
+});
diff --git a/x-pack/plugins/spaces/public/management/spaces_management_app.tsx b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
new file mode 100644
index 0000000000000..663237cfc2e8a
--- /dev/null
+++ b/x-pack/plugins/spaces/public/management/spaces_management_app.tsx
@@ -0,0 +1,131 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import React from 'react';
+import { render, unmountComponentAtNode } from 'react-dom';
+import { HashRouter as Router, Route, Switch, useParams } from 'react-router-dom';
+import { i18n } from '@kbn/i18n';
+import { CoreSetup } from 'src/core/public';
+import { SecurityLicense } from '../../../security/public';
+import { RegisterManagementAppArgs } from '../../../../../src/plugins/management/public';
+import { PluginsStart } from '../plugin';
+import { SpacesManager } from '../spaces_manager';
+import { SpacesGridPage } from './spaces_grid';
+import { ManageSpacePage } from './edit_space';
+import { Space } from '..';
+
+interface CreateParams {
+ getStartServices: CoreSetup['getStartServices'];
+ spacesManager: SpacesManager;
+ securityLicense?: SecurityLicense;
+}
+
+export const spacesManagementApp = Object.freeze({
+ id: 'spaces',
+ create({ getStartServices, spacesManager, securityLicense }: CreateParams) {
+ return {
+ id: this.id,
+ order: 10,
+ title: i18n.translate('xpack.spaces.displayName', {
+ defaultMessage: 'Spaces',
+ }),
+ async mount({ basePath, element, setBreadcrumbs }) {
+ const [{ http, notifications, i18n: i18nStart, application }] = await getStartServices();
+ const spacesBreadcrumbs = [
+ {
+ text: i18n.translate('xpack.spaces.management.breadcrumb', {
+ defaultMessage: 'Spaces',
+ }),
+ href: `#${basePath}`,
+ },
+ ];
+
+ const SpacesGridPageWithBreadcrumbs = () => {
+ setBreadcrumbs(spacesBreadcrumbs);
+ return (
+
+ );
+ };
+
+ const CreateSpacePageWithBreadcrumbs = () => {
+ setBreadcrumbs([
+ ...spacesBreadcrumbs,
+ {
+ text: i18n.translate('xpack.spaces.management.createSpaceBreadcrumb', {
+ defaultMessage: 'Create',
+ }),
+ },
+ ]);
+
+ return (
+
+ );
+ };
+
+ const EditSpacePageWithBreadcrumbs = () => {
+ const { spaceId } = useParams<{ spaceId: string }>();
+
+ const onLoadSpace = (space: Space) => {
+ setBreadcrumbs([
+ ...spacesBreadcrumbs,
+ {
+ text: space.name,
+ href: `#${basePath}/edit/${encodeURIComponent(space.id)}`,
+ },
+ ]);
+ };
+
+ return (
+
+ );
+ };
+
+ render(
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+ element
+ );
+
+ return () => {
+ unmountComponentAtNode(element);
+ };
+ },
+ } as RegisterManagementAppArgs;
+ },
+});
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap b/x-pack/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap
similarity index 96%
rename from x-pack/legacy/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap
rename to x-pack/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap
index 45daa03e94c2e..22d65f4600e05 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap
+++ b/x-pack/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap
@@ -40,6 +40,7 @@ exports[`NavControlPopover renders without crashing 1`] = `
}
}
id="headerSpacesMenuContent"
+ navigateToApp={[MockFunction]}
onManageSpacesClick={[Function]}
/>
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/_index.scss b/x-pack/plugins/spaces/public/nav_control/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/_index.scss
rename to x-pack/plugins/spaces/public/nav_control/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/_nav_control.scss b/x-pack/plugins/spaces/public/nav_control/_nav_control.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/_nav_control.scss
rename to x-pack/plugins/spaces/public/nav_control/_nav_control.scss
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/manage_spaces_button.test.tsx.snap b/x-pack/plugins/spaces/public/nav_control/components/__snapshots__/manage_spaces_button.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/manage_spaces_button.test.tsx.snap
rename to x-pack/plugins/spaces/public/nav_control/components/__snapshots__/manage_spaces_button.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/_index.scss b/x-pack/plugins/spaces/public/nav_control/components/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/_index.scss
rename to x-pack/plugins/spaces/public/nav_control/components/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/_spaces_description.scss b/x-pack/plugins/spaces/public/nav_control/components/_spaces_description.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/_spaces_description.scss
rename to x-pack/plugins/spaces/public/nav_control/components/_spaces_description.scss
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/_spaces_menu.scss b/x-pack/plugins/spaces/public/nav_control/components/_spaces_menu.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/_spaces_menu.scss
rename to x-pack/plugins/spaces/public/nav_control/components/_spaces_menu.scss
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx
similarity index 94%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx
rename to x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx
index 2dc6ae919c018..009b6aa89d089 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx
@@ -12,6 +12,7 @@ describe('ManageSpacesButton', () => {
it('renders as expected', () => {
const component = (
{
it(`doesn't render if user profile forbids managing spaces`, () => {
const component = (
void;
capabilities: Capabilities;
+ navigateToApp: ApplicationStart['navigateToApp'];
}
export class ManageSpacesButton extends Component {
@@ -45,6 +45,7 @@ export class ManageSpacesButton extends Component {
if (this.props.onClick) {
this.props.onClick();
}
- window.location.replace(getManageSpacesUrl());
+
+ this.props.navigateToApp('kibana', { path: '#/management/kibana/spaces' });
};
}
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.tsx b/x-pack/plugins/spaces/public/nav_control/components/spaces_description.tsx
similarity index 88%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.tsx
rename to x-pack/plugins/spaces/public/nav_control/components/spaces_description.tsx
index b6982a3d687a6..3a431ae0929b8 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/components/spaces_description.tsx
@@ -6,7 +6,7 @@
import { EuiContextMenuPanel, EuiText } from '@elastic/eui';
import React, { FC } from 'react';
-import { Capabilities } from 'src/core/public';
+import { Capabilities, ApplicationStart } from 'src/core/public';
import { ManageSpacesButton } from './manage_spaces_button';
import { getSpacesFeatureDescription } from '../../constants';
@@ -14,6 +14,7 @@ interface Props {
id: string;
onManageSpacesClick: () => void;
capabilities: Capabilities;
+ navigateToApp: ApplicationStart['navigateToApp'];
}
export const SpacesDescription: FC = (props: Props) => {
@@ -34,6 +35,7 @@ export const SpacesDescription: FC = (props: Props) => {
style={{ width: `100%` }}
onClick={props.onManageSpacesClick}
capabilities={props.capabilities}
+ navigateToApp={props.navigateToApp}
/>
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx
similarity index 97%
rename from x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_menu.tsx
rename to x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx
index 4d89f57d4ccf1..59656333f865e 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_menu.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx
@@ -13,7 +13,7 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React, { Component, ReactElement } from 'react';
-import { Capabilities } from 'src/core/public';
+import { Capabilities, ApplicationStart } from 'src/core/public';
import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../common/constants';
import { Space } from '../../../common/model/space';
import { ManageSpacesButton } from './manage_spaces_button';
@@ -27,6 +27,7 @@ interface Props {
onManageSpacesClick: () => void;
intl: InjectedIntl;
capabilities: Capabilities;
+ navigateToApp: ApplicationStart['navigateToApp'];
}
interface State {
@@ -166,6 +167,7 @@ class SpacesMenuUI extends Component {
size="s"
onClick={this.props.onManageSpacesClick}
capabilities={this.props.capabilities}
+ navigateToApp={this.props.navigateToApp}
/>
);
};
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/index.ts b/x-pack/plugins/spaces/public/nav_control/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/index.ts
rename to x-pack/plugins/spaces/public/nav_control/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control.tsx
similarity index 95%
rename from x-pack/legacy/plugins/spaces/public/nav_control/nav_control.tsx
rename to x-pack/plugins/spaces/public/nav_control/nav_control.tsx
index 9ec070eff3fed..53d7038cec4d5 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/nav_control.tsx
@@ -25,6 +25,7 @@ export function initSpacesNavControl(spacesManager: SpacesManager, core: CoreSta
spacesManager={spacesManager}
anchorPosition="downLeft"
capabilities={core.application.capabilities}
+ navigateToApp={core.application.navigateToApp}
/>
,
targetDomElement
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.test.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx
similarity index 96%
rename from x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.test.tsx
rename to x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx
index 5ce141abb713e..0e0a3473be7ff 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.test.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx
@@ -23,6 +23,7 @@ describe('NavControlPopover', () => {
spacesManager={(spacesManager as unknown) as SpacesManager}
anchorPosition={'downRight'}
capabilities={{ navLinks: {}, management: {}, catalogue: {}, spaces: { manage: true } }}
+ navigateToApp={jest.fn()}
/>
);
expect(wrapper).toMatchSnapshot();
@@ -54,6 +55,7 @@ describe('NavControlPopover', () => {
spacesManager={(spacesManager as unknown) as SpacesManager}
anchorPosition={'rightCenter'}
capabilities={{ navLinks: {}, management: {}, catalogue: {}, spaces: { manage: true } }}
+ navigateToApp={jest.fn()}
/>
);
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx
similarity index 95%
rename from x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.tsx
rename to x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx
index 59c8052a644da..ef7eff437c86a 100644
--- a/x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.tsx
+++ b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx
@@ -11,7 +11,7 @@ import {
EuiHeaderSectionItemButton,
} from '@elastic/eui';
import React, { Component } from 'react';
-import { Capabilities } from 'src/core/public';
+import { Capabilities, ApplicationStart } from 'src/core/public';
import { Subscription } from 'rxjs';
import { Space } from '../../common/model/space';
import { SpaceAvatar } from '../space_avatar';
@@ -23,6 +23,7 @@ interface Props {
spacesManager: SpacesManager;
anchorPosition: PopoverAnchorPosition;
capabilities: Capabilities;
+ navigateToApp: ApplicationStart['navigateToApp'];
}
interface State {
@@ -76,6 +77,7 @@ export class NavControlPopover extends Component {
id={popoutContentId}
onManageSpacesClick={this.toggleSpaceSelector}
capabilities={this.props.capabilities}
+ navigateToApp={this.props.navigateToApp}
/>
);
} else {
@@ -87,6 +89,7 @@ export class NavControlPopover extends Component {
onSelectSpace={this.onSelectSpace}
onManageSpacesClick={this.toggleSpaceSelector}
capabilities={this.props.capabilities}
+ navigateToApp={this.props.navigateToApp}
/>
);
}
diff --git a/x-pack/legacy/plugins/spaces/public/nav_control/types.tsx b/x-pack/plugins/spaces/public/nav_control/types.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/nav_control/types.tsx
rename to x-pack/plugins/spaces/public/nav_control/types.tsx
diff --git a/x-pack/plugins/spaces/public/plugin.test.ts b/x-pack/plugins/spaces/public/plugin.test.ts
new file mode 100644
index 0000000000000..28f8433be6fd9
--- /dev/null
+++ b/x-pack/plugins/spaces/public/plugin.test.ts
@@ -0,0 +1,109 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { coreMock } from 'src/core/public/mocks';
+import { SpacesPlugin } from './plugin';
+import { homePluginMock } from '../../../../src/plugins/home/public/mocks';
+import { ManagementSection } from '../../../../src/plugins/management/public';
+import { managementPluginMock } from '../../../../src/plugins/management/public/mocks';
+import { advancedSettingsMock } from '../../../../src/plugins/advanced_settings/public/mocks';
+
+describe('Spaces plugin', () => {
+ describe('#setup', () => {
+ it('should register the space selector app', () => {
+ const coreSetup = coreMock.createSetup();
+
+ const plugin = new SpacesPlugin();
+ plugin.setup(coreSetup, {});
+
+ expect(coreSetup.application.register).toHaveBeenCalledWith(
+ expect.objectContaining({
+ id: 'space_selector',
+ chromeless: true,
+ appRoute: '/spaces/space_selector',
+ mount: expect.any(Function),
+ })
+ );
+ });
+
+ it('should register the management and feature catalogue sections when the management and home plugins are both available', () => {
+ const coreSetup = coreMock.createSetup();
+
+ const kibanaSection = new ManagementSection(
+ {
+ id: 'kibana',
+ title: 'Mock Kibana Section',
+ order: 1,
+ },
+ jest.fn(),
+ jest.fn(),
+ jest.fn(),
+ coreSetup.getStartServices
+ );
+
+ const registerAppSpy = jest.spyOn(kibanaSection, 'registerApp');
+
+ const home = homePluginMock.createSetupContract();
+
+ const management = managementPluginMock.createSetupContract();
+ management.sections.getSection.mockReturnValue(kibanaSection);
+
+ const plugin = new SpacesPlugin();
+ plugin.setup(coreSetup, {
+ management,
+ home,
+ });
+
+ expect(registerAppSpy).toHaveBeenCalledWith(expect.objectContaining({ id: 'spaces' }));
+
+ expect(home.featureCatalogue.register).toHaveBeenCalledWith(
+ expect.objectContaining({
+ category: 'admin',
+ icon: 'spacesApp',
+ id: 'spaces',
+ showOnHomePage: true,
+ })
+ );
+ });
+
+ it('should register the advanced settings components if the advanced_settings plugin is available', () => {
+ const coreSetup = coreMock.createSetup();
+ const advancedSettings = advancedSettingsMock.createSetupContract();
+
+ const plugin = new SpacesPlugin();
+ plugin.setup(coreSetup, { advancedSettings });
+
+ expect(advancedSettings.component.register.mock.calls).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "advanced_settings_page_title",
+ [Function],
+ true,
+ ],
+ Array [
+ "advanced_settings_page_subtitle",
+ [Function],
+ true,
+ ],
+ ]
+ `);
+ });
+ });
+
+ describe('#start', () => {
+ it('should register the spaces nav control', () => {
+ const coreSetup = coreMock.createSetup();
+ const coreStart = coreMock.createStart();
+
+ const plugin = new SpacesPlugin();
+ plugin.setup(coreSetup, {});
+
+ plugin.start(coreStart, {});
+
+ expect(coreStart.chrome.navControls.registerLeft).toHaveBeenCalled();
+ });
+ });
+});
diff --git a/x-pack/plugins/spaces/public/plugin.tsx b/x-pack/plugins/spaces/public/plugin.tsx
new file mode 100644
index 0000000000000..73dae84c1873b
--- /dev/null
+++ b/x-pack/plugins/spaces/public/plugin.tsx
@@ -0,0 +1,120 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
+import { HomePublicPluginSetup } from 'src/plugins/home/public';
+import { SavedObjectsManagementAction } from 'src/legacy/core_plugins/management/public';
+import { ManagementStart, ManagementSetup } from 'src/plugins/management/public';
+import { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public';
+import { SecurityPluginStart, SecurityPluginSetup } from '../../security/public';
+import { SpacesManager } from './spaces_manager';
+import { initSpacesNavControl } from './nav_control';
+import { createSpacesFeatureCatalogueEntry } from './create_feature_catalogue_entry';
+import { CopySavedObjectsToSpaceService } from './copy_saved_objects_to_space';
+import { AdvancedSettingsService } from './advanced_settings';
+import { ManagementService } from './management';
+import { spaceSelectorApp } from './space_selector';
+
+export interface PluginsSetup {
+ advancedSettings?: AdvancedSettingsSetup;
+ home?: HomePublicPluginSetup;
+ management?: ManagementSetup;
+ security?: SecurityPluginSetup;
+}
+
+export interface PluginsStart {
+ management?: ManagementStart;
+ security?: SecurityPluginStart;
+}
+
+interface LegacyAPI {
+ registerSavedObjectsManagementAction: (action: SavedObjectsManagementAction) => void;
+}
+
+export type SpacesPluginSetup = ReturnType;
+export type SpacesPluginStart = ReturnType;
+
+export class SpacesPlugin implements Plugin {
+ private spacesManager!: SpacesManager;
+
+ private managementService?: ManagementService;
+
+ public setup(core: CoreSetup, plugins: PluginsSetup) {
+ const serverBasePath = core.injectedMetadata.getInjectedVar('serverBasePath') as string;
+ this.spacesManager = new SpacesManager(serverBasePath, core.http);
+
+ if (plugins.home) {
+ plugins.home.featureCatalogue.register(createSpacesFeatureCatalogueEntry());
+ }
+
+ if (plugins.management) {
+ this.managementService = new ManagementService();
+ this.managementService.setup({
+ management: plugins.management,
+ getStartServices: core.getStartServices,
+ spacesManager: this.spacesManager,
+ securityLicense: plugins.security?.license,
+ });
+ }
+
+ if (plugins.advancedSettings) {
+ const advancedSettingsService = new AdvancedSettingsService();
+ advancedSettingsService.setup({
+ getActiveSpace: () => this.spacesManager.getActiveSpace(),
+ componentRegistry: plugins.advancedSettings.component,
+ });
+ }
+
+ spaceSelectorApp.create({
+ getStartServices: core.getStartServices,
+ application: core.application,
+ spacesManager: this.spacesManager,
+ });
+
+ return {
+ registerLegacyAPI: (legacyAPI: LegacyAPI) => {
+ const copySavedObjectsToSpaceService = new CopySavedObjectsToSpaceService();
+ copySavedObjectsToSpaceService.setup({
+ spacesManager: this.spacesManager,
+ managementSetup: {
+ savedObjects: {
+ registry: {
+ register: action => legacyAPI.registerSavedObjectsManagementAction(action),
+ has: () => {
+ throw new Error('not available in legacy shim');
+ },
+ get: () => {
+ throw new Error('not available in legacy shim');
+ },
+ },
+ },
+ },
+ notificationsSetup: core.notifications,
+ });
+ },
+ };
+ }
+
+ public start(core: CoreStart, plugins: PluginsStart) {
+ initSpacesNavControl(this.spacesManager, core);
+
+ if (this.managementService) {
+ this.managementService.start({ capabilities: core.application.capabilities });
+ }
+
+ return {
+ activeSpace$: this.spacesManager.onActiveSpaceChange$,
+ getActiveSpace: () => this.spacesManager.getActiveSpace(),
+ };
+ }
+
+ public stop() {
+ if (this.managementService) {
+ this.managementService.stop();
+ this.managementService = undefined;
+ }
+ }
+}
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/__snapshots__/space_avatar.test.tsx.snap b/x-pack/plugins/spaces/public/space_avatar/__snapshots__/space_avatar.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/__snapshots__/space_avatar.test.tsx.snap
rename to x-pack/plugins/spaces/public/space_avatar/__snapshots__/space_avatar.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/index.ts b/x-pack/plugins/spaces/public/space_avatar/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/index.ts
rename to x-pack/plugins/spaces/public/space_avatar/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/space_attributes.test.ts b/x-pack/plugins/spaces/public/space_avatar/space_attributes.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/space_attributes.test.ts
rename to x-pack/plugins/spaces/public/space_avatar/space_attributes.test.ts
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/space_attributes.ts b/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/space_attributes.ts
rename to x-pack/plugins/spaces/public/space_avatar/space_attributes.ts
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/space_avatar.test.tsx b/x-pack/plugins/spaces/public/space_avatar/space_avatar.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/space_avatar.test.tsx
rename to x-pack/plugins/spaces/public/space_avatar/space_avatar.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/space_avatar/space_avatar.tsx b/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_avatar/space_avatar.tsx
rename to x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/__snapshots__/space_selector.test.tsx.snap b/x-pack/plugins/spaces/public/space_selector/__snapshots__/space_selector.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/__snapshots__/space_selector.test.tsx.snap
rename to x-pack/plugins/spaces/public/space_selector/__snapshots__/space_selector.test.tsx.snap
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/_index.scss b/x-pack/plugins/spaces/public/space_selector/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/_index.scss
rename to x-pack/plugins/spaces/public/space_selector/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/_space_selector.scss b/x-pack/plugins/spaces/public/space_selector/_space_selector.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/_space_selector.scss
rename to x-pack/plugins/spaces/public/space_selector/_space_selector.scss
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/_index.scss b/x-pack/plugins/spaces/public/space_selector/components/_index.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/_index.scss
rename to x-pack/plugins/spaces/public/space_selector/components/_index.scss
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/_space_card.scss b/x-pack/plugins/spaces/public/space_selector/components/_space_card.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/_space_card.scss
rename to x-pack/plugins/spaces/public/space_selector/components/_space_card.scss
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/_space_cards.scss b/x-pack/plugins/spaces/public/space_selector/components/_space_cards.scss
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/_space_cards.scss
rename to x-pack/plugins/spaces/public/space_selector/components/_space_cards.scss
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/index.ts b/x-pack/plugins/spaces/public/space_selector/components/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/index.ts
rename to x-pack/plugins/spaces/public/space_selector/components/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/space_card.test.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_card.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/space_card.test.tsx
rename to x-pack/plugins/spaces/public/space_selector/components/space_card.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/space_card.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_card.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/space_card.tsx
rename to x-pack/plugins/spaces/public/space_selector/components/space_card.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/space_cards.test.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_cards.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/space_cards.test.tsx
rename to x-pack/plugins/spaces/public/space_selector/components/space_cards.test.tsx
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/components/space_cards.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/space_selector/components/space_cards.tsx
rename to x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx
diff --git a/x-pack/legacy/plugins/spaces/common/model/types.ts b/x-pack/plugins/spaces/public/space_selector/index.tsx
similarity index 78%
rename from x-pack/legacy/plugins/spaces/common/model/types.ts
rename to x-pack/plugins/spaces/public/space_selector/index.tsx
index 58c36da33dbd7..b99689cbabab1 100644
--- a/x-pack/legacy/plugins/spaces/common/model/types.ts
+++ b/x-pack/plugins/spaces/public/space_selector/index.tsx
@@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export type GetSpacePurpose = 'any' | 'copySavedObjectsIntoSpace';
+export { spaceSelectorApp } from './space_selector_app';
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.test.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx
similarity index 82%
rename from x-pack/legacy/plugins/spaces/public/space_selector/space_selector.test.tsx
rename to x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx
index b4d0f96307500..c8173de1661be 100644
--- a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.test.tsx
+++ b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx
@@ -7,8 +7,8 @@
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { Space } from '../../common/model/space';
-import { spacesManagerMock } from '../spaces_manager/mocks';
import { SpaceSelector } from './space_selector';
+import { spacesManagerMock } from '../spaces_manager/mocks';
function getSpacesManager(spaces: Space[] = []) {
const manager = spacesManagerMock.create();
@@ -18,9 +18,7 @@ function getSpacesManager(spaces: Space[] = []) {
test('it renders without crashing', () => {
const spacesManager = getSpacesManager();
- const component = shallowWithIntl(
-
- );
+ const component = shallowWithIntl();
expect(component).toMatchSnapshot();
});
@@ -36,9 +34,7 @@ test('it queries for spaces when loaded', () => {
const spacesManager = getSpacesManager(spaces);
- shallowWithIntl(
-
- );
+ shallowWithIntl();
return Promise.resolve().then(() => {
expect(spacesManager.getSpaces).toHaveBeenCalledTimes(1);
diff --git a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx
similarity index 89%
rename from x-pack/legacy/plugins/spaces/public/space_selector/space_selector.tsx
rename to x-pack/plugins/spaces/public/space_selector/space_selector.tsx
index 206d38454fa8c..b63de399b95c9 100644
--- a/x-pack/legacy/plugins/spaces/public/space_selector/space_selector.tsx
+++ b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx
@@ -18,16 +18,18 @@ import {
EuiTitle,
EuiLoadingSpinner,
} from '@elastic/eui';
-import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
+import { i18n } from '@kbn/i18n';
+import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
-import { SpacesManager } from '../spaces_manager';
+import ReactDOM from 'react-dom';
+import { CoreStart } from 'src/core/public';
import { Space } from '../../common/model/space';
import { SpaceCards } from './components';
import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../common/constants';
+import { SpacesManager } from '../spaces_manager';
interface Props {
spacesManager: SpacesManager;
- intl: InjectedIntl;
}
interface State {
@@ -36,7 +38,7 @@ interface State {
spaces: Space[];
}
-class SpaceSelectorUI extends Component {
+export class SpaceSelector extends Component {
private headerRef?: HTMLElement | null;
constructor(props: Props) {
super(props);
@@ -152,7 +154,6 @@ class SpaceSelectorUI extends Component {
}
public getSearchField = () => {
- const { intl } = this.props;
if (!this.state.spaces || this.state.spaces.length < SPACE_SEARCH_COUNT_THRESHOLD) {
return null;
}
@@ -162,8 +163,7 @@ class SpaceSelectorUI extends Component {
// @ts-ignore onSearch doesn't exist on EuiFieldSearch
{
};
}
-export const SpaceSelector = injectI18n(SpaceSelectorUI);
+export const renderSpaceSelectorApp = (i18nStart: CoreStart['i18n'], el: Element, props: Props) => {
+ ReactDOM.render(
+
+
+ ,
+ el
+ );
+ return () => ReactDOM.unmountComponentAtNode(el);
+};
diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector_app.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector_app.tsx
new file mode 100644
index 0000000000000..29ead8d34994d
--- /dev/null
+++ b/x-pack/plugins/spaces/public/space_selector/space_selector_app.tsx
@@ -0,0 +1,36 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { CoreSetup, AppMountParameters } from 'src/core/public';
+import { i18n } from '@kbn/i18n';
+import { SpacesManager } from '../spaces_manager';
+
+interface CreateDeps {
+ application: CoreSetup['application'];
+ spacesManager: SpacesManager;
+ getStartServices: CoreSetup['getStartServices'];
+}
+
+export const spaceSelectorApp = Object.freeze({
+ id: 'space_selector',
+ create({ application, getStartServices, spacesManager }: CreateDeps) {
+ application.register({
+ id: this.id,
+ title: i18n.translate('xpack.spaces.spaceSelector.appTitle', {
+ defaultMessage: 'Select a space',
+ }),
+ chromeless: true,
+ appRoute: '/spaces/space_selector',
+ mount: async (params: AppMountParameters) => {
+ const [[coreStart], { renderSpaceSelectorApp }] = await Promise.all([
+ getStartServices(),
+ import('./space_selector'),
+ ]);
+ return renderSpaceSelectorApp(coreStart.i18n, params.element, { spacesManager });
+ },
+ });
+ },
+});
diff --git a/x-pack/legacy/plugins/spaces/public/spaces_manager/index.ts b/x-pack/plugins/spaces/public/spaces_manager/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/spaces_manager/index.ts
rename to x-pack/plugins/spaces/public/spaces_manager/index.ts
diff --git a/x-pack/legacy/plugins/spaces/public/spaces_manager/mocks.ts b/x-pack/plugins/spaces/public/spaces_manager/mocks.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/spaces_manager/mocks.ts
rename to x-pack/plugins/spaces/public/spaces_manager/mocks.ts
diff --git a/x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts
rename to x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts
diff --git a/x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.test.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.test.ts
rename to x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts
diff --git a/x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts
similarity index 95%
rename from x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.ts
rename to x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts
index e9c738cf40c69..e151dcd4f9368 100644
--- a/x-pack/legacy/plugins/spaces/public/spaces_manager/spaces_manager.ts
+++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts
@@ -6,12 +6,12 @@
import { Observable, BehaviorSubject } from 'rxjs';
import { skipWhile } from 'rxjs/operators';
import { HttpSetup } from 'src/core/public';
-import { SavedObjectsManagementRecord } from '../../../../../../src/legacy/core_plugins/management/public';
+import { SavedObjectsManagementRecord } from 'src/legacy/core_plugins/management/public';
import { Space } from '../../common/model/space';
import { GetSpacePurpose } from '../../common/model/types';
import { ENTER_SPACE_PATH } from '../../common/constants';
-import { addSpaceIdToPath } from '../../../../../plugins/spaces/common';
import { CopySavedObjectsToSpaceResponse } from '../copy_saved_objects_to_space/types';
+import { addSpaceIdToPath } from '../../common';
export class SpacesManager {
private activeSpace$: BehaviorSubject = new BehaviorSubject(null);
diff --git a/x-pack/plugins/spaces/server/index.ts b/x-pack/plugins/spaces/server/index.ts
index 18f7575ff75d6..77eb3e9c73980 100644
--- a/x-pack/plugins/spaces/server/index.ts
+++ b/x-pack/plugins/spaces/server/index.ts
@@ -17,6 +17,7 @@ import { Plugin } from './plugin';
export { SpacesPluginSetup } from './plugin';
export { SpacesServiceSetup } from './spaces_service';
+export { Space } from '../common/model/space';
export const config = { schema: ConfigSchema };
export const plugin = (initializerContext: PluginInitializerContext) =>
diff --git a/x-pack/plugins/spaces/server/plugin.ts b/x-pack/plugins/spaces/server/plugin.ts
index 52ff7eaee3d68..90c2da6e69df8 100644
--- a/x-pack/plugins/spaces/server/plugin.ts
+++ b/x-pack/plugins/spaces/server/plugin.ts
@@ -16,7 +16,6 @@ import {
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { SecurityPluginSetup } from '../../security/server';
import { LicensingPluginSetup } from '../../licensing/server';
-import { XPackMainPlugin } from '../../../legacy/plugins/xpack_main/server/xpack_main';
import { createDefaultSpace } from './lib/create_default_space';
// @ts-ignore
import { AuditLogger } from '../../../../server/lib/audit_logger';
@@ -31,6 +30,7 @@ import { toggleUICapabilities } from './lib/toggle_ui_capabilities';
import { initSpacesRequestInterceptors } from './lib/request_interceptors';
import { initExternalSpacesApi } from './routes/api/external';
import { initInternalSpacesApi } from './routes/api/internal';
+import { initSpacesViewsRoutes } from './routes/views';
/**
* Describes a set of APIs that is available in the legacy platform only and required by this plugin
@@ -44,7 +44,6 @@ export interface LegacyAPI {
legacyConfig: {
kibanaIndex: string;
};
- xpackMain: XPackMainPlugin;
}
export interface PluginsSetup {
@@ -109,6 +108,12 @@ export class Plugin {
config$: this.config$,
});
+ const viewRouter = core.http.createRouter();
+ initSpacesViewsRoutes({
+ viewRouter,
+ cspHeader: core.http.csp.header,
+ });
+
const externalRouter = core.http.createRouter();
initExternalSpacesApi({
externalRouter,
diff --git a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_legacy_api.ts b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_legacy_api.ts
index dfeb094e34e25..812b02e94f591 100644
--- a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_legacy_api.ts
+++ b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_legacy_api.ts
@@ -104,7 +104,6 @@ export const createLegacyAPI = ({
kibanaIndex: '',
},
auditLogger: {} as any,
- xpackMain: {} as any,
savedObjects: savedObjectsService,
};
diff --git a/x-pack/plugins/spaces/server/routes/views/index.ts b/x-pack/plugins/spaces/server/routes/views/index.ts
new file mode 100644
index 0000000000000..2a346c7e5241a
--- /dev/null
+++ b/x-pack/plugins/spaces/server/routes/views/index.ts
@@ -0,0 +1,29 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { IRouter } from 'src/core/server';
+
+export interface ViewRouteDeps {
+ viewRouter: IRouter;
+ cspHeader: string;
+}
+
+export function initSpacesViewsRoutes(deps: ViewRouteDeps) {
+ deps.viewRouter.get(
+ {
+ path: '/spaces/space_selector',
+ validate: false,
+ },
+ async (context, request, response) => {
+ return response.ok({
+ headers: {
+ 'Content-Security-Policy': deps.cspHeader,
+ },
+ body: await context.core.rendering.render({ includeUserSettings: true }),
+ });
+ }
+ );
+}
diff --git a/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts b/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts
index d71d197a6ea19..9ca314ba5ec18 100644
--- a/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts
+++ b/x-pack/test/functional/apps/spaces/feature_controls/spaces_security.ts
@@ -66,7 +66,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
});
it(`can navigate to spaces grid page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/list', {
+ await PageObjects.common.navigateToActualUrl('kibana', 'management/kibana/spaces', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
@@ -75,7 +75,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
});
it(`can navigate to create new space page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/create', {
+ await PageObjects.common.navigateToActualUrl('kibana', 'management/kibana/spaces/create', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
@@ -84,10 +84,14 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
});
it(`can navigate to edit space page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/edit/default', {
- ensureCurrentUrl: false,
- shouldLoginIfPrompted: false,
- });
+ await PageObjects.common.navigateToActualUrl(
+ 'kibana',
+ 'management/kibana/spaces/edit/default',
+ {
+ ensureCurrentUrl: false,
+ shouldLoginIfPrompted: false,
+ }
+ );
await testSubjects.existOrFail('spaces-edit-page');
});
@@ -136,35 +140,39 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
it(`doesn't display Spaces management section`, async () => {
await PageObjects.settings.navigateTo();
- await testSubjects.existOrFail('objects'); // this ensures we've gotten to the management page
+ await testSubjects.existOrFail('management-landing'); // this ensures we've gotten to the management page
await testSubjects.missingOrFail('spaces');
});
it(`can't navigate to spaces grid page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/list', {
+ await PageObjects.common.navigateToActualUrl('kibana', 'management/kibana/spaces', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
- await testSubjects.existOrFail('homeApp');
+ await testSubjects.existOrFail('management-landing');
});
it(`can't navigate to create new space page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/create', {
+ await PageObjects.common.navigateToActualUrl('kibana', 'management/kibana/spaces/create', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
- await testSubjects.existOrFail('homeApp');
+ await testSubjects.existOrFail('management-landing');
});
it(`can't navigate to edit space page`, async () => {
- await PageObjects.common.navigateToActualUrl('kibana', 'management/spaces/edit/default', {
- ensureCurrentUrl: false,
- shouldLoginIfPrompted: false,
- });
+ await PageObjects.common.navigateToActualUrl(
+ 'kibana',
+ 'management/kibana/spaces/edit/default',
+ {
+ ensureCurrentUrl: false,
+ shouldLoginIfPrompted: false,
+ }
+ );
- await testSubjects.existOrFail('homeApp');
+ await testSubjects.existOrFail('management-landing');
});
});
});
diff --git a/x-pack/test/saved_object_api_integration/common/lib/space_test_utils.ts b/x-pack/test/saved_object_api_integration/common/lib/space_test_utils.ts
index d858177dc62ca..1619d77761c84 100644
--- a/x-pack/test/saved_object_api_integration/common/lib/space_test_utils.ts
+++ b/x-pack/test/saved_object_api_integration/common/lib/space_test_utils.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
export function getUrlPrefix(spaceId: string) {
return spaceId && spaceId !== DEFAULT_SPACE_ID ? `/s/${spaceId}` : ``;
diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts
index d719543fa3807..b6f1bb956d72d 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts
index ab7babff8dead..9c5cc375502d1 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_get.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts
index e0cc1498d71ca..d14c5ccbd1d0e 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_update.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/create.ts b/x-pack/test/saved_object_api_integration/common/suites/create.ts
index 3ee0548b707bc..29960c513d40f 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/create.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/create.ts
@@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/delete.ts b/x-pack/test/saved_object_api_integration/common/suites/delete.ts
index 9581a2b3983ef..d96ae5446d732 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/delete.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/delete.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/export.ts b/x-pack/test/saved_object_api_integration/common/suites/export.ts
index 114a1fe53ccd6..4a56d18342dc9 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/export.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/export.ts
@@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/find.ts b/x-pack/test/saved_object_api_integration/common/suites/find.ts
index 6799f0ec63846..f270fc8f4db05 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/find.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/find.ts
@@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/get.ts b/x-pack/test/saved_object_api_integration/common/suites/get.ts
index 39bfc5df4d6e3..c98209ca1e105 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/get.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/get.ts
@@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts
index 8e4ef61cf3c12..f6723c912f82e 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/import.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts
index 8ae3a1258ab3a..1b538b9b1b65d 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/saved_object_api_integration/common/suites/update.ts b/x-pack/test/saved_object_api_integration/common/suites/update.ts
index cd291c53c5f34..d6b7602c0114a 100644
--- a/x-pack/test/saved_object_api_integration/common/suites/update.ts
+++ b/x-pack/test/saved_object_api_integration/common/suites/update.ts
@@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { getIdPrefix, getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';
diff --git a/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts b/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts
index 9206e48afe9a4..f233bc1d11d7c 100644
--- a/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts
+++ b/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
export function getUrlPrefix(spaceId?: string) {
return spaceId && spaceId !== DEFAULT_SPACE_ID ? `/s/${spaceId}` : ``;
diff --git a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts
index 20b4d024803d7..071067ffa85cb 100644
--- a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts
+++ b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts
@@ -8,7 +8,7 @@ import expect from '@kbn/expect';
import { SuperTest } from 'supertest';
import { EsArchiver } from 'src/es_archiver';
import { SavedObject } from 'src/core/server';
-import { DEFAULT_SPACE_ID } from '../../../../legacy/plugins/spaces/common/constants';
+import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants';
import { CopyResponse } from '../../../../plugins/spaces/server/lib/copy_to_spaces';
import { getUrlPrefix } from '../lib/space_test_utils';
import { DescribeFn, TestDefinitionAuthentication } from '../lib/types';