diff --git a/x-pack/plugins/advanced_ui_actions/public/drilldowns/drilldown_definition.ts b/x-pack/plugins/advanced_ui_actions/public/drilldowns/drilldown_definition.ts index 16c8077d727cb..f01dd22c06bc5 100644 --- a/x-pack/plugins/advanced_ui_actions/public/drilldowns/drilldown_definition.ts +++ b/x-pack/plugins/advanced_ui_actions/public/drilldowns/drilldown_definition.ts @@ -15,11 +15,6 @@ import { ActionFactoryDefinition } from '../dynamic_actions'; * `Config` is a serializable object containing the configuration that the * drilldown is able to collect using UI. * - * `PlaceContext` is an object that the app that opens drilldown management - * flyout provides to the React component, specifying the contextual information - * about that app. For example, on Dashboard app this context contains - * information about the current embeddable and dashboard. - * * `ExecutionContext` is an object created in response to user's interaction * and provided to the `execute` function of the drilldown. This object contains * information about the action user performed. diff --git a/x-pack/plugins/advanced_ui_actions/public/dynamic_actions/types.ts b/x-pack/plugins/advanced_ui_actions/public/dynamic_actions/types.ts index 9148d1ec7055a..fb513e892d413 100644 --- a/x-pack/plugins/advanced_ui_actions/public/dynamic_actions/types.ts +++ b/x-pack/plugins/advanced_ui_actions/public/dynamic_actions/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export interface SerializedAction { +export interface SerializedAction { readonly factoryId: string; readonly name: string; readonly config: Config; @@ -16,5 +16,5 @@ export interface SerializedAction { export interface SerializedEvent { eventId: string; triggers: string[]; - action: SerializedAction; + action: SerializedAction; } diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx index 81f88e563a258..381cad443e3ad 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx @@ -72,7 +72,6 @@ export class FlyoutCreateDrilldownAction implements ActionByType handle.close()} - placeContext={context} viewMode={'create'} dynamicActionManager={embeddable.enhancements.dynamicActions} /> diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx index a4499ba4d757d..5d2a90fdaff08 100644 --- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx +++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx @@ -60,7 +60,6 @@ export class FlyoutEditDrilldownAction implements ActionByType handle.close()} - placeContext={context} viewMode={'manage'} dynamicActionManager={embeddable.enhancements.dynamicActions} /> diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx index 16b4d3a25d9e5..a186feec33924 100644 --- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx +++ b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx @@ -38,6 +38,6 @@ const FlyoutManageDrilldowns = createFlyoutManageDrilldowns({ storiesOf('components/FlyoutManageDrilldowns', module).add('default', () => ( {}}> - + )); diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx index 52c53f32ff09b..152eaf18f16c1 100644 --- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx +++ b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx @@ -43,9 +43,7 @@ beforeEach(() => { }); test('Allows to manage drilldowns', async () => { - const screen = render( - - ); + const screen = render(); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getByText(/Manage Drilldowns/i)).toBeVisible()); @@ -112,9 +110,7 @@ test('Allows to manage drilldowns', async () => { }); test('Can delete multiple drilldowns', async () => { - const screen = render( - - ); + const screen = render(); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getByText(/Manage Drilldowns/i)).toBeVisible()); @@ -151,7 +147,6 @@ test('Create only mode', async () => { const onClose = jest.fn(); const screen = render( { test('After switching between action factories state is restored', async () => { const screen = render( - + ); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getAllByText(/Create/i).length).toBeGreaterThan(0)); @@ -216,9 +207,7 @@ test("Error when can't save drilldown changes", async () => { jest.spyOn(mockDynamicActionManager, 'createEvent').mockImplementationOnce(async () => { throw error; }); - const screen = render( - - ); + const screen = render(); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getByText(/Manage Drilldowns/i)).toBeVisible()); fireEvent.click(screen.getByText(/Create new/i)); @@ -236,9 +225,7 @@ test("Error when can't save drilldown changes", async () => { }); test('Should show drilldown welcome message. Should be able to dismiss it', async () => { - let screen = render( - - ); + let screen = render(); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getByText(/Manage Drilldowns/i)).toBeVisible()); @@ -248,9 +235,7 @@ test('Should show drilldown welcome message. Should be able to dismiss it', asyn expect(screen.queryByTestId(WELCOME_MESSAGE_TEST_SUBJ)).toBeNull(); cleanup(); - screen = render( - - ); + screen = render(); // wait for initial render. It is async because resolving compatible action factories is async await wait(() => expect(screen.getByText(/Manage Drilldowns/i)).toBeVisible()); expect(screen.queryByTestId(WELCOME_MESSAGE_TEST_SUBJ)).toBeNull(); diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx index 0d4a67e325e4d..fc9225c4ec04c 100644 --- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx +++ b/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx @@ -32,8 +32,7 @@ import { toastDrilldownsDeleted, } from './i18n'; -interface ConnectedFlyoutManageDrilldownsProps { - placeContext: Context; +interface ConnectedFlyoutManageDrilldownsProps { dynamicActionManager: DynamicActionManager; viewMode?: 'create' | 'manage'; onClose?: () => void; @@ -75,10 +74,9 @@ export function createFlyoutManageDrilldowns({ const factoryContext: object = React.useMemo( () => ({ - placeContext: props.placeContext, triggers: selectedTriggers, }), - [props.placeContext, selectedTriggers] + [selectedTriggers] ); const actionFactories = useCompatibleActionFactoriesForCurrentContext( @@ -222,12 +220,10 @@ export function createFlyoutManageDrilldowns({ } function useCompatibleActionFactoriesForCurrentContext( - actionFactories: Array>, + actionFactories: ActionFactory[], context: Context ) { - const [compatibleActionFactories, setCompatibleActionFactories] = useState< - Array> - >(); + const [compatibleActionFactories, setCompatibleActionFactories] = useState(); useEffect(() => { let canceled = false; async function updateCompatibleFactoriesForContext() { @@ -283,7 +279,7 @@ function useDrilldownsStateManager( } async function createDrilldown( - action: UiActionsEnhancedSerializedAction, + action: UiActionsEnhancedSerializedAction, selectedTriggers: Array ) { await run(async () => { @@ -297,7 +293,7 @@ function useDrilldownsStateManager( async function editDrilldown( drilldownId: string, - action: UiActionsEnhancedSerializedAction, + action: UiActionsEnhancedSerializedAction, selectedTriggers: Array ) { await run(async () => { diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx b/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx index 152cd393b9d3e..add8b748afee9 100644 --- a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx +++ b/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx @@ -15,17 +15,25 @@ import { urlFactory, // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../advanced_ui_actions/public/components/action_wizard/test_data'; +import { AdvancedUiActionsActionFactory as ActionFactory } from '../../../../advanced_ui_actions/public/'; storiesOf('components/FlyoutDrilldownWizard', module) .add('default', () => { - return ; + return ( + + ); }) .add('open in flyout - create', () => { return ( {}}> {}} - drilldownActionFactories={[urlFactory, dashboardFactory]} + drilldownActionFactories={[ + urlFactory as ActionFactory, + dashboardFactory as ActionFactory, + ]} /> ); @@ -35,7 +43,10 @@ storiesOf('components/FlyoutDrilldownWizard', module) {}}> {}} - drilldownActionFactories={[urlFactory, dashboardFactory]} + drilldownActionFactories={[ + urlFactory as ActionFactory, + dashboardFactory as ActionFactory, + ]} initialDrilldownWizardConfig={{ name: 'My fancy drilldown', actionFactory: urlFactory as any, @@ -54,7 +65,7 @@ storiesOf('components/FlyoutDrilldownWizard', module) {}}> {}} - drilldownActionFactories={[dashboardFactory]} + drilldownActionFactories={[dashboardFactory as ActionFactory]} initialDrilldownWizardConfig={{ name: 'My fancy drilldown', actionFactory: urlFactory as any, diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx b/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx index 1f775a5ff103f..84c1a04a71d15 100644 --- a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx +++ b/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx @@ -25,7 +25,7 @@ export interface DrilldownWizardConfig { } export interface FlyoutDrilldownWizardProps { - drilldownActionFactories: Array>; + drilldownActionFactories: ActionFactory[]; onSubmit?: (drilldownWizardConfig: Required) => void; onDelete?: () => void;