kibana/x-pack/plugins/saved_objects_tagging/common/capabilities.ts
Brandon Kobel 4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00

34 lines
1.1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { Capabilities } from 'src/core/types';
import { tagFeatureId } from './constants';
/**
* Represent the UI capabilities for the `savedObjectsTagging` section of `Capabilities`
*/
export interface TagsCapabilities {
view: boolean;
create: boolean;
edit: boolean;
delete: boolean;
assign: boolean;
viewConnections: boolean;
}
export const getTagsCapabilities = (capabilities: Capabilities): TagsCapabilities => {
const rawTagCapabilities = capabilities[tagFeatureId];
return {
view: (rawTagCapabilities?.view as boolean) ?? false,
create: (rawTagCapabilities?.create as boolean) ?? false,
edit: (rawTagCapabilities?.edit as boolean) ?? false,
delete: (rawTagCapabilities?.delete as boolean) ?? false,
assign: (rawTagCapabilities?.assign as boolean) ?? false,
viewConnections: (capabilities.savedObjectsManagement?.read as boolean) ?? false,
};
};