mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Uses async ui action for the triggers (#212008)](https://github.com/elastic/kibana/pull/212008) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-02-25T07:13:52Z","message":"[ES|QL] Uses async ui action for the triggers (#212008)\n\n## Summary\n\nChanges to use remove the deprecated method (almost no size changes)","sha":"8284bbeaecd31f341b774fd46ee2164f072dab8a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL] Uses async ui action for the triggers","number":212008,"url":"https://github.com/elastic/kibana/pull/212008","mergeCommit":{"message":"[ES|QL] Uses async ui action for the triggers (#212008)\n\n## Summary\n\nChanges to use remove the deprecated method (almost no size changes)","sha":"8284bbeaecd31f341b774fd46ee2164f072dab8a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212008","number":212008,"mergeCommit":{"message":"[ES|QL] Uses async ui action for the triggers (#212008)\n\n## Summary\n\nChanges to use remove the deprecated method (almost no size changes)","sha":"8284bbeaecd31f341b774fd46ee2164f072dab8a"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
a1cac05dae
commit
6202fd9d35
5 changed files with 54 additions and 44 deletions
|
@ -17,13 +17,14 @@ import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/publ
|
|||
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
|
||||
import { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||
import {
|
||||
updateESQLQueryTrigger,
|
||||
UpdateESQLQueryAction,
|
||||
UPDATE_ESQL_QUERY_TRIGGER,
|
||||
esqlControlTrigger,
|
||||
CreateESQLControlAction,
|
||||
ESQL_CONTROL_TRIGGER,
|
||||
} from './triggers';
|
||||
} from './triggers/esql_controls/esql_control_trigger';
|
||||
import {
|
||||
updateESQLQueryTrigger,
|
||||
UPDATE_ESQL_QUERY_TRIGGER,
|
||||
} from './triggers/update_esql_query/update_esql_query_trigger';
|
||||
import { ACTION_UPDATE_ESQL_QUERY, ACTION_CREATE_ESQL_CONTROL } from './triggers/constants';
|
||||
import { setKibanaServices } from './kibana_services';
|
||||
import { JoinIndicesAutocompleteResult } from '../common';
|
||||
import { cacheNonParametrizedAsyncFunction } from './util/cache';
|
||||
|
@ -74,11 +75,25 @@ export class EsqlPlugin implements Plugin<{}, EsqlPluginStart> {
|
|||
const storage = new Storage(localStorage);
|
||||
|
||||
// Register triggers
|
||||
const appendESQLAction = new UpdateESQLQueryAction(data);
|
||||
uiActions.addTriggerActionAsync(
|
||||
UPDATE_ESQL_QUERY_TRIGGER,
|
||||
ACTION_UPDATE_ESQL_QUERY,
|
||||
async () => {
|
||||
const { UpdateESQLQueryAction } = await import(
|
||||
'./triggers/update_esql_query/update_esql_query_actions'
|
||||
);
|
||||
const appendESQLAction = new UpdateESQLQueryAction(data);
|
||||
return appendESQLAction;
|
||||
}
|
||||
);
|
||||
|
||||
uiActions.addTriggerAction(UPDATE_ESQL_QUERY_TRIGGER, appendESQLAction);
|
||||
const createESQLControlAction = new CreateESQLControlAction(core, data.search.search);
|
||||
uiActions.addTriggerAction(ESQL_CONTROL_TRIGGER, createESQLControlAction);
|
||||
uiActions.addTriggerActionAsync(ESQL_CONTROL_TRIGGER, ACTION_CREATE_ESQL_CONTROL, async () => {
|
||||
const { CreateESQLControlAction } = await import(
|
||||
'./triggers/esql_controls/esql_control_action'
|
||||
);
|
||||
const createESQLControlAction = new CreateESQLControlAction(core, data.search.search);
|
||||
return createESQLControlAction;
|
||||
});
|
||||
|
||||
const variablesService = new EsqlVariablesService();
|
||||
|
||||
|
|
|
@ -7,11 +7,5 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export {
|
||||
updateESQLQueryTrigger,
|
||||
UPDATE_ESQL_QUERY_TRIGGER,
|
||||
} from './update_esql_query/update_esql_query_trigger';
|
||||
export { UpdateESQLQueryAction } from './update_esql_query/update_esql_query_actions';
|
||||
|
||||
export { esqlControlTrigger, ESQL_CONTROL_TRIGGER } from './esql_controls/esql_control_trigger';
|
||||
export { CreateESQLControlAction } from './esql_controls/esql_control_action';
|
||||
export const ACTION_CREATE_ESQL_CONTROL = 'ACTION_CREATE_ESQL_CONTROL';
|
||||
export const ACTION_UPDATE_ESQL_QUERY = 'ACTION_UPDATE_ESQL_QUERY';
|
|
@ -14,8 +14,8 @@ import type { ISearchGeneric } from '@kbn/search-types';
|
|||
import type { ESQLVariableType, ESQLControlVariable } from '@kbn/esql-validation-autocomplete';
|
||||
import { monaco } from '@kbn/monaco';
|
||||
import type { ESQLControlState } from './types';
|
||||
|
||||
const ACTION_CREATE_ESQL_CONTROL = 'ACTION_CREATE_ESQL_CONTROL';
|
||||
import { isActionCompatible, executeAction } from './esql_control_helpers';
|
||||
import { ACTION_CREATE_ESQL_CONTROL } from '../constants';
|
||||
|
||||
interface Context {
|
||||
queryString: string;
|
||||
|
@ -27,8 +27,6 @@ interface Context {
|
|||
initialState?: ESQLControlState;
|
||||
}
|
||||
|
||||
export const getHelpersAsync = async () => await import('./esql_control_helpers');
|
||||
|
||||
export class CreateESQLControlAction implements Action<Context> {
|
||||
public type = ACTION_CREATE_ESQL_CONTROL;
|
||||
public id = ACTION_CREATE_ESQL_CONTROL;
|
||||
|
@ -47,7 +45,6 @@ export class CreateESQLControlAction implements Action<Context> {
|
|||
}
|
||||
|
||||
public async isCompatible({ queryString }: Context) {
|
||||
const { isActionCompatible } = await getHelpersAsync();
|
||||
return isActionCompatible(queryString);
|
||||
}
|
||||
|
||||
|
@ -60,7 +57,6 @@ export class CreateESQLControlAction implements Action<Context> {
|
|||
cursorPosition,
|
||||
initialState,
|
||||
}: Context) {
|
||||
const { executeAction } = await getHelpersAsync();
|
||||
return executeAction({
|
||||
queryString,
|
||||
core: this.core,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* 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 React from 'react';
|
||||
import React, { lazy, Suspense, Fragment } from 'react';
|
||||
import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
|
||||
|
@ -15,7 +15,6 @@ import type { ISearchGeneric } from '@kbn/search-types';
|
|||
import type { ESQLVariableType, ESQLControlVariable } from '@kbn/esql-validation-autocomplete';
|
||||
import { toMountPoint } from '@kbn/react-kibana-mount';
|
||||
import { monaco } from '@kbn/monaco';
|
||||
import { ESQLControlsFlyout } from './control_flyout';
|
||||
import { untilPluginStartServicesReady } from '../../kibana_services';
|
||||
import type { ESQLControlState } from './types';
|
||||
|
||||
|
@ -35,6 +34,8 @@ export async function isActionCompatible(queryString: string) {
|
|||
return Boolean(queryString && queryString.trim().length > 0);
|
||||
}
|
||||
|
||||
const Fallback = () => <Fragment />;
|
||||
|
||||
export async function executeAction({
|
||||
queryString,
|
||||
core,
|
||||
|
@ -50,6 +51,12 @@ export async function executeAction({
|
|||
if (!isCompatibleAction) {
|
||||
throw new IncompatibleActionError();
|
||||
}
|
||||
const LazyControlFlyout = lazy(async () => {
|
||||
const { ESQLControlsFlyout } = await import('./control_flyout');
|
||||
return {
|
||||
default: ESQLControlsFlyout,
|
||||
};
|
||||
});
|
||||
|
||||
const deps = await untilPluginStartServicesReady();
|
||||
const handle = core.overlays.openFlyout(
|
||||
|
@ -61,19 +68,21 @@ export async function executeAction({
|
|||
...deps,
|
||||
}}
|
||||
>
|
||||
<ESQLControlsFlyout
|
||||
queryString={queryString}
|
||||
search={search}
|
||||
variableType={variableType}
|
||||
closeFlyout={() => {
|
||||
handle.close();
|
||||
}}
|
||||
onSaveControl={onSaveControl}
|
||||
onCancelControl={onCancelControl}
|
||||
cursorPosition={cursorPosition}
|
||||
initialState={initialState}
|
||||
esqlVariables={esqlVariables}
|
||||
/>
|
||||
<Suspense fallback={<Fallback />}>
|
||||
<LazyControlFlyout
|
||||
queryString={queryString}
|
||||
search={search}
|
||||
variableType={variableType}
|
||||
closeFlyout={() => {
|
||||
handle.close();
|
||||
}}
|
||||
onSaveControl={onSaveControl}
|
||||
onCancelControl={onCancelControl}
|
||||
cursorPosition={cursorPosition}
|
||||
initialState={initialState}
|
||||
esqlVariables={esqlVariables}
|
||||
/>
|
||||
</Suspense>
|
||||
</KibanaContextProvider>
|
||||
</KibanaRenderContextProvider>,
|
||||
{
|
||||
|
|
|
@ -10,15 +10,13 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import type { Action } from '@kbn/ui-actions-plugin/public';
|
||||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
|
||||
const ACTION_UPDATE_ESQL_QUERY = 'ACTION_UPDATE_ESQL_QUERY';
|
||||
import { isActionCompatible, executeAction } from './update_esql_query_helpers';
|
||||
import { ACTION_UPDATE_ESQL_QUERY } from '../constants';
|
||||
|
||||
interface Context {
|
||||
queryString: string;
|
||||
}
|
||||
|
||||
export const getHelpersAsync = async () => await import('./update_esql_query_helpers');
|
||||
|
||||
export class UpdateESQLQueryAction implements Action<Context> {
|
||||
public type = ACTION_UPDATE_ESQL_QUERY;
|
||||
public id = ACTION_UPDATE_ESQL_QUERY;
|
||||
|
@ -37,12 +35,10 @@ export class UpdateESQLQueryAction implements Action<Context> {
|
|||
}
|
||||
|
||||
public async isCompatible() {
|
||||
const { isActionCompatible } = await getHelpersAsync();
|
||||
return isActionCompatible(this.data);
|
||||
}
|
||||
|
||||
public async execute({ queryString }: Context) {
|
||||
const { executeAction } = await getHelpersAsync();
|
||||
return executeAction({
|
||||
queryString,
|
||||
data: this.data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue