Skip to content

Commit

Permalink
[NP] Migrate ui capabilities (#64185) (#64508)
Browse files Browse the repository at this point in the history
* Migrate ui capabilities

* Add capabilities for dashboard

Co-authored-by: Maryia Lapata <[email protected]>
  • Loading branch information
kertal and maryia-lapata authored Apr 27, 2020
1 parent aa01c28 commit d48b412
Show file tree
Hide file tree
Showing 25 changed files with 504 additions and 60 deletions.
55 changes: 0 additions & 55 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/advanced_settings/kibana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "advancedSettings",
"version": "kibana",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": ["management"]
}
25 changes: 25 additions & 0 deletions src/plugins/advanced_settings/server/capabilities_provider.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
24 changes: 24 additions & 0 deletions src/plugins/advanced_settings/server/index.ts
Original file line number Diff line number Diff line change
@@ -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);
44 changes: 44 additions & 0 deletions src/plugins/advanced_settings/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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() {}
}
27 changes: 27 additions & 0 deletions src/plugins/dashboard/server/capabilities_provider.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
2 changes: 2 additions & 0 deletions src/plugins/dashboard/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '../../../core/server';

import { dashboardSavedObjectType } from './saved_objects';
import { capabilitiesProvider } from './capabilities_provider';

import { DashboardPluginSetup, DashboardPluginStart } from './types';

Expand All @@ -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 {};
}
Expand Down
24 changes: 24 additions & 0 deletions src/plugins/data/server/index_patterns/capabilities_provider.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/kibana.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "discover",
"version": "kibana",
"server": false,
"server": true,
"ui": true
}
27 changes: 27 additions & 0 deletions src/plugins/discover/server/capabilities_provider.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
24 changes: 24 additions & 0 deletions src/plugins/discover/server/index.ts
Original file line number Diff line number Diff line change
@@ -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);
44 changes: 44 additions & 0 deletions src/plugins/discover/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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() {}
}
29 changes: 29 additions & 0 deletions src/plugins/home/server/capabilities_provider.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
Loading

0 comments on commit d48b412

Please sign in to comment.