Skip to content

Commit

Permalink
Merge branch 'main' into move-structure-list-apis
Browse files Browse the repository at this point in the history
  • Loading branch information
WafaaNasr authored Nov 28, 2023
2 parents ab329e5 + a658233 commit e7c6037
Show file tree
Hide file tree
Showing 229 changed files with 2,827 additions and 1,136 deletions.
4 changes: 3 additions & 1 deletion .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ enabled:
- test/server_integration/http/ssl_with_p12/config.js
- test/server_integration/http/ssl/config.js
- test/ui_capabilities/newsfeed_err/config.ts
- x-pack/test/accessibility/config.ts
- x-pack/test/accessibility/apps/group1/config.ts
- x-pack/test/accessibility/apps/group2/config.ts
- x-pack/test/accessibility/apps/group3/config.ts
- x-pack/test/localization/config.ja_jp.ts
- x-pack/test/localization/config.fr_fr.ts
- x-pack/test/localization/config.zh_cn.ts
Expand Down
17 changes: 9 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ packages/kbn-bazel-runner @elastic/kibana-operations
examples/bfetch_explorer @elastic/appex-sharedux
src/plugins/bfetch @elastic/appex-sharedux
packages/kbn-calculate-auto @elastic/obs-ux-management-team
packages/kbn-calculate-width-from-char-count @elastic/kibana-visualizations
x-pack/plugins/canvas @elastic/kibana-presentation
x-pack/test/cases_api_integration/common/plugins/cases @elastic/response-ops
packages/kbn-cases-components @elastic/response-ops
Expand Down Expand Up @@ -871,7 +872,7 @@ packages/kbn-zod-helpers @elastic/security-detection-rule-management
/test/functional/apps/management/ccs_compatibility/_data_views_ccs.ts @elastic/kibana-data-discovery
/test/functional/apps/management/data_views @elastic/kibana-data-discovery
/test/plugin_functional/test_suites/data_plugin @elastic/kibana-data-discovery
/x-pack/test/accessibility/apps/search_sessions.ts @elastic/kibana-data-discovery
/x-pack/test/accessibility/apps/group3/search_sessions.ts @elastic/kibana-data-discovery
/x-pack/test/api_integration/apis/management/rollup/index_patterns_extensions.js @elastic/kibana-data-discovery
/x-pack/test/api_integration/apis/search @elastic/kibana-data-discovery
/x-pack/test/examples/search_examples @elastic/kibana-data-discovery
Expand Down Expand Up @@ -1074,8 +1075,8 @@ x-pack/plugins/infra/server/lib/alerting @elastic/obs-ux-management-team
#CC# /src/plugins/kibana_react/public/code_editor/ @elastic/kibana-presentation

# Machine Learning
/x-pack/test/accessibility/apps/ml.ts @elastic/ml-ui
/x-pack/test/accessibility/apps/ml_embeddables_in_dashboard.ts @elastic/ml-ui
/x-pack/test/accessibility/apps/group2/ml.ts @elastic/ml-ui
/x-pack/test/accessibility/apps/group3/ml_embeddables_in_dashboard.ts @elastic/ml-ui
/x-pack/test/api_integration/apis/ml/ @elastic/ml-ui
/x-pack/test/api_integration_basic/apis/ml/ @elastic/ml-ui
/x-pack/test/functional/apps/ml/ @elastic/ml-ui
Expand All @@ -1089,7 +1090,7 @@ x-pack/plugins/infra/server/lib/alerting @elastic/obs-ux-management-team
/x-pack/test/screenshot_creation/services/ml_screenshots.ts @elastic/ml-ui

# Additional plugins and packages maintained by the ML team.
/x-pack/test/accessibility/apps/transform.ts @elastic/ml-ui
/x-pack/test/accessibility/apps/group2/transform.ts @elastic/ml-ui
/x-pack/test/api_integration/apis/aiops/ @elastic/ml-ui
/x-pack/test/api_integration/apis/transform/ @elastic/ml-ui
/x-pack/test/api_integration_basic/apis/transform/ @elastic/ml-ui
Expand Down Expand Up @@ -1176,10 +1177,10 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/test/interactive_setup_api_integration/ @elastic/kibana-security
/test/interactive_setup_functional/ @elastic/kibana-security
/test/plugin_functional/test_suites/core_plugins/rendering.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/login_page.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/roles.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/spaces.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/users.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/login_page.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/roles.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/spaces.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/users.ts @elastic/kibana-security
/x-pack/test/api_integration/apis/security/ @elastic/kibana-security
/x-pack/test/api_integration/apis/spaces/ @elastic/kibana-security
/x-pack/test/ui_capabilities/ @elastic/kibana-security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ node scripts/functional_test_runner.js --config test/accessibility/config.ts
-----------

To run the x-pack tests, swap the config file out for
`x-pack/test/accessibility/config.ts`.
`x-pack/test/accessibility/apps/{group1,group2,group3}/config.ts`.

