diff --git a/x-pack/plugins/ml/index.js b/x-pack/plugins/ml/index.js index 4510d0f01621d..52eb09e98649c 100644 --- a/x-pack/plugins/ml/index.js +++ b/x-pack/plugins/ml/index.js @@ -79,11 +79,6 @@ export const ml = (kibana) => { navLinkId: 'ml', privileges: { all: { - metadata: { - tooltip: i18n.translate('xpack.ml.privileges.tooltip', { - defaultMessage: 'The machine_learning_user or machine_learning_admin role should also be assigned to users to grant access' - }) - }, catalogue: ['ml'], app: ['ml', 'kibana'], savedObject: { @@ -92,7 +87,10 @@ export const ml = (kibana) => { }, ui: [], }, - } + }, + privilegesTooltip: i18n.translate('xpack.ml.privileges.tooltip', { + defaultMessage: 'The machine_learning_user or machine_learning_admin role should also be assigned to users to grant access' + }) }); // Add server routes and initialize the plugin here diff --git a/x-pack/plugins/monitoring/init.js b/x-pack/plugins/monitoring/init.js index 8d1ef7f879b03..a46b6982adaf2 100644 --- a/x-pack/plugins/monitoring/init.js +++ b/x-pack/plugins/monitoring/init.js @@ -64,11 +64,6 @@ export const init = (monitoringPlugin, server) => { navLinkId: 'monitoring', privileges: { all: { - metadata: { - tooltip: i18n.translate('xpack.monitoring.privileges.tooltip', { - defaultMessage: 'The monitoring_user role should also be assigned to users to grant access' - }) - }, catalogue: ['monitoring'], app: ['monitoring', 'kibana'], savedObject: { @@ -77,7 +72,10 @@ export const init = (monitoringPlugin, server) => { }, ui: [], }, - } + }, + privilegesTooltip: i18n.translate('xpack.monitoring.privileges.tooltip', { + defaultMessage: 'The monitoring_user role should also be assigned to users to grant access' + }) }); const bulkUploader = initBulkUploader(kbnServer, server); diff --git a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx index 4ab7d8216c078..5910d5924e4af 100644 --- a/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx +++ b/x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/feature_table/feature_table.tsx @@ -40,11 +40,6 @@ interface Props { disabled?: boolean; } -interface ToolTipDefinition { - privilegeId: string; - tooltip: string; -} - interface TableFeature extends Feature { hasAnyPrivilegeAssigned: boolean; } @@ -105,30 +100,11 @@ export class FeatureTable extends Component { defaultMessage: 'Feature', }), render: (feature: TableFeature) => { - const tooltips = Object.entries(feature.privileges).reduce( - (acc: ToolTipDefinition[], [privilegeId, privilege]) => { - if (!privilege.metadata || !privilege.metadata.tooltip) { - return acc; - } - - return [ - ...acc, - { - privilegeId, - tooltip: privilege.metadata.tooltip, - }, - ]; - }, - [] as ToolTipDefinition[] - ); - let tooltipElement = null; - if (tooltips.length > 0) { + if (feature.privilegesTooltip) { const tooltipContent = ( - {tooltips.map(tip => ( -

{tip.tooltip}

- ))} +

{feature.privilegesTooltip}

); tooltipElement = ( diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.test.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.test.ts index 5e0656e0dfdb1..4f7252f3938cb 100644 --- a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.test.ts +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.test.ts @@ -39,9 +39,6 @@ describe('registerFeature', () => { validLicenses: ['standard', 'basic', 'gold', 'platinum'], privileges: { all: { - metadata: { - tooltip: 'some fancy tooltip', - }, app: ['app1', 'app2'], savedObject: { all: ['config', 'space', 'etc'], @@ -51,6 +48,7 @@ describe('registerFeature', () => { ui: ['allowsFoo', 'showBar', 'showBaz'], }, }, + privilegesTooltip: 'some fancy tooltip', }; registerFeature(feature); @@ -100,9 +98,6 @@ describe('registerFeature', () => { name: 'Test Feature', privileges: { ['some invalid key']: { - metadata: { - tooltip: 'some fancy tooltip', - }, app: ['app1', 'app2'], savedObject: { all: ['config', 'space', 'etc'], diff --git a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts index 0ea97af522036..370644ab9aaed 100644 --- a/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts +++ b/x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts @@ -10,9 +10,6 @@ import _ from 'lodash'; import { UICapabilities } from 'ui/capabilities'; export interface FeaturePrivilegeDefinition { - metadata?: { - tooltip?: string; - }; management?: { [sectionId: string]: string[]; }; @@ -36,6 +33,7 @@ export interface Feature { privileges: { [key: string]: FeaturePrivilegeDefinition; }; + privilegesTooltip?: string; } // Each feature gets its own property on the UICapabilities object, @@ -60,9 +58,6 @@ const schema = Joi.object({ .pattern( featurePrivilegePartRegex, Joi.object({ - metadata: Joi.object({ - tooltip: Joi.string(), - }), management: Joi.object().pattern(managementSectionIdRegex, Joi.array().items(Joi.string())), catalogue: Joi.array().items(Joi.string()), api: Joi.array().items(Joi.string()), @@ -83,6 +78,7 @@ const schema = Joi.object({ }) ) .required(), + privilegesTooltip: Joi.string(), }); const features: Record = {};