From 07a3756a62ec8b5998233f099684d53e06c4c831 Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Tue, 12 Jan 2021 12:26:40 -0500 Subject: [PATCH] Create Spaces OSS plugin (#87585) --- .github/CODEOWNERS | 1 + docs/developer/plugin-list.asciidoc | 4 ++ packages/kbn-optimizer/limits.yml | 1 + src/plugins/spaces_oss/README.md | 3 + src/plugins/spaces_oss/common/index.ts | 20 ++++++ src/plugins/spaces_oss/common/types.ts | 29 +++++++++ src/plugins/spaces_oss/jest.config.js | 24 +++++++ src/plugins/spaces_oss/kibana.json | 8 +++ src/plugins/spaces_oss/public/api.mock.ts | 30 +++++++++ src/plugins/spaces_oss/public/api.ts | 29 +++++++++ src/plugins/spaces_oss/public/index.ts | 26 ++++++++ src/plugins/spaces_oss/public/mocks/index.ts | 35 ++++++++++ src/plugins/spaces_oss/public/plugin.test.ts | 65 +++++++++++++++++++ src/plugins/spaces_oss/public/plugin.ts | 52 +++++++++++++++ src/plugins/spaces_oss/public/types.ts | 39 +++++++++++ src/plugins/spaces_oss/tsconfig.json | 17 +++++ tsconfig.json | 4 +- tsconfig.refs.json | 1 + .../privilege_summary/privilege_summary.tsx | 2 +- .../privilege_summary_table.tsx | 2 +- .../space_selector.tsx | 3 +- .../secure_spaces_client_wrapper.test.ts | 2 +- .../spaces/secure_spaces_client_wrapper.ts | 14 ++-- x-pack/plugins/spaces/common/index.ts | 1 + .../spaces/common/is_reserved_space.test.ts | 2 +- .../spaces/common/is_reserved_space.ts | 2 +- x-pack/plugins/spaces/common/model/space.ts | 16 ----- .../spaces/common/{model => }/types.ts | 7 +- x-pack/plugins/spaces/kibana.json | 2 +- .../advanced_settings_service.tsx | 2 +- .../advanced_settings_subtitle.tsx | 2 +- .../advanced_settings_title.tsx | 2 +- .../copy_status_summary_indicator.tsx | 2 +- .../components/copy_to_space_flyout.test.tsx | 2 +- .../components/copy_to_space_flyout.tsx | 2 +- .../components/copy_to_space_form.tsx | 2 +- .../components/processing_copy_to_space.tsx | 2 +- .../components/selectable_spaces_control.tsx | 2 +- .../components/space_result.tsx | 2 +- .../components/space_result_details.tsx | 2 +- x-pack/plugins/spaces/public/index.ts | 9 +-- .../confirm_delete_modal.tsx | 2 +- .../customize_space/customize_space.tsx | 2 +- .../customize_space_avatar.tsx | 2 +- .../customize_space/space_identifier.tsx | 2 +- .../edit_space/delete_spaces_button.tsx | 2 +- .../enabled_features/enabled_features.tsx | 2 +- .../enabled_features/feature_table.tsx | 2 +- .../edit_space/manage_space_page.tsx | 2 +- .../edit_space/reserved_space_badge.tsx | 2 +- .../public/management/lib/validate_space.ts | 2 +- .../spaces_grid/spaces_grid_page.tsx | 2 +- .../nav_control/components/spaces_menu.tsx | 2 +- .../nav_control/nav_control_popover.tsx | 2 +- x-pack/plugins/spaces/public/plugin.test.ts | 19 ++++-- x-pack/plugins/spaces/public/plugin.tsx | 20 ++++-- .../components/share_to_space_flyout.test.tsx | 2 +- .../components/share_to_space_flyout.tsx | 2 +- .../public/space_avatar/space_attributes.ts | 2 +- .../public/space_avatar/space_avatar.tsx | 2 +- .../space_selector/components/space_cards.tsx | 2 +- .../space_selector/space_selector.test.tsx | 2 +- .../public/space_selector/space_selector.tsx | 2 +- .../spaces_manager/spaces_manager.mock.ts | 2 +- .../public/spaces_manager/spaces_manager.ts | 20 +++--- .../capabilities_switcher.test.ts | 2 +- .../capabilities/capabilities_switcher.ts | 2 +- x-pack/plugins/spaces/server/index.ts | 6 +- .../on_post_auth_interceptor.ts | 2 +- .../server/routes/api/external/get_all.ts | 2 +- .../spaces/server/routes/api/external/put.ts | 2 +- .../lib/convert_saved_object_to_space.ts | 2 +- .../spaces_client/spaces_client.mock.ts | 2 +- .../spaces_client/spaces_client.test.ts | 2 +- .../server/spaces_client/spaces_client.ts | 9 +-- 75 files changed, 496 insertions(+), 108 deletions(-) create mode 100644 src/plugins/spaces_oss/README.md create mode 100644 src/plugins/spaces_oss/common/index.ts create mode 100644 src/plugins/spaces_oss/common/types.ts create mode 100644 src/plugins/spaces_oss/jest.config.js create mode 100644 src/plugins/spaces_oss/kibana.json create mode 100644 src/plugins/spaces_oss/public/api.mock.ts create mode 100644 src/plugins/spaces_oss/public/api.ts create mode 100644 src/plugins/spaces_oss/public/index.ts create mode 100644 src/plugins/spaces_oss/public/mocks/index.ts create mode 100644 src/plugins/spaces_oss/public/plugin.test.ts create mode 100644 src/plugins/spaces_oss/public/plugin.ts create mode 100644 src/plugins/spaces_oss/public/types.ts create mode 100644 src/plugins/spaces_oss/tsconfig.json delete mode 100644 x-pack/plugins/spaces/common/model/space.ts rename x-pack/plugins/spaces/common/{model => }/types.ts (72%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cbdf292964472..5c768dccaf274 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -236,6 +236,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib # Security /src/core/server/csp/ @elastic/kibana-security @elastic/kibana-core /src/plugins/security_oss/ @elastic/kibana-security +/src/plugins/spaces_oss/ @elastic/kibana-security /test/security_functional/ @elastic/kibana-security /x-pack/plugins/spaces/ @elastic/kibana-security /x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index c79e46c1d9173..ba2ea98cad5e6 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -194,6 +194,10 @@ so they can properly protect the data within their clusters. |Replaces the legacy ui/share module for registering share context menus. +|{kib-repo}blob/{branch}/src/plugins/spaces_oss/README.md[spacesOss] +|Bridge plugin for consumption of the Spaces feature from OSS plugins. + + |{kib-repo}blob/{branch}/src/plugins/telemetry/README.md[telemetry] |Telemetry allows Kibana features to have usage tracked in the wild. The general term "telemetry" refers to multiple things: diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 67287089489e1..485481e2a7f14 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -106,3 +106,4 @@ pageLoadAssetSize: stackAlerts: 29684 presentationUtil: 28545 runtimeFieldEditor: 46986 + spacesOss: 18817 diff --git a/src/plugins/spaces_oss/README.md b/src/plugins/spaces_oss/README.md new file mode 100644 index 0000000000000..73de736d6fb4e --- /dev/null +++ b/src/plugins/spaces_oss/README.md @@ -0,0 +1,3 @@ +# SpacesOss + +Bridge plugin for consumption of the Spaces feature from OSS plugins. diff --git a/src/plugins/spaces_oss/common/index.ts b/src/plugins/spaces_oss/common/index.ts new file mode 100644 index 0000000000000..8a04df861b5e5 --- /dev/null +++ b/src/plugins/spaces_oss/common/index.ts @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { Space } from './types'; diff --git a/src/plugins/spaces_oss/common/types.ts b/src/plugins/spaces_oss/common/types.ts new file mode 100644 index 0000000000000..6eff95a8d3d9f --- /dev/null +++ b/src/plugins/spaces_oss/common/types.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +export interface Space { + id: string; + name: string; + description?: string; + color?: string; + initials?: string; + disabledFeatures: string[]; + _reserved?: boolean; + imageUrl?: string; +} diff --git a/src/plugins/spaces_oss/jest.config.js b/src/plugins/spaces_oss/jest.config.js new file mode 100644 index 0000000000000..d60652d15bfad --- /dev/null +++ b/src/plugins/spaces_oss/jest.config.js @@ -0,0 +1,24 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/src/plugins/spaces_oss'], +}; diff --git a/src/plugins/spaces_oss/kibana.json b/src/plugins/spaces_oss/kibana.json new file mode 100644 index 0000000000000..e048fb7ffb79c --- /dev/null +++ b/src/plugins/spaces_oss/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "spacesOss", + "version": "kibana", + "server": false, + "ui": true, + "requiredPlugins": [], + "optionalPlugins": [] +} diff --git a/src/plugins/spaces_oss/public/api.mock.ts b/src/plugins/spaces_oss/public/api.mock.ts new file mode 100644 index 0000000000000..21d991c33e382 --- /dev/null +++ b/src/plugins/spaces_oss/public/api.mock.ts @@ -0,0 +1,30 @@ +/* + * 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 { of } from 'rxjs'; +import { SpacesApi } from './api'; + +const createApiMock = (): jest.Mocked => ({ + activeSpace$: of(), + getActiveSpace: jest.fn(), +}); + +export const spacesApiMock = { + create: createApiMock, +}; diff --git a/src/plugins/spaces_oss/public/api.ts b/src/plugins/spaces_oss/public/api.ts new file mode 100644 index 0000000000000..7725175a5b873 --- /dev/null +++ b/src/plugins/spaces_oss/public/api.ts @@ -0,0 +1,29 @@ +/* + * 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 { Observable } from 'rxjs'; +import { Space } from '../common'; + +/** + * @public + */ +export interface SpacesApi { + readonly activeSpace$: Observable; + getActiveSpace(): Promise; +} diff --git a/src/plugins/spaces_oss/public/index.ts b/src/plugins/spaces_oss/public/index.ts new file mode 100644 index 0000000000000..f6e551053ae6c --- /dev/null +++ b/src/plugins/spaces_oss/public/index.ts @@ -0,0 +1,26 @@ +/* + * 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 { SpacesOssPlugin } from './plugin'; + +export { SpacesOssPluginSetup, SpacesOssPluginStart } from './types'; + +export { SpacesApi } from './api'; + +export const plugin = () => new SpacesOssPlugin(); diff --git a/src/plugins/spaces_oss/public/mocks/index.ts b/src/plugins/spaces_oss/public/mocks/index.ts new file mode 100644 index 0000000000000..f201ed9334804 --- /dev/null +++ b/src/plugins/spaces_oss/public/mocks/index.ts @@ -0,0 +1,35 @@ +/* + * 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 { spacesApiMock } from '../api.mock'; +import { SpacesOssPluginSetup, SpacesOssPluginStart } from '..'; + +const createSetupContract = (): jest.Mocked => ({ + registerSpacesApi: jest.fn(), +}); + +const createStartContract = (): jest.Mocked => ({ + isSpacesAvailable: true, + ...spacesApiMock.create(), +}); + +export const spacesOssPluginMock = { + createSetupContract, + createStartContract, +}; diff --git a/src/plugins/spaces_oss/public/plugin.test.ts b/src/plugins/spaces_oss/public/plugin.test.ts new file mode 100644 index 0000000000000..4099c9a7eb4c0 --- /dev/null +++ b/src/plugins/spaces_oss/public/plugin.test.ts @@ -0,0 +1,65 @@ +/* + * 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 { spacesApiMock } from './api.mock'; +import { SpacesOssPlugin } from './plugin'; + +describe('SpacesOssPlugin', () => { + let plugin: SpacesOssPlugin; + + beforeEach(() => { + plugin = new SpacesOssPlugin(); + }); + + describe('#setup', () => { + it('only allows the API to be registered once', async () => { + const spacesApi = spacesApiMock.create(); + const { registerSpacesApi } = plugin.setup(); + + expect(() => registerSpacesApi(spacesApi)).not.toThrow(); + + expect(() => registerSpacesApi(spacesApi)).toThrowErrorMatchingInlineSnapshot( + `"Spaces API can only be registered once"` + ); + }); + }); + + describe('#start', () => { + it('returns the spaces API if registered', async () => { + const spacesApi = spacesApiMock.create(); + const { registerSpacesApi } = plugin.setup(); + + registerSpacesApi(spacesApi); + + const { isSpacesAvailable, ...api } = plugin.start(); + + expect(isSpacesAvailable).toBe(true); + expect(api).toStrictEqual(spacesApi); + }); + + it('does not return the spaces API if not registered', async () => { + plugin.setup(); + + const { isSpacesAvailable, ...api } = plugin.start(); + + expect(isSpacesAvailable).toBe(false); + expect(Object.keys(api)).toHaveLength(0); + }); + }); +}); diff --git a/src/plugins/spaces_oss/public/plugin.ts b/src/plugins/spaces_oss/public/plugin.ts new file mode 100644 index 0000000000000..93b1c7696f0fb --- /dev/null +++ b/src/plugins/spaces_oss/public/plugin.ts @@ -0,0 +1,52 @@ +/* + * 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 { Plugin } from 'src/core/public'; +import { SpacesOssPluginSetup, SpacesOssPluginStart } from './types'; +import { SpacesApi } from './api'; + +export class SpacesOssPlugin implements Plugin { + private api?: SpacesApi; + + constructor() {} + + public setup() { + return { + registerSpacesApi: (provider: SpacesApi) => { + if (this.api) { + throw new Error('Spaces API can only be registered once'); + } + this.api = provider; + }, + }; + } + + public start() { + if (this.api) { + return { + isSpacesAvailable: true as true, + ...this.api!, + }; + } else { + return { + isSpacesAvailable: false as false, + }; + } + } +} diff --git a/src/plugins/spaces_oss/public/types.ts b/src/plugins/spaces_oss/public/types.ts new file mode 100644 index 0000000000000..e089231513e23 --- /dev/null +++ b/src/plugins/spaces_oss/public/types.ts @@ -0,0 +1,39 @@ +/* + * 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 { SpacesApi } from './api'; + +interface SpacesAvailableStartContract extends SpacesApi { + isSpacesAvailable: true; +} + +interface SpacesUnavailableStartContract { + isSpacesAvailable: false; +} + +export interface SpacesOssPluginSetup { + /** + * Register a provider for the Spaces API. + * + * Only one provider can be registered, subsequent calls to this method will fail. + */ + registerSpacesApi(provider: SpacesApi): void; +} + +export type SpacesOssPluginStart = SpacesAvailableStartContract | SpacesUnavailableStartContract; diff --git a/src/plugins/spaces_oss/tsconfig.json b/src/plugins/spaces_oss/tsconfig.json new file mode 100644 index 0000000000000..0cc82d7e5d124 --- /dev/null +++ b/src/plugins/spaces_oss/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "public/**/*", + ], + "references": [ + { "path": "../../core/tsconfig.json" }, + ] +} diff --git a/tsconfig.json b/tsconfig.json index 259449c67444a..1d8c61d515fdf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,9 +27,10 @@ "src/plugins/navigation/**/*", "src/plugins/newsfeed/**/*", "src/plugins/saved_objects/**/*", - "src/plugins/security_oss/**/*", "src/plugins/saved_objects_tagging_oss/**/*", + "src/plugins/security_oss/**/*", "src/plugins/share/**/*", + "src/plugins/spaces_oss/**/*", "src/plugins/telemetry/**/*", "src/plugins/telemetry_collection_manager/**/*", "src/plugins/ui_actions/**/*", @@ -67,6 +68,7 @@ { "path": "./src/plugins/saved_objects_tagging_oss/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, + { "path": "./src/plugins/spaces_oss/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "./src/plugins/ui_actions/tsconfig.json" }, diff --git a/tsconfig.refs.json b/tsconfig.refs.json index 91ee34c490f7b..d6e87da6ac19d 100644 --- a/tsconfig.refs.json +++ b/tsconfig.refs.json @@ -27,6 +27,7 @@ { "path": "./src/plugins/presentation_util/tsconfig.json" }, { "path": "./src/plugins/security_oss/tsconfig.json" }, { "path": "./src/plugins/share/tsconfig.json" }, + { "path": "./src/plugins/spaces_oss/tsconfig.json" }, { "path": "./src/plugins/telemetry/tsconfig.json" }, { "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" }, { "path": "./src/plugins/ui_actions/tsconfig.json" }, diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx index aa37b95ba3f2a..c99fd4f03b134 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.tsx @@ -9,7 +9,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButtonEmpty, EuiOverlayMask, EuiButton } from '@elastic/eui'; import { EuiFlyout } from '@elastic/eui'; import { EuiFlyoutHeader, EuiTitle, EuiFlyoutBody, EuiFlyoutFooter } from '@elastic/eui'; -import { Space } from '../../../../../../../../spaces/common/model/space'; +import { Space } from '../../../../../../../../spaces/public'; import { Role } from '../../../../../../../common/model'; import { PrivilegeSummaryTable } from './privilege_summary_table'; import { KibanaPrivileges } from '../../../../model'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx index 8d24c0b220863..b503a24d649da 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.tsx @@ -18,7 +18,7 @@ import { EuiAccordion, EuiTitle, } from '@elastic/eui'; -import { Space } from '../../../../../../../../spaces/common/model/space'; +import { Space } from '../../../../../../../../spaces/public'; import { Role, RoleKibanaPrivilege } from '../../../../../../../common/model'; import { isGlobalPrivilegeDefinition } from '../../../privilege_utils'; import { FeatureTableCell } from '../feature_table_cell'; 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 4344cd4b0784e..b70c1748b283b 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, EuiComboBoxOptionOption, EuiHealth, EuiHighlight } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { Component } from 'react'; -import { getSpaceColor } from '../../../../../../../../spaces/public'; -import { Space } from '../../../../../../../../spaces/common/model/space'; +import { getSpaceColor, Space } from '../../../../../../../../spaces/public'; const spaceToOption = (space?: Space, currentSelection?: 'global' | 'spaces') => { if (!space) { diff --git a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts index 24f26c3827056..d4657a3a5655e 100644 --- a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts +++ b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.test.ts @@ -14,7 +14,7 @@ import { deepFreeze } from '@kbn/std'; import { Space } from '../../../spaces/server'; import { authorizationMock } from '../authorization/index.mock'; import { AuthorizationServiceSetup } from '../authorization'; -import { GetAllSpacesPurpose } from '../../../spaces/common/model/types'; +import { GetAllSpacesPurpose } from '../../../spaces/server'; import { CheckPrivilegesResponse } from '../authorization/types'; import { LegacySpacesAuditLogger } from './legacy_audit_logger'; import { SavedObjectsErrorHelpers } from 'src/core/server'; diff --git a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.ts b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.ts index a0b174d979a8d..6325e5e7f8eec 100644 --- a/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.ts +++ b/x-pack/plugins/security/server/spaces/secure_spaces_client_wrapper.ts @@ -6,8 +6,13 @@ import Boom from '@hapi/boom'; import { KibanaRequest } from 'src/core/server'; -import { GetAllSpacesPurpose, GetSpaceResult } from '../../../spaces/common/model/types'; -import { Space, ISpacesClient } from '../../../spaces/server'; +import { + Space, + ISpacesClient, + GetAllSpacesOptions, + GetAllSpacesPurpose, + GetSpaceResult, +} from '../../../spaces/server'; import { LegacySpacesAuditLogger } from './legacy_audit_logger'; import { AuthorizationServiceSetup } from '../authorization'; import { AuditLogger, EventOutcome, SpaceAuditAction, spaceAuditEvent } from '../audit'; @@ -29,11 +34,6 @@ const PURPOSE_PRIVILEGE_MAP: Record< ], }; -interface GetAllSpacesOptions { - purpose?: GetAllSpacesPurpose; - includeAuthorizedPurposes?: boolean; -} - export class SecureSpacesClientWrapper implements ISpacesClient { private readonly useRbac = this.authorization.mode.useRbacForRequest(this.request); diff --git a/x-pack/plugins/spaces/common/index.ts b/x-pack/plugins/spaces/common/index.ts index 703722fcf8f52..4840898dda983 100644 --- a/x-pack/plugins/spaces/common/index.ts +++ b/x-pack/plugins/spaces/common/index.ts @@ -7,3 +7,4 @@ export { isReservedSpace } from './is_reserved_space'; export { MAX_SPACE_INITIALS, SPACE_SEARCH_COUNT_THRESHOLD, ENTER_SPACE_PATH } from './constants'; export { addSpaceIdToPath, getSpaceIdFromPath } from './lib/spaces_url_parser'; +export { GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult } from './types'; diff --git a/x-pack/plugins/spaces/common/is_reserved_space.test.ts b/x-pack/plugins/spaces/common/is_reserved_space.test.ts index dd1372183ed8a..4f2069fa28dd5 100644 --- a/x-pack/plugins/spaces/common/is_reserved_space.test.ts +++ b/x-pack/plugins/spaces/common/is_reserved_space.test.ts @@ -5,7 +5,7 @@ */ import { isReservedSpace } from './is_reserved_space'; -import { Space } from './model/space'; +import { Space } from '../../../../src/plugins/spaces_oss/common'; test('it returns true for reserved spaces', () => { const space: Space = { diff --git a/x-pack/plugins/spaces/common/is_reserved_space.ts b/x-pack/plugins/spaces/common/is_reserved_space.ts index 788ef80c194ce..7904b48dd8c7c 100644 --- a/x-pack/plugins/spaces/common/is_reserved_space.ts +++ b/x-pack/plugins/spaces/common/is_reserved_space.ts @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { Space } from './model/space'; +import { Space } from '../../../../src/plugins/spaces_oss/common'; /** * Returns whether the given Space is reserved or not. diff --git a/x-pack/plugins/spaces/common/model/space.ts b/x-pack/plugins/spaces/common/model/space.ts deleted file mode 100644 index c44ce41ec51c0..0000000000000 --- a/x-pack/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/plugins/spaces/common/model/types.ts b/x-pack/plugins/spaces/common/types.ts similarity index 72% rename from x-pack/plugins/spaces/common/model/types.ts rename to x-pack/plugins/spaces/common/types.ts index 465bbce756864..a75db7dbcb0f8 100644 --- a/x-pack/plugins/spaces/common/model/types.ts +++ b/x-pack/plugins/spaces/common/types.ts @@ -4,7 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Space } from './space'; +import type { Space } from '../../../../src/plugins/spaces_oss/common'; + +export interface GetAllSpacesOptions { + purpose?: GetAllSpacesPurpose; + includeAuthorizedPurposes?: boolean; +} export type GetAllSpacesPurpose = | 'any' diff --git a/x-pack/plugins/spaces/kibana.json b/x-pack/plugins/spaces/kibana.json index 62a86409d8889..e67931d4a3b8d 100644 --- a/x-pack/plugins/spaces/kibana.json +++ b/x-pack/plugins/spaces/kibana.json @@ -3,7 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": ["xpack", "spaces"], - "requiredPlugins": ["features", "licensing"], + "requiredPlugins": ["features", "licensing", "spacesOss"], "optionalPlugins": [ "advancedSettings", "home", diff --git a/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx index 5dedb285014f8..ee4f09b03dc44 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/advanced_settings_service.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; import { AdvancedSettingsSetup } from 'src/plugins/advanced_settings/public'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { AdvancedSettingsTitle, AdvancedSettingsSubtitle } from './components'; interface SetupDeps { diff --git a/x-pack/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 index 29c0a0f6a53d7..810a4dce3c347 100644 --- a/x-pack/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 @@ -7,7 +7,7 @@ import { EuiCallOut, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Fragment, useState, useEffect } from 'react'; -import { Space } from '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; interface Props { getActiveSpace: () => Promise; diff --git a/x-pack/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 index 3364551620235..6c7793ad7be77 100644 --- a/x-pack/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 '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { SpaceAvatar } from '../../../space_avatar'; interface Props { diff --git a/x-pack/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 index 4dfb14e756cd6..b31d28d4576e8 100644 --- a/x-pack/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 @@ -8,7 +8,7 @@ import './copy_status_summary_indicator.scss'; import React, { Fragment } from 'react'; import { EuiLoadingSpinner, EuiIconTip, EuiBadge } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { ImportRetry } from '../types'; import { ResolveAllConflicts } from './resolve_all_conflicts'; import { SummarizedCopyToSpaceResult } from '..'; diff --git a/x-pack/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 index 96fc3bacd59ba..5ede5f8a38797 100644 --- a/x-pack/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 @@ -9,7 +9,7 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { CopySavedObjectsToSpaceFlyout } from './copy_to_space_flyout'; import { CopyToSpaceForm } from './copy_to_space_form'; import { EuiLoadingSpinner, EuiEmptyPrompt } from '@elastic/eui'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { findTestSubject } from '@kbn/test/jest'; import { SelectableSpacesControl } from './selectable_spaces_control'; import { CopyModeControl } from './copy_mode_control'; diff --git a/x-pack/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 index aeb6aab8c8dad..325917f2622ea 100644 --- a/x-pack/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 @@ -27,7 +27,7 @@ import { processImportResponse, SavedObjectsManagementRecord, } from '../../../../../../src/plugins/saved_objects_management/public'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SpacesManager } from '../../spaces_manager'; import { ProcessingCopyToSpace } from './processing_copy_to_space'; import { CopyToSpaceFlyoutFooter } from './copy_to_space_flyout_footer'; diff --git a/x-pack/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 index 9c38b747ba074..91aff2ef0c315 100644 --- a/x-pack/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 @@ -9,7 +9,7 @@ import { EuiSpacer, EuiTitle, EuiFormRow } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { CopyOptions } from '../types'; import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SelectableSpacesControl } from './selectable_spaces_control'; import { CopyModeControl, CopyMode } from './copy_mode_control'; diff --git a/x-pack/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 index ab8fb0b438f67..b4b68ea01586a 100644 --- a/x-pack/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 @@ -17,7 +17,7 @@ import { ProcessedImportResponse, SavedObjectsManagementRecord, } from 'src/plugins/saved_objects_management/public'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { CopyOptions, ImportRetry } from '../types'; import { SpaceResult, SpaceResultProcessing } from './space_result'; import { summarizeCopyResult } from '..'; diff --git a/x-pack/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 index bfd25ba4de0bb..eb83d58babffe 100644 --- a/x-pack/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 @@ -8,8 +8,8 @@ import './selectable_spaces_control.scss'; import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSelectable, EuiSelectableOption, EuiLoadingSpinner, EuiIconTip } from '@elastic/eui'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SpaceAvatar } from '../../space_avatar'; -import { Space } from '../../../common/model/space'; interface Props { spaces: Space[]; diff --git a/x-pack/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 index eefd9f8ea2467..b8fc26dc95618 100644 --- a/x-pack/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 @@ -15,9 +15,9 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SummarizedCopyToSpaceResult } from '../index'; import { SpaceAvatar } from '../../space_avatar'; -import { Space } from '../../../common/model/space'; import { CopyStatusSummaryIndicator } from './copy_status_summary_indicator'; import { SpaceCopyResultDetails } from './space_result_details'; import { ImportRetry } from '../types'; diff --git a/x-pack/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 index 776ed99c41120..3efdea499ed0d 100644 --- a/x-pack/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 @@ -24,7 +24,7 @@ import { EuiSuperSelect } from '@elastic/eui'; import moment from 'moment'; import { SummarizedCopyToSpaceResult } from '../index'; import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { CopyStatusIndicator } from './copy_status_indicator'; import { ImportRetry } from '../types'; diff --git a/x-pack/plugins/spaces/public/index.ts b/x-pack/plugins/spaces/public/index.ts index 5fc56dfb7a295..5bd3b5f00aee6 100644 --- a/x-pack/plugins/spaces/public/index.ts +++ b/x-pack/plugins/spaces/public/index.ts @@ -6,16 +6,17 @@ import { SpacesPlugin } from './plugin'; -export { Space } from '../common/model/space'; - -export { GetSpaceResult } from '../common/model/types'; - export { SpaceAvatar, getSpaceColor, getSpaceImageUrl, getSpaceInitials } from './space_avatar'; export { SpacesPluginSetup, SpacesPluginStart } from './plugin'; export { SpacesManager } from './spaces_manager'; +export { GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult } from '../common'; + +// re-export types from oss definition +export type { Space } from '../../../../src/plugins/spaces_oss/common'; + export const plugin = () => { return new SpacesPlugin(); }; diff --git a/x-pack/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 index 06347a58a70ee..dd31aee639db5 100644 --- a/x-pack/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 @@ -24,8 +24,8 @@ import { } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { ChangeEvent, Component } from 'react'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { SpacesManager } from '../../../spaces_manager'; -import { Space } from '../../../../../../plugins/spaces/common/model/space'; interface Props { space: Space; diff --git a/x-pack/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 index 95295b8e64732..e8e19a2274922 100644 --- a/x-pack/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 @@ -17,8 +17,8 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import React, { ChangeEvent, Component, Fragment } from 'react'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { isReservedSpace } from '../../../../common'; -import { Space } from '../../../../common/model/space'; import { SpaceAvatar } from '../../../space_avatar'; import { SpaceValidator, toSpaceIdentifier } from '../../lib'; import { SectionPanel } from '../section_panel'; diff --git a/x-pack/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 index 614e9a0f7faf0..d933eaa920b81 100644 --- a/x-pack/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 @@ -17,7 +17,7 @@ import { isValidHex, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Space } from '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { imageTypes, encode } from '../../../../common/lib/dataurl'; import { getSpaceColor, getSpaceInitials } from '../../../space_avatar'; import { MAX_SPACE_INITIALS } from '../../../../common'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.tsx index e7643d233f229..eae0aa325dd43 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.tsx @@ -7,7 +7,7 @@ import { EuiFieldText, EuiFormRow, EuiLink } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { ChangeEvent, Component, Fragment } from 'react'; -import { Space } from '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { SpaceValidator, toSpaceIdentifier } from '../../lib'; interface Props { diff --git a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx index a03d42d10c30f..ae3fa41a8373c 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.tsx @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import { NotificationsStart } from 'src/core/public'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SpacesManager } from '../../spaces_manager'; import { ConfirmDeleteModal } from '../components/confirm_delete_modal'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx index 7d8516f396e79..9429472d9e342 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.tsx @@ -9,8 +9,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment, ReactNode } from 'react'; import { ApplicationStart } from 'kibana/public'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { KibanaFeatureConfig } from '../../../../../../plugins/features/public'; -import { Space } from '../../../../common/model/space'; import { getEnabledFeatures } from '../../lib/feature_utils'; import { SectionPanel } from '../section_panel'; import { FeatureTable } from './feature_table'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx index 95ff475ef4e30..62356211e66a5 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/feature_table.tsx @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n'; import { AppCategory } from 'kibana/public'; import _ from 'lodash'; import React, { ChangeEvent, Component, ReactElement } from 'react'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { KibanaFeatureConfig } from '../../../../../../plugins/features/public'; -import { Space } from '../../../../common/model/space'; import { getEnabledFeatures } from '../../lib/feature_utils'; import './feature_table.scss'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx index 6943e27501554..285dd6a1134ec 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx @@ -19,9 +19,9 @@ import { i18n } from '@kbn/i18n'; import _ from 'lodash'; import React, { Component, Fragment } from 'react'; import { ApplicationStart, Capabilities, NotificationsStart, ScopedHistory } from 'src/core/public'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { KibanaFeature, FeaturesPluginStart } from '../../../../features/public'; import { isReservedSpace } from '../../../common'; -import { Space } from '../../../common/model/space'; import { SpacesManager } from '../../spaces_manager'; import { SecureSpaceMessage, UnauthorizedPrompt } from '../components'; import { toSpaceIdentifier } from '../lib'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx index f3a2273d90e8c..637653ec52da6 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { EuiBadge, EuiToolTip } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { isReservedSpace } from '../../../common'; -import { Space } from '../../../common/model/space'; interface Props { space?: Space; diff --git a/x-pack/plugins/spaces/public/management/lib/validate_space.ts b/x-pack/plugins/spaces/public/management/lib/validate_space.ts index 43d42dacdd36d..5ae573863bdee 100644 --- a/x-pack/plugins/spaces/public/management/lib/validate_space.ts +++ b/x-pack/plugins/spaces/public/management/lib/validate_space.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ import { i18n } from '@kbn/i18n'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { isReservedSpace } from '../../../common/is_reserved_space'; -import { Space } from '../../../common/model/space'; import { isValidSpaceIdentifier } from './space_identifier_utils'; interface SpaceValidatorOptions { diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx index 68c4a4ff02b94..ae93ae80c7cd2 100644 --- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.tsx @@ -21,10 +21,10 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { ApplicationStart, Capabilities, NotificationsStart, ScopedHistory } from 'src/core/public'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { KibanaFeature, FeaturesPluginStart } from '../../../../features/public'; import { isReservedSpace } from '../../../common'; import { DEFAULT_SPACE_ID } from '../../../common/constants'; -import { Space } from '../../../common/model/space'; import { SpaceAvatar } from '../../space_avatar'; import { getSpacesFeatureDescription } from '../../constants'; import { SpacesManager } from '../..//spaces_manager'; diff --git a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx index 5aaf41209f36f..d97d0c37c07c5 100644 --- a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx +++ b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx @@ -15,8 +15,8 @@ import { import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, ReactElement } from 'react'; import { Capabilities, ApplicationStart } from 'src/core/public'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { addSpaceIdToPath, SPACE_SEARCH_COUNT_THRESHOLD, ENTER_SPACE_PATH } from '../../../common'; -import { Space } from '../../../common/model/space'; import { ManageSpacesButton } from './manage_spaces_button'; import { SpaceAvatar } from '../../space_avatar'; diff --git a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx index 56b11b6e74f0b..f2f124c3cc08e 100644 --- a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx +++ b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx @@ -13,7 +13,7 @@ import { import React, { Component } from 'react'; import { Capabilities, ApplicationStart } from 'src/core/public'; import { Subscription } from 'rxjs'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { SpaceAvatar } from '../space_avatar'; import { SpacesManager } from '../spaces_manager'; import { SpacesDescription } from './components/spaces_description'; diff --git a/x-pack/plugins/spaces/public/plugin.test.ts b/x-pack/plugins/spaces/public/plugin.test.ts index c1282aef8b343..3e0d195e5c419 100644 --- a/x-pack/plugins/spaces/public/plugin.test.ts +++ b/x-pack/plugins/spaces/public/plugin.test.ts @@ -6,21 +6,24 @@ import { coreMock } from 'src/core/public/mocks'; import { SpacesPlugin } from './plugin'; +import { spacesOssPluginMock } from '../../../../src/plugins/spaces_oss/public/mocks'; import { homePluginMock } from '../../../../src/plugins/home/public/mocks'; import { managementPluginMock, createManagementSectionMock, } from '../../../../src/plugins/management/public/mocks'; import { advancedSettingsMock } from '../../../../src/plugins/advanced_settings/public/mocks'; -import { featuresPluginMock } from '../../features/public/mocks'; describe('Spaces plugin', () => { describe('#setup', () => { - it('should register the space selector app', () => { + it('should register the spaces API and the space selector app', () => { const coreSetup = coreMock.createSetup(); + const spacesOss = spacesOssPluginMock.createSetupContract(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, {}); + plugin.setup(coreSetup, { spacesOss }); + + expect(spacesOss.registerSpacesApi).toHaveBeenCalledTimes(1); expect(coreSetup.application.register).toHaveBeenCalledWith( expect.objectContaining({ @@ -34,6 +37,7 @@ describe('Spaces plugin', () => { it('should register the management and feature catalogue sections when the management and home plugins are both available', () => { const coreSetup = coreMock.createSetup(); + const spacesOss = spacesOssPluginMock.createSetupContract(); const home = homePluginMock.createSetupContract(); const management = managementPluginMock.createSetupContract(); @@ -44,6 +48,7 @@ describe('Spaces plugin', () => { const plugin = new SpacesPlugin(); plugin.setup(coreSetup, { + spacesOss, management, home, }); @@ -64,10 +69,11 @@ describe('Spaces plugin', () => { it('should register the advanced settings components if the advanced_settings plugin is available', () => { const coreSetup = coreMock.createSetup(); + const spacesOss = spacesOssPluginMock.createSetupContract(); const advancedSettings = advancedSettingsMock.createSetupContract(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, { advancedSettings }); + plugin.setup(coreSetup, { spacesOss, advancedSettings }); expect(advancedSettings.component.register.mock.calls).toMatchInlineSnapshot(` Array [ @@ -89,12 +95,13 @@ describe('Spaces plugin', () => { describe('#start', () => { it('should register the spaces nav control', () => { const coreSetup = coreMock.createSetup(); + const spacesOss = spacesOssPluginMock.createSetupContract(); const coreStart = coreMock.createStart(); const plugin = new SpacesPlugin(); - plugin.setup(coreSetup, {}); + plugin.setup(coreSetup, { spacesOss }); - plugin.start(coreStart, { features: featuresPluginMock.createStart() }); + 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 index 2a08f41266456..c479c01991e31 100644 --- a/x-pack/plugins/spaces/public/plugin.tsx +++ b/x-pack/plugins/spaces/public/plugin.tsx @@ -5,6 +5,7 @@ */ import { CoreSetup, CoreStart, Plugin, StartServicesAccessor } from 'src/core/public'; +import { SpacesOssPluginSetup, SpacesApi } from 'src/plugins/spaces_oss/public'; import { HomePublicPluginSetup } from 'src/plugins/home/public'; import { SavedObjectsManagementPluginSetup } from 'src/plugins/saved_objects_management/public'; import { ManagementStart, ManagementSetup } from 'src/plugins/management/public'; @@ -21,6 +22,7 @@ import { ManagementService } from './management'; import { spaceSelectorApp } from './space_selector'; export interface PluginsSetup { + spacesOss: SpacesOssPluginSetup; advancedSettings?: AdvancedSettingsSetup; home?: HomePublicPluginSetup; management?: ManagementSetup; @@ -42,7 +44,7 @@ export class SpacesPlugin implements Plugin, plugins: PluginsSetup) { this.spacesManager = new SpacesManager(core.http); if (plugins.home) { @@ -89,16 +91,15 @@ export class SpacesPlugin implements Plugin this.spacesManager.getActiveSpace(), - }; + return this.createSpacesApi(); } public stop() { @@ -107,4 +108,11 @@ export class SpacesPlugin implements Plugin this.spacesManager.getActiveSpace(), + }; + } } diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx index 2f4188f1e6ed8..d89d0b91781c3 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx @@ -9,7 +9,7 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { ShareSavedObjectsToSpaceFlyout } from './share_to_space_flyout'; import { ShareToSpaceForm } from './share_to_space_form'; import { EuiLoadingSpinner, EuiSelectable } from '@elastic/eui'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { findTestSubject } from '@kbn/test/jest'; import { SelectableSpacesControl } from './selectable_spaces_control'; import { act } from '@testing-library/react'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx index f467bfe496e5a..c1d76faa3f7a3 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.tsx @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { ToastsStart } from 'src/core/public'; import { SavedObjectsManagementRecord } from '../../../../../../src/plugins/saved_objects_management/public'; +import { GetSpaceResult } from '../../../common'; import { ALL_SPACES_ID, UNKNOWN_SPACE } from '../../../common/constants'; -import { GetSpaceResult } from '../../../common/model/types'; import { SpacesManager } from '../../spaces_manager'; import { ShareToSpaceForm } from './share_to_space_form'; import { ShareOptions, SpaceTarget } from '../types'; diff --git a/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts b/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts index aa7d0f89980ff..bd7f6de2cf914 100644 --- a/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts +++ b/x-pack/plugins/spaces/public/space_avatar/space_attributes.ts @@ -5,7 +5,7 @@ */ import { VISUALIZATION_COLORS } from '@elastic/eui'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { MAX_SPACE_INITIALS } from '../../common'; // code point for lowercase "a" diff --git a/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx b/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx index c89f492a8fc99..f7341fdf4ecda 100644 --- a/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx +++ b/x-pack/plugins/spaces/public/space_avatar/space_avatar.tsx @@ -6,8 +6,8 @@ import { EuiAvatar, isValidHex } from '@elastic/eui'; import React, { FC } from 'react'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { MAX_SPACE_INITIALS } from '../../common'; -import { Space } from '../../common/model/space'; import { getSpaceColor, getSpaceInitials, getSpaceImageUrl } from './space_attributes'; interface Props { diff --git a/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx b/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx index b5500ebc1cd7e..ea8afc0246f24 100644 --- a/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx +++ b/x-pack/plugins/spaces/public/space_selector/components/space_cards.tsx @@ -7,7 +7,7 @@ import './space_cards.scss'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { Component } from 'react'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { SpaceCard } from './space_card'; interface Props { diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx index 8ecc8e8200e47..601f921492c51 100644 --- a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx +++ b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { shallowWithIntl } from '@kbn/test/jest'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { SpaceSelector } from './space_selector'; import { spacesManagerMock } from '../spaces_manager/mocks'; diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx index 494e68e0b15aa..eb03d7c6a266d 100644 --- a/x-pack/plugins/spaces/public/space_selector/space_selector.tsx +++ b/x-pack/plugins/spaces/public/space_selector/space_selector.tsx @@ -26,7 +26,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { Component, Fragment } from 'react'; import ReactDOM from 'react-dom'; import { CoreStart } from 'src/core/public'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { SpaceCards } from './components'; import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../common/constants'; import { SpacesManager } from '../spaces_manager'; diff --git a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts index 0888448753353..912417dc01f75 100644 --- a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts +++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.mock.ts @@ -5,7 +5,7 @@ */ import { of, Observable } from 'rxjs'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { SpacesManager } from './spaces_manager'; function createSpacesManagerMock() { diff --git a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts index a7d74de603505..59d376d6f2e25 100644 --- a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts +++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.ts @@ -6,15 +6,13 @@ import { Observable, BehaviorSubject } from 'rxjs'; import { skipWhile } from 'rxjs/operators'; import { HttpSetup } from 'src/core/public'; -import { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public'; -import { Space } from '../../common/model/space'; -import { GetAllSpacesPurpose, GetSpaceResult } from '../../common/model/types'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; +import { GetAllSpacesOptions, GetSpaceResult } from '../../common'; import { CopySavedObjectsToSpaceResponse } from '../copy_saved_objects_to_space/types'; -type SavedObject = Pick; -interface GetAllSpacesOptions { - purpose?: GetAllSpacesPurpose; - includeAuthorizedPurposes?: boolean; +interface SavedObjectTarget { + type: string; + id: string; } export class SpacesManager { @@ -85,7 +83,7 @@ export class SpacesManager { } public async copySavedObjects( - objects: SavedObject[], + objects: SavedObjectTarget[], spaces: string[], includeReferences: boolean, createNewCopies: boolean, @@ -103,7 +101,7 @@ export class SpacesManager { } public async resolveCopySavedObjectsErrors( - objects: SavedObject[], + objects: SavedObjectTarget[], retries: unknown, includeReferences: boolean, createNewCopies: boolean @@ -133,13 +131,13 @@ export class SpacesManager { }); } - public async shareSavedObjectAdd(object: SavedObject, spaces: string[]): Promise { + public async shareSavedObjectAdd(object: SavedObjectTarget, spaces: string[]): Promise { return this.http.post(`/api/spaces/_share_saved_object_add`, { body: JSON.stringify({ object, spaces }), }); } - public async shareSavedObjectRemove(object: SavedObject, spaces: string[]): Promise { + public async shareSavedObjectRemove(object: SavedObjectTarget, spaces: string[]): Promise { return this.http.post(`/api/spaces/_share_saved_object_remove`, { body: JSON.stringify({ object, spaces }), }); diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts index 770f8a16560ec..dee1a8772791e 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.test.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { KibanaFeature } from '../../../../plugins/features/server'; -import { Space } from '../../common/model/space'; import { setupCapabilitiesSwitcher } from './capabilities_switcher'; import { Capabilities, CoreSetup } from 'src/core/server'; import { coreMock, httpServerMock, loggingSystemMock } from 'src/core/server/mocks'; diff --git a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts index 4bf4c0683f570..c2389786122fb 100644 --- a/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts +++ b/x-pack/plugins/spaces/server/capabilities/capabilities_switcher.ts @@ -5,8 +5,8 @@ */ import _ from 'lodash'; import { Capabilities, CapabilitiesSwitcher, CoreSetup, Logger } from 'src/core/server'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { KibanaFeature } from '../../../../plugins/features/server'; -import { Space } from '../../common/model/space'; import { SpacesServiceStart } from '../spaces_service'; import { PluginsStart } from '../plugin'; diff --git a/x-pack/plugins/spaces/server/index.ts b/x-pack/plugins/spaces/server/index.ts index 4d3d184ec41a3..1150dfdf1c980 100644 --- a/x-pack/plugins/spaces/server/index.ts +++ b/x-pack/plugins/spaces/server/index.ts @@ -20,7 +20,11 @@ export { addSpaceIdToPath } from '../common'; export { SpacesPluginSetup, SpacesPluginStart } from './plugin'; export { SpacesServiceSetup, SpacesServiceStart } from './spaces_service'; export { ISpacesClient } from './spaces_client'; -export { Space } from '../common/model/space'; + +export { GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult } from '../common'; + +// re-export types from oss definition +export { Space } from '../../../../src/plugins/spaces_oss/common'; export const config: PluginConfigDescriptor = { schema: ConfigSchema, diff --git a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts index 4731ddbac10c3..add78ad9a9583 100644 --- a/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts +++ b/x-pack/plugins/spaces/server/lib/request_interceptors/on_post_auth_interceptor.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { Logger, CoreSetup } from 'src/core/server'; -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; import { wrapError } from '../errors'; import { SpacesServiceStart } from '../../spaces_service/spaces_service'; import { PluginsSetup } from '../../plugin'; diff --git a/x-pack/plugins/spaces/server/routes/api/external/get_all.ts b/x-pack/plugins/spaces/server/routes/api/external/get_all.ts index 20ad5e730db6b..fb6a72acbed84 100644 --- a/x-pack/plugins/spaces/server/routes/api/external/get_all.ts +++ b/x-pack/plugins/spaces/server/routes/api/external/get_all.ts @@ -5,7 +5,7 @@ */ import { schema } from '@kbn/config-schema'; -import { Space } from '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { wrapError } from '../../../lib/errors'; import { ExternalRouteDeps } from '.'; import { createLicensedRouteHandler } from '../../lib'; diff --git a/x-pack/plugins/spaces/server/routes/api/external/put.ts b/x-pack/plugins/spaces/server/routes/api/external/put.ts index 68ebdb55af1e3..0f523ecff3ed0 100644 --- a/x-pack/plugins/spaces/server/routes/api/external/put.ts +++ b/x-pack/plugins/spaces/server/routes/api/external/put.ts @@ -6,7 +6,7 @@ import { schema } from '@kbn/config-schema'; import { SavedObjectsErrorHelpers } from '../../../../../../../src/core/server'; -import { Space } from '../../../../common/model/space'; +import { Space } from '../../../../../../../src/plugins/spaces_oss/common'; import { wrapError } from '../../../lib/errors'; import { spaceSchema } from '../../../lib/space_schema'; import { ExternalRouteDeps } from '.'; diff --git a/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts b/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts index d3ee173a2e80f..09e51efa77f42 100644 --- a/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts +++ b/x-pack/plugins/spaces/server/routes/lib/convert_saved_object_to_space.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Space } from '../../../common/model/space'; +import { Space } from '../../../../../../src/plugins/spaces_oss/common'; /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one diff --git a/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts b/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts index 8383d32cc6517..66a661573c3e0 100644 --- a/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts +++ b/x-pack/plugins/spaces/server/spaces_client/spaces_client.mock.ts @@ -5,7 +5,7 @@ */ import { DEFAULT_SPACE_ID } from '../../common/constants'; -import { Space } from '../../common/model/space'; +import { Space } from '../../../../../src/plugins/spaces_oss/common'; import { SpacesClient } from './spaces_client'; const createSpacesClientMock = () => diff --git a/x-pack/plugins/spaces/server/spaces_client/spaces_client.test.ts b/x-pack/plugins/spaces/server/spaces_client/spaces_client.test.ts index 7c2f90f5dfb2c..76afa4733c211 100644 --- a/x-pack/plugins/spaces/server/spaces_client/spaces_client.test.ts +++ b/x-pack/plugins/spaces/server/spaces_client/spaces_client.test.ts @@ -6,8 +6,8 @@ import { SpacesClient } from './spaces_client'; import { ConfigType, ConfigSchema } from '../config'; -import { GetAllSpacesPurpose } from '../../common/model/types'; import { savedObjectsRepositoryMock } from '../../../../../src/core/server/mocks'; +import { GetAllSpacesPurpose } from '../../common'; const createMockDebugLogger = () => { return jest.fn(); diff --git a/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts b/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts index 7142ec8dc2fba..cb8636715ccee 100644 --- a/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts +++ b/x-pack/plugins/spaces/server/spaces_client/spaces_client.ts @@ -8,15 +8,10 @@ import Boom from '@hapi/boom'; import { omit } from 'lodash'; import { ISavedObjectsRepository, SavedObject } from 'src/core/server'; import { PublicMethodsOf } from '@kbn/utility-types'; +import { Space } from 'src/plugins/spaces_oss/common'; +import { GetAllSpacesOptions, GetAllSpacesPurpose, GetSpaceResult } from '../../common'; import { isReservedSpace } from '../../common'; -import { Space } from '../../common/model/space'; import { ConfigType } from '../config'; -import { GetAllSpacesPurpose, GetSpaceResult } from '../../common/model/types'; - -export interface GetAllSpacesOptions { - purpose?: GetAllSpacesPurpose; - includeAuthorizedPurposes?: boolean; -} const SUPPORTED_GET_SPACE_PURPOSES: GetAllSpacesPurpose[] = [ 'any',