Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup feature registration #80909

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions docs/api/features.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ The API returns the following:
{
"id": "discover",
"name": "Discover",
"icon": "discoverApp",
"navLinkId": "discover",
"app": [
"kibana"
],
Expand Down Expand Up @@ -73,8 +71,6 @@ The API returns the following:
{
"id": "visualize",
"name": "Visualize",
"icon": "visualizeApp",
"navLinkId": "visualize",
"app": [
"kibana"
],
Expand Down Expand Up @@ -120,8 +116,6 @@ The API returns the following:
{
"id": "dashboard",
"name": "Dashboard",
"icon": "dashboardApp",
"navLinkId": "dashboards",
"app": [
"kibana"
],
Expand Down Expand Up @@ -172,8 +166,6 @@ The API returns the following:
{
"id": "dev_tools",
"name": "Dev Tools",
"icon": "devToolsApp",
"navLinkId": "dev_tools",
"app": [
"kibana"
],
Expand Down
15 changes: 0 additions & 15 deletions docs/developer/architecture/security/feature-registration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@ of features within the management screens.
|See <<example-3-discover,Example 3>>
|The set of subfeatures that enables finer access control than the `all` and `read` feature privileges. These options are only available in the Gold subscription level and higher.

|`icon`
|`string`
|"discoverApp"
|An https://elastic.github.io/eui/#/display/icons[EUI Icon] to use for this feature.

|`navLinkId`
|`string`
|"sample_app"
|The ID of the navigation link associated with your feature.
|===

==== Privilege definition
Expand Down Expand Up @@ -100,8 +91,6 @@ public setup(core, { features }) {
features.registerKibanaFeature({
id: 'canvas',
name: 'Canvas',
icon: 'canvasApp',
navLinkId: 'canvas',
category: DEFAULT_APP_CATEGORIES.kibana,
app: ['canvas', 'kibana'],
catalogue: ['canvas'],
Expand Down Expand Up @@ -160,8 +149,6 @@ public setup(core, { features }) {
name: i18n.translate('xpack.features.devToolsFeatureName', {
defaultMessage: 'Dev Tools',
}),
icon: 'devToolsApp',
navLinkId: 'dev_tools',
category: DEFAULT_APP_CATEGORIES.management,
app: ['kibana'],
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
Expand Down Expand Up @@ -223,8 +210,6 @@ public setup(core, { features }) {
defaultMessage: 'Discover',
}),
order: 100,
icon: 'discoverApp',
navLinkId: 'discover',
category: DEFAULT_APP_CATEGORIES.kibana,
app: ['kibana'],
catalogue: ['discover'],
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/actions/server/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export const ACTIONS_FEATURE = {
name: i18n.translate('xpack.actions.featureRegistry.actionsFeatureName', {
defaultMessage: 'Actions and Connectors',
}),
icon: 'bell',
navLinkId: 'actions',
category: DEFAULT_APP_CATEGORIES.management,
app: [],
management: {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/apm/server/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export const APM_FEATURE = {
}),
order: 900,
category: DEFAULT_APP_CATEGORIES.observability,
icon: 'apmApp',
navLinkId: 'apm',
app: ['apm', 'ux', 'kibana'],
catalogue: ['apm'],
management: {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/canvas/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export class CanvasPlugin implements Plugin {
name: 'Canvas',
order: 300,
category: DEFAULT_APP_CATEGORIES.kibana,
icon: 'canvasApp',
navLinkId: 'canvas',
app: ['canvas', 'kibana'],
catalogue: ['canvas'],
privileges: {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/enterprise_search/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export class EnterpriseSearchPlugin implements Plugin {
name: ENTERPRISE_SEARCH_PLUGIN.NAME,
order: 0,
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
icon: 'logoEnterpriseSearch',
app: [
'kibana',
ENTERPRISE_SEARCH_PLUGIN.ID,
Expand Down
30 changes: 5 additions & 25 deletions x-pack/plugins/features/common/kibana_feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { RecursiveReadonly } from '@kbn/utility-types';
import { AppCategory } from 'src/core/types';
import { LicenseType } from '../../licensing/common/types';
import { FeatureKibanaPrivileges } from './feature_kibana_privileges';
import { SubFeatureConfig, SubFeature as KibanaSubFeature } from './sub_feature';
import { ReservedKibanaPrivilege } from './reserved_kibana_privilege';
Expand Down Expand Up @@ -52,25 +53,12 @@ export interface KibanaFeatureConfig {
excludeFromBasePrivileges?: boolean;

/**
* Optional array of supported licenses.
* Optional minimum supported license.
* If omitted, all licenses are allowed.
* This does not restrict access to your feature based on license.
* Its only purpose is to inform the space and roles UIs on which features to display.
*/
validLicenses?: ReadonlyArray<
'basic' | 'standard' | 'gold' | 'platinum' | 'enterprise' | 'trial'
>;

/**
* An optional EUI Icon to be used when displaying your feature.
*/
icon?: string;

/**
* The optional Nav Link ID for feature.
* If specified, your link will be automatically hidden if needed based on the current space and user permissions.
*/
navLinkId?: string;
minimumLicense?: LicenseType;

/**
* An array of app ids that are enabled when this feature is enabled.
Expand Down Expand Up @@ -170,10 +158,6 @@ export class KibanaFeature {
return this.config.category;
}

public get navLinkId() {
return this.config.navLinkId;
}

public get app() {
return this.config.app;
}
Expand All @@ -186,12 +170,8 @@ export class KibanaFeature {
return this.config.management;
}

public get icon() {
return this.config.icon;
}

public get validLicenses() {
return this.config.validLicenses;
public get minimumLicense() {
return this.config.minimumLicense;
}

public get privileges() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 1 addition & 17 deletions x-pack/plugins/features/server/feature_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ describe('FeatureRegistry', () => {
id: 'test-feature',
name: 'Test Feature',
excludeFromBasePrivileges: true,
icon: 'addDataApp',
navLinkId: 'someNavLink',
app: ['app1'],
category: { id: 'foo', label: 'foo' },
validLicenses: ['standard', 'basic', 'gold', 'platinum'],
minimumLicense: 'platinum',
catalogue: ['foo'],
management: {
foo: ['bar'],
Expand Down Expand Up @@ -421,20 +419,6 @@ describe('FeatureRegistry', () => {
});

['contains space', 'contains_invalid()_chars', ''].forEach((prohibitedChars) => {
it(`prevents features from being registered with a navLinkId of "${prohibitedChars}"`, () => {
const featureRegistry = new FeatureRegistry();
expect(() =>
featureRegistry.registerKibanaFeature({
id: 'foo',
name: 'some feature',
navLinkId: prohibitedChars,
app: [],
category: { id: 'foo', label: 'foo' },
privileges: null,
})
).toThrowErrorMatchingSnapshot();
});

it(`prevents features from being registered with a management id of "${prohibitedChars}"`, () => {
const featureRegistry = new FeatureRegistry();
expect(() =>
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugins/features/server/feature_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ const kibanaFeatureSchema = Joi.object({
category: appCategorySchema,
order: Joi.number(),
excludeFromBasePrivileges: Joi.boolean(),
validLicenses: Joi.array().items(
Joi.string().valid('basic', 'standard', 'gold', 'platinum', 'enterprise', 'trial')
minimumLicense: Joi.string().valid(
'basic',
'standard',
'gold',
'platinum',
'enterprise',
'trial'
),
icon: Joi.string(),
description: Joi.string(),
navLinkId: Joi.string().regex(uiCapabilitiesRegex),
app: Joi.array().items(Joi.string()).required(),
management: managementSchema,
catalogue: catalogueSchema,
Expand Down
13 changes: 0 additions & 13 deletions x-pack/plugins/features/server/oss_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 100,
category: DEFAULT_APP_CATEGORIES.kibana,
icon: 'discoverApp',
navLinkId: 'discover',
app: ['discover', 'kibana'],
catalogue: ['discover'],
privileges: {
Expand Down Expand Up @@ -82,8 +80,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 700,
category: DEFAULT_APP_CATEGORIES.kibana,
icon: 'visualizeApp',
navLinkId: 'visualize',
app: ['visualize', 'lens', 'kibana'],
catalogue: ['visualize'],
privileges: {
Expand Down Expand Up @@ -143,8 +139,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 200,
category: DEFAULT_APP_CATEGORIES.kibana,
icon: 'dashboardApp',
navLinkId: 'dashboards',
app: ['dashboards', 'kibana'],
catalogue: ['dashboard'],
privileges: {
Expand Down Expand Up @@ -222,8 +216,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 1300,
category: DEFAULT_APP_CATEGORIES.management,
icon: 'devToolsApp',
navLinkId: 'dev_tools',
app: ['dev_tools', 'kibana'],
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
privileges: {
Expand Down Expand Up @@ -260,7 +252,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 1500,
category: DEFAULT_APP_CATEGORIES.management,
icon: 'advancedSettingsApp',
app: ['kibana'],
catalogue: ['advanced_settings'],
management: {
Expand Down Expand Up @@ -300,7 +291,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 1600,
category: DEFAULT_APP_CATEGORIES.management,
icon: 'indexPatternApp',
app: ['kibana'],
catalogue: ['indexPatterns'],
management: {
Expand Down Expand Up @@ -340,7 +330,6 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
}),
order: 1700,
category: DEFAULT_APP_CATEGORIES.management,
icon: 'savedObjectsApp',
app: ['kibana'],
catalogue: ['saved_objects'],
management: {
Expand Down Expand Up @@ -384,8 +373,6 @@ const timelionFeature: KibanaFeatureConfig = {
name: 'Timelion',
order: 350,
category: DEFAULT_APP_CATEGORIES.kibana,
icon: 'timelionApp',
navLinkId: 'timelion',
app: ['timelion', 'kibana'],
catalogue: ['timelion'],
privileges: {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/features/server/routes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('GET /api/features', () => {
name: 'Licensed Feature',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
validLicenses: ['gold'],
minimumLicense: 'gold',
privileges: null,
});

Expand Down
7 changes: 3 additions & 4 deletions x-pack/plugins/features/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export function defineRoutes({ router, featureRegistry }: RouteDefinitionParams)
.filter(
(feature) =>
request.query.ignoreValidLicenses ||
!feature.validLicenses ||
!feature.validLicenses.length ||
(context.licensing!.license.type &&
feature.validLicenses.includes(context.licensing!.license.type))
!feature.minimumLicense ||
(context.licensing!.license &&
context.licensing!.license.hasAtLeast(feature.minimumLicense))
)
.sort(
(f1, f2) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: {
Expand Down Expand Up @@ -146,7 +145,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
catalogue: ['anotherFooEntry', 'anotherBarEntry'],
Expand Down Expand Up @@ -216,7 +214,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: {
Expand Down Expand Up @@ -247,7 +244,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: null,
Expand Down Expand Up @@ -292,7 +288,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: {
Expand Down Expand Up @@ -364,7 +359,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'newFeature',
name: 'my new feature',
navLinkId: 'newFeatureNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: {
Expand All @@ -385,7 +379,6 @@ describe('populateUICapabilities', () => {
new KibanaFeature({
id: 'yetAnotherNewFeature',
name: 'yet another new feature',
navLinkId: 'yetAnotherNavLink',
app: ['bar-app'],
category: { id: 'foo', label: 'foo' },
privileges: {
Expand Down
Loading