Skip to content

Commit

Permalink
Merge branch '8.11' into backport/8.11/pr-170988
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 20, 2023
2 parents 701450f + 3952ce8 commit 91f4c3d
Show file tree
Hide file tree
Showing 37 changed files with 292 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ enabled:
- x-pack/test/alerting_api_integration/security_and_spaces/group1/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group2/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group3/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group4/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group3/config_with_schedule_circuit_breaker.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group2/config_non_dedicated_task_runner.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group4/config_non_dedicated_task_runner.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/config.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/config.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/config.ts
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,6 @@ export class Config {
}

getDistPluginsFromRepo() {
return getPackages(this.repoRoot).filter(this.pluginFilter);
return getPackages(this.repoRoot).filter((p) => !p.isDevOnly() && this.pluginFilter(p));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
* Side Public License, v 1.
*/

import { PluginPackage } from '@kbn/repo-packages';
import { findUsedDependencies } from './find_used_dependencies';
import { read, write, Task } from '../../lib';

export const CreatePackageJson: Task = {
description: 'Creating build-ready version of package.json',

async run(config, log, build) {
const plugins = config.getDistPluginsFromRepo();
const plugins = config.getDistPluginsFromRepo() as PluginPackage[];
const distPkgIds = new Set(config.getDistPackagesFromRepo().map((p) => p.id));
const pkg = config.getKibanaPkg();

Expand Down
15 changes: 9 additions & 6 deletions src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { useDashboardOutcomeValidation } from './hooks/use_dashboard_outcome_val
import { loadDashboardHistoryLocationState } from './locator/load_dashboard_history_location_state';
import type { DashboardCreationOptions } from '../dashboard_container/embeddable/dashboard_container_factory';
import { DashboardTopNav } from '../dashboard_top_nav';
import { DashboardTabTitleSetter } from './tab_title_setter/dashboard_tab_title_setter';

export interface DashboardAppProps {
history: History;
Expand Down Expand Up @@ -196,15 +197,17 @@ export function DashboardApp({
{!showNoDataPage && (
<>
{dashboardAPI && (
<DashboardTopNav
redirectTo={redirectTo}
embedSettings={embedSettings}
dashboardContainer={dashboardAPI}
/>
<>
<DashboardTabTitleSetter dashboardContainer={dashboardAPI} />
<DashboardTopNav
redirectTo={redirectTo}
embedSettings={embedSettings}
dashboardContainer={dashboardAPI}
/>
</>
)}

{getLegacyConflictWarning?.()}

<DashboardRenderer
ref={setDashboardAPI}
dashboardRedirect={redirectTo}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 { useEffect } from 'react';

import { ViewMode } from '@kbn/embeddable-plugin/common';

import { pluginServices } from '../../services/plugin_services';
import { DashboardAPI } from '../..';
import { getDashboardTitle } from '../_dashboard_app_strings';

export const DashboardTabTitleSetter = ({
dashboardContainer,
}: {
dashboardContainer: DashboardAPI;
}) => {
const {
chrome: { docTitle: chromeDocTitle },
} = pluginServices.getServices();
const title = dashboardContainer.select((state) => state.explicitInput.title);
const lastSavedId = dashboardContainer.select((state) => state.componentState.lastSavedId);

/**
* Set chrome tab title when dashboard's title changes
*/
useEffect(() => {
/** We do not want the tab title to include the "Editing" prefix, so always send in view mode */
chromeDocTitle.change(getDashboardTitle(title, ViewMode.VIEW, !lastSavedId));
}, [title, chromeDocTitle, lastSavedId]);

return null;
};
21 changes: 15 additions & 6 deletions test/functional/apps/dashboard/group5/dashboard_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const browser = getService('browser');
const globalNav = getService('globalNav');
const kibanaServer = getService('kibanaServer');
const dashboardSettings = getService('dashboardSettings');
Expand All @@ -20,6 +21,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('dashboard settings', () => {
let originalTitles: string[] = [];

const checkDashboardTitle = async (expectedTitle: string) => {
expect(await browser.getTitle()).to.equal(`${expectedTitle} - Elastic`);
await retry.try(async () => {
const breadcrumb = await globalNav.getLastBreadcrumb();
expect(breadcrumb).to.equal(`Editing ${expectedTitle}`);
});
};

before(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
Expand Down Expand Up @@ -60,13 +69,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should update the title of the dashboard', async () => {
await checkDashboardTitle('few panels');

const newTitle = 'My awesome dashboard!!1';
await PageObjects.dashboard.openSettingsFlyout();
await dashboardSettings.setCustomPanelTitle(newTitle);
await dashboardSettings.clickApplyButton();
await retry.try(async () => {
expect((await globalNav.getLastBreadcrumb()) === newTitle);
});

await checkDashboardTitle(newTitle);
});

it('should disable quick save when the settings are open', async () => {
Expand Down Expand Up @@ -106,9 +116,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardSettings.expectDuplicateTitleWarningDisplayed();
});
await dashboardSettings.clickApplyButton();
await retry.try(async () => {
expect((await globalNav.getLastBreadcrumb()) === newTitle);
});

await checkDashboardTitle(newTitle);
});
});
}
36 changes: 23 additions & 13 deletions x-pack/plugins/features/server/feature_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ describe('FeatureRegistry', () => {
app: ['app1'],
savedObject: {
all: ['space', 'etc', 'telemetry'],
read: ['canvas', 'config', 'url'],
read: ['canvas', 'config', 'config-global', 'url'],
},
api: ['someApiEndpointTag', 'anotherEndpointTag'],
ui: ['allowsFoo', 'showBar', 'showBaz'],
},
read: {
savedObject: {
all: [],
read: ['config', 'url', 'telemetry'],
read: ['config', 'config-global', 'url', 'telemetry'],
},
ui: [],
},
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('FeatureRegistry', () => {
app: ['app1'],
savedObject: {
all: ['space', 'etc', 'telemetry'],
read: ['canvas', 'config', 'url'],
read: ['canvas', 'config', 'config-global', 'url'],
},
api: ['someApiEndpointTag', 'anotherEndpointTag'],
ui: ['allowsFoo', 'showBar', 'showBaz'],
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('FeatureRegistry', () => {
expect(allPrivilege?.savedObject.all).toEqual(['telemetry']);
});

it(`automatically grants access to config, url, and telemetry saved objects`, () => {
it(`automatically grants access to config, config-global, url, and telemetry saved objects`, () => {
const feature: KibanaFeatureConfig = {
id: 'test-feature',
name: 'Test Feature',
Expand Down Expand Up @@ -324,11 +324,16 @@ describe('FeatureRegistry', () => {

const allPrivilege = result[0].privileges?.all;
const readPrivilege = result[0].privileges?.read;
expect(allPrivilege?.savedObject.read).toEqual(['config', 'url']);
expect(readPrivilege?.savedObject.read).toEqual(['config', 'telemetry', 'url']);
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url']);
expect(readPrivilege?.savedObject.read).toEqual([
'config',
'config-global',
'telemetry',
'url',
]);
});

it(`automatically grants 'all' access to telemetry and 'read' to [config, url] saved objects for the reserved privilege`, () => {
it(`automatically grants 'all' access to telemetry and 'read' to [config, config-global, url] saved objects for the reserved privilege`, () => {
const feature: KibanaFeatureConfig = {
id: 'test-feature',
name: 'Test Feature',
Expand Down Expand Up @@ -359,7 +364,7 @@ describe('FeatureRegistry', () => {

const reservedPrivilege = result[0]!.reserved!.privileges[0].privilege;
expect(reservedPrivilege.savedObject.all).toEqual(['telemetry']);
expect(reservedPrivilege.savedObject.read).toEqual(['config', 'url']);
expect(reservedPrivilege.savedObject.read).toEqual(['config', 'config-global', 'url']);
});

it(`does not duplicate the automatic grants if specified on the incoming feature`, () => {
Expand All @@ -373,14 +378,14 @@ describe('FeatureRegistry', () => {
ui: [],
savedObject: {
all: ['telemetry'],
read: ['config', 'url'],
read: ['config', 'config-global', 'url'],
},
},
read: {
ui: [],
savedObject: {
all: [],
read: ['config', 'url'],
read: ['config', 'config-global', 'url'],
},
},
},
Expand All @@ -397,8 +402,13 @@ describe('FeatureRegistry', () => {
const allPrivilege = result[0].privileges!.all;
const readPrivilege = result[0].privileges!.read;
expect(allPrivilege?.savedObject.all).toEqual(['telemetry']);
expect(allPrivilege?.savedObject.read).toEqual(['config', 'url']);
expect(readPrivilege?.savedObject.read).toEqual(['config', 'url', 'telemetry']);
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url']);
expect(readPrivilege?.savedObject.read).toEqual([
'config',
'config-global',
'url',
'telemetry',
]);
});

it(`does not allow duplicate features to be registered`, () => {
Expand Down Expand Up @@ -484,7 +494,7 @@ describe('FeatureRegistry', () => {
name: 'Foo',
app: ['app1', 'app2'],
savedObject: {
all: ['config', 'space', 'etc'],
all: ['config', 'config-global', 'space', 'etc'],
read: ['canvas'],
},
api: ['someApiEndpointTag', 'anotherEndpointTag'],
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/features/server/feature_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ function applyAutomaticAllPrivilegeGrants(
allPrivileges.forEach((allPrivilege) => {
if (allPrivilege) {
allPrivilege.savedObject.all = uniq([...allPrivilege.savedObject.all, 'telemetry']);
allPrivilege.savedObject.read = uniq([...allPrivilege.savedObject.read, 'config', 'url']);
allPrivilege.savedObject.read = uniq([
...allPrivilege.savedObject.read,
'config',
'config-global',
'url',
]);
}
});
}
Expand All @@ -131,6 +136,7 @@ function applyAutomaticReadPrivilegeGrants(
readPrivilege.savedObject.read = uniq([
...readPrivilege.savedObject.read,
'config',
'config-global',
'telemetry',
'url',
]);
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/maps/common/mvt_request_body.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ describe('getHitsTileRequest', () => {
expect(path).toEqual('/my%20index/_mvt/my%20location/0/0/0');
});

test(`Should use requestBody.size to set both track_total_hits and size parameters`, () => {
const searchRequest = {
size: 20000,
runtime_mappings: {},
query: {},
};
const { body } = getHitsTileRequest({
buffer: 5,
risonRequestBody: rison.encode(searchRequest),
geometryFieldName: 'my location',
hasLabels: true,
index: 'my index',
x: 0,
y: 0,
z: 0,
});
expect(body?.track_total_hits).toEqual(20001);
expect(body?.size).toEqual(20000);
});

describe('sort', () => {
test(`Should include sort`, () => {
const searchRequest = {
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/maps/common/mvt_request_body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ export function getHitsTileRequest({
if (!requestBody) {
throw new Error('Required requestBody parameter not provided');
}
const size = typeof requestBody.size === 'number' ? requestBody.size : 10000;
const tileRequestBody = {
buffer,
grid_precision: 0, // no aggs
exact_bounds: true,
extent: 4096, // full resolution,
query: requestBody.query,
runtime_mappings: requestBody.runtime_mappings,
track_total_hits: typeof requestBody.size === 'number' ? requestBody.size + 1 : false,
// Number of hits matching the query to count accurately
// Used to notify users of truncated results
track_total_hits: size + 1,
// Maximum number of features to return in the hits layer
// Used to fetch number of hits that correspondes with track_total_hits
size,
with_labels: hasLabels,
} as SearchMvtRequest['body'];
if (requestBody.fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ test('Should return elasticsearch vector tile request for hits tiles', () => {
type: 'long',
},
},
size: 10000,
sort: [
{
'@timestamp': {
Expand Down
7 changes: 2 additions & 5 deletions x-pack/plugins/security_solution/public/assistant/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
* 2.0.
*/

import { EuiIcon, EuiToolTip } from '@elastic/eui';
import { EuiIcon } from '@elastic/eui';
import { analyzeMarkdown } from '@kbn/elastic-assistant';
import type { Conversation, CodeBlockDetails } from '@kbn/elastic-assistant';
import React from 'react';

import type { TimelineEventsDetailsItem } from '../../common/search_strategy';
import type { Rule } from '../detection_engine/rule_management/logic';
import { SendToTimelineButton } from './send_to_timeline';
import { INVESTIGATE_IN_TIMELINE } from '../actions/add_to_timeline/constants';

export const LOCAL_STORAGE_KEY = `securityAssistant`;

Expand Down Expand Up @@ -125,9 +124,7 @@ export const augmentMessageCodeBlocks = (
]}
keepDataView={true}
>
<EuiToolTip position="right" content={INVESTIGATE_IN_TIMELINE}>
<EuiIcon type="timeline" />
</EuiToolTip>
<EuiIcon type="timeline" />
</SendToTimelineButton>
) : null,
};
Expand Down
Loading

0 comments on commit 91f4c3d

Please sign in to comment.