Skip to content

Commit

Permalink
Merge branch 'main' into 124254-add-bundled-package-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 1, 2022
2 parents f3c266e + 49ad584 commit 1a2a2fd
Show file tree
Hide file tree
Showing 50 changed files with 676 additions and 382 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-to-fleet-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
headers: '{"GraphQL-Features": "projects_next_graphql"}'
query: |
mutation add_to_project($projectid:String!,$contentid:String!) {
mutation add_to_project($projectid: ID!, $contentid: ID!) {
addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) {
projectNextItem {
id
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/label-qa-fixed-in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ jobs:
id: add_labels_to_closed_issue
with:
query: |
mutation add_label($issueid:String!, $labelids:[String!]!) {
mutation add_label($issueid: ID!, $labelids:[ID!]!) {
addLabelsToLabelable(input: {labelableId: $issueid, labelIds: $labelids}) {
clientMutationId
}
}
issueid: ${{ matrix.issueNodeId }}
labelids: ${{ needs.fetch_issues_to_label.outputs.label_ids }}
labelids: ${{ fromJSON(needs.fetch_issues_to_label.outputs.label_ids) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/project-assigner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
{"label": "Feature:Drilldowns", "projectNumber": 68, "columnName": "Inbox"},
{"label": "Feature:Input Controls", "projectNumber": 72, "columnName": "Inbox"},
{"label": "Team:Security", "projectNumber": 320, "columnName": "Awaiting triage", "projectScope": "org"},
{"label": "Team:Operations", "projectNumber": 314, "columnName": "Triage", "projectScope": "org"},
{"label": "Team:Fleet", "projectNumber": 490, "columnName": "Inbox", "projectScope": "org"}
{"label": "Team:Operations", "projectNumber": 314, "columnName": "Triage", "projectScope": "org"}
]
ghToken: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}
Binary file modified docs/maps/images/gs_add_cloropeth_layer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/maps/images/gs_add_es_document_layer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/maps/images/gs_dashboard_with_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/maps/images/gs_dashboard_with_terms_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/maps/images/sample_data_web_logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/maps/maps-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ The layer is only visible when users zoom in.

. Set **Data view** to **kibana_sample_data_logs**.

. Set **Scaling** to *Limits results to 10000.*

. Click **Add layer**.

. In **Layer settings**, set:
Expand All @@ -109,6 +107,8 @@ The layer is only visible when users zoom in.
. Add a tooltip field and select **agent**, **bytes**, **clientip**, **host**,
**machine.os**, **request**, **response**, and **timestamp**.

. In **Scaling**, set *Limits results to 10,000.*

. In **Layer style**, set **Fill color** to **#2200FF**.

. Click **Save & close**.
Expand Down
4 changes: 4 additions & 0 deletions docs/maps/vector-layer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ When a tile exceeds `index.max_result_window`, results exceeding `index.max_resu

*EMS Boundaries*:: Administrative boundaries from https://www.elastic.co/elastic-maps-service[Elastic Maps Service].

*ML Anomalies*:: Points and lines associated with anomalies. The {anomaly-job}
must use a `lat_long` function. Go to
{ml-docs}/geographic-anomalies.html[Detecting anomalous locations in geographic data] for an example.

*Point to point*:: Aggregated data paths between the source and destination.
The index must contain at least 2 fields mapped as {ref}/geo-point.html[geo_point], source and destination.

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ exports.Cluster = class Cluster {
'action.destructive_requires_name=true',
'ingest.geoip.downloader.enabled=false',
'search.check_ccs_compatibility=true',
'cluster.routing.allocation.disk.threshold_enabled=false',
].concat(options.esArgs || []);

// Add to esArgs if ssl is enabled
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-es/src/integration_tests/cluster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ describe('#start(installPath)', () => {
"action.destructive_requires_name=true",
"ingest.geoip.downloader.enabled=false",
"search.check_ccs_compatibility=true",
"cluster.routing.allocation.disk.threshold_enabled=false",
],
undefined,
Object {
Expand Down Expand Up @@ -389,6 +390,7 @@ describe('#run()', () => {
"action.destructive_requires_name=true",
"ingest.geoip.downloader.enabled=false",
"search.check_ccs_compatibility=true",
"cluster.routing.allocation.disk.threshold_enabled=false",
],
undefined,
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const exceptionListType = t.keyof({
endpoint_trusted_apps: null,
endpoint_events: null,
endpoint_host_isolation_exceptions: null,
endpoint_blocklists: null,
});
export const exceptionListTypeOrUndefined = t.union([exceptionListType, t.undefined]);
export type ExceptionListType = t.TypeOf<typeof exceptionListType>;
Expand All @@ -24,4 +25,5 @@ export enum ExceptionListTypeEnum {
ENDPOINT_TRUSTED_APPS = 'endpoint',
ENDPOINT_EVENTS = 'endpoint_events',
ENDPOINT_HOST_ISOLATION_EXCEPTIONS = 'endpoint_host_isolation_exceptions',
ENDPOINT_BLOCKLISTS = 'endpoint_blocklists',
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Lists', () => {
const message = pipe(decoded, foldLeftRight);

expect(getPaths(left(message.errors))).toEqual([
'Invalid value "1" supplied to "Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions", namespace_type: "agnostic" | "single" |}>"',
'Invalid value "1" supplied to "Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions" | "endpoint_blocklists", namespace_type: "agnostic" | "single" |}>"',
]);
expect(message.schema).toEqual({});
});
Expand Down Expand Up @@ -117,8 +117,8 @@ describe('Lists', () => {
const message = pipe(decoded, foldLeftRight);

expect(getPaths(left(message.errors))).toEqual([
'Invalid value "1" supplied to "(Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions", namespace_type: "agnostic" | "single" |}> | undefined)"',
'Invalid value "[1]" supplied to "(Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions", namespace_type: "agnostic" | "single" |}> | undefined)"',
'Invalid value "1" supplied to "(Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions" | "endpoint_blocklists", namespace_type: "agnostic" | "single" |}> | undefined)"',
'Invalid value "[1]" supplied to "(Array<{| id: NonEmptyString, list_id: NonEmptyString, type: "detection" | "endpoint" | "endpoint_trusted_apps" | "endpoint_events" | "endpoint_host_isolation_exceptions" | "endpoint_blocklists", namespace_type: "agnostic" | "single" |}> | undefined)"',
]);
expect(message.schema).toEqual({});
});
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-securitysolution-list-constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ export const ENDPOINT_HOST_ISOLATION_EXCEPTIONS_LIST_NAME =
'Endpoint Security Host isolation exceptions List';
export const ENDPOINT_HOST_ISOLATION_EXCEPTIONS_LIST_DESCRIPTION =
'Endpoint Security Host isolation exceptions List';

export const ENDPOINT_BLOCKLISTS_LIST_ID = 'endpoint_blocklists';
export const ENDPOINT_BLOCKLISTS_LIST_NAME = 'Endpoint Security Blocklists List';
export const ENDPOINT_BLOCKLISTS_LIST_DESCRIPTION = 'Endpoint Security Blocklists List';
12 changes: 10 additions & 2 deletions packages/kbn-typed-react-router-config/src/create_router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ describe('createRouter', () => {
it('throws an error if the given path does not match any routes', () => {
expect(() => {
router.getParams('/service-map', history.location);
}).toThrowError('No matching route found for /service-map');
}).toThrowError('/service-map does not match current path /');

expect(() => {
router.getParams('/services/{serviceName}', history.location);
}).toThrowError('/services/{serviceName} does not match current path /');

expect(() => {
router.getParams('/service-map', '/services/{serviceName}', history.location);
}).toThrowError('None of /service-map, /services/{serviceName} match current path /');
});

it('does not throw an error if the given path does not match any routes but is marked as optional', () => {
Expand Down Expand Up @@ -248,7 +256,7 @@ describe('createRouter', () => {

expect(() => {
router.matchRoutes('/traces', history.location);
}).toThrowError('No matching route found for /traces');
}).toThrowError('/traces does not match current path /service-map');
});

it('applies defaults', () => {
Expand Down
10 changes: 9 additions & 1 deletion packages/kbn-typed-react-router-config/src/create_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ export function createRouter<TRoutes extends RouteMap>(routes: TRoutes): Router<
if (optional) {
return [];
}
throw new Error(`No matching route found for ${paths}`);

let errorMessage: string;

if (paths.length === 1) {
errorMessage = `${paths[0]} does not match current path ${location.pathname}`;
} else {
errorMessage = `None of ${paths.join(', ')} match current path ${location.pathname}`;
}
throw new Error(errorMessage);
}

return matches.slice(0, matchIndex + 1).map((matchedRoute) => {
Expand Down
14 changes: 11 additions & 3 deletions x-pack/examples/testing_embedded_lens/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export const App = (props: {
plugins: StartDependencies;
defaultDataView: DataView;
stateHelpers: Awaited<ReturnType<LensPublicStart['stateHelperApi']>>;
preloadedVisualization: TypedLensByValueInput['attributes'];
}) => {
const [isLoading, setIsLoading] = useState(false);
const [isSaveModalVisible, setIsSaveModalVisible] = useState(false);
Expand All @@ -380,7 +381,11 @@ export const App = (props: {
const [enableTriggers, toggleTriggers] = useState(false);
const [loadedCharts, addChartConfiguration] = useState<
Array<{ id: string; attributes: TypedLensByValueInput['attributes'] }>
>([]);
>(
props.preloadedVisualization
? [{ id: 'from_lens', attributes: props.preloadedVisualization }]
: []
);
const [hasParsingError, setErrorFlag] = useState(false);
const [hasParsingErrorDebounced, setErrorDebounced] = useState(hasParsingError);
const LensComponent = props.plugins.lens.EmbeddableComponent;
Expand Down Expand Up @@ -414,8 +419,11 @@ export const App = (props: {
// eslint-disable-next-line react-hooks/exhaustive-deps
const charts = useMemo(() => [...defaultCharts, ...loadedCharts], [loadedCharts]);

// eslint-disable-next-line react-hooks/exhaustive-deps
const initialAttributes = useMemo(() => JSON.stringify(charts[0].attributes, null, 2), []);
const initialAttributes = useMemo(
() => JSON.stringify(props.preloadedVisualization ?? charts[0].attributes, null, 2),
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

const currentSO = useRef<string>(initialAttributes);
const [currentValid, saveValidSO] = useState(initialAttributes);
Expand Down
12 changes: 8 additions & 4 deletions x-pack/examples/testing_embedded_lens/public/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,30 @@ import { EuiCallOut } from '@elastic/eui';

import type { CoreSetup, AppMountParameters } from 'kibana/public';
import type { StartDependencies } from './plugin';
import type { TypedLensByValueInput } from '../../../plugins/lens/public';

export const mount =
(coreSetup: CoreSetup<StartDependencies>) =>
async ({ element }: AppMountParameters) => {
async ({ element, history }: AppMountParameters) => {
const [core, plugins] = await coreSetup.getStartServices();
const { App } = await import('./app');
const preloadedVisualizationAttributes = history.location
?.state as TypedLensByValueInput['attributes'];

const defaultDataView = await plugins.data.indexPatterns.getDefault();
const dataView = await plugins.data.indexPatterns.getDefault();
const stateHelpers = await plugins.lens.stateHelperApi();

const i18nCore = core.i18n;

const reactElement = (
<i18nCore.Context>
{defaultDataView ? (
{dataView ? (
<App
core={core}
plugins={plugins}
defaultDataView={defaultDataView}
defaultDataView={dataView}
stateHelpers={stateHelpers}
preloadedVisualization={preloadedVisualizationAttributes}
/>
) : (
<EuiCallOut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"ui": true,
"requiredPlugins": [
"lens",
"discover",
"data",
"dataViews",
"embeddable",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 49 additions & 33 deletions x-pack/examples/third_party_lens_navigation_prompt/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { DiscoverSetup } from 'src/plugins/discover/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { Plugin, CoreSetup, AppNavLinkStatus } from '../../../../src/core/public';
import { DataViewsPublicPluginStart, DataView } from '../../../../src/plugins/data_views/public';
Expand All @@ -22,7 +21,6 @@ import image from './image.png';
export interface SetupDependencies {
developerExamples: DeveloperExamplesSetup;
lens: LensPublicSetup;
discover: DiscoverSetup;
}

export interface StartDependencies {
Expand Down Expand Up @@ -94,10 +92,7 @@ function getLensAttributes(defaultDataView: DataView): TypedLensByValueInput['at
export class EmbeddedLensExamplePlugin
implements Plugin<void, void, SetupDependencies, StartDependencies>
{
public setup(
core: CoreSetup<StartDependencies>,
{ developerExamples, lens, discover }: SetupDependencies
) {
public setup(core: CoreSetup<StartDependencies>, { developerExamples, lens }: SetupDependencies) {
core.application.register({
id: 'third_party_lens_navigation_prompt',
title: 'Third party Lens navigation prompt',
Expand All @@ -123,7 +118,7 @@ export class EmbeddedLensExamplePlugin
appId: 'third_party_lens_navigation_prompt',
title: 'Third party Lens navigation prompt',
description:
'Add custom menu entries to the Lens editor, like the "Go to discover" link in this example.',
'Add custom menu entries to the Lens editor, like the "Debug in Playground" link in this example.',
image,
links: [
{
Expand All @@ -136,33 +131,54 @@ export class EmbeddedLensExamplePlugin
],
});

if (!discover.locator) return;
lens.registerTopNavMenuEntryGenerator(({ datasourceStates, query, filters }) => {
if (!datasourceStates.indexpattern.state) return;
lens.registerTopNavMenuEntryGenerator(
({ visualizationId, visualizationState, datasourceStates, query, filters }) => {
if (!datasourceStates.indexpattern.state || !visualizationState) return;

return {
label: 'Go to discover',
iconType: 'discoverApp',
run: async () => {
const [, { data }] = await core.getStartServices();
const firstLayer = Object.values(
(datasourceStates.indexpattern.state as IndexPatternPersistedState).layers
)[0] as PersistedIndexPatternLayer & { indexPatternId: string };
discover.locator!.navigate({
indexPatternId: firstLayer.indexPatternId,
timeRange: data.query.timefilter.timefilter.getTime(),
filters,
query,
columns: firstLayer.columnOrder
.map((columnId) => {
const column = firstLayer.columns[columnId];
if ('sourceField' in column) return column.sourceField;
})
.filter(Boolean) as string[],
});
},
};
});
return {
label: 'Debug in Playground',
iconType: 'wrench',
run: async () => {
const [coreStart] = await core.getStartServices();
const datasourceState = datasourceStates.indexpattern
.state as IndexPatternPersistedState;
const layersIds = Object.keys(datasourceState.layers);
const layers = Object.values(datasourceState.layers) as Array<
PersistedIndexPatternLayer & { indexPatternId: string }
>;
const serializedFilters = JSON.parse(JSON.stringify(filters));
coreStart.application.navigateToApp('testing_embedded_lens', {
state: {
visualizationType: visualizationId,
title: 'Lens visualization',
references: [
{
id: layers[0].indexPatternId,
name: 'indexpattern-datasource-current-indexpattern',
type: 'index-pattern',
},
...layers.map(({ indexPatternId }, i) => ({
id: indexPatternId,
name: `indexpattern-datasource-layer-${layersIds[i]}`,
type: 'index-pattern',
})),
],
state: {
datasourceStates: {
indexpattern: {
layers: datasourceState.layers,
},
},
visualization: visualizationState,
filters: serializedFilters,
query,
},
},
});
},
};
}
);
}

public start() {}
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/apm/dev_docs/vscode_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ To make the [VSCode debugger](https://vscode.readthedocs.io/en/latest/editor/deb
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": ["--runInBand"],
"args": [
"--runInBand",
"--config=${workspaceFolder}/jest.config.js"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/constants/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const OUTPUT_SAVED_OBJECT_TYPE = 'ingest-outputs';

export const outputType = {
Elasticsearch: 'elasticsearch',
Logstash: 'logstash',
} as const;

export const DEFAULT_OUTPUT_ID = 'fleet-default-output';
Expand Down
Loading

0 comments on commit 1a2a2fd

Please sign in to comment.