From c1fd1d7146ddf3231507211be5b2c56e647f09fa Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Tue, 28 Sep 2021 11:07:50 -0700 Subject: [PATCH] Enable ML embeddables in Canvas Fixed conditional Restore ml embeddable options --- .../components/workpad_header/editor_menu/editor_menu.tsx | 7 +------ x-pack/plugins/canvas/public/index.ts | 2 +- x-pack/plugins/ml/kibana.json | 1 + .../ml/public/embeddables/common/resolve_job_selection.tsx | 5 +++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/canvas/public/components/workpad_header/editor_menu/editor_menu.tsx b/x-pack/plugins/canvas/public/components/workpad_header/editor_menu/editor_menu.tsx index c0c5fd0f1667774..929c8682e5cf70f 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/editor_menu/editor_menu.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_header/editor_menu/editor_menu.tsx @@ -123,12 +123,7 @@ export const EditorMenu: FC = ({ addElement }) => { const factories = embeddablesService ? Array.from(embeddablesService.getEmbeddableFactories()).filter( ({ type, isEditable, canCreateNew, isContainerType }) => - isEditable() && - !isContainerType && - canCreateNew() && - !['visualization', 'ml'].some((factoryType) => { - return type.includes(factoryType); - }) + isEditable() && !isContainerType && canCreateNew() && type !== 'visualization' ) : []; diff --git a/x-pack/plugins/canvas/public/index.ts b/x-pack/plugins/canvas/public/index.ts index a15b15fcae3337f..1143663c84abe8d 100644 --- a/x-pack/plugins/canvas/public/index.ts +++ b/x-pack/plugins/canvas/public/index.ts @@ -9,9 +9,9 @@ import { PluginInitializerContext } from 'kibana/public'; import { CoreStart } from '../../../../src/core/public'; import { CanvasServices } from './services'; import { CanvasSetup, CanvasStart, CanvasStartDeps, CanvasPlugin } from './plugin'; +export { CANVAS_APP } from '../common/lib/constants'; export { CanvasSetup, CanvasStart }; - export interface WithKibanaProps { kibana: { services: CoreStart & CanvasStartDeps & { canvas: CanvasServices }; diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index 310ac5d65c98661..ca5a455411267c6 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -33,6 +33,7 @@ "server": true, "ui": true, "requiredBundles": [ + "canvas", "esUiShared", "kibanaUtils", "kibanaReact", diff --git a/x-pack/plugins/ml/public/embeddables/common/resolve_job_selection.tsx b/x-pack/plugins/ml/public/embeddables/common/resolve_job_selection.tsx index fbceeb7f7cf793b..01f0d884038b36b 100644 --- a/x-pack/plugins/ml/public/embeddables/common/resolve_job_selection.tsx +++ b/x-pack/plugins/ml/public/embeddables/common/resolve_job_selection.tsx @@ -16,6 +16,7 @@ import { } from '../../../../../../src/plugins/kibana_react/public'; import { getMlGlobalServices } from '../../application/app'; import { DashboardConstants } from '../../../../../../src/plugins/dashboard/public'; +import { CANVAS_APP } from '../../../../../../x-pack/plugins/canvas/public'; import { JobId } from '../../../common/types/anomaly_detection_jobs'; import { JobSelectorFlyout } from './components/job_selector_flyout'; @@ -90,8 +91,8 @@ export async function resolveJobSelection( } ); // Close the flyout when user navigates out of the dashboard plugin - currentAppId$.pipe(takeUntil(from(flyoutSession.onClose))).subscribe((appId) => { - if (appId !== DashboardConstants.DASHBOARDS_ID) { + currentAppId$.pipe(takeUntil(from(flyoutSession.onClose))).subscribe((appId = '') => { + if (![DashboardConstants.DASHBOARDS_ID, CANVAS_APP].includes(appId)) { flyoutSession.close(); } });