-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '172506-obsux-add-feedback-form-to-apm' of https://githu…
…b.com/jennypavlova/kibana into 172506-obsux-add-feedback-form-to-apm
- Loading branch information
Showing
32 changed files
with
667 additions
and
37 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/plugins/dashboard/public/dashboard_app/top_nav/add_panel_action_menu_items.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { getAddPanelActionMenuItems } from './add_panel_action_menu_items'; | ||
|
||
describe('getAddPanelActionMenuItems', () => { | ||
it('returns the items correctly', async () => { | ||
const registeredActions = [ | ||
{ | ||
id: 'ACTION_CREATE_ESQL_CHART', | ||
type: 'ACTION_CREATE_ESQL_CHART', | ||
getDisplayName: () => 'Action name', | ||
getIconType: () => 'pencil', | ||
getDisplayNameTooltip: () => 'Action tooltip', | ||
isCompatible: () => Promise.resolve(true), | ||
execute: jest.fn(), | ||
}, | ||
]; | ||
const items = getAddPanelActionMenuItems(registeredActions, jest.fn(), jest.fn(), jest.fn()); | ||
expect(items).toStrictEqual([ | ||
{ | ||
'data-test-subj': 'create-action-Action name', | ||
icon: 'pencil', | ||
name: 'Action name', | ||
onClick: expect.any(Function), | ||
toolTipContent: 'Action tooltip', | ||
}, | ||
]); | ||
}); | ||
|
||
it('returns empty array if no actions have been registered', async () => { | ||
const items = getAddPanelActionMenuItems([], jest.fn(), jest.fn(), jest.fn()); | ||
expect(items).toStrictEqual([]); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
src/plugins/dashboard/public/dashboard_app/top_nav/add_panel_action_menu_items.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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 { ActionExecutionContext, Action } from '@kbn/ui-actions-plugin/public'; | ||
import type { EmbeddableFactory } from '@kbn/embeddable-plugin/public'; | ||
import { addPanelMenuTrigger } from '../../triggers'; | ||
|
||
const onAddPanelActionClick = | ||
(action: Action, context: ActionExecutionContext<object>, closePopover: () => void) => | ||
(event: React.MouseEvent) => { | ||
closePopover(); | ||
if (event.currentTarget instanceof HTMLAnchorElement) { | ||
if ( | ||
!event.defaultPrevented && // onClick prevented default | ||
event.button === 0 && | ||
(!event.currentTarget.target || event.currentTarget.target === '_self') && | ||
!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) | ||
) { | ||
event.preventDefault(); | ||
action.execute(context); | ||
} | ||
} else action.execute(context); | ||
}; | ||
|
||
export const getAddPanelActionMenuItems = ( | ||
actions: Array<Action<object>> | undefined, | ||
createNewEmbeddable: (embeddableFactory: EmbeddableFactory) => void, | ||
deleteEmbeddable: (embeddableId: string) => void, | ||
closePopover: () => void | ||
) => { | ||
return ( | ||
actions?.map((item) => { | ||
const context = { | ||
createNewEmbeddable, | ||
deleteEmbeddable, | ||
trigger: addPanelMenuTrigger, | ||
}; | ||
const actionName = item.getDisplayName(context); | ||
return { | ||
name: actionName, | ||
icon: item.getIconType(context), | ||
onClick: onAddPanelActionClick(item, context, closePopover), | ||
'data-test-subj': `create-action-${actionName}`, | ||
toolTipContent: item?.getDisplayNameTooltip?.(context), | ||
}; | ||
}) ?? [] | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 { UiActionsStart } from '@kbn/ui-actions-plugin/public'; | ||
|
||
export interface DashboardUiActionsService { | ||
getTriggerCompatibleActions?: UiActionsStart['getTriggerCompatibleActions']; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/plugins/dashboard/public/services/ui_actions/ui_actions_service.stub.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; | ||
import { PluginServiceFactory } from '@kbn/presentation-util-plugin/public'; | ||
import { DashboardUiActionsService } from './types'; | ||
|
||
export type UIActionsServiceFactory = PluginServiceFactory<DashboardUiActionsService>; | ||
|
||
export const uiActionsServiceFactory: UIActionsServiceFactory = () => { | ||
const pluginMock = uiActionsPluginMock.createStartContract(); | ||
return { getTriggerCompatibleActions: pluginMock.getTriggerCompatibleActions }; | ||
}; |
Oops, something went wrong.