From f47827c1c03c429e6054b7407d8b8d66d34b4798 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Mon, 17 Apr 2023 18:13:59 +0200 Subject: [PATCH 01/13] [Guided onboarding] Add a Kibana feature for guided onboarding to handle permissions issues --- .../guided_onboarding/common/constants.ts | 2 + src/plugins/guided_onboarding/kibana.jsonc | 3 +- .../guided_onboarding/public/plugin.tsx | 9 +++-- .../guided_onboarding/server/feature.ts | 40 +++++++++++++++++++ .../guided_onboarding/server/plugin.ts | 6 ++- 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 src/plugins/guided_onboarding/server/feature.ts diff --git a/src/plugins/guided_onboarding/common/constants.ts b/src/plugins/guided_onboarding/common/constants.ts index e0c5961c1f6aa8..4640680fb1fc4c 100755 --- a/src/plugins/guided_onboarding/common/constants.ts +++ b/src/plugins/guided_onboarding/common/constants.ts @@ -10,3 +10,5 @@ export const PLUGIN_ID = 'guidedOnboarding'; export const PLUGIN_NAME = 'guidedOnboarding'; export const API_BASE_PATH = '/api/guided_onboarding'; + +export const PLUGIN_FEATURE = 'guidedOnboardingFeature'; diff --git a/src/plugins/guided_onboarding/kibana.jsonc b/src/plugins/guided_onboarding/kibana.jsonc index e816f0e027fe98..300df79253dacd 100644 --- a/src/plugins/guided_onboarding/kibana.jsonc +++ b/src/plugins/guided_onboarding/kibana.jsonc @@ -8,7 +8,8 @@ "server": true, "browser": true, "optionalPlugins": [ - "cloud" + "cloud", + "features" ], "requiredBundles": [ "kibanaReact" diff --git a/src/plugins/guided_onboarding/public/plugin.tsx b/src/plugins/guided_onboarding/public/plugin.tsx index 97eac765c5dddb..8f37552ae53de8 100755 --- a/src/plugins/guided_onboarding/public/plugin.tsx +++ b/src/plugins/guided_onboarding/public/plugin.tsx @@ -21,6 +21,8 @@ import { } from '@kbn/core/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; + +import { PLUGIN_FEATURE } from '../common/constants'; import type { AppPluginStartDependencies, GuidedOnboardingPluginSetup, @@ -43,11 +45,12 @@ export class GuidedOnboardingPlugin ): GuidedOnboardingPluginStart { const { chrome, http, theme, application, notifications, uiSettings } = core; + // Guided onboarding UI is only available on cloud and if the access to the Kibana feature is granted + const isEnabled = !!(cloud?.isCloudEnabled && application.capabilities[PLUGIN_FEATURE].enabled); // Initialize services - apiService.setup(http, !!cloud?.isCloudEnabled); + apiService.setup(http, isEnabled); - // Guided onboarding UI is only available on cloud - if (cloud?.isCloudEnabled) { + if (isEnabled) { chrome.navControls.registerExtension({ order: 1000, mount: (target) => diff --git a/src/plugins/guided_onboarding/server/feature.ts b/src/plugins/guided_onboarding/server/feature.ts new file mode 100644 index 00000000000000..c18b41419a76e1 --- /dev/null +++ b/src/plugins/guided_onboarding/server/feature.ts @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { KibanaFeatureConfig } from '@kbn/features-plugin/common'; +import { i18n } from '@kbn/i18n'; +import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server'; +import { PLUGIN_FEATURE, PLUGIN_ID } from '../common/constants'; +import { guideStateSavedObjectsType, pluginStateSavedObjectsType } from './saved_objects'; + +export const GUIDED_ONBOARDING_FEATURE: KibanaFeatureConfig = { + id: PLUGIN_FEATURE, + name: i18n.translate('guidedOnboarding.featureRegistry.featureName', { + defaultMessage: 'Setup guides', + }), + category: DEFAULT_APP_CATEGORIES.management, + app: [PLUGIN_ID], + privileges: { + all: { + app: [PLUGIN_ID], + savedObject: { + all: [guideStateSavedObjectsType, pluginStateSavedObjectsType], + read: [], + }, + ui: ['enabled'], + }, + read: { + disabled: true, + savedObject: { + all: [], + read: [], + }, + ui: [], + }, + }, +}; diff --git a/src/plugins/guided_onboarding/server/plugin.ts b/src/plugins/guided_onboarding/server/plugin.ts index f264771d780ee5..3a5138d20133ba 100755 --- a/src/plugins/guided_onboarding/server/plugin.ts +++ b/src/plugins/guided_onboarding/server/plugin.ts @@ -9,6 +9,8 @@ import { PluginInitializerContext, CoreSetup, Plugin, Logger } from '@kbn/core/server'; import type { GuideId, GuideConfig } from '@kbn/guided-onboarding'; +import { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server'; +import { GUIDED_ONBOARDING_FEATURE } from './feature'; import { GuidedOnboardingPluginSetup, GuidedOnboardingPluginStart } from './types'; import { defineRoutes } from './routes'; import { guideStateSavedObjects, pluginStateSavedObjects } from './saved_objects'; @@ -25,7 +27,7 @@ export class GuidedOnboardingPlugin this.guidesConfig = {} as GuidesConfig; } - public setup(core: CoreSetup) { + public setup(core: CoreSetup, plugins: { features?: FeaturesPluginSetup }) { this.logger.debug('guidedOnboarding: Setup'); const router = core.http.createRouter(); @@ -36,6 +38,8 @@ export class GuidedOnboardingPlugin core.savedObjects.registerType(guideStateSavedObjects); core.savedObjects.registerType(pluginStateSavedObjects); + plugins.features?.registerKibanaFeature(GUIDED_ONBOARDING_FEATURE); + return { registerGuideConfig: (guideId: GuideId, guideConfig: GuideConfig) => { if (this.guidesConfig[guideId]) { From 40b3babea233cdd6025e01be139bdf86fd3a0b80 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:21:20 +0000 Subject: [PATCH 02/13] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- src/plugins/guided_onboarding/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/guided_onboarding/tsconfig.json b/src/plugins/guided_onboarding/tsconfig.json index 42026215e18fd1..88569a7a43238b 100644 --- a/src/plugins/guided_onboarding/tsconfig.json +++ b/src/plugins/guided_onboarding/tsconfig.json @@ -18,6 +18,7 @@ "@kbn/core-http-browser", "@kbn/core-http-browser-mocks", "@kbn/config-schema", + "@kbn/features-plugin", ], "exclude": [ "target/**/*", From f57bc64d5fd6bc9844a161b4eb23b3c9a7c30d27 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Wed, 19 Apr 2023 18:46:34 +0200 Subject: [PATCH 03/13] [Guided onboarding] Remove the header button and the landing page route/redirection when guided onboarding is disabled --- .../public/services/api.service.ts | 18 +++++++++++------- src/plugins/guided_onboarding/public/types.ts | 1 + .../components/add_data/add_data.tsx | 10 +++++----- .../public/application/components/home.tsx | 5 ++--- .../public/application/components/home_app.js | 9 ++++++--- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/plugins/guided_onboarding/public/services/api.service.ts b/src/plugins/guided_onboarding/public/services/api.service.ts index 949002b19ea6aa..a85c2e67f10b02 100644 --- a/src/plugins/guided_onboarding/public/services/api.service.ts +++ b/src/plugins/guided_onboarding/public/services/api.service.ts @@ -40,15 +40,15 @@ import { import { ConfigService } from './config.service'; export class ApiService implements GuidedOnboardingApi { - private isCloudEnabled: boolean | undefined; + private _isEnabled: boolean = false; private client: HttpSetup | undefined; private pluginState$!: BehaviorSubject; public isLoading$ = new BehaviorSubject(false); public isGuidePanelOpen$: BehaviorSubject = new BehaviorSubject(false); private configService = new ConfigService(); - public setup(httpClient: HttpSetup, isCloudEnabled: boolean) { - this.isCloudEnabled = isCloudEnabled; + public setup(httpClient: HttpSetup, isEnabled: boolean) { + this._isEnabled = isEnabled; this.client = httpClient; this.pluginState$ = new BehaviorSubject(undefined); this.isGuidePanelOpen$ = new BehaviorSubject(false); @@ -93,7 +93,7 @@ export class ApiService implements GuidedOnboardingApi { * Subsequently, the observable is updated automatically, when the state changes. */ public fetchPluginState$(): Observable { - if (!this.isCloudEnabled) { + if (!this._isEnabled) { return of(undefined); } if (!this.client) { @@ -117,7 +117,7 @@ export class ApiService implements GuidedOnboardingApi { * where all guides are displayed with their corresponding status. */ public async fetchAllGuidesState(): Promise<{ state: GuideState[] } | undefined> { - if (!this.isCloudEnabled) { + if (!this._isEnabled) { return undefined; } if (!this.client) { @@ -142,7 +142,7 @@ export class ApiService implements GuidedOnboardingApi { state: { status?: PluginStatus; guide?: GuideState }, panelState: boolean ): Promise<{ pluginState: PluginState } | undefined> { - if (!this.isCloudEnabled) { + if (!this._isEnabled) { return undefined; } if (!this.client) { @@ -464,7 +464,7 @@ export class ApiService implements GuidedOnboardingApi { * @return {Promise} a promise with the guide config or undefined if the config is not found */ public async getGuideConfig(guideId: GuideId): Promise { - if (!this.isCloudEnabled) { + if (!this._isEnabled) { return undefined; } if (!this.client) { @@ -475,6 +475,10 @@ export class ApiService implements GuidedOnboardingApi { this.isLoading$.next(false); return config; } + + public get isEnabled() { + return this._isEnabled; + } } export const apiService = new ApiService(); diff --git a/src/plugins/guided_onboarding/public/types.ts b/src/plugins/guided_onboarding/public/types.ts index 1b0ccc7d925b36..7cc6f9c428f330 100755 --- a/src/plugins/guided_onboarding/public/types.ts +++ b/src/plugins/guided_onboarding/public/types.ts @@ -55,4 +55,5 @@ export interface GuidedOnboardingApi { isGuidePanelOpen$: Observable; isLoading$: Observable; getGuideConfig: (guideId: GuideId) => Promise; + readonly isEnabled: boolean; } diff --git a/src/plugins/home/public/application/components/add_data/add_data.tsx b/src/plugins/home/public/application/components/add_data/add_data.tsx index 086e28cbb1f83a..5440ad09d2c156 100644 --- a/src/plugins/home/public/application/components/add_data/add_data.tsx +++ b/src/plugins/home/public/application/components/add_data/add_data.tsx @@ -35,7 +35,7 @@ interface Props { } export const AddData: FC = ({ addBasePath, application, isDarkMode, isCloudEnabled }) => { - const { trackUiMetric } = getServices(); + const { trackUiMetric, guidedOnboardingService } = getServices(); const canAccessIntegrations = application.capabilities.navLinks.integrations; if (canAccessIntegrations) { return ( @@ -70,7 +70,7 @@ export const AddData: FC = ({ addBasePath, application, isDarkMode, isClo - {isCloudEnabled && ( + {guidedOnboardingService?.isEnabled && ( {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} = ({ addBasePath, application, isDarkMode, isClo {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} { diff --git a/src/plugins/home/public/application/components/home.tsx b/src/plugins/home/public/application/components/home.tsx index 7a65c48807a33e..176b620430a56b 100644 --- a/src/plugins/home/public/application/components/home.tsx +++ b/src/plugins/home/public/application/components/home.tsx @@ -188,15 +188,14 @@ export class Home extends Component { public render() { const { isLoading, isWelcomeEnabled, isNewKibanaInstance } = this.state; - const { isCloudEnabled } = this.props; - const { application } = getServices(); + const { application, guidedOnboardingService } = getServices(); if (isWelcomeEnabled) { if (isLoading) { return this.renderLoading(); } if (isNewKibanaInstance) { - if (isCloudEnabled) { + if (guidedOnboardingService?.isEnabled) { application.navigateToUrl('./home#/getting_started'); return null; } diff --git a/src/plugins/home/public/application/components/home_app.js b/src/plugins/home/public/application/components/home_app.js index 58d9c2a0f3fc4e..f800a26c787ba2 100644 --- a/src/plugins/home/public/application/components/home_app.js +++ b/src/plugins/home/public/application/components/home_app.js @@ -29,6 +29,7 @@ export function HomeApp({ directories, solutions }) { addBasePath, environmentService, dataViewsService, + guidedOnboardingService, } = getServices(); const environment = environmentService.getEnvironment(); const isCloudEnabled = environment.cloud; @@ -69,9 +70,11 @@ export function HomeApp({ directories, solutions }) { - - - + {guidedOnboardingService.isEnabled && ( + + + + )} Date: Thu, 20 Apr 2023 13:57:52 +0200 Subject: [PATCH 04/13] [Guided onboarding] Remove the help link if guided onboarding is disabled --- .../cloud_links/kibana.jsonc | 3 ++- .../cloud_links/public/plugin.tsx | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/cloud_integrations/cloud_links/kibana.jsonc b/x-pack/plugins/cloud_integrations/cloud_links/kibana.jsonc index 36fa7445213bae..58fc030e6c8df0 100644 --- a/x-pack/plugins/cloud_integrations/cloud_links/kibana.jsonc +++ b/x-pack/plugins/cloud_integrations/cloud_links/kibana.jsonc @@ -9,7 +9,8 @@ "browser": true, "optionalPlugins": [ "cloud", - "security" + "security", + "guided_onboarding" ] } } diff --git a/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.tsx b/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.tsx index b5c3c4aeeb5558..a2f8af345ac0a0 100755 --- a/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.tsx +++ b/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.tsx @@ -10,6 +10,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import type { CoreStart, Plugin } from '@kbn/core/public'; import type { CloudSetup, CloudStart } from '@kbn/cloud-plugin/public'; import type { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public'; +import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public'; import { maybeAddCloudLinks } from './maybe_add_cloud_links'; interface CloudLinksDepsSetup { @@ -20,6 +21,7 @@ interface CloudLinksDepsSetup { interface CloudLinksDepsStart { cloud?: CloudStart; security?: SecurityPluginStart; + guidedOnboarding?: GuidedOnboardingPluginStart; } export class CloudLinksPlugin @@ -27,18 +29,19 @@ export class CloudLinksPlugin { public setup() {} - public start(core: CoreStart, { cloud, security }: CloudLinksDepsStart) { + public start(core: CoreStart, { cloud, security, guidedOnboarding }: CloudLinksDepsStart) { if (cloud?.isCloudEnabled && !core.http.anonymousPaths.isAnonymous(window.location.pathname)) { - core.chrome.registerGlobalHelpExtensionMenuLink({ - linkType: 'custom', - href: core.http.basePath.prepend('/app/home#/getting_started'), - content: ( - - ), - 'data-test-subj': 'cloudOnboardingSetupGuideLink', - priority: 1000, // We want this link to be at the very top. - }); - + if (guidedOnboarding?.guidedOnboardingApi?.isEnabled) { + core.chrome.registerGlobalHelpExtensionMenuLink({ + linkType: 'custom', + href: core.http.basePath.prepend('/app/home#/getting_started'), + content: ( + + ), + 'data-test-subj': 'cloudOnboardingSetupGuideLink', + priority: 1000, // We want this link to be at the very top. + }); + } if (security) { maybeAddCloudLinks({ security, chrome: core.chrome, cloud }); } From 16d92f63eecea963a5697b0199ee3f9b3abadc7c Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 13:58:23 +0200 Subject: [PATCH 05/13] [Guided onboarding] Add an error state to the example plugin --- .../public/components/app.tsx | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/examples/guided_onboarding_example/public/components/app.tsx b/examples/guided_onboarding_example/public/components/app.tsx index 41b9f62ddc075e..14377112d1c264 100755 --- a/examples/guided_onboarding_example/public/components/app.tsx +++ b/examples/guided_onboarding_example/public/components/app.tsx @@ -11,13 +11,7 @@ import { FormattedMessage, I18nProvider } from '@kbn/i18n-react'; import { Router, Switch } from 'react-router-dom'; import { Route } from '@kbn/shared-ux-router'; -import { - EuiPage, - EuiPageBody, - EuiPageContent_Deprecated as EuiPageContent, - EuiPageHeader, - EuiTitle, -} from '@elastic/eui'; +import { EuiPageTemplate } from '@elastic/eui'; import { CoreStart, ScopedHistory } from '@kbn/core/public'; @@ -38,19 +32,17 @@ export const GuidedOnboardingExampleApp = (props: GuidedOnboardingExampleAppDeps return ( - - - - -

- -

-
-
- + + + } + /> + {guidedOnboarding.guidedOnboardingApi?.isEnabled ? ( + @@ -67,9 +59,31 @@ export const GuidedOnboardingExampleApp = (props: GuidedOnboardingExampleAppDeps - -
-
+ + ) : ( + + + + } + body={ +

+ +

+ } + /> + )} +
); }; From 4d48b582b614952b7dec64b33512617291ab47c7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 20 Apr 2023 12:04:40 +0000 Subject: [PATCH 06/13] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/cloud_integrations/cloud_links/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/cloud_integrations/cloud_links/tsconfig.json b/x-pack/plugins/cloud_integrations/cloud_links/tsconfig.json index 2354df693cb95c..ab4f52a3475910 100644 --- a/x-pack/plugins/cloud_integrations/cloud_links/tsconfig.json +++ b/x-pack/plugins/cloud_integrations/cloud_links/tsconfig.json @@ -16,6 +16,7 @@ "@kbn/security-plugin", "@kbn/i18n", "@kbn/i18n-react", + "@kbn/guided-onboarding-plugin", ], "exclude": [ "target/**/*", From 2c8af74eef920250187262675f9ed0b633bfa688 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 17:06:10 +0200 Subject: [PATCH 07/13] [Guided onboarding] Fix cloud links tests --- src/plugins/guided_onboarding/public/mocks.ts | 1 + .../cloud_links/public/plugin.test.ts | 51 +++++++++++++------ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/plugins/guided_onboarding/public/mocks.ts b/src/plugins/guided_onboarding/public/mocks.ts index e190ddbcc219e1..a6fb3ae40da92d 100644 --- a/src/plugins/guided_onboarding/public/mocks.ts +++ b/src/plugins/guided_onboarding/public/mocks.ts @@ -28,6 +28,7 @@ const apiServiceMock: jest.Mocked = { isGuidePanelOpen$: new BehaviorSubject(false), isLoading$: new BehaviorSubject(false), getGuideConfig: jest.fn(), + isEnabled: true, }, }; diff --git a/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.test.ts b/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.test.ts index f086f209567780..d928b7a6f0e8a2 100644 --- a/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.test.ts +++ b/x-pack/plugins/cloud_integrations/cloud_links/public/plugin.test.ts @@ -10,6 +10,7 @@ import { CloudLinksPlugin } from './plugin'; import { coreMock } from '@kbn/core/public/mocks'; import { cloudMock } from '@kbn/cloud-plugin/public/mocks'; import { securityMock } from '@kbn/security-plugin/public/mocks'; +import { guidedOnboardingMock } from '@kbn/guided-onboarding-plugin/public/mocks'; describe('Cloud Links Plugin - public', () => { let plugin: CloudLinksPlugin; @@ -32,26 +33,46 @@ describe('Cloud Links Plugin - public', () => { }); describe('Onboarding Setup Guide link registration', () => { - test('registers the Onboarding Setup Guide link when cloud is enabled and it is an authenticated page', () => { - const coreStart = coreMock.createStart(); - coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); - const cloud = { ...cloudMock.createStart(), isCloudEnabled: true }; - plugin.start(coreStart, { cloud }); - expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).toHaveBeenCalledTimes(1); + describe('guided onboarding is enabled', () => { + const guidedOnboarding = guidedOnboardingMock.createStart(); + test('registers the Onboarding Setup Guide link when cloud and guided onboarding is enabled and it is an authenticated page', () => { + const coreStart = coreMock.createStart(); + coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); + const cloud = { ...cloudMock.createStart(), isCloudEnabled: true }; + + plugin.start(coreStart, { cloud, guidedOnboarding }); + expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).toHaveBeenCalledTimes(1); + }); + + test('does not register the Onboarding Setup Guide link when cloud is enabled but it is an unauthenticated page', () => { + const coreStart = coreMock.createStart(); + coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(true); + const cloud = { ...cloudMock.createStart(), isCloudEnabled: true }; + plugin.start(coreStart, { cloud, guidedOnboarding }); + expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).not.toHaveBeenCalled(); + }); + + test('does not register the Onboarding Setup Guide link when cloud is not enabled', () => { + const coreStart = coreMock.createStart(); + const cloud = { ...cloudMock.createStart(), isCloudEnabled: false }; + plugin.start(coreStart, { cloud, guidedOnboarding }); + expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).not.toHaveBeenCalled(); + }); }); - test('does not register the Onboarding Setup Guide link when cloud is enabled but it is an unauthenticated page', () => { + test('do not register the Onboarding Setup Guide link when guided onboarding is disabled', () => { + let { guidedOnboardingApi } = guidedOnboardingMock.createStart(); + guidedOnboardingApi = { + ...guidedOnboardingApi!, + isEnabled: false, + }; + const guidedOnboarding = { guidedOnboardingApi }; + const coreStart = coreMock.createStart(); - coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(true); + coreStart.http.anonymousPaths.isAnonymous.mockReturnValue(false); const cloud = { ...cloudMock.createStart(), isCloudEnabled: true }; - plugin.start(coreStart, { cloud }); - expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).not.toHaveBeenCalled(); - }); - test('does not register the Onboarding Setup Guide link when cloud is not enabled', () => { - const coreStart = coreMock.createStart(); - const cloud = { ...cloudMock.createStart(), isCloudEnabled: false }; - plugin.start(coreStart, { cloud }); + plugin.start(coreStart, { cloud, guidedOnboarding }); expect(coreStart.chrome.registerGlobalHelpExtensionMenuLink).not.toHaveBeenCalled(); }); }); From 72e70d8a4844251ace232ea3e941d6b46ad4cc95 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 17:42:18 +0200 Subject: [PATCH 08/13] [Guided onboarding] Fix home plugin tests --- .../home/public/application/components/home.test.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/home/public/application/components/home.test.tsx b/src/plugins/home/public/application/components/home.test.tsx index 806ceed7d7591a..c7240d43090789 100644 --- a/src/plugins/home/public/application/components/home.test.tsx +++ b/src/plugins/home/public/application/components/home.test.tsx @@ -15,6 +15,8 @@ import { Welcome } from './welcome'; let mockHasIntegrationsPermission = true; const mockNavigateToUrl = jest.fn(); +let mockIsEnabled = false; + jest.mock('../kibana_services', () => ({ getServices: () => ({ getBasePath: () => 'path', @@ -31,6 +33,9 @@ jest.mock('../kibana_services', () => ({ }, }, }, + guidedOnboardingService: { + isEnabled: mockIsEnabled, + }, }), })); @@ -234,7 +239,8 @@ describe('home', () => { expect(component.find(Welcome).exists()).toBe(false); }); - test('should redirect to guided onboarding on Cloud instead of welcome screen', async () => { + test('should redirect to guided onboarding on Cloud instead of welcome screen if guided onboarding is enabled', async () => { + mockIsEnabled = true; const isCloudEnabled = true; const hasUserDataView = jest.fn(async () => false); From 5e9cee73d49facb5b6b814e31411cfae950ecd26 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 17:53:10 +0200 Subject: [PATCH 09/13] [Guided onboarding] Update home plugin snapshots --- .../__snapshots__/home.test.tsx.snap | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/plugins/home/public/application/components/__snapshots__/home.test.tsx.snap b/src/plugins/home/public/application/components/__snapshots__/home.test.tsx.snap index 53df35833013f1..03dfb38204295f 100644 --- a/src/plugins/home/public/application/components/__snapshots__/home.test.tsx.snap +++ b/src/plugins/home/public/application/components/__snapshots__/home.test.tsx.snap @@ -308,12 +308,19 @@ exports[`home isNewKibanaInstance should safely handle exceptions 1`] = ` Array [ "./home#/getting_started", ], + Array [ + "./home#/getting_started", + ], ], "results": Array [ Object { "type": "return", "value": undefined, }, + Object { + "type": "return", + "value": undefined, + }, ], }, } @@ -335,12 +342,19 @@ exports[`home isNewKibanaInstance should safely handle exceptions 1`] = ` Array [ "./home#/getting_started", ], + Array [ + "./home#/getting_started", + ], ], "results": Array [ Object { "type": "return", "value": undefined, }, + Object { + "type": "return", + "value": undefined, + }, ], }, } @@ -389,12 +403,19 @@ exports[`home isNewKibanaInstance should set isNewKibanaInstance to false when t Array [ "./home#/getting_started", ], + Array [ + "./home#/getting_started", + ], ], "results": Array [ Object { "type": "return", "value": undefined, }, + Object { + "type": "return", + "value": undefined, + }, ], }, } @@ -416,12 +437,19 @@ exports[`home isNewKibanaInstance should set isNewKibanaInstance to false when t Array [ "./home#/getting_started", ], + Array [ + "./home#/getting_started", + ], ], "results": Array [ Object { "type": "return", "value": undefined, }, + Object { + "type": "return", + "value": undefined, + }, ], }, } @@ -437,12 +465,7 @@ exports[`home isNewKibanaInstance should set isNewKibanaInstance to false when t `; -exports[`home isNewKibanaInstance should set isNewKibanaInstance to true when there are no index patterns 1`] = ` - -`; +exports[`home isNewKibanaInstance should set isNewKibanaInstance to true when there are no index patterns 1`] = `""`; exports[`home should render home component 1`] = ` <_KibanaPageTemplate From 50e8d8d220897f6c21af3267662ea66269705baa Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 17:53:33 +0200 Subject: [PATCH 10/13] [Guided onboarding] Fix security functional tests --- x-pack/test/api_integration/apis/features/features/features.ts | 1 + x-pack/test/api_integration/apis/security/privileges.ts | 1 + x-pack/test/api_integration/apis/security/privileges_basic.ts | 2 ++ .../ui_capabilities/security_and_spaces/tests/nav_links.ts | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/features/features/features.ts b/x-pack/test/api_integration/apis/features/features/features.ts index 538782b272dfcb..d5038a7c51dedb 100644 --- a/x-pack/test/api_integration/apis/features/features/features.ts +++ b/x-pack/test/api_integration/apis/features/features/features.ts @@ -105,6 +105,7 @@ export default function ({ getService }: FtrProviderContext) { 'advancedSettings', 'indexPatterns', 'graph', + 'guidedOnboardingFeature', 'monitoring', 'observabilityCases', 'savedObjectsManagement', diff --git a/x-pack/test/api_integration/apis/security/privileges.ts b/x-pack/test/api_integration/apis/security/privileges.ts index 6dd11fa55dbc55..f5c5220e38658c 100644 --- a/x-pack/test/api_integration/apis/security/privileges.ts +++ b/x-pack/test/api_integration/apis/security/privileges.ts @@ -103,6 +103,7 @@ export default function ({ getService }: FtrProviderContext) { 'readFlappingSettings', ], maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'], + guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read' ], }, reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'], }; diff --git a/x-pack/test/api_integration/apis/security/privileges_basic.ts b/x-pack/test/api_integration/apis/security/privileges_basic.ts index 66871a1cf7e1ae..92f71b0cf148bd 100644 --- a/x-pack/test/api_integration/apis/security/privileges_basic.ts +++ b/x-pack/test/api_integration/apis/security/privileges_basic.ts @@ -50,6 +50,7 @@ export default function ({ getService }: FtrProviderContext) { filesSharedImage: ['all', 'read', 'minimal_all', 'minimal_read'], rulesSettings: ['all', 'read', 'minimal_all', 'minimal_read'], maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'], + guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'], }, global: ['all', 'read'], space: ['all', 'read'], @@ -175,6 +176,7 @@ export default function ({ getService }: FtrProviderContext) { 'readFlappingSettings', ], maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'], + guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read' ], }, reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'], }; diff --git a/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts b/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts index 5167b611de2b48..382d66d0f1b2d0 100644 --- a/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts +++ b/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts @@ -57,7 +57,8 @@ export default function navLinksTests({ getService }: FtrProviderContext) { 'enterpriseSearchContent', 'enterpriseSearchAnalytics', 'appSearch', - 'workplaceSearch' + 'workplaceSearch', + 'guidedOnboarding' ) ); break; From 547f790e53cae31749243a201c9b6a78f623cb4d Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:25:13 +0000 Subject: [PATCH 11/13] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- x-pack/test/api_integration/apis/security/privileges.ts | 2 +- x-pack/test/api_integration/apis/security/privileges_basic.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/security/privileges.ts b/x-pack/test/api_integration/apis/security/privileges.ts index f5c5220e38658c..ae5a6b9ee2a80d 100644 --- a/x-pack/test/api_integration/apis/security/privileges.ts +++ b/x-pack/test/api_integration/apis/security/privileges.ts @@ -103,7 +103,7 @@ export default function ({ getService }: FtrProviderContext) { 'readFlappingSettings', ], maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'], - guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read' ], + guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'], }, reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'], }; diff --git a/x-pack/test/api_integration/apis/security/privileges_basic.ts b/x-pack/test/api_integration/apis/security/privileges_basic.ts index 92f71b0cf148bd..0b8c7bc0b99202 100644 --- a/x-pack/test/api_integration/apis/security/privileges_basic.ts +++ b/x-pack/test/api_integration/apis/security/privileges_basic.ts @@ -176,7 +176,7 @@ export default function ({ getService }: FtrProviderContext) { 'readFlappingSettings', ], maintenanceWindow: ['all', 'read', 'minimal_all', 'minimal_read'], - guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read' ], + guidedOnboardingFeature: ['all', 'read', 'minimal_all', 'minimal_read'], }, reserved: ['fleet-setup', 'ml_user', 'ml_admin', 'ml_apm_user', 'monitoring'], }; From f8d73b5501f7af271e436e4ef1a8e01d4f7fe05a Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Thu, 20 Apr 2023 19:56:31 +0200 Subject: [PATCH 12/13] [Guided onboarding] Add a comment to the "read" feature privileges --- src/plugins/guided_onboarding/server/feature.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/guided_onboarding/server/feature.ts b/src/plugins/guided_onboarding/server/feature.ts index c18b41419a76e1..fce2cb9033b9dc 100644 --- a/src/plugins/guided_onboarding/server/feature.ts +++ b/src/plugins/guided_onboarding/server/feature.ts @@ -29,6 +29,8 @@ export const GUIDED_ONBOARDING_FEATURE: KibanaFeatureConfig = { ui: ['enabled'], }, read: { + // we haven't implemented "read-only" access yet, so this feature can only be granted + // as "all" or "none" disabled: true, savedObject: { all: [], From 77a5b7a94c9bbbe079052a999ea64f9406160f54 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Mon, 24 Apr 2023 18:35:26 +0200 Subject: [PATCH 13/13] [Guided onboarding] Fix functional tests --- .../security_and_spaces/tests/nav_links.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts b/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts index 382d66d0f1b2d0..f72a9a467b2649 100644 --- a/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts +++ b/x-pack/test/ui_capabilities/security_and_spaces/tests/nav_links.ts @@ -45,6 +45,19 @@ export default function navLinksTests({ getService }: FtrProviderContext) { expect(uiCapabilities.value!.navLinks).to.eql(navLinksBuilder.except('monitoring')); break; case 'everything_space_all at everything_space': + expect(uiCapabilities.success).to.be(true); + expect(uiCapabilities.value).to.have.property('navLinks'); + expect(uiCapabilities.value!.navLinks).to.eql( + navLinksBuilder.except( + 'monitoring', + 'enterpriseSearch', + 'enterpriseSearchContent', + 'enterpriseSearchAnalytics', + 'appSearch', + 'workplaceSearch' + ) + ); + break; case 'global_read at everything_space': case 'dual_privileges_read at everything_space': case 'everything_space_read at everything_space': @@ -58,7 +71,7 @@ export default function navLinksTests({ getService }: FtrProviderContext) { 'enterpriseSearchAnalytics', 'appSearch', 'workplaceSearch', - 'guidedOnboarding' + 'guidedOnboardingFeature' ) ); break;