-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[visualizations] lazy load actions #207147
Changes from 16 commits
4a737da
d531462
38a0327
7716863
12d3a91
a7f8948
369600f
5b763ad
a6ffda8
c553c90
3af143d
b67ff3d
0b5e490
17f52e1
ad4f6e6
0371c2c
c850ebb
4bcd8f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { DataPublicPluginStart } from '@kbn/data-plugin/public'; | ||
import { CONTEXT_MENU_TRIGGER } from '@kbn/embeddable-plugin/public'; | ||
import { ADD_PANEL_TRIGGER, type UiActionsStart } from '@kbn/ui-actions-plugin/public'; | ||
import { ACTION_EDIT_IN_LENS, ADD_AGG_VIS_ACTION_ID } from './constants'; | ||
import { TypesStart } from '../vis_types/types_service'; | ||
|
||
export function registerActions( | ||
uiActions: UiActionsStart, | ||
data: DataPublicPluginStart, | ||
types: TypesStart | ||
) { | ||
uiActions.addTriggerActionAsync(CONTEXT_MENU_TRIGGER, ACTION_EDIT_IN_LENS, async () => { | ||
const { EditInLensAction } = await import('./actions_module'); | ||
return new EditInLensAction(data.query.timefilter.timefilter); | ||
}); | ||
|
||
uiActions.addTriggerActionAsync(ADD_PANEL_TRIGGER, ADD_AGG_VIS_ACTION_ID, async () => { | ||
const { AddAggVisualizationPanelAction } = await import('./actions_module'); | ||
return new AddAggVisualizationPanelAction(types); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { type HasType, apiIsOfType } from '@kbn/presentation-publishing'; | ||
import type { HasType } from '@kbn/presentation-publishing'; | ||
import { VisParams } from '../../types'; | ||
import Vis from '../../vis'; | ||
|
||
|
@@ -18,7 +18,7 @@ export type HasVisualizeConfig = HasType<'visualization'> & { | |
export const apiHasVisualizeConfig = (api: unknown): api is HasVisualizeConfig => { | ||
return Boolean( | ||
api && | ||
apiIsOfType(api, 'visualization') && | ||
(api as HasType)?.type === 'visualization' && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid using |
||
typeof (api as HasVisualizeConfig).getVis === 'function' | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
export function getFullPath(id: string) { | ||
return `/app/visualize#/edit/${id}`; | ||
} | ||
|
||
export function urlFor(id: string) { | ||
return `#/edit/${encodeURIComponent(id)}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of importing the
actions_modules
isn't better to directly import the Action directly from its file?Since we are async loading these to reduce a bit the initial loading we can probably also gain a bit during the action loading if we async load the Actions independently, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense since the actions are for different triggers. Resolved with 4bcd8f0