-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Move base feature controls functionality from XPack Main plugin to a dedicated XPack Features plugin #44664
Move base feature controls functionality from XPack Main plugin to a dedicated XPack Features plugin #44664
Changes from 8 commits
3eed113
af66d11
f3a1ef1
48c298d
b646d6b
fdbe9f3
1bbeae4
eb03238
2d35f6d
e2abff6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -22,7 +22,7 @@ init(server) { | |||||||
----------- | ||||||||
|
||||||||
===== Feature details | ||||||||
Registering a feature consists of the following fields. For more information, consult the {repo}blob/{branch}/x-pack/legacy/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts[feature registry interface]. | ||||||||
Registering a feature consists of the following fields. For more information, consult the {repo}blob/{branch}/x-pack/plugins/features/server/feature_registry.ts[feature registry interface]. | ||||||||
|
||||||||
|
||||||||
[cols="1a, 1a, 1a, 1a"] | ||||||||
|
@@ -45,7 +45,7 @@ Registering a feature consists of the following fields. For more information, co | |||||||
|An array of applications this feature enables. Typically, all of your plugin's apps (from `uiExports`) will be included here. | ||||||||
|
||||||||
|`privileges` (required) | ||||||||
|{repo}blob/{branch}/x-pack/legacy/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts[`FeatureWithAllOrReadPrivileges`]. | ||||||||
|{repo}blob/{branch}/x-pack/plugins/features/server/feature.ts[`FeatureWithAllOrReadPrivileges`]. | ||||||||
|see examples below | ||||||||
|The set of privileges this feature requires to function. | ||||||||
|
||||||||
|
@@ -63,7 +63,7 @@ Registering a feature consists of the following fields. For more information, co | |||||||
===== Privilege definition | ||||||||
The `privileges` section of feature registration allows plugins to implement read/write and read-only modes for their applications. | ||||||||
|
||||||||
For a full explanation of fields and options, consult the {repo}blob/{branch}/x-pack/legacy/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts[feature registry interface]. | ||||||||
For a full explanation of fields and options, consult the {repo}blob/{branch}/x-pack/plugins/features/server/feature_registry.ts[feature registry interface]. | ||||||||
|
||||||||
==== Using UI Capabilities | ||||||||
|
||||||||
|
@@ -142,7 +142,7 @@ init(server) { | |||||||
const xpackMainPlugin = server.plugins.xpack_main; | ||||||||
xpackMainPlugin.registerFeature({ | ||||||||
id: 'dev_tools', | ||||||||
name: i18n.translate('xpack.main.featureRegistry.devToolsFeatureName', { | ||||||||
name: i18n.translate('xpack.features.devToolsFeatureName', { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has a few references to the legacy filepath that we'll want to update:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||||||||
defaultMessage: 'Dev Tools', | ||||||||
}), | ||||||||
icon: 'devToolsApp', | ||||||||
|
@@ -167,7 +167,7 @@ init(server) { | |||||||
ui: ['show'], | ||||||||
}, | ||||||||
}, | ||||||||
privilegesTooltip: i18n.translate('xpack.main.featureRegistry.devToolsPrivilegesTooltip', { | ||||||||
privilegesTooltip: i18n.translate('xpack.features.devToolsPrivilegesTooltip', { | ||||||||
defaultMessage: | ||||||||
'User should also be granted the appropriate Elasticsearch cluster and index privileges', | ||||||||
}), | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: we need to get access to the |
||
"id": "timelion", | ||
"version": "8.0.0", | ||
"kibanaVersion": "kibana", | ||
"configPath": ["timelion"], | ||
"server": true, | ||
"ui": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
|
||
export const ConfigSchema = schema.object( | ||
{ | ||
ui: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), | ||
}, | ||
// This option should be removed as soon as we entirely migrate config from legacy Timelion plugin. | ||
{ allowUnknowns: true } | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { PluginInitializerContext } from '../../../../src/core/server'; | ||
import { ConfigSchema } from './config'; | ||
import { Plugin } from './plugin'; | ||
|
||
export { PluginSetupContract } from './plugin'; | ||
|
||
export const config = { schema: ConfigSchema }; | ||
export const plugin = (initializerContext: PluginInitializerContext) => | ||
new Plugin(initializerContext); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { first } from 'rxjs/operators'; | ||
import { TypeOf } from '@kbn/config-schema'; | ||
import { PluginInitializerContext, RecursiveReadonly } from '../../../../src/core/server'; | ||
import { deepFreeze } from '../../../../src/core/utils'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know we could import from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We use it for Security plugin already, so it should be supported: https://github.com/elastic/kibana/blob/master/x-pack/plugins/security/server/plugin.ts#L16 |
||
import { ConfigSchema } from './config'; | ||
|
||
/** | ||
* Describes public Timelion plugin contract returned at the `setup` stage. | ||
*/ | ||
export interface PluginSetupContract { | ||
uiEnabled: boolean; | ||
} | ||
|
||
/** | ||
* Represents Timelion Plugin instance that will be managed by the Kibana plugin system. | ||
*/ | ||
export class Plugin { | ||
constructor(private readonly initializerContext: PluginInitializerContext) {} | ||
|
||
public async setup(): Promise<RecursiveReadonly<PluginSetupContract>> { | ||
const config = await this.initializerContext.config | ||
.create<TypeOf<typeof ConfigSchema>>() | ||
.pipe(first()) | ||
.toPromise(); | ||
|
||
return deepFreeze({ uiEnabled: config.ui.enabled }); | ||
} | ||
|
||
public start() { | ||
this.initializerContext.logger.get().debug('Starting plugin'); | ||
} | ||
|
||
public stop() { | ||
this.initializerContext.logger.get().debug('Stopping plugin'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Platform team will own this plugin as soon as we merge it.