From 9cca1c88e3172d8620cc772cc1479217bcd9865c Mon Sep 17 00:00:00 2001
From: Aleh Zasypkin
Date: Wed, 13 Jan 2021 12:30:39 +0100
Subject: [PATCH 1/3] Use documentation links service provided by the core
directly.
---
...-plugin-core-public.doclinksstart.links.md | 30 ++-
...kibana-plugin-core-public.doclinksstart.md | 2 +-
.../public/doc_links/doc_links_service.ts | 32 ++-
src/core/public/public.api.md | 30 ++-
.../api_keys_grid_page.test.tsx.snap | 197 +++++++++---------
.../api_keys_grid/api_keys_grid_page.test.tsx | 5 +-
.../api_keys_grid/api_keys_grid_page.tsx | 5 +-
.../empty_prompt/empty_prompt.tsx | 7 +-
.../api_keys_grid/not_enabled/not_enabled.tsx | 6 +-
.../api_keys/api_keys_management_app.test.tsx | 6 +-
.../api_keys/api_keys_management_app.tsx | 3 +-
.../api_keys/documentation_links.ts | 25 ---
.../no_compatible_realms.tsx | 6 +-
.../role_mappings/documentation_links.ts | 37 ----
.../edit_role_mapping_page.test.tsx | 19 +-
.../edit_role_mapping_page.tsx | 7 +-
.../mapping_info_panel.test.tsx | 13 +-
.../mapping_info_panel/mapping_info_panel.tsx | 6 +-
.../json_rule_editor.test.tsx | 11 +-
.../rule_editor_panel/json_rule_editor.tsx | 6 +-
.../rule_editor_panel.test.tsx | 9 +-
.../rule_editor_panel/rule_editor_panel.tsx | 6 +-
.../role_mappings_grid_page.test.tsx | 15 +-
.../role_mappings_grid_page.tsx | 12 +-
.../role_mappings_management_app.test.tsx | 20 +-
.../role_mappings_management_app.tsx | 6 +-
.../management/roles/documentation_links.ts | 31 ---
.../roles/edit_role/edit_role_page.test.tsx | 3 +-
.../roles/edit_role/edit_role_page.tsx | 5 +-
.../es/elasticsearch_privileges.test.tsx | 3 +-
.../es/elasticsearch_privileges.tsx | 10 +-
.../roles/roles_management_app.test.tsx | 10 +-
.../management/roles/roles_management_app.tsx | 3 +-
.../components/insecure_cluster_alert.tsx | 10 +-
.../security_checkup/documentation_links.ts | 19 --
.../security_checkup_service.tsx | 9 +-
36 files changed, 292 insertions(+), 332 deletions(-)
delete mode 100644 x-pack/plugins/security/public/management/api_keys/documentation_links.ts
delete mode 100644 x-pack/plugins/security/public/management/role_mappings/documentation_links.ts
delete mode 100644 x-pack/plugins/security/public/management/roles/documentation_links.ts
delete mode 100644 x-pack/plugins/security/public/security_checkup/documentation_links.ts
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
index 0e23064385a63..93bd6886c0974 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
@@ -108,12 +108,38 @@ readonly links: {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: Record;
+ readonly apis: {
+ createIndex: string;
+ createSnapshotLifecyclePolicy: string;
+ createRoleMapping: string;
+ createRoleMappingTemplates: string;
+ createApiKey: string;
+ createPipeline: string;
+ createTransformRequest: string;
+ executeWatchActionModes: string;
+ openIndex: string;
+ putComponentTemplate: string;
+ painlessExecute: string;
+ putComponentTemplateMetadata: string;
+ putWatch: string;
+ updateTransform: string;
+ };
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: Record;
+ readonly security: {
+ apiKeyServiceSettings: string;
+ clusterPrivileges: string;
+ elasticsearchSettings: string;
+ elasticsearchEnableSecurity: string;
+ indicesPrivileges: string;
+ kibanaTLS: string;
+ kibanaPrivileges: string;
+ mappingRoles: string;
+ mappingRolesFieldRules: string;
+ runAsPrivilege: string;
+ };
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
index 3ad747a42f84e..6db8c98633834 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
@@ -17,5 +17,5 @@ export interface DocLinksStart
| --- | --- | --- |
| [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | string
| |
| [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | string
| |
-| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly addData: string;
readonly kibana: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Record<string, string>;
readonly observability: Record<string, string>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: Record<string, string>;
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
}
| |
+| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly addData: string;
readonly kibana: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: {
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
executeWatchActionModes: string;
openIndex: string;
putComponentTemplate: string;
painlessExecute: string;
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
};
readonly observability: Record<string, string>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: {
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
elasticsearchEnableSecurity: string;
indicesPrivileges: string;
kibanaTLS: string;
kibanaPrivileges: string;
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
};
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
}
| |
diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts
index 43960ce7db467..605f9dcfd8b63 100644
--- a/src/core/public/doc_links/doc_links_service.ts
+++ b/src/core/public/doc_links/doc_links_service.ts
@@ -220,7 +220,7 @@ export class DocLinksService {
},
apis: {
createIndex: `${ELASTICSEARCH_DOCS}indices-create-index.html`,
- createSnapshotLifecylePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
+ createSnapshotLifecyclePolicy: `${ELASTICSEARCH_DOCS}slm-api-put-policy.html`,
createRoleMapping: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html`,
createRoleMappingTemplates: `${ELASTICSEARCH_DOCS}security-api-put-role-mapping.html#_role_templates`,
createApiKey: `${ELASTICSEARCH_DOCS}security-api-create-api-key.html`,
@@ -344,12 +344,38 @@ export interface DocLinksStart {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: Record;
+ readonly apis: {
+ createIndex: string;
+ createSnapshotLifecyclePolicy: string;
+ createRoleMapping: string;
+ createRoleMappingTemplates: string;
+ createApiKey: string;
+ createPipeline: string;
+ createTransformRequest: string;
+ executeWatchActionModes: string;
+ openIndex: string;
+ putComponentTemplate: string;
+ painlessExecute: string;
+ putComponentTemplateMetadata: string;
+ putWatch: string;
+ updateTransform: string;
+ };
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: Record;
+ readonly security: {
+ apiKeyServiceSettings: string;
+ clusterPrivileges: string;
+ elasticsearchSettings: string;
+ elasticsearchEnableSecurity: string;
+ indicesPrivileges: string;
+ kibanaTLS: string;
+ kibanaPrivileges: string;
+ mappingRoles: string;
+ mappingRolesFieldRules: string;
+ runAsPrivilege: string;
+ };
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index c5b49519ef7b2..99277c7e31c24 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -587,12 +587,38 @@ export interface DocLinksStart {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: Record;
+ readonly apis: {
+ createIndex: string;
+ createSnapshotLifecyclePolicy: string;
+ createRoleMapping: string;
+ createRoleMappingTemplates: string;
+ createApiKey: string;
+ createPipeline: string;
+ createTransformRequest: string;
+ executeWatchActionModes: string;
+ openIndex: string;
+ putComponentTemplate: string;
+ painlessExecute: string;
+ putComponentTemplateMetadata: string;
+ putWatch: string;
+ updateTransform: string;
+ };
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: Record;
+ readonly security: {
+ apiKeyServiceSettings: string;
+ clusterPrivileges: string;
+ elasticsearchSettings: string;
+ elasticsearchEnableSecurity: string;
+ indicesPrivileges: string;
+ kibanaTLS: string;
+ kibanaPrivileges: string;
+ mappingRoles: string;
+ mappingRolesFieldRules: string;
+ runAsPrivilege: string;
+ };
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/__snapshots__/api_keys_grid_page.test.tsx.snap b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/__snapshots__/api_keys_grid_page.test.tsx.snap
index 3c6458a6d2467..44b6c081bcfba 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/__snapshots__/api_keys_grid_page.test.tsx.snap
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/__snapshots__/api_keys_grid_page.test.tsx.snap
@@ -1,132 +1,123 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`APIKeysGridPage renders a callout when API keys are not enabled 1`] = `
-
}
>
-
- }
+
-
-
-
-
-
-
- API keys not enabled in Elasticsearch
-
-
-
-
+
+
-
-
-
- ,
- }
- }
- >
- Contact your system administrator and refer to the
-
-
+
+
+
+
-
-
-
-
+ (opens in a new tab or window)
+
+
+
+
+
+ to enable API keys.
+
+
+
+
+
`;
exports[`APIKeysGridPage renders permission denied if user does not have required permissions 1`] = `
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
index 68daf427677ff..b3fc3d3642f58 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
@@ -13,7 +13,6 @@ import type { PublicMethodsOf } from '@kbn/utility-types';
import { NotEnabled } from './not_enabled';
import { PermissionDenied } from './permission_denied';
import { APIKeysAPIClient } from '../api_keys_api_client';
-import { DocumentationLinksService } from '../documentation_links';
import { APIKeysGridPage } from './api_keys_grid_page';
import { coreMock } from '../../../../../../../src/core/public/mocks';
@@ -70,7 +69,7 @@ describe('APIKeysGridPage', () => {
const getViewProperties = () => {
const { docLinks, notifications, application } = coreStart;
return {
- docLinks: new DocumentationLinksService(docLinks),
+ docLinks,
navigateToApp: application.navigateToApp,
notifications,
apiKeysAPIClient: apiClientMock,
@@ -96,7 +95,7 @@ describe('APIKeysGridPage', () => {
return updatedWrapper.find(NotEnabled).length > 0;
});
- expect(wrapper.find(NotEnabled)).toMatchSnapshot();
+ expect(wrapper.find(NotEnabled).find(EuiCallOut)).toMatchSnapshot();
});
it('renders permission denied if user does not have required permissions', async () => {
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
index b4ea91ea024f9..0a647e2797b97 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
@@ -28,11 +28,10 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
import moment from 'moment-timezone';
-import { ApplicationStart, NotificationsStart } from 'src/core/public';
+import type { ApplicationStart, DocLinksStart, NotificationsStart } from 'src/core/public';
import { SectionLoading } from '../../../../../../../src/plugins/es_ui_shared/public';
import { ApiKey, ApiKeyToInvalidate } from '../../../../common/model';
import { APIKeysAPIClient } from '../api_keys_api_client';
-import { DocumentationLinksService } from '../documentation_links';
import { PermissionDenied } from './permission_denied';
import { EmptyPrompt } from './empty_prompt';
import { NotEnabled } from './not_enabled';
@@ -40,7 +39,7 @@ import { InvalidateProvider } from './invalidate_provider';
interface Props {
notifications: NotificationsStart;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
apiKeysAPIClient: PublicMethodsOf;
navigateToApp: ApplicationStart['navigateToApp'];
}
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
index 9b2ccfcb99ef3..e70e687dfe9b8 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
@@ -5,15 +5,14 @@
*/
import React, { Fragment } from 'react';
-import { ApplicationStart } from 'kibana/public';
+import type { ApplicationStart, DocLinksStart } from 'kibana/public';
import { EuiEmptyPrompt, EuiButton, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DocumentationLinksService } from '../../documentation_links';
interface Props {
isAdmin: boolean;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
navigateToApp: ApplicationStart['navigateToApp'];
}
@@ -47,7 +46,7 @@ export const EmptyPrompt: React.FunctionComponent = ({
defaultMessage="You can create an {link} from Console."
values={{
link: (
-
+
= ({ docLinks }) => (
@@ -29,7 +29,7 @@ export const NotEnabled: React.FunctionComponent = ({ docLinks }) => (
defaultMessage="Contact your system administrator and refer to the {link} to enable API keys."
values={{
link: (
-
+
({
- APIKeysGridPage: (props: any) => `Page: ${JSON.stringify(props)}`,
+ APIKeysGridPage: (props: any) =>
+ // `docLinks` object is too big to include into test snapshot, so we just check its existence.
+ `Page: ${JSON.stringify({ ...props, docLinks: props.docLinks ? {} : undefined })}`,
}));
import { apiKeysManagementApp } from './api_keys_management_app';
import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
@@ -43,7 +45,7 @@ describe('apiKeysManagementApp', () => {
expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: '/', text: 'API Keys' }]);
expect(container).toMatchInlineSnapshot(`
- Page: {"notifications":{"toasts":{}},"docLinks":{"apiKeySettings":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-settings.html#api-key-service-settings","createApiKey":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-create-api-key.html"},"apiKeysAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}}}
+ Page: {"notifications":{"toasts":{}},"docLinks":{},"apiKeysAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}}}
`);
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
index 6ff91852d0a3e..7240375d26213 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
@@ -10,7 +10,6 @@ import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
import { PluginStartDependencies } from '../../plugin';
-import { DocumentationLinksService } from './documentation_links';
interface CreateParams {
getStartServices: StartServicesAccessor;
@@ -50,7 +49,7 @@ export const apiKeysManagementApp = Object.freeze({
,
diff --git a/x-pack/plugins/security/public/management/api_keys/documentation_links.ts b/x-pack/plugins/security/public/management/api_keys/documentation_links.ts
deleted file mode 100644
index 66a54f1cb7b72..0000000000000
--- a/x-pack/plugins/security/public/management/api_keys/documentation_links.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { DocLinksStart } from 'src/core/public';
-
-export class DocumentationLinksService {
- private readonly apiKeySettings: string;
- private readonly createApiKey: string;
-
- constructor(docLinks: DocLinksStart) {
- this.apiKeySettings = `${docLinks.links.security.apiKeyServiceSettings}`;
- this.createApiKey = `${docLinks.links.apis.createApiKey}`;
- }
-
- public getApiKeyServiceSettingsDocUrl() {
- return `${this.apiKeySettings}`;
- }
-
- public getCreateApiKeyDocUrl() {
- return `${this.createApiKey}`;
- }
-}
diff --git a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
index 5e14b0c179bfd..96e8ba2901046 100644
--- a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
@@ -7,10 +7,10 @@
import React from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import { DocumentationLinksService } from '../../documentation_links';
+import type { DocLinksStart } from 'src/core/public';
interface Props {
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
}
export const NoCompatibleRealms: React.FunctionComponent = ({ docLinks }: Props) => (
@@ -29,7 +29,7 @@ export const NoCompatibleRealms: React.FunctionComponent = ({ docLinks }:
defaultMessage="Role mappings will not be applied to any users. Contact your system administrator and refer to the {link} for more information."
values={{
link: (
-
+
{
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -119,7 +118,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -167,7 +166,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -195,7 +194,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -233,7 +232,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -274,7 +273,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -317,7 +316,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -372,7 +371,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
@@ -428,7 +427,7 @@ describe('EditRoleMappingPage', () => {
roleMappingsAPI={roleMappingsAPI}
rolesAPIClient={rolesAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
/>
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
index 30584348960a5..cca8ca966ebda 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
@@ -20,7 +20,7 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
-import { NotificationsStart, ScopedHistory } from 'src/core/public';
+import type { NotificationsStart, ScopedHistory, DocLinksStart } from 'src/core/public';
import { RoleMapping } from '../../../../common/model';
import { RuleEditorPanel } from './rule_editor_panel';
import {
@@ -32,7 +32,6 @@ import {
import { RolesAPIClient } from '../../roles';
import { validateRoleMappingForSave } from './services/role_mapping_validation';
import { MappingInfoPanel } from './mapping_info_panel';
-import { DocumentationLinksService } from '../documentation_links';
import { RoleMappingsAPIClient } from '../role_mappings_api_client';
interface State {
@@ -54,7 +53,7 @@ interface Props {
roleMappingsAPI: PublicMethodsOf;
rolesAPIClient: PublicMethodsOf;
notifications: NotificationsStart;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
history: ScopedHistory;
}
@@ -163,7 +162,7 @@ export class EditRoleMappingPage extends Component {
values={{
learnMoreLink: (
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx
index dbd034ff3f764..f9201a8dbf249 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx
@@ -10,7 +10,6 @@ import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@kbn/test/jest';
import { Role, RoleMapping } from '../../../../../common/model';
import { RolesAPIClient } from '../../../roles';
-import { DocumentationLinksService } from '../../documentation_links';
import { RoleSelector } from '../role_selector';
import { RoleTemplateEditor } from '../role_selector/role_template_editor';
import { MappingInfoPanel } from '.';
@@ -39,7 +38,7 @@ describe('MappingInfoPanel', () => {
metadata: {},
} as RoleMapping,
mode: 'create',
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
} as MappingInfoPanel['props'];
@@ -86,7 +85,7 @@ describe('MappingInfoPanel', () => {
metadata: {},
} as RoleMapping,
mode: 'edit',
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
} as MappingInfoPanel['props'];
@@ -112,7 +111,7 @@ describe('MappingInfoPanel', () => {
canUseInlineScripts: true,
canUseStoredScripts: false,
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
};
@@ -153,7 +152,7 @@ describe('MappingInfoPanel', () => {
canUseInlineScripts: false,
canUseStoredScripts: true,
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
};
@@ -194,7 +193,7 @@ describe('MappingInfoPanel', () => {
canUseInlineScripts: false,
canUseStoredScripts: false,
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
};
@@ -219,7 +218,7 @@ describe('MappingInfoPanel', () => {
metadata: {},
} as RoleMapping,
mode: 'edit',
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
rolesAPIClient: rolesAPI,
} as MappingInfoPanel['props'];
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.tsx
index faf0278e5d8f3..8176950a46339 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.tsx
@@ -20,6 +20,7 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
+import type { DocLinksStart } from 'src/core/public';
import { RoleMapping } from '../../../../../common/model';
import { RolesAPIClient } from '../../../roles';
import {
@@ -28,7 +29,6 @@ import {
validateRoleMappingRoleTemplates,
} from '../services/role_mapping_validation';
import { RoleSelector } from '../role_selector';
-import { DocumentationLinksService } from '../../documentation_links';
interface Props {
roleMapping: RoleMapping;
@@ -38,7 +38,7 @@ interface Props {
canUseInlineScripts: boolean;
canUseStoredScripts: boolean;
rolesAPIClient: PublicMethodsOf;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
}
interface State {
@@ -205,7 +205,7 @@ export class MappingInfoPanel extends Component {
defaultMessage="Create templates that describe the roles to assign to your users."
/>{' '}
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
index bae41b31cdcc1..c327609a8c05b 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
@@ -18,7 +18,6 @@ import { mountWithIntl } from '@kbn/test/jest';
import { JSONRuleEditor } from './json_rule_editor';
import { EuiCodeEditor } from '@elastic/eui';
import { AllRule, AnyRule, FieldRule, ExceptAnyRule, ExceptAllRule } from '../../model';
-import { DocumentationLinksService } from '../../documentation_links';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
@@ -28,7 +27,7 @@ describe('JSONRuleEditor', () => {
rules: null,
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
@@ -50,7 +49,7 @@ describe('JSONRuleEditor', () => {
]),
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
@@ -84,7 +83,7 @@ describe('JSONRuleEditor', () => {
rules: null,
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
@@ -103,7 +102,7 @@ describe('JSONRuleEditor', () => {
rules: null,
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
@@ -131,7 +130,7 @@ describe('JSONRuleEditor', () => {
rules: null,
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
index e7a9149513d20..a535c99b31b60 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
@@ -11,14 +11,14 @@ import 'brace/theme/github';
import { EuiCodeEditor, EuiFormRow, EuiButton, EuiSpacer, EuiLink, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import { DocumentationLinksService } from '../../documentation_links';
+import type { DocLinksStart } from 'src/core/public';
import { Rule, RuleBuilderError, generateRulesFromRaw } from '../../model';
interface Props {
rules: Rule | null;
onChange: (updatedRules: Rule | null) => void;
onValidityChange: (isValid: boolean) => void;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
}
export const JSONRuleEditor = (props: Props) => {
@@ -108,7 +108,7 @@ export const JSONRuleEditor = (props: Props) => {
values={{
roleMappingAPI: (
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
index ac31900b11a67..7c0101ce94996 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
@@ -17,7 +17,6 @@ import '@kbn/test/target/jest/utils/stub_web_worker';
import { AllRule, FieldRule } from '../../model';
import { EuiErrorBoundary } from '@elastic/eui';
-import { DocumentationLinksService } from '../../documentation_links';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
@@ -28,7 +27,7 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
expect(wrapper.find(VisualRuleEditor)).toHaveLength(1);
@@ -49,7 +48,7 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
expect(wrapper.find(VisualRuleEditor)).toHaveLength(1);
@@ -73,7 +72,7 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
@@ -109,7 +108,7 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: new DocumentationLinksService(coreMock.createStart().docLinks),
+ docLinks: coreMock.createStart().docLinks,
};
const wrapper = mountWithIntl();
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
index 6e6641caa1f39..8e350c1d6ff9d 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
@@ -22,12 +22,12 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
+import type { DocLinksStart } from 'src/core/public';
import { RoleMapping } from '../../../../../common/model';
import { VisualRuleEditor } from './visual_rule_editor';
import { JSONRuleEditor } from './json_rule_editor';
import { VISUAL_MAX_RULE_DEPTH } from '../services/role_mapping_constants';
import { Rule, generateRulesFromRaw } from '../../model';
-import { DocumentationLinksService } from '../../documentation_links';
import { validateRoleMappingRules } from '../services/role_mapping_validation';
interface Props {
@@ -35,7 +35,7 @@ interface Props {
onChange: (rawRules: RoleMapping['rules']) => void;
onValidityChange: (isValid: boolean) => void;
validateForm: boolean;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
}
interface State {
@@ -92,7 +92,7 @@ export class RuleEditorPanel extends Component {
values={{
learnMoreLink: (
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
index a8001c1b775ea..f9e44e9b73c2f 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
@@ -13,7 +13,6 @@ import { EmptyPrompt } from './empty_prompt';
import { findTestSubject } from '@kbn/test/jest';
import { EuiLink } from '@elastic/eui';
import { act } from '@testing-library/react';
-import { DocumentationLinksService } from '../documentation_links';
import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks';
import { roleMappingsAPIClientMock } from '../role_mappings_api_client.mock';
@@ -42,7 +41,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -71,7 +70,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -108,7 +107,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -144,7 +143,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -178,7 +177,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -218,7 +217,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={rolesAPIClientMock.create()}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -281,7 +280,7 @@ describe('RoleMappingsGridPage', () => {
rolesAPIClient={roleAPIClient}
roleMappingsAPI={roleMappingsAPI}
notifications={notifications}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
index 7e83c3654cac3..59d5769a00480 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
@@ -25,7 +25,12 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
-import { NotificationsStart, ApplicationStart, ScopedHistory } from 'src/core/public';
+import type {
+ NotificationsStart,
+ ApplicationStart,
+ DocLinksStart,
+ ScopedHistory,
+} from 'src/core/public';
import { RoleMapping, Role } from '../../../../common/model';
import { EmptyPrompt } from './empty_prompt';
import {
@@ -35,7 +40,6 @@ import {
SectionLoading,
} from '../components';
import { EDIT_ROLE_MAPPING_PATH, getEditRoleMappingHref } from '../../management_urls';
-import { DocumentationLinksService } from '../documentation_links';
import { RoleMappingsAPIClient } from '../role_mappings_api_client';
import { RoleTableDisplay } from '../../role_table_display';
import { RolesAPIClient } from '../../roles';
@@ -46,7 +50,7 @@ interface Props {
rolesAPIClient: PublicMethodsOf;
roleMappingsAPI: PublicMethodsOf;
notifications: NotificationsStart;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
history: ScopedHistory;
navigateToApp: ApplicationStart['navigateToApp'];
}
@@ -148,7 +152,7 @@ export class RoleMappingsGridPage extends Component {
values={{
learnMoreLink: (
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
index c72aeac5ba6f2..0d7443bad5f32 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.test.tsx
@@ -5,11 +5,21 @@
*/
jest.mock('./role_mappings_grid', () => ({
- RoleMappingsGridPage: (props: any) => `Role Mappings Page: ${JSON.stringify(props)}`,
+ RoleMappingsGridPage: (props: any) =>
+ // `docLinks` object is too big to include into test snapshot, so we just check its existence.
+ `Role Mappings Page: ${JSON.stringify({
+ ...props,
+ docLinks: props.docLinks ? {} : undefined,
+ })}`,
}));
jest.mock('./edit_role_mapping', () => ({
- EditRoleMappingPage: (props: any) => `Role Mapping Edit Page: ${JSON.stringify(props)}`,
+ EditRoleMappingPage: (props: any) =>
+ // `docLinks` object is too big to include into test snapshot, so we just check its existence.
+ `Role Mapping Edit Page: ${JSON.stringify({
+ ...props,
+ docLinks: props.docLinks ? {} : undefined,
+ })}`,
}));
import { roleMappingsManagementApp } from './role_mappings_management_app';
@@ -54,7 +64,7 @@ describe('roleMappingsManagementApp', () => {
expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: `/`, text: 'Role Mappings' }]);
expect(container).toMatchInlineSnapshot(`
- Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"docLinks":{"mappingRoles":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/mapping-roles.html","createRoleMapping":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html","createRoleMappingTemplates":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html#_role_templates","roleMappingFieldRules":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/role-mapping-resources.html#mapping-roles-rule-field"},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}}}
+ Role Mappings Page: {"notifications":{"toasts":{}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/","search":"","hash":""}}}
`);
@@ -73,7 +83,7 @@ describe('roleMappingsManagementApp', () => {
]);
expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{"mappingRoles":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/mapping-roles.html","createRoleMapping":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html","createRoleMappingTemplates":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html#_role_templates","roleMappingFieldRules":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/role-mapping-resources.html#mapping-roles-rule-field"},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
+ Role Mapping Edit Page: {"roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
`);
@@ -94,7 +104,7 @@ describe('roleMappingsManagementApp', () => {
]);
expect(container).toMatchInlineSnapshot(`
- Role Mapping Edit Page: {"name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{"mappingRoles":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/mapping-roles.html","createRoleMapping":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html","createRoleMappingTemplates":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-api-put-role-mapping.html#_role_templates","roleMappingFieldRules":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/role-mapping-resources.html#mapping-roles-rule-field"},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}}}
+ Role Mapping Edit Page: {"name":"role@mapping","roleMappingsAPI":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"notifications":{"toasts":{}},"docLinks":{},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@mapping","search":"","hash":""}}}
`);
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
index ce4ded5a9acbc..74eac417f0c4e 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
@@ -11,7 +11,6 @@ import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
import { PluginStartDependencies } from '../../plugin';
-import { DocumentationLinksService } from './documentation_links';
import { tryDecodeURIComponent } from '../url_utils';
interface CreateParams {
@@ -53,7 +52,6 @@ export const roleMappingsManagementApp = Object.freeze({
]);
const roleMappingsAPIClient = new RoleMappingsAPIClient(http);
- const dockLinksService = new DocumentationLinksService(docLinks);
const RoleMappingsGridPageWithBreadcrumbs = () => {
setBreadcrumbs(roleMappingsBreadcrumbs);
return (
@@ -61,7 +59,7 @@ export const roleMappingsManagementApp = Object.freeze({
notifications={notifications}
rolesAPIClient={new RolesAPIClient(http)}
roleMappingsAPI={roleMappingsAPIClient}
- docLinks={dockLinksService}
+ docLinks={docLinks}
history={history}
navigateToApp={coreStart.application.navigateToApp}
/>
@@ -92,7 +90,7 @@ export const roleMappingsManagementApp = Object.freeze({
roleMappingsAPI={roleMappingsAPIClient}
rolesAPIClient={new RolesAPIClient(http)}
notifications={notifications}
- docLinks={dockLinksService}
+ docLinks={docLinks}
history={history}
/>
);
diff --git a/x-pack/plugins/security/public/management/roles/documentation_links.ts b/x-pack/plugins/security/public/management/roles/documentation_links.ts
deleted file mode 100644
index aa19fbecb9c7b..0000000000000
--- a/x-pack/plugins/security/public/management/roles/documentation_links.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { DocLinksStart } from 'src/core/public';
-
-export class DocumentationLinksService {
- private readonly esClusterPrivileges: string;
- private readonly esRunAsPrivilege: string;
- private readonly esIndicesPrivileges: string;
-
- constructor(docLinks: DocLinksStart) {
- this.esClusterPrivileges = `${docLinks.links.security.clusterPrivileges}`;
- this.esRunAsPrivilege = `${docLinks.links.security.runAsPrivilege}`;
- this.esIndicesPrivileges = `${docLinks.links.security.indicesPrivileges}`;
- }
-
- public getESClusterPrivilegesDocUrl() {
- return `${this.esClusterPrivileges}`;
- }
-
- public getESRunAsPrivilegesDocUrl() {
- return `${this.esRunAsPrivilege}`;
- }
-
- public getESIndicesPrivilegesDocUrl() {
- return `${this.esIndicesPrivileges}`;
- }
-}
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
index b86fa1f175e96..e431b49bf2f84 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx
@@ -11,7 +11,6 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest';
import { Capabilities } from 'src/core/public';
import { KibanaFeature } from '../../../../../features/public';
import { Role } from '../../../../common/model';
-import { DocumentationLinksService } from '../documentation_links';
import { EditRolePage } from './edit_role_page';
import { SimplePrivilegeSection } from './privileges/kibana/simple_privilege_section';
@@ -184,7 +183,7 @@ function getProps({
userAPIClient,
getFeatures: () => Promise.resolve(buildFeatures()),
notifications,
- docLinks: new DocumentationLinksService(docLinks),
+ docLinks,
fatalErrors,
uiCapabilities: buildUICapabilities(canManageSpaces),
history: scopedHistoryMock.create(),
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
index d24191c54bd94..c750ec373b9f7 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx
@@ -38,7 +38,7 @@ import {
IHttpFetchError,
NotificationsStart,
} from 'src/core/public';
-import { ScopedHistory } from 'kibana/public';
+import type { DocLinksStart, ScopedHistory } from 'kibana/public';
import { FeaturesPluginStart } from '../../../../../features/public';
import { KibanaFeature } from '../../../../../features/common';
import { IndexPatternsContract } from '../../../../../../../src/plugins/data/public';
@@ -61,7 +61,6 @@ import { ElasticsearchPrivileges, KibanaPrivilegesRegion } from './privileges';
import { ReservedRoleBadge } from './reserved_role_badge';
import { SecurityLicense } from '../../../../common/licensing';
import { UserAPIClient } from '../../users';
-import { DocumentationLinksService } from '../documentation_links';
import { IndicesAPIClient } from '../indices_api_client';
import { RolesAPIClient } from '../roles_api_client';
import { PrivilegesAPIClient } from '../privileges_api_client';
@@ -77,7 +76,7 @@ interface Props {
rolesAPIClient: PublicMethodsOf;
privilegesAPIClient: PublicMethodsOf;
getFeatures: FeaturesPluginStart['getFeatures'];
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
http: HttpStart;
license: SecurityLicense;
uiCapabilities: Capabilities;
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx
index 316822f7db024..4a29c5a5b134c 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx
@@ -6,7 +6,6 @@
import React from 'react';
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
-import { DocumentationLinksService } from '../../../documentation_links';
import { RoleValidator } from '../../validate_role';
import { ClusterPrivileges } from './cluster_privileges';
import { ElasticsearchPrivileges } from './elasticsearch_privileges';
@@ -45,7 +44,7 @@ function getProps() {
index: ['all', 'read', 'write', 'index'],
},
indicesAPIClient: indicesAPIClientMock.create(),
- docLinks: new DocumentationLinksService(docLinks),
+ docLinks,
license,
};
}
diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.tsx
index 8fc09ce167400..ca7a086639051 100644
--- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.tsx
+++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.tsx
@@ -19,6 +19,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
import React, { Component, Fragment } from 'react';
+import type { DocLinksStart } from 'src/core/public';
import { Role, BuiltinESPrivileges } from '../../../../../../common/model';
import { SecurityLicense } from '../../../../../../common/licensing';
import { IndicesAPIClient } from '../../../indices_api_client';
@@ -26,13 +27,12 @@ import { RoleValidator } from '../../validate_role';
import { CollapsiblePanel } from '../../collapsible_panel';
import { ClusterPrivileges } from './cluster_privileges';
import { IndexPrivileges } from './index_privileges';
-import { DocumentationLinksService } from '../../../documentation_links';
interface Props {
role: Role;
editable: boolean;
indicesAPIClient: PublicMethodsOf;
- docLinks: DocumentationLinksService;
+ docLinks: DocLinksStart;
license: SecurityLicense;
onChange: (role: Role) => void;
runAsUsers: string[];
@@ -90,7 +90,7 @@ export class ElasticsearchPrivileges extends Component {
id="xpack.security.management.editRole.elasticSearchPrivileges.manageRoleActionsDescription"
defaultMessage="Manage the actions this role can perform against your cluster. "
/>
- {this.learnMore(docLinks.getESClusterPrivilegesDocUrl())}
+ {this.learnMore(docLinks.links.security.clusterPrivileges)}
}
>
@@ -120,7 +120,7 @@ export class ElasticsearchPrivileges extends Component {
id="xpack.security.management.editRole.elasticSearchPrivileges.howToBeSubmittedOnBehalfOfOtherUsersDescription"
defaultMessage="Allow requests to be submitted on the behalf of other users. "
/>
- {this.learnMore(docLinks.getESRunAsPrivilegesDocUrl())}
+ {this.learnMore(docLinks.links.security.runAsPrivilege)}
}
>
@@ -164,7 +164,7 @@ export class ElasticsearchPrivileges extends Component {
id="xpack.security.management.editRole.elasticSearchPrivileges.controlAccessToClusterDataDescription"
defaultMessage="Control access to the data in your cluster. "
/>
- {this.learnMore(docLinks.getESIndicesPrivilegesDocUrl())}
+ {this.learnMore(docLinks.links.security.indicesPrivileges)}
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
index 8003b21f5d906..12c1951fc60f0 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.test.tsx
@@ -11,7 +11,9 @@ jest.mock('./roles_grid', () => ({
}));
jest.mock('./edit_role', () => ({
- EditRolePage: (props: any) => `Role Edit Page: ${JSON.stringify(props)}`,
+ // `docLinks` object is too big to include into test snapshot, so we just check its existence.
+ EditRolePage: (props: any) =>
+ `Role Edit Page: ${JSON.stringify({ ...props, docLinks: props.docLinks ? {} : undefined })}`,
}));
import { rolesManagementApp } from './roles_management_app';
@@ -87,7 +89,7 @@ describe('rolesManagementApp', () => {
expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: `/`, text: 'Roles' }, { text: 'Create' }]);
expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"edit","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{"esClusterPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-cluster","esRunAsPrivilege":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#_run_as_privilege","esIndicesPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-indices"},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
+ Role Edit Page: {"action":"edit","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit","search":"","hash":""}}}
`);
@@ -108,7 +110,7 @@ describe('rolesManagementApp', () => {
]);
expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"edit","roleName":"role@name","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{"esClusterPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-cluster","esRunAsPrivilege":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#_run_as_privilege","esIndicesPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-indices"},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@name","search":"","hash":""}}}
+ Role Edit Page: {"action":"edit","roleName":"role@name","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/edit/role@name","search":"","hash":""}}}
`);
@@ -126,7 +128,7 @@ describe('rolesManagementApp', () => {
expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: `/`, text: 'Roles' }, { text: 'Create' }]);
expect(container).toMatchInlineSnapshot(`
- Role Edit Page: {"action":"clone","roleName":"someRoleName","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{"esClusterPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-cluster","esRunAsPrivilege":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#_run_as_privilege","esIndicesPrivileges":"https://www.elastic.co/guide/en/elasticsearch/reference/mocked-test-branch/security-privileges.html#privileges-list-indices"},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/clone/someRoleName","search":"","hash":""}}}
+ Role Edit Page: {"action":"clone","roleName":"someRoleName","rolesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"userAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"indicesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"privilegesAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}},"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}},"notifications":{"toasts":{}},"fatalErrors":{},"license":{"features$":{"_isScalar":false}},"docLinks":{},"uiCapabilities":{"catalogue":{},"management":{},"navLinks":{}},"history":{"action":"PUSH","length":1,"location":{"pathname":"/clone/someRoleName","search":"","hash":""}}}
`);
diff --git a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
index d5b3b4998a09d..26c679516b46e 100644
--- a/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
+++ b/x-pack/plugins/security/public/management/roles/roles_management_app.tsx
@@ -12,7 +12,6 @@ import { StartServicesAccessor, FatalErrorsSetup } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
import { SecurityLicense } from '../../../common/licensing';
import { PluginStartDependencies } from '../../plugin';
-import { DocumentationLinksService } from './documentation_links';
import { tryDecodeURIComponent } from '../url_utils';
interface CreateParams {
@@ -97,7 +96,7 @@ export const rolesManagementApp = Object.freeze({
notifications={notifications}
fatalErrors={fatalErrors}
license={license}
- docLinks={new DocumentationLinksService(docLinks)}
+ docLinks={docLinks}
uiCapabilities={application.capabilities}
indexPatterns={data.indexPatterns}
history={history}
diff --git a/x-pack/plugins/security/public/security_checkup/components/insecure_cluster_alert.tsx b/x-pack/plugins/security/public/security_checkup/components/insecure_cluster_alert.tsx
index 310caeac91dc1..844444c0e64d5 100644
--- a/x-pack/plugins/security/public/security_checkup/components/insecure_cluster_alert.tsx
+++ b/x-pack/plugins/security/public/security_checkup/components/insecure_cluster_alert.tsx
@@ -7,7 +7,7 @@ import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { I18nProvider, FormattedMessage } from '@kbn/i18n/react';
import { render, unmountComponentAtNode } from 'react-dom';
-import { MountPoint } from 'kibana/public';
+import type { DocLinksStart, MountPoint } from 'kibana/public';
import {
EuiCheckbox,
EuiText,
@@ -16,7 +16,6 @@ import {
EuiFlexItem,
EuiButton,
} from '@elastic/eui';
-import { DocumentationLinksService } from '../documentation_links';
export const insecureClusterAlertTitle = i18n.translate(
'xpack.security.checkup.insecureClusterTitle',
@@ -24,12 +23,15 @@ export const insecureClusterAlertTitle = i18n.translate(
);
export const insecureClusterAlertText = (
- getDocLinksService: () => DocumentationLinksService,
+ getDocLinks: () => DocLinksStart,
onDismiss: (persist: boolean) => void
) =>
((e) => {
const AlertText = () => {
const [persist, setPersist] = useState(false);
+ const enableSecurityDocLink = `${
+ getDocLinks().links.security.elasticsearchEnableSecurity
+ }?blade=kibanasecuritymessage`;
return (
@@ -56,7 +58,7 @@ export const insecureClusterAlertText = (
size="s"
color="primary"
fill
- href={getDocLinksService().getEnableSecurityDocUrl()}
+ href={enableSecurityDocLink}
target="_blank"
data-test-subj="learnMoreButton"
>
diff --git a/x-pack/plugins/security/public/security_checkup/documentation_links.ts b/x-pack/plugins/security/public/security_checkup/documentation_links.ts
deleted file mode 100644
index 4a2a2bc968cc6..0000000000000
--- a/x-pack/plugins/security/public/security_checkup/documentation_links.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { DocLinksStart } from 'src/core/public';
-
-export class DocumentationLinksService {
- private readonly esEnableSecurity: string;
-
- constructor(docLinks: DocLinksStart) {
- this.esEnableSecurity = `${docLinks.links.security.elasticsearchEnableSecurity}`;
- }
-
- public getEnableSecurityDocUrl() {
- return `${this.esEnableSecurity}?blade=kibanasecuritymessage`;
- }
-}
diff --git a/x-pack/plugins/security/public/security_checkup/security_checkup_service.tsx b/x-pack/plugins/security/public/security_checkup/security_checkup_service.tsx
index a0ea194170dff..bda9f210b02ec 100644
--- a/x-pack/plugins/security/public/security_checkup/security_checkup_service.tsx
+++ b/x-pack/plugins/security/public/security_checkup/security_checkup_service.tsx
@@ -4,14 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { DocLinksStart } from 'kibana/public';
+import type { DocLinksStart } from 'kibana/public';
import {
SecurityOssPluginSetup,
SecurityOssPluginStart,
} from '../../../../../src/plugins/security_oss/public';
import { insecureClusterAlertTitle, insecureClusterAlertText } from './components';
-import { DocumentationLinksService } from './documentation_links';
interface SetupDeps {
securityOssSetup: SecurityOssPluginSetup;
@@ -25,13 +24,13 @@ interface StartDeps {
export class SecurityCheckupService {
private securityOssStart?: SecurityOssPluginStart;
- private docLinksService?: DocumentationLinksService;
+ private docLinks?: DocLinksStart;
public setup({ securityOssSetup }: SetupDeps) {
securityOssSetup.insecureCluster.setAlertTitle(insecureClusterAlertTitle);
securityOssSetup.insecureCluster.setAlertText(
insecureClusterAlertText(
- () => this.docLinksService!,
+ () => this.docLinks!,
(persist: boolean) => this.onDismiss(persist)
)
);
@@ -39,7 +38,7 @@ export class SecurityCheckupService {
public start({ securityOssStart, docLinks }: StartDeps) {
this.securityOssStart = securityOssStart;
- this.docLinksService = new DocumentationLinksService(docLinks);
+ this.docLinks = docLinks;
}
private onDismiss(persist: boolean) {
From d2952c39a35904cd8f65a6e54d5e650f9ce2fe56 Mon Sep 17 00:00:00 2001
From: Aleh Zasypkin
Date: Thu, 14 Jan 2021 12:49:35 +0100
Subject: [PATCH 2/3] Review#1: use `useKibana` hook.
---
.../api_keys_grid/api_keys_grid_page.test.tsx | 32 ++---
.../api_keys_grid/api_keys_grid_page.tsx | 12 +-
.../empty_prompt/empty_prompt.tsx | 115 ++++++++-------
.../api_keys_grid/not_enabled/not_enabled.tsx | 59 ++++----
.../api_keys/api_keys_management_app.test.tsx | 6 +-
.../api_keys/api_keys_management_app.tsx | 17 +--
.../no_compatible_realms.tsx | 59 ++++----
.../edit_role_mapping_page.test.tsx | 132 ++++--------------
.../edit_role_mapping_page.tsx | 2 +-
.../json_rule_editor.test.tsx | 49 +++----
.../rule_editor_panel/json_rule_editor.tsx | 6 +-
.../rule_editor_panel.test.tsx | 16 ++-
.../rule_editor_panel/rule_editor_panel.tsx | 1 -
.../role_mappings_grid_page.test.tsx | 104 ++++----------
.../role_mappings_grid_page.tsx | 2 +-
.../role_mappings_management_app.tsx | 27 ++--
16 files changed, 249 insertions(+), 390 deletions(-)
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
index b3fc3d3642f58..04d543fc0292b 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
@@ -10,6 +10,7 @@ import { ReactWrapper } from 'enzyme';
import { EuiCallOut } from '@elastic/eui';
import type { PublicMethodsOf } from '@kbn/utility-types';
+import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { NotEnabled } from './not_enabled';
import { PermissionDenied } from './permission_denied';
import { APIKeysAPIClient } from '../api_keys_api_client';
@@ -65,21 +66,17 @@ describe('APIKeysGridPage', () => {
});
const coreStart = coreMock.createStart();
-
- const getViewProperties = () => {
+ const renderView = () => {
const { docLinks, notifications, application } = coreStart;
- return {
- docLinks,
- navigateToApp: application.navigateToApp,
- notifications,
- apiKeysAPIClient: apiClientMock,
- };
+ return mountWithIntl(
+
+
+
+ );
};
it('renders a loading state when fetching API keys', async () => {
- const wrapper = mountWithIntl();
-
- expect(wrapper.find('[data-test-subj="apiKeysSectionLoading"]')).toHaveLength(1);
+ expect(renderView().find('[data-test-subj="apiKeysSectionLoading"]')).toHaveLength(1);
});
it('renders a callout when API keys are not enabled', async () => {
@@ -89,8 +86,7 @@ describe('APIKeysGridPage', () => {
areApiKeysEnabled: false,
});
- const wrapper = mountWithIntl();
-
+ const wrapper = renderView();
await waitForRender(wrapper, (updatedWrapper) => {
return updatedWrapper.find(NotEnabled).length > 0;
});
@@ -105,8 +101,7 @@ describe('APIKeysGridPage', () => {
areApiKeysEnabled: true,
});
- const wrapper = mountWithIntl();
-
+ const wrapper = renderView();
await waitForRender(wrapper, (updatedWrapper) => {
return updatedWrapper.find(PermissionDenied).length > 0;
});
@@ -117,8 +112,7 @@ describe('APIKeysGridPage', () => {
it('renders error callout if error fetching API keys', async () => {
apiClientMock.getApiKeys.mockRejectedValue(mock500());
- const wrapper = mountWithIntl();
-
+ const wrapper = renderView();
await waitForRender(wrapper, (updatedWrapper) => {
return updatedWrapper.find(EuiCallOut).length > 0;
});
@@ -129,7 +123,7 @@ describe('APIKeysGridPage', () => {
describe('Admin view', () => {
let wrapper: ReactWrapper;
beforeEach(() => {
- wrapper = mountWithIntl();
+ wrapper = renderView();
});
it('renders a callout indicating the user is an administrator', async () => {
@@ -164,7 +158,7 @@ describe('APIKeysGridPage', () => {
areApiKeysEnabled: true,
});
- wrapper = mountWithIntl();
+ wrapper = renderView();
});
it('does NOT render a callout indicating the user is an administrator', async () => {
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
index 0a647e2797b97..c208502fc6a37 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.tsx
@@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import type { PublicMethodsOf } from '@kbn/utility-types';
import moment from 'moment-timezone';
-import type { ApplicationStart, DocLinksStart, NotificationsStart } from 'src/core/public';
+import type { NotificationsStart } from 'src/core/public';
import { SectionLoading } from '../../../../../../../src/plugins/es_ui_shared/public';
import { ApiKey, ApiKeyToInvalidate } from '../../../../common/model';
import { APIKeysAPIClient } from '../api_keys_api_client';
@@ -39,9 +39,7 @@ import { InvalidateProvider } from './invalidate_provider';
interface Props {
notifications: NotificationsStart;
- docLinks: DocLinksStart;
apiKeysAPIClient: PublicMethodsOf;
- navigateToApp: ApplicationStart['navigateToApp'];
}
interface State {
@@ -131,7 +129,7 @@ export class APIKeysGridPage extends Component {
if (!areApiKeysEnabled) {
return (
-
+
);
}
@@ -139,11 +137,7 @@ export class APIKeysGridPage extends Component {
if (!isLoadingTable && apiKeys && apiKeys.length === 0) {
return (
-
+
);
}
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
index e70e687dfe9b8..2a75ff1723c64 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
@@ -5,71 +5,70 @@
*/
import React, { Fragment } from 'react';
-import type { ApplicationStart, DocLinksStart } from 'kibana/public';
import { EuiEmptyPrompt, EuiButton, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
+import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
interface Props {
isAdmin: boolean;
- docLinks: DocLinksStart;
- navigateToApp: ApplicationStart['navigateToApp'];
}
-export const EmptyPrompt: React.FunctionComponent = ({
- isAdmin,
- docLinks,
- navigateToApp,
-}) => (
-
- {isAdmin ? (
+export const EmptyPrompt: React.FunctionComponent = ({ isAdmin }) => {
+ const { services } = useKibana();
+ const application = services.application!;
+ const docLinks = services.docLinks!;
+ return (
+
+ {isAdmin ? (
+
+ ) : (
+
+ )}
+
+ }
+ body={
+
+
+
+
+
+ ),
+ }}
+ />
+
+
+ }
+ actions={
+ application.navigateToApp('dev_tools')}
+ data-test-subj="goToConsoleButton"
+ >
- ) : (
-
- )}
-
- }
- body={
-
-
-
-
-
- ),
- }}
- />
-
-
- }
- actions={
- navigateToApp('dev_tools')}
- data-test-subj="goToConsoleButton"
- >
-
-
- }
- data-test-subj="emptyPrompt"
- />
-);
+
+ }
+ data-test-subj="emptyPrompt"
+ />
+ );
+};
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/not_enabled/not_enabled.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/not_enabled/not_enabled.tsx
index 11be2a2564902..54ea724cfef1d 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/not_enabled/not_enabled.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/not_enabled/not_enabled.tsx
@@ -7,36 +7,35 @@
import React from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import type { DocLinksStart } from 'src/core/public';
+import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
-interface Props {
- docLinks: DocLinksStart;
-}
-
-export const NotEnabled: React.FunctionComponent = ({ docLinks }) => (
- {
+ const docLinks = useKibana().services.docLinks!;
+ return (
+
+ }
+ color="danger"
+ iconType="alert"
+ >
+
+
+ ),
+ }}
/>
- }
- color="danger"
- iconType="alert"
- >
-
-
-
- ),
- }}
- />
-
-);
+
+ );
+};
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
index 71a114cc12095..e9901b8f7847c 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.test.tsx
@@ -5,9 +5,7 @@
*/
jest.mock('./api_keys_grid', () => ({
- APIKeysGridPage: (props: any) =>
- // `docLinks` object is too big to include into test snapshot, so we just check its existence.
- `Page: ${JSON.stringify({ ...props, docLinks: props.docLinks ? {} : undefined })}`,
+ APIKeysGridPage: (props: any) => `Page: ${JSON.stringify(props)}`,
}));
import { apiKeysManagementApp } from './api_keys_management_app';
import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks';
@@ -45,7 +43,7 @@ describe('apiKeysManagementApp', () => {
expect(setBreadcrumbs).toHaveBeenCalledWith([{ href: '/', text: 'API Keys' }]);
expect(container).toMatchInlineSnapshot(`
- Page: {"notifications":{"toasts":{}},"docLinks":{},"apiKeysAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}}}
+ Page: {"notifications":{"toasts":{}},"apiKeysAPIClient":{"http":{"basePath":{"basePath":"","serverBasePath":""},"anonymousPaths":{},"externalUrl":{}}}}
`);
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
index 7240375d26213..8a925d062ca9a 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_management_app.tsx
@@ -9,6 +9,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { i18n } from '@kbn/i18n';
import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
+import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { PluginStartDependencies } from '../../plugin';
interface CreateParams {
@@ -45,14 +46,14 @@ export const apiKeysManagementApp = Object.freeze({
]);
render(
-
-
- ,
+
+
+
+
+ ,
element
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
index 96e8ba2901046..0c70a8228e454 100644
--- a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
@@ -7,36 +7,35 @@
import React from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
-import type { DocLinksStart } from 'src/core/public';
+import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
-interface Props {
- docLinks: DocLinksStart;
-}
-
-export const NoCompatibleRealms: React.FunctionComponent = ({ docLinks }: Props) => (
- {
+ const docLinks = useKibana().services.docLinks!;
+ return (
+
+ }
+ color="warning"
+ iconType="alert"
+ >
+
+
+ ),
+ }}
/>
- }
- color="warning"
- iconType="alert"
- >
-
-
-
- ),
- }}
- />
-
-);
+
+ );
+};
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx
index 07e744760c0f2..587552c26d7c9 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx
@@ -20,6 +20,7 @@ import { VisualRuleEditor } from './rule_editor_panel/visual_rule_editor';
import { JSONRuleEditor } from './rule_editor_panel/json_rule_editor';
import { RolesAPIClient } from '../../roles';
import { Role } from '../../../../common/model';
+import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks';
import { roleMappingsAPIClientMock } from '../role_mappings_api_client.mock';
@@ -30,6 +31,25 @@ describe('EditRoleMappingPage', () => {
const history = scopedHistoryMock.create();
let rolesAPI: PublicMethodsOf;
+ const renderView = (
+ roleMappingsAPI: ReturnType,
+ name?: string
+ ) => {
+ const { docLinks, notifications } = coreMock.createStart();
+ return mountWithIntl(
+
+
+
+ );
+ };
+
beforeEach(() => {
rolesAPI = rolesAPIClientMock.create();
(rolesAPI as jest.Mocked).getRoles.mockResolvedValue([
@@ -49,17 +69,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI);
await nextTick();
wrapper.update();
@@ -111,18 +121,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
await nextTick();
wrapper.update();
@@ -160,16 +159,7 @@ describe('EditRoleMappingPage', () => {
hasCompatibleRealms: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
expect(wrapper.find(SectionLoading)).toHaveLength(1);
expect(wrapper.find(PermissionDenied)).toHaveLength(0);
@@ -188,16 +178,7 @@ describe('EditRoleMappingPage', () => {
hasCompatibleRealms: false,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
expect(wrapper.find(SectionLoading)).toHaveLength(1);
expect(wrapper.find(NoCompatibleRealms)).toHaveLength(0);
@@ -225,18 +206,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
expect(findTestSubject(wrapper, 'deprecatedRolesAssigned')).toHaveLength(0);
await nextTick();
@@ -266,18 +236,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: false,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
expect(findTestSubject(wrapper, 'roleMappingInlineScriptsDisabled')).toHaveLength(0);
expect(findTestSubject(wrapper, 'roleMappingStoredScriptsDisabled')).toHaveLength(0);
@@ -309,18 +268,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
expect(findTestSubject(wrapper, 'roleMappingInlineScriptsDisabled')).toHaveLength(0);
expect(findTestSubject(wrapper, 'roleMappingStoredScriptsDisabled')).toHaveLength(0);
@@ -364,18 +312,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
await nextTick();
wrapper.update();
@@ -420,18 +357,7 @@ describe('EditRoleMappingPage', () => {
canUseStoredScripts: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
-
+ const wrapper = renderView(roleMappingsAPI, 'foo');
await nextTick();
wrapper.update();
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
index cca8ca966ebda..3de11e84e042b 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.tsx
@@ -179,7 +179,7 @@ export class EditRoleMappingPage extends Component {
{!this.state.hasCompatibleRealms && (
<>
-
+
>
)}
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
index c327609a8c05b..4d73c70f891e3 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
@@ -17,19 +17,24 @@ import { act } from 'react-dom/test-utils';
import { mountWithIntl } from '@kbn/test/jest';
import { JSONRuleEditor } from './json_rule_editor';
import { EuiCodeEditor } from '@elastic/eui';
+import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public';
import { AllRule, AnyRule, FieldRule, ExceptAnyRule, ExceptAllRule } from '../../model';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
describe('JSONRuleEditor', () => {
+ const renderView = (props: React.ComponentProps) => {
+ const { docLinks } = coreMock.createStart();
+ return mountWithIntl(
+
+
+
+ );
+ };
+
it('renders an empty rule set', () => {
- const props = {
- rules: null,
- onChange: jest.fn(),
- onValidityChange: jest.fn(),
- docLinks: coreMock.createStart().docLinks,
- };
- const wrapper = mountWithIntl();
+ const props = { rules: null, onChange: jest.fn(), onValidityChange: jest.fn() };
+ const wrapper = renderView(props);
expect(props.onChange).not.toHaveBeenCalled();
expect(props.onValidityChange).not.toHaveBeenCalled();
@@ -49,9 +54,8 @@ describe('JSONRuleEditor', () => {
]),
onChange: jest.fn(),
onValidityChange: jest.fn(),
- docLinks: coreMock.createStart().docLinks,
};
- const wrapper = mountWithIntl();
+ const wrapper = renderView(props);
const { value } = wrapper.find(EuiCodeEditor).props();
expect(JSON.parse(value as string)).toEqual({
@@ -79,13 +83,8 @@ describe('JSONRuleEditor', () => {
});
it('notifies when input contains invalid JSON', () => {
- const props = {
- rules: null,
- onChange: jest.fn(),
- onValidityChange: jest.fn(),
- docLinks: coreMock.createStart().docLinks,
- };
- const wrapper = mountWithIntl();
+ const props = { rules: null, onChange: jest.fn(), onValidityChange: jest.fn() };
+ const wrapper = renderView(props);
const allRule = JSON.stringify(new AllRule().toRaw());
act(() => {
@@ -98,13 +97,8 @@ describe('JSONRuleEditor', () => {
});
it('notifies when input contains an invalid rule set, even if it is valid JSON', () => {
- const props = {
- rules: null,
- onChange: jest.fn(),
- onValidityChange: jest.fn(),
- docLinks: coreMock.createStart().docLinks,
- };
- const wrapper = mountWithIntl();
+ const props = { rules: null, onChange: jest.fn(), onValidityChange: jest.fn() };
+ const wrapper = renderView(props);
const invalidRule = JSON.stringify({
all: [
@@ -126,13 +120,8 @@ describe('JSONRuleEditor', () => {
});
it('fires onChange when a valid rule set is provided after being previously invalidated', () => {
- const props = {
- rules: null,
- onChange: jest.fn(),
- onValidityChange: jest.fn(),
- docLinks: coreMock.createStart().docLinks,
- };
- const wrapper = mountWithIntl();
+ const props = { rules: null, onChange: jest.fn(), onValidityChange: jest.fn() };
+ const wrapper = renderView(props);
const allRule = JSON.stringify(new AllRule().toRaw());
act(() => {
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
index a535c99b31b60..931803ddc6ffe 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.tsx
@@ -11,17 +11,17 @@ import 'brace/theme/github';
import { EuiCodeEditor, EuiFormRow, EuiButton, EuiSpacer, EuiLink, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
-import type { DocLinksStart } from 'src/core/public';
import { Rule, RuleBuilderError, generateRulesFromRaw } from '../../model';
+import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
interface Props {
rules: Rule | null;
onChange: (updatedRules: Rule | null) => void;
onValidityChange: (isValid: boolean) => void;
- docLinks: DocLinksStart;
}
export const JSONRuleEditor = (props: Props) => {
+ const docLinks = useKibana().services.docLinks!;
const [rawRules, setRawRules] = useState(
JSON.stringify(props.rules ? props.rules.toRaw() : {}, null, 2)
);
@@ -108,7 +108,7 @@ export const JSONRuleEditor = (props: Props) => {
values={{
roleMappingAPI: (
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
index 7c0101ce94996..2cc414f1fbd1f 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
@@ -17,10 +17,18 @@ import '@kbn/test/target/jest/utils/stub_web_worker';
import { AllRule, FieldRule } from '../../model';
import { EuiErrorBoundary } from '@elastic/eui';
+import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
describe('RuleEditorPanel', () => {
+ const renderView = (props: React.ComponentProps) => {
+ return mountWithIntl(
+
+
+
+ );
+ };
it('renders the visual editor when no rules are defined', () => {
const props = {
rawRules: {},
@@ -29,7 +37,7 @@ describe('RuleEditorPanel', () => {
validateForm: false,
docLinks: coreMock.createStart().docLinks,
};
- const wrapper = mountWithIntl();
+ const wrapper = renderView(props);
expect(wrapper.find(VisualRuleEditor)).toHaveLength(1);
expect(wrapper.find(JSONRuleEditor)).toHaveLength(0);
});
@@ -50,7 +58,7 @@ describe('RuleEditorPanel', () => {
validateForm: false,
docLinks: coreMock.createStart().docLinks,
};
- const wrapper = mountWithIntl();
+ const wrapper = renderView(props);
expect(wrapper.find(VisualRuleEditor)).toHaveLength(1);
expect(wrapper.find(JSONRuleEditor)).toHaveLength(0);
@@ -74,7 +82,7 @@ describe('RuleEditorPanel', () => {
validateForm: false,
docLinks: coreMock.createStart().docLinks,
};
- const wrapper = mountWithIntl();
+ const wrapper = renderView(props);
findTestSubject(wrapper, 'roleMappingsJSONRuleEditorButton').simulate('click');
@@ -110,7 +118,7 @@ describe('RuleEditorPanel', () => {
validateForm: false,
docLinks: coreMock.createStart().docLinks,
};
- const wrapper = mountWithIntl();
+ const wrapper = renderView(props);
wrapper.find(VisualRuleEditor).simulateError(new Error('Something awful happened here.'));
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
index 8e350c1d6ff9d..1b5cda1df5b52 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.tsx
@@ -215,7 +215,6 @@ export class RuleEditorPanel extends Component {
rules={this.state.rules}
onChange={this.onRuleChange}
onValidityChange={this.onValidityChange}
- docLinks={this.props.docLinks}
/>
);
default:
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
index f9e44e9b73c2f..5c79cb4b7742d 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
@@ -13,6 +13,7 @@ import { EmptyPrompt } from './empty_prompt';
import { findTestSubject } from '@kbn/test/jest';
import { EuiLink } from '@elastic/eui';
import { act } from '@testing-library/react';
+import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks';
import { roleMappingsAPIClientMock } from '../role_mappings_api_client.mock';
@@ -22,6 +23,25 @@ describe('RoleMappingsGridPage', () => {
let history: ScopedHistory;
let coreStart: CoreStart;
+ const renderView = (
+ roleMappingsAPI: ReturnType,
+ rolesAPI: ReturnType = rolesAPIClientMock.create()
+ ) => {
+ const { application, docLinks, notifications } = coreStart;
+ return mountWithIntl(
+
+
+
+ );
+ };
+
beforeEach(() => {
history = scopedHistoryMock.create();
coreStart = coreMock.createStart();
@@ -35,17 +55,7 @@ describe('RoleMappingsGridPage', () => {
hasCompatibleRealms: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
expect(wrapper.find(SectionLoading)).toHaveLength(1);
expect(wrapper.find(EmptyPrompt)).toHaveLength(0);
@@ -64,17 +74,7 @@ describe('RoleMappingsGridPage', () => {
hasCompatibleRealms: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
expect(wrapper.find(SectionLoading)).toHaveLength(1);
expect(wrapper.find(PermissionDenied)).toHaveLength(0);
@@ -101,17 +101,7 @@ describe('RoleMappingsGridPage', () => {
hasCompatibleRealms: false,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
expect(wrapper.find(SectionLoading)).toHaveLength(1);
expect(wrapper.find(NoCompatibleRealms)).toHaveLength(0);
@@ -137,17 +127,7 @@ describe('RoleMappingsGridPage', () => {
hasCompatibleRealms: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
await nextTick();
wrapper.update();
@@ -171,17 +151,7 @@ describe('RoleMappingsGridPage', () => {
hasCompatibleRealms: true,
});
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
await nextTick();
wrapper.update();
@@ -211,17 +181,7 @@ describe('RoleMappingsGridPage', () => {
},
]);
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI);
await nextTick();
wrapper.update();
@@ -274,17 +234,7 @@ describe('RoleMappingsGridPage', () => {
},
]);
- const { docLinks, notifications } = coreMock.createStart();
- const wrapper = mountWithIntl(
-
- );
+ const wrapper = renderView(roleMappingsAPI, roleAPIClient);
await nextTick();
wrapper.update();
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
index 59d5769a00480..2d225f5ebd084 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx
@@ -183,7 +183,7 @@ export class RoleMappingsGridPage extends Component {
{!this.state.hasCompatibleRealms && (
<>
-
+
>
)}
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
index 74eac417f0c4e..3f3bf4ad809ce 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
@@ -12,6 +12,7 @@ import { StartServicesAccessor } from 'src/core/public';
import { RegisterManagementAppArgs } from '../../../../../../src/plugins/management/public';
import { PluginStartDependencies } from '../../plugin';
import { tryDecodeURIComponent } from '../url_utils';
+import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
interface CreateParams {
getStartServices: StartServicesAccessor;
@@ -97,18 +98,20 @@ export const roleMappingsManagementApp = Object.freeze({
};
render(
-
-
-
-
-
-
-
-
-
-
-
- ,
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
element
);
From 778def9edb5dde425cde49c531df36a5e53c455e Mon Sep 17 00:00:00 2001
From: Aleh Zasypkin
Date: Fri, 15 Jan 2021 08:40:04 +0100
Subject: [PATCH 3/3] Review#2: handle review suggestions.
---
...-plugin-core-public.doclinksstart.links.md | 8 +++----
...kibana-plugin-core-public.doclinksstart.md | 2 +-
.../public/doc_links/doc_links_service.ts | 8 +++----
src/core/public/public.api.md | 8 +++----
.../api_keys_grid/api_keys_grid_page.test.tsx | 5 ++---
.../empty_prompt/empty_prompt.tsx | 2 +-
.../api_keys/api_keys_management_app.tsx | 16 +++++---------
.../no_compatible_realms.tsx | 2 +-
.../edit_role_mapping_page.test.tsx | 8 +++----
.../json_rule_editor.test.tsx | 4 ++--
.../rule_editor_panel.test.tsx | 11 +++++-----
.../role_mappings_grid_page.test.tsx | 9 ++++----
.../role_mappings_management_app.tsx | 22 +++++++++----------
13 files changed, 49 insertions(+), 56 deletions(-)
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
index 93bd6886c0974..ff2a8a2b5f75f 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.links.md
@@ -108,7 +108,7 @@ readonly links: {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: {
+ readonly apis: Readonly<{
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@@ -123,12 +123,12 @@ readonly links: {
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
- };
+ }>;
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: {
+ readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
@@ -139,7 +139,7 @@ readonly links: {
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
- };
+ }>;
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
index 6db8c98633834..8404326f773e6 100644
--- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
+++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md
@@ -17,5 +17,5 @@ export interface DocLinksStart
| --- | --- | --- |
| [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | string
| |
| [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | string
| |
-| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly addData: string;
readonly kibana: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: {
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
executeWatchActionModes: string;
openIndex: string;
putComponentTemplate: string;
painlessExecute: string;
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
};
readonly observability: Record<string, string>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: {
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
elasticsearchEnableSecurity: string;
indicesPrivileges: string;
kibanaTLS: string;
kibanaPrivileges: string;
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
};
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
}
| |
+| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly startup: string;
readonly exportedFields: string;
};
readonly auditbeat: {
readonly base: string;
};
readonly metricbeat: {
readonly base: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: string;
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessSyntax: string;
readonly luceneExpressions: string;
};
readonly indexPatterns: {
readonly loadingData: string;
readonly introduction: string;
};
readonly addData: string;
readonly kibana: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly guide: string;
readonly gettingStarted: string;
};
readonly query: {
readonly eql: string;
readonly luceneQuerySyntax: string;
readonly queryDsl: string;
readonly kueryQuerySyntax: string;
};
readonly date: {
readonly dateMath: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
executeWatchActionModes: string;
openIndex: string;
putComponentTemplate: string;
painlessExecute: string;
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
}>;
readonly observability: Record<string, string>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
elasticsearchEnableSecurity: string;
indicesPrivileges: string;
kibanaTLS: string;
kibanaPrivileges: string;
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
}>;
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
}
| |
diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts
index 605f9dcfd8b63..6c0ced7022cb2 100644
--- a/src/core/public/doc_links/doc_links_service.ts
+++ b/src/core/public/doc_links/doc_links_service.ts
@@ -344,7 +344,7 @@ export interface DocLinksStart {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: {
+ readonly apis: Readonly<{
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@@ -359,12 +359,12 @@ export interface DocLinksStart {
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
- };
+ }>;
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: {
+ readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
@@ -375,7 +375,7 @@ export interface DocLinksStart {
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
- };
+ }>;
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index 99277c7e31c24..2f4c871c33431 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -587,7 +587,7 @@ export interface DocLinksStart {
readonly ml: Record;
readonly transforms: Record;
readonly visualize: Record;
- readonly apis: {
+ readonly apis: Readonly<{
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
@@ -602,12 +602,12 @@ export interface DocLinksStart {
putComponentTemplateMetadata: string;
putWatch: string;
updateTransform: string;
- };
+ }>;
readonly observability: Record;
readonly alerting: Record;
readonly maps: Record;
readonly monitoring: Record;
- readonly security: {
+ readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
@@ -618,7 +618,7 @@ export interface DocLinksStart {
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
- };
+ }>;
readonly watcher: Record;
readonly ccs: Record;
};
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
index 04d543fc0292b..a55d872ca60f9 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx
@@ -67,10 +67,9 @@ describe('APIKeysGridPage', () => {
const coreStart = coreMock.createStart();
const renderView = () => {
- const { docLinks, notifications, application } = coreStart;
return mountWithIntl(
-
-
+
+
);
};
diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
index 2a75ff1723c64..39a34efb9f934 100644
--- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
+++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/empty_prompt/empty_prompt.tsx
@@ -44,7 +44,7 @@ export const EmptyPrompt: React.FunctionComponent = ({ isAdmin }) => {
defaultMessage="You can create an {link} from Console."
values={{
link: (
-
+
-
+
+
-
+
,
element
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
index 0c70a8228e454..a3a7377b0d395 100644
--- a/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/components/no_compatible_realms/no_compatible_realms.tsx
@@ -27,7 +27,7 @@ export const NoCompatibleRealms: React.FunctionComponent = () => {
defaultMessage="Role mappings will not be applied to any users. Contact your system administrator and refer to the {link} for more information."
values={{
link: (
-
+
{
roleMappingsAPI: ReturnType,
name?: string
) => {
- const { docLinks, notifications } = coreMock.createStart();
+ const coreStart = coreMock.createStart();
return mountWithIntl(
-
+
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
index 4d73c70f891e3..5c7c6ed5b3ca1 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx
@@ -24,9 +24,9 @@ import { coreMock } from '../../../../../../../../src/core/public/mocks';
describe('JSONRuleEditor', () => {
const renderView = (props: React.ComponentProps) => {
- const { docLinks } = coreMock.createStart();
+ const coreStart = coreMock.createStart();
return mountWithIntl(
-
+
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
index 2cc414f1fbd1f..5a44a7c05c193 100644
--- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx
@@ -22,10 +22,12 @@ import { KibanaContextProvider } from '../../../../../../../../src/plugins/kiban
import { coreMock } from '../../../../../../../../src/core/public/mocks';
describe('RuleEditorPanel', () => {
- const renderView = (props: React.ComponentProps) => {
+ const renderView = (props: Omit, 'docLinks'>) => {
+ const coreStart = coreMock.createStart();
+ const viewProps = { ...props, docLinks: coreStart.docLinks };
return mountWithIntl(
-
-
+
+
);
};
@@ -35,7 +37,6 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: coreMock.createStart().docLinks,
};
const wrapper = renderView(props);
expect(wrapper.find(VisualRuleEditor)).toHaveLength(1);
@@ -80,7 +81,6 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: coreMock.createStart().docLinks,
};
const wrapper = renderView(props);
@@ -116,7 +116,6 @@ describe('RuleEditorPanel', () => {
onChange: jest.fn(),
onValidityChange: jest.fn(),
validateForm: false,
- docLinks: coreMock.createStart().docLinks,
};
const wrapper = renderView(props);
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
index 5c79cb4b7742d..05edd3a370092 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx
@@ -27,16 +27,15 @@ describe('RoleMappingsGridPage', () => {
roleMappingsAPI: ReturnType,
rolesAPI: ReturnType = rolesAPIClientMock.create()
) => {
- const { application, docLinks, notifications } = coreStart;
return mountWithIntl(
-
+
);
diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
index 3f3bf4ad809ce..28b452c10c237 100644
--- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
+++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_management_app.tsx
@@ -39,7 +39,7 @@ export const roleMappingsManagementApp = Object.freeze({
];
const [
- [{ docLinks, http, notifications, i18n: i18nStart }],
+ [core],
{ RoleMappingsGridPage },
{ EditRoleMappingPage },
{ RoleMappingsAPIClient },
@@ -52,15 +52,15 @@ export const roleMappingsManagementApp = Object.freeze({
import('../roles'),
]);
- const roleMappingsAPIClient = new RoleMappingsAPIClient(http);
+ const roleMappingsAPIClient = new RoleMappingsAPIClient(core.http);
const RoleMappingsGridPageWithBreadcrumbs = () => {
setBreadcrumbs(roleMappingsBreadcrumbs);
return (
@@ -89,17 +89,17 @@ export const roleMappingsManagementApp = Object.freeze({
);
};
render(
-
-
+
+
@@ -110,7 +110,7 @@ export const roleMappingsManagementApp = Object.freeze({
-
+
,
element
);