The testing is done using https://github.com/dequelabs/axe-core[axe].
You can run the same thing that runs CI using browser plugins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ image::images/test_results.png[Buildkite build screenshot]
Looking at the failure, we first look at the Error and stack trace. In the example below, this test failed to find an element within the timeout;
`Error: retry.try timeout: TimeoutError: Waiting for element to be located By(css selector, [data-test-subj="createSpace"])`

We know the test file from the stack trace was on line 50 of `test/accessibility/apps/spaces.ts` (this test and the stack trace context is kibana/x-pack/ so the file is https://github.com/elastic/kibana/blob/main/x-pack/test/accessibility/apps/spaces.ts#L50).
We know the test file from the stack trace was on line 50 of `test/accessibility/apps/spaces.ts` (this test and the stack trace context is kibana/x-pack/ so the file is https://github.com/elastic/kibana/blob/main/x-pack/test/accessibility/apps/group1/spaces.ts#L50).
The function to click on the element was called from a page object method in `test/functional/page_objects/space_selector_page.ts` https://github.com/elastic/kibana/blob/main/x-pack/test/functional/page_objects/space_selector_page.ts#L58


Expand Down
4 changes: 3 additions & 1 deletion docs/setup/configuring-reporting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Granting the privilege to generate reports also grants the user the privilege to
==== Grant access with the role API
With <<grant-user-access, {kib} application privileges>> enabled in Reporting, you can also use the {ref}/security-api-put-role.html[role API] to grant access to the {report-features}, using *All* privileges, or sub-feature privileges.

NOTE: this [API request](https://www.elastic.co/guide/en/kibana/current/role-management-api-put.html) needs to be executed against the Kibana API endpoint
NOTE: This link:https://www.elastic.co/guide/en/kibana/current/role-management-api-put.html[API request] needs to be executed against the link:https://www.elastic.co/guide/en/kibana/current/api.html[Kibana API endpoint].
[source, sh]
---------------------------------------------------------------
POST <kibana host>:<port>/api/_security/role/custom_reporting_user
Expand Down Expand Up @@ -229,3 +229,5 @@ For more information, see {ref}/notification-settings.html#ssl-notification-sett
. Add one or more users who have access to the {report-features}.
+
Once you've enabled SSL for {kib}, all requests to the reporting endpoints must include valid credentials.

For more information on sharing reports, direct links, and more, refer to <<reporting-getting-started, Reporting and sharing>>.
2 changes: 2 additions & 0 deletions docs/user/reporting/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ You access the options from the *Share* menu in the toolbar. The sharing options
NOTE: For Elastic Cloud deployments, {kib} instances require a minimum of 2GB RAM to generate PDF or PNG reports. To
change {kib} sizing, {ess-console}[edit the deployment].

For more information on how to configure reporting in {kib}, refer to <<secure-reporting,Configure reporting in {kib}>>

[float]
[[manually-generate-reports]]
== Create reports
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"@kbn/bfetch-explorer-plugin": "link:examples/bfetch_explorer",
"@kbn/bfetch-plugin": "link:src/plugins/bfetch",
"@kbn/calculate-auto": "link:packages/kbn-calculate-auto",
"@kbn/calculate-width-from-char-count": "link:packages/kbn-calculate-width-from-char-count",
"@kbn/canvas-plugin": "link:x-pack/plugins/canvas",
"@kbn/cases-api-integration-test-plugin": "link:x-pack/test/cases_api_integration/common/plugins/cases",
"@kbn/cases-components": "link:packages/kbn-cases-components",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

module.exports = require('@kbn/storybook').defaultConfig;
3 changes: 3 additions & 0 deletions packages/kbn-calculate-width-from-char-count/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/calculate-width-from-char-count

This package contains a function that calculates the approximate width of the component from a text length.
9 changes: 9 additions & 0 deletions packages/kbn-calculate-width-from-char-count/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

export * from './src';
13 changes: 13 additions & 0 deletions packages/kbn-calculate-width-from-char-count/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-calculate-width-from-char-count'],
};
5 changes: 5 additions & 0 deletions packages/kbn-calculate-width-from-char-count/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/calculate-width-from-char-count",
"owner": "@elastic/kibana-visualizations"
}
7 changes: 7 additions & 0 deletions packages/kbn-calculate-width-from-char-count/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/calculate-width-from-char-count",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { calculateWidthFromCharCount, MAX_WIDTH } from './calculate_width_from_char_count';

describe('calculateWidthFromCharCount', () => {
it('should return minimum width if char count is smaller than minWidth', () => {
expect(calculateWidthFromCharCount(10, { minWidth: 300 })).toBe(300);
});
it('should return calculated width', () => {
expect(calculateWidthFromCharCount(30)).toBe(30 * 7 + 116);
});
it('should return maximum width if char count is bigger than maxWidth', () => {
expect(calculateWidthFromCharCount(1000)).toBe(MAX_WIDTH);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.
*/

export interface LIMITS {
paddingsWidth: number;
minWidth?: number;
avCharWidth: number;
maxWidth: number;
}

export const MAX_WIDTH = 550;
const PADDINGS_WIDTH = 116;
const AVERAGE_CHAR_WIDTH = 7;

const defaultPanelWidths: LIMITS = {
maxWidth: MAX_WIDTH,
avCharWidth: AVERAGE_CHAR_WIDTH,
paddingsWidth: PADDINGS_WIDTH,
};

export function calculateWidthFromCharCount(
labelLength: number,
overridesPanelWidths?: Partial<LIMITS>
) {
const { maxWidth, avCharWidth, paddingsWidth, minWidth } = {
...defaultPanelWidths,
...overridesPanelWidths,
};
const widthForCharCount = paddingsWidth + labelLength * avCharWidth;

if (minWidth && widthForCharCount < minWidth) {
return minWidth;
}

return Math.min(widthForCharCount, maxWidth);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 { calculateWidthFromEntries } from './calculate_width_from_entries';
import { MAX_WIDTH } from './calculate_width_from_char_count';
import faker from 'faker';

const generateLabel = (length: number) => faker.random.alpha({ count: length });

const generateObjectWithLabelOfLength = (length: number, propOverrides?: Record<string, any>) => ({
label: generateLabel(length),
...propOverrides,
});

describe('calculateWidthFromEntries', () => {
it('calculates width for array of strings', () => {
const shortLabels = [10, 20].map(generateLabel);
expect(calculateWidthFromEntries(shortLabels)).toBe(256);

const mediumLabels = [50, 55, 10, 20].map(generateLabel);
expect(calculateWidthFromEntries(mediumLabels)).toBe(501);

const longLabels = [80, 90, 10].map(generateLabel);
expect(calculateWidthFromEntries(longLabels)).toBe(MAX_WIDTH);
});

it('calculates width for array of objects with keys', () => {
const shortLabels = [10, 20].map((v) => generateObjectWithLabelOfLength(v));
expect(calculateWidthFromEntries(shortLabels, ['label'])).toBe(256);

const mediumLabels = [50, 55, 10, 20].map((v) => generateObjectWithLabelOfLength(v));
expect(calculateWidthFromEntries(mediumLabels, ['label'])).toBe(501);

const longLabels = [80, 90, 10].map((v) => generateObjectWithLabelOfLength(v));
expect(calculateWidthFromEntries(longLabels, ['label'])).toBe(MAX_WIDTH);
});
it('calculates width for array of objects for fallback keys', () => {
const shortLabels = [10, 20].map((v) =>
generateObjectWithLabelOfLength(v, { label: undefined, name: generateLabel(v) })
);
expect(calculateWidthFromEntries(shortLabels, ['id', 'label', 'name'])).toBe(256);

const mediumLabels = [50, 55, 10, 20].map((v) =>
generateObjectWithLabelOfLength(v, { label: undefined, name: generateLabel(v) })
);
expect(calculateWidthFromEntries(mediumLabels, ['id', 'label', 'name'])).toBe(501);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 { LIMITS, calculateWidthFromCharCount } from './calculate_width_from_char_count';

type GenericObject<T = Record<string, any>> = T;

const getMaxLabelLengthForObjects = (
entries: GenericObject[],
labelKeys: Array<keyof GenericObject>
) =>
entries.reduce((acc, curr) => {
const labelKey = labelKeys.find((key) => curr[key]);
if (!labelKey) {
return acc;
}
const labelLength = curr[labelKey].length;
return acc > labelLength ? acc : labelLength;
}, 0);

const getMaxLabelLengthForStrings = (arr: string[]) =>
arr.reduce((acc, curr) => (acc > curr.length ? acc : curr.length), 0);

export function calculateWidthFromEntries(
entries: GenericObject[] | string[],
labelKeys?: Array<keyof GenericObject>,
overridesPanelWidths?: Partial<LIMITS>
) {
const maxLabelLength = labelKeys
? getMaxLabelLengthForObjects(entries as GenericObject[], labelKeys)
: getMaxLabelLengthForStrings(entries as string[]);

return calculateWidthFromCharCount(maxLabelLength, overridesPanelWidths);
}
11 changes: 11 additions & 0 deletions packages/kbn-calculate-width-from-char-count/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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.
*/

export { calculateWidthFromCharCount } from './calculate_width_from_char_count';

export { calculateWidthFromEntries } from './calculate_width_from_entries';
19 changes: 19 additions & 0 deletions packages/kbn-calculate-width-from-char-count/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react",
],
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"kbn_references": [],
"exclude": [
"target/**/*",
]
}
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
privileges: `${SECURITY_SOLUTION_DOCS}endpoint-management-req.html`,
manageDetectionRules: `${SECURITY_SOLUTION_DOCS}rules-ui-management.html`,
createEsqlRuleType: `${SECURITY_SOLUTION_DOCS}rules-ui-create.html#create-esql-rule`,
entityAnalytics: {
riskScorePrerequisites: `${SECURITY_SOLUTION_DOCS}ers-requirements.html`,
},
},
query: {
eql: `${ELASTICSEARCH_DOCS}eql.html`,
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ export interface DocLinks {
readonly privileges: string;
readonly manageDetectionRules: string;
readonly createEsqlRuleType: string;
readonly entityAnalytics: {
readonly riskScorePrerequisites: string;
};
};
readonly query: {
readonly eql: string;
Expand Down
Loading

0 comments on commit e7c6037

Please sign in to comment.