Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-202707
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko authored Dec 18, 2024
2 parents a02bb80 + b10bef3 commit abd836c
Show file tree
Hide file tree
Showing 33 changed files with 92 additions and 592 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ packages/kbn-apm-types @elastic/obs-ux-infra_services-team
packages/kbn-apm-utils @elastic/obs-ux-infra_services-team
test/plugin_functional/plugins/app_link_test @elastic/kibana-core
x-pack/test/usage_collection/plugins/application_usage_test @elastic/kibana-core
x-pack/solutions/security/plugins/asset_inventory @elastic/kibana-cloud-security-posture
x-pack/test/security_api_integration/plugins/audit_log @elastic/kibana-security
src/platform/packages/shared/kbn-avc-banner @elastic/security-defend-workflows
packages/kbn-axe-config @elastic/kibana-qa
Expand Down
4 changes: 0 additions & 4 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,6 @@ The plugin exposes the static DefaultEditorController class to consume.
|WARNING: Missing README.
|{kib-repo}blob/{branch}/x-pack/solutions/security/plugins/asset_inventory/README.md[assetInventory]
|Centralized asset inventory experience within the Elastic Security solution. A central place for users to view and manage all their assets from different environments.
|{kib-repo}blob/{branch}/x-pack/plugins/banners/README.md[banners]
|Allow to add a header banner that will be displayed on every page of the Kibana application
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@
"@kbn/apm-utils": "link:packages/kbn-apm-utils",
"@kbn/app-link-test-plugin": "link:test/plugin_functional/plugins/app_link_test",
"@kbn/application-usage-test-plugin": "link:x-pack/test/usage_collection/plugins/application_usage_test",
"@kbn/asset-inventory-plugin": "link:x-pack/solutions/security/plugins/asset_inventory",
"@kbn/audit-log-plugin": "link:x-pack/test/security_api_integration/plugins/audit_log",
"@kbn/avc-banner": "link:src/platform/packages/shared/kbn-avc-banner",
"@kbn/banners-plugin": "link:x-pack/plugins/banners",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pageLoadAssetSize:
aiops: 18000
alerting: 106936
apm: 64385
assetInventory: 18478
banners: 17946
bfetch: 22837
canvas: 29355
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
"@kbn/app-link-test-plugin/*": ["test/plugin_functional/plugins/app_link_test/*"],
"@kbn/application-usage-test-plugin": ["x-pack/test/usage_collection/plugins/application_usage_test"],
"@kbn/application-usage-test-plugin/*": ["x-pack/test/usage_collection/plugins/application_usage_test/*"],
"@kbn/asset-inventory-plugin": ["x-pack/solutions/security/plugins/asset_inventory"],
"@kbn/asset-inventory-plugin/*": ["x-pack/solutions/security/plugins/asset_inventory/*"],
"@kbn/audit-log-plugin": ["x-pack/test/security_api_integration/plugins/audit_log"],
"@kbn/audit-log-plugin/*": ["x-pack/test/security_api_integration/plugins/audit_log/*"],
"@kbn/avc-banner": ["src/platform/packages/shared/kbn-avc-banner"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ export const StandaloneInstructions = ({
const { windows: windowsDownloadSourceProxyArgs, curl: curlDownloadSourceProxyArgs } =
getDownloadSourceProxyArgs(downloadSourceProxy);

const linuxDebCommand = `curl -L -O ${downloadBaseUrl}/downloads/beats/elastic-agent/elastic-agent-${agentVersion}-amd64.deb ${curlDownloadSourceProxyArgs}
const linuxDebCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-amd64.deb ${curlDownloadSourceProxyArgs}
sudo dpkg -i elastic-agent-${agentVersion}-amd64.deb \nsudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent`;

const linuxRpmCommand = `curl -L -O ${downloadBaseUrl}/downloads/beats/elastic-agent/elastic-agent-${agentVersion}-x86_64.rpm ${curlDownloadSourceProxyArgs}
const linuxRpmCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-x86_64.rpm ${curlDownloadSourceProxyArgs}
sudo rpm -vi elastic-agent-${agentVersion}-x86_64.rpm \nsudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent`;

const linuxCommand = `curl -L -O ${downloadBaseUrl}/downloads/beats/elastic-agent/elastic-agent-${agentVersion}-linux-x86_64.tar.gz ${curlDownloadSourceProxyArgs}
const linuxCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-linux-x86_64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-linux-x86_64.tar.gz
cd elastic-agent-${agentVersion}-linux-x86_64
sudo ./elastic-agent install`;

const macCommand = `curl -L -O ${downloadBaseUrl}/downloads/beats/elastic-agent/elastic-agent-${agentVersion}-darwin-aarch64.tar.gz ${curlDownloadSourceProxyArgs}
const macCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-darwin-aarch64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-darwin-aarch64.tar.gz
cd elastic-agent-${agentVersion}-darwin-aarch64
sudo ./elastic-agent install`;

const windowsCommand = `$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri ${downloadBaseUrl}/downloads/beats/elastic-agent/elastic-agent-${agentVersion}-windows-x86_64.zip -OutFile elastic-agent-${agentVersion}-windows-x86_64.zip ${windowsDownloadSourceProxyArgs}
Invoke-WebRequest -Uri ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-windows-x86_64.zip -OutFile elastic-agent-${agentVersion}-windows-x86_64.zip ${windowsDownloadSourceProxyArgs}
Expand-Archive .\elastic-agent-${agentVersion}-windows-x86_64.zip -DestinationPath .
cd elastic-agent-${agentVersion}-windows-x86_64
.\\elastic-agent.exe install`;
Expand Down
16 changes: 4 additions & 12 deletions x-pack/plugins/lens/public/react_embeddable/data_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import {
import fastIsEqual from 'fast-deep-equal';
import { pick } from 'lodash';
import { getEditPath } from '../../common/constants';
import type {
GetStateType,
LensApi,
LensInternalApi,
LensPublicCallbacks,
VisualizationContextHelper,
} from './types';
import type { GetStateType, LensApi, LensInternalApi, LensPublicCallbacks } from './types';
import { getExpressionRendererParams } from './expressions/expression_params';
import type { LensEmbeddableStartServices } from './types';
import { prepareCallbacks } from './expressions/callbacks';
Expand Down Expand Up @@ -84,7 +78,6 @@ export function loadEmbeddableData(
parentApi: unknown,
internalApi: LensInternalApi,
services: LensEmbeddableStartServices,
{ getVisualizationContext, updateVisualizationContext }: VisualizationContextHelper,
metaInfo?: SharingSavedObjectProps
) {
const { onLoad, onBeforeBadgesRender, ...callbacks } = apiHasLensComponentCallbacks(parentApi)
Expand All @@ -103,7 +96,6 @@ export function loadEmbeddableData(
} = buildUserMessagesHelpers(
api,
internalApi,
getVisualizationContext,
services,
onBeforeBadgesRender,
services.spaces,
Expand Down Expand Up @@ -174,7 +166,7 @@ export function loadEmbeddableData(
};

const onDataCallback = (adapters: Partial<DefaultInspectorAdapters> | undefined) => {
updateVisualizationContext({
internalApi.updateVisualizationContext({
activeData: adapters?.tables?.tables,
});
// data has loaded
Expand Down Expand Up @@ -243,8 +235,8 @@ export function loadEmbeddableData(

// update the visualization context before anything else
// as it will be used to compute blocking errors also in case of issues
updateVisualizationContext({
doc: currentState.attributes,
internalApi.updateVisualizationContext({
activeAttributes: currentState.attributes,
mergedSearchContext: params?.searchContext || {},
...rest,
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/react_embeddable/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function createEmptyLensState(
query: query || { query: '', language: 'kuery' },
filters: filters || [],
internalReferences: [],
datasourceStates: { ...(isTextBased ? { text_based: {} } : { form_based: {} }) },
datasourceStates: { ...(isTextBased ? { textBased: {} } : { formBased: {} }) },
visualization: {},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
getLensApiMock,
makeEmbeddableServices,
getLensRuntimeStateMock,
getVisualizationContextHelperMock,
createUnifiedSearchApi,
getLensInternalApiMock,
} from '../mocks';
import { createEmptyLensState } from '../helper';
const DATAVIEW_ID = 'myDataView';
Expand All @@ -40,11 +40,17 @@ function setupActionsApi(
) {
const services = makeEmbeddableServices(undefined, undefined, {
visOverrides: { id: 'lnsXY' },
dataOverrides: { id: 'form_based' },
dataOverrides: { id: 'formBased' },
});
const uuid = faker.random.uuid();
const runtimeState = getLensRuntimeStateMock(stateOverrides);
const apiMock = getLensApiMock();
// create the internal API and customize internal state
const internalApi = getLensInternalApiMock();
internalApi.updateVisualizationContext({
...contextOverrides,
activeAttributes: runtimeState.attributes,
});

const { api } = initializeActionApi(
uuid,
Expand All @@ -53,7 +59,7 @@ function setupActionsApi(
createUnifiedSearchApi(),
pick(apiMock, ['timeRange$']),
pick(apiMock, ['panelTitle']),
getVisualizationContextHelperMock(stateOverrides?.attributes, contextOverrides),
internalApi,
{
...services,
data: {
Expand Down Expand Up @@ -85,6 +91,7 @@ describe('Dashboard actions', () => {
describe('Explore in Discover', () => {
// make it pass the basic check on viewUnderlyingData
const visualizationContextMockOverrides = {
activeAttributes: undefined,
mergedSearchContext: {},
indexPatterns: {
[DATAVIEW_ID]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import { buildObservableVariable, isTextBasedLanguage } from '../helper';
import type {
GetStateType,
LensEmbeddableStartServices,
LensInternalApi,
LensRuntimeState,
ViewInDiscoverCallbacks,
ViewUnderlyingDataArgs,
VisualizationContextHelper,
} from '../types';
import { getActiveDatasourceIdFromDoc, getActiveVisualizationIdFromDoc } from '../../utils';

Expand Down Expand Up @@ -120,7 +120,7 @@ function getViewUnderlyingDataArgs({

function loadViewUnderlyingDataArgs(
state: LensRuntimeState,
{ getVisualizationContext }: VisualizationContextHelper,
{ getVisualizationContext }: LensInternalApi,
searchContextApi: { timeRange$: PublishingSubject<TimeRange | undefined> },
parentApi: unknown,
{
Expand All @@ -132,16 +132,21 @@ function loadViewUnderlyingDataArgs(
visualizationMap,
}: LensEmbeddableStartServices
) {
const { doc, activeData, activeDatasourceState, activeVisualizationState, indexPatterns } =
getVisualizationContext();
const activeVisualizationId = getActiveVisualizationIdFromDoc(doc);
const activeDatasourceId = getActiveDatasourceIdFromDoc(doc);
const {
activeAttributes,
activeData,
activeDatasourceState,
activeVisualizationState,
indexPatterns,
} = getVisualizationContext();
const activeVisualizationId = getActiveVisualizationIdFromDoc(activeAttributes);
const activeDatasourceId = getActiveDatasourceIdFromDoc(activeAttributes);
const activeVisualization = activeVisualizationId
? visualizationMap[activeVisualizationId]
: undefined;
const activeDatasource = activeDatasourceId ? datasourceMap[activeDatasourceId] : undefined;
if (
!doc ||
!activeAttributes ||
!activeData ||
!activeDatasource ||
!activeDatasourceState ||
Expand Down Expand Up @@ -199,7 +204,7 @@ function loadViewUnderlyingDataArgs(

function createViewUnderlyingDataApis(
getState: GetStateType,
visualizationContextHelper: VisualizationContextHelper,
internalApi: LensInternalApi,
searchContextApi: { timeRange$: PublishingSubject<TimeRange | undefined> },
parentApi: unknown,
services: LensEmbeddableStartServices
Expand All @@ -213,7 +218,7 @@ function createViewUnderlyingDataApis(
loadViewUnderlyingData: () => {
viewUnderlyingDataArgs = loadViewUnderlyingDataArgs(
getState(),
visualizationContextHelper,
internalApi,
searchContextApi,
parentApi,
services
Expand All @@ -237,7 +242,7 @@ export function initializeActionApi(
parentApi: unknown,
searchContextApi: { timeRange$: PublishingSubject<TimeRange | undefined> },
titleApi: { panelTitle: PublishingSubject<string | undefined> },
visualizationContextHelper: VisualizationContextHelper,
internalApi: LensInternalApi,
services: LensEmbeddableStartServices
): {
api: ViewInDiscoverCallbacks & HasDynamicActions;
Expand All @@ -257,7 +262,7 @@ export function initializeActionApi(
...(isTextBasedLanguage(initialState) ? {} : dynamicActionsApi?.dynamicActionsApi ?? {}),
...createViewUnderlyingDataApis(
getLatestState,
visualizationContextHelper,
internalApi,
searchContextApi,
parentApi,
services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
LensInternalApi,
LensOverrides,
LensRuntimeState,
VisualizationContext,
} from '../types';
import { apiHasAbortController, apiHasLensComponentProps } from '../type_guards';
import type { UserMessage } from '../../types';
Expand Down Expand Up @@ -52,6 +53,18 @@ export function initializeInternalApi(
// the isNewPanel won't be serialized so it will be always false after the edit panel closes applying the changes
const isNewlyCreated$ = new BehaviorSubject<boolean>(initialState.isNewPanel || false);

const visualizationContext$ = new BehaviorSubject<VisualizationContext>({
// doc can point to a different set of attributes for the visualization
// i.e. when inline editing or applying a suggestion
activeAttributes: initialState.attributes,
mergedSearchContext: {},
indexPatterns: {},
indexPatternRefs: [],
activeVisualizationState: undefined,
activeDatasourceState: undefined,
activeData: undefined,
});

// No need to expose anything at public API right now, that would happen later on
// where each initializer will pick what it needs and publish it
return {
Expand All @@ -65,6 +78,8 @@ export function initializeInternalApi(
renderCount$,
isNewlyCreated$,
dataViews: dataViews$,
messages$,
validationMessages$,
dispatchError: () => {
hasRenderCompleted$.next(true);
renderCount$.next(renderCount$.getValue() + 1);
Expand All @@ -82,9 +97,7 @@ export function initializeInternalApi(
updateAbortController: (abortController: AbortController | undefined) =>
expressionAbortController$.next(abortController),
updateDataViews: (dataViews: DataView[] | undefined) => dataViews$.next(dataViews),
messages$,
updateMessages: (newMessages: UserMessage[]) => messages$.next(newMessages),
validationMessages$,
updateValidationMessages: (newMessages: UserMessage[]) => validationMessages$.next(newMessages),
resetAllMessages: () => {
messages$.next([]);
Expand Down Expand Up @@ -116,5 +129,12 @@ export function initializeInternalApi(

return displayOptions;
},
getVisualizationContext: () => visualizationContext$.getValue(),
updateVisualizationContext: (newVisualizationContext: Partial<VisualizationContext>) => {
visualizationContext$.next({
...visualizationContext$.getValue(),
...newVisualizationContext,
});
},
};
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { initializeInspector } from './initializers/initialize_inspector';
import { initializeDashboardServices } from './initializers/initialize_dashboard_services';
import { initializeInternalApi } from './initializers/initialize_internal_api';
import { initializeSearchContext } from './initializers/initialize_search_context';
import { initializeVisualizationContext } from './initializers/initialize_visualization_context';
import { initializeActionApi } from './initializers/initialize_actions';
import { initializeIntegrations } from './initializers/initialize_integrations';
import { initializeStateManagement } from './initializers/initialize_state_management';
Expand Down Expand Up @@ -61,8 +60,6 @@ export const createLensEmbeddableFactory = (
*/
const internalApi = initializeInternalApi(initialState, parentApi, services);

const visualizationContextHelper = initializeVisualizationContext(internalApi);

/**
* Initialize various configurations required to build all the required
* parts for the Lens embeddable.
Expand Down Expand Up @@ -108,7 +105,7 @@ export const createLensEmbeddableFactory = (
parentApi,
searchContextConfig.api,
dashboardConfig.api,
visualizationContextHelper,
internalApi,
services
);

Expand Down Expand Up @@ -165,8 +162,7 @@ export const createLensEmbeddableFactory = (
api,
parentApi,
internalApi,
services,
visualizationContextHelper
services
);

const onUnmount = () => {
Expand Down
Loading

0 comments on commit abd836c

Please sign in to comment.