[NP] Migrate ui capabilities (#64185)

* Migrate ui capabilities

* Add capabilities for dashboard
This commit is contained in:
Maryia Lapata 2020-04-27 14:19:46 +03:00 committed by GitHub
parent a6fff8b298
commit 5f13ad107f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 504 additions and 60 deletions

View file

@ -152,61 +152,6 @@ export default function(kibana) {
uiSettingDefaults: getUiSettingDefaults(),
},
uiCapabilities: async function() {
return {
discover: {
show: true,
createShortUrl: true,
save: true,
saveQuery: true,
},
visualize: {
show: true,
createShortUrl: true,
delete: true,
save: true,
saveQuery: true,
},
dashboard: {
createNew: true,
show: true,
showWriteControls: true,
saveQuery: true,
},
catalogue: {
discover: true,
dashboard: true,
visualize: true,
console: true,
advanced_settings: true,
index_patterns: true,
},
advancedSettings: {
show: true,
save: true,
},
indexPatterns: {
save: true,
},
savedObjectsManagement: {
delete: true,
edit: true,
read: true,
},
management: {
/*
* Management settings correspond to management section/link ids, and should not be changed
* without also updating those definitions.
*/
kibana: {
settings: true,
index_patterns: true,
objects: true,
},
},
};
},
preInit: async function(server) {
try {
// Create the data directory (recursively, if the a parent dir doesn't exist).

View file

@ -1,7 +1,7 @@
{
"id": "advancedSettings",
"version": "kibana",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": ["management"]
}

View file

@ -0,0 +1,25 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
advancedSettings: {
show: true,
save: true,
},
});

View file

@ -0,0 +1,24 @@
/*
* 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 'kibana/server';
import { AdvancedSettingsServerPlugin } from './plugin';
export const plugin = (initContext: PluginInitializerContext) =>
new AdvancedSettingsServerPlugin(initContext);

View file

@ -0,0 +1,44 @@
/*
* 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, CoreSetup, CoreStart, Plugin, Logger } from 'kibana/server';
import { capabilitiesProvider } from './capabilities_provider';
export class AdvancedSettingsServerPlugin implements Plugin<object, object> {
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}
public setup(core: CoreSetup) {
this.logger.debug('advancedSettings: Setup');
core.capabilities.registerProvider(capabilitiesProvider);
return {};
}
public start(core: CoreStart) {
this.logger.debug('advancedSettings: Started');
return {};
}
public stop() {}
}

View file

@ -0,0 +1,27 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
dashboard: {
createNew: true,
show: true,
showWriteControls: true,
saveQuery: true,
},
});

View file

@ -26,6 +26,7 @@ import {
} from '../../../core/server';
import { dashboardSavedObjectType } from './saved_objects';
import { capabilitiesProvider } from './capabilities_provider';
import { DashboardPluginSetup, DashboardPluginStart } from './types';
@ -40,6 +41,7 @@ export class DashboardPlugin implements Plugin<DashboardPluginSetup, DashboardPl
this.logger.debug('dashboard: Setup');
core.savedObjects.registerType(dashboardSavedObjectType);
core.capabilities.registerProvider(capabilitiesProvider);
return {};
}

View file

@ -0,0 +1,24 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
indexPatterns: {
save: true,
},
});

View file

@ -20,10 +20,12 @@
import { CoreSetup, Plugin } from 'kibana/server';
import { registerRoutes } from './routes';
import { indexPatternSavedObjectType } from '../saved_objects';
import { capabilitiesProvider } from './capabilities_provider';
export class IndexPatternsService implements Plugin<void> {
public setup(core: CoreSetup) {
core.savedObjects.registerType(indexPatternSavedObjectType);
core.capabilities.registerProvider(capabilitiesProvider);
registerRoutes(core.http);
}

View file

@ -1,6 +1,6 @@
{
"id": "discover",
"version": "kibana",
"server": false,
"server": true,
"ui": true
}

View file

@ -0,0 +1,27 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
discover: {
show: true,
createShortUrl: true,
save: true,
saveQuery: true,
},
});

View file

@ -0,0 +1,24 @@
/*
* 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 'kibana/server';
import { DiscoverServerPlugin } from './plugin';
export const plugin = (initContext: PluginInitializerContext) =>
new DiscoverServerPlugin(initContext);

View file

@ -0,0 +1,44 @@
/*
* 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, CoreSetup, CoreStart, Plugin, Logger } from 'kibana/server';
import { capabilitiesProvider } from './capabilities_provider';
export class DiscoverServerPlugin implements Plugin<object, object> {
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}
public setup(core: CoreSetup) {
this.logger.debug('discover: Setup');
core.capabilities.registerProvider(capabilitiesProvider);
return {};
}
public start(core: CoreStart) {
this.logger.debug('discover: Started');
return {};
}
public stop() {}
}

View file

@ -0,0 +1,29 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
catalogue: {
discover: true,
dashboard: true,
visualize: true,
console: true,
advanced_settings: true,
index_patterns: true,
},
});

View file

@ -26,6 +26,7 @@ import {
SampleDataRegistryStart,
} from './services';
import { UsageCollectionSetup } from '../../usage_collection/server';
import { capabilitiesProvider } from './capabilities_provider';
import { sampleDataTelemetry } from './saved_objects';
interface HomeServerPluginSetupDependencies {
@ -38,6 +39,7 @@ export class HomeServerPlugin implements Plugin<HomeServerPluginSetup, HomeServe
private readonly sampleDataRegistry = new SampleDataRegistry(this.initContext);
public setup(core: CoreSetup, plugins: HomeServerPluginSetupDependencies): HomeServerPluginSetup {
core.capabilities.registerProvider(capabilitiesProvider);
core.savedObjects.registerType(sampleDataTelemetry);
return {
tutorials: { ...this.tutorialsRegistry.setup(core) },

View file

@ -1,7 +1,7 @@
{
"id": "management",
"version": "kibana",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": ["kibanaLegacy", "home"]
}

View file

@ -0,0 +1,32 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
management: {
/*
* Management settings correspond to management section/link ids, and should not be changed
* without also updating those definitions.
*/
kibana: {
settings: true,
index_patterns: true,
objects: true,
},
},
});

View file

@ -0,0 +1,24 @@
/*
* 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 'kibana/server';
import { ManagementServerPlugin } from './plugin';
export const plugin = (initContext: PluginInitializerContext) =>
new ManagementServerPlugin(initContext);

View file

@ -0,0 +1,44 @@
/*
* 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, CoreSetup, CoreStart, Plugin, Logger } from 'kibana/server';
import { capabilitiesProvider } from './capabilities_provider';
export class ManagementServerPlugin implements Plugin<object, object> {
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}
public setup(core: CoreSetup) {
this.logger.debug('management: Setup');
core.capabilities.registerProvider(capabilitiesProvider);
return {};
}
public start(core: CoreStart) {
this.logger.debug('management: Started');
return {};
}
public stop() {}
}

View file

@ -0,0 +1,26 @@
/*
* 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.
*/
export const capabilitiesProvider = () => ({
savedObjectsManagement: {
delete: true,
edit: true,
read: true,
},
});

View file

@ -23,6 +23,7 @@ import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from '
import { SavedObjectsManagementPluginSetup, SavedObjectsManagementPluginStart } from './types';
import { SavedObjectsManagement } from './services';
import { registerRoutes } from './routes';
import { capabilitiesProvider } from './capabilities_provider';
export class SavedObjectsManagementPlugin
implements Plugin<SavedObjectsManagementPluginSetup, SavedObjectsManagementPluginStart, {}, {}> {
@ -33,13 +34,15 @@ export class SavedObjectsManagementPlugin
this.logger = this.context.logger.get();
}
public async setup({ http }: CoreSetup) {
public async setup({ http, capabilities }: CoreSetup) {
this.logger.debug('Setting up SavedObjectsManagement plugin');
registerRoutes({
http,
managementServicePromise: this.managementService$.pipe(first()).toPromise(),
});
capabilities.registerProvider(capabilitiesProvider);
return {};
}

View file

@ -1,7 +1,7 @@
{
"id": "visualize",
"version": "kibana",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": [
"data",

View file

@ -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.
*/
export const capabilitiesProvider = () => ({
visualize: {
show: true,
createShortUrl: true,
delete: true,
save: true,
saveQuery: true,
},
});

View file

@ -0,0 +1,24 @@
/*
* 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 'kibana/server';
import { VisualizeServerPlugin } from './plugin';
export const plugin = (initContext: PluginInitializerContext) =>
new VisualizeServerPlugin(initContext);

View file

@ -0,0 +1,44 @@
/*
* 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, CoreSetup, CoreStart, Plugin, Logger } from 'kibana/server';
import { capabilitiesProvider } from './capabilities_provider';
export class VisualizeServerPlugin implements Plugin<object, object> {
private readonly logger: Logger;
constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
}
public setup(core: CoreSetup) {
this.logger.debug('visualize: Setup');
core.capabilities.registerProvider(capabilitiesProvider);
return {};
}
public start(core: CoreStart) {
this.logger.debug('visualize: Started');
return {};
}
public stop() {}
}