Migrate UI capabilities to use new platform APIs (#56070)
This commit is contained in:
parent
54d40e3670
commit
f97bc898bb
|
@ -11,6 +11,7 @@ import {
|
|||
ToastsSetup,
|
||||
HttpSetup,
|
||||
IUiSettingsClient,
|
||||
ApplicationStart,
|
||||
} from 'kibana/public';
|
||||
import { BASE_PATH, Section } from './constants';
|
||||
import { TriggersActionsUIHome } from './home';
|
||||
|
@ -27,6 +28,7 @@ export interface AppDeps {
|
|||
http: HttpSetup;
|
||||
uiSettings: IUiSettingsClient;
|
||||
legacy: LegacyDependencies;
|
||||
capabilities: ApplicationStart['capabilities'];
|
||||
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
|
||||
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
|
||||
}
|
||||
|
@ -46,10 +48,8 @@ export const App = (appDeps: AppDeps) => {
|
|||
};
|
||||
|
||||
export const AppWithoutRouter = ({ sectionsRegex }: any) => {
|
||||
const {
|
||||
legacy: { capabilities },
|
||||
} = useAppDependencies();
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities.get());
|
||||
const { capabilities } = useAppDependencies();
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities);
|
||||
const DEFAULT_SECTION: Section = canShowAlerts ? 'alerts' : 'connectors';
|
||||
return (
|
||||
<Switch>
|
||||
|
|
|
@ -39,11 +39,12 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
|
|||
}) => {
|
||||
const {
|
||||
chrome,
|
||||
legacy: { MANAGEMENT_BREADCRUMB, capabilities },
|
||||
capabilities,
|
||||
legacy: { MANAGEMENT_BREADCRUMB },
|
||||
} = useAppDependencies();
|
||||
|
||||
const canShowActions = hasShowActionsCapability(capabilities.get());
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities.get());
|
||||
const canShowActions = hasShowActionsCapability(capabilities);
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities);
|
||||
const tabs: Array<{
|
||||
id: Section;
|
||||
name: React.ReactNode;
|
||||
|
|
|
@ -20,7 +20,13 @@ describe('action_connector_form', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -28,18 +34,15 @@ describe('action_connector_form', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
|
|
@ -39,15 +39,10 @@ export const ActionConnectorForm = ({
|
|||
actionTypeName,
|
||||
setFlyoutVisibility,
|
||||
}: ActionConnectorProps) => {
|
||||
const {
|
||||
http,
|
||||
toastNotifications,
|
||||
legacy: { capabilities },
|
||||
actionTypeRegistry,
|
||||
} = useAppDependencies();
|
||||
const { http, toastNotifications, capabilities, actionTypeRegistry } = useAppDependencies();
|
||||
|
||||
const { reloadConnectors } = useActionsConnectorsContext();
|
||||
const canSave = hasSaveActionsCapability(capabilities.get());
|
||||
const canSave = hasSaveActionsCapability(capabilities);
|
||||
|
||||
// hooks
|
||||
const [{ connector }, dispatch] = useReducer(connectorReducer, { connector: initialConnector });
|
||||
|
|
|
@ -18,7 +18,13 @@ describe('connector_add_flyout', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -26,18 +32,15 @@ describe('connector_add_flyout', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
|
|
@ -20,7 +20,13 @@ describe('connector_add_flyout', () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -28,18 +34,15 @@ describe('connector_add_flyout', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
|
|
@ -17,7 +17,13 @@ let deps: any;
|
|||
describe('connector_edit_flyout', () => {
|
||||
beforeAll(async () => {
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -25,18 +31,15 @@ describe('connector_edit_flyout', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
actions: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
|
|
@ -42,7 +42,13 @@ describe('actions_connectors_list component empty', () => {
|
|||
},
|
||||
]);
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -50,18 +56,15 @@ describe('actions_connectors_list component empty', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': true,
|
||||
'actions:delete': true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': true,
|
||||
'actions:delete': true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
@ -136,7 +139,13 @@ describe('actions_connectors_list component with items', () => {
|
|||
]);
|
||||
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -144,18 +153,15 @@ describe('actions_connectors_list component with items', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': true,
|
||||
'actions:delete': true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': true,
|
||||
'actions:delete': true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: {
|
||||
|
@ -217,7 +223,13 @@ describe('actions_connectors_list component empty with show only capability', ()
|
|||
},
|
||||
]);
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -225,18 +237,15 @@ describe('actions_connectors_list component empty with show only capability', ()
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': false,
|
||||
'actions:delete': false,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': false,
|
||||
'actions:delete': false,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: {
|
||||
|
@ -303,7 +312,13 @@ describe('actions_connectors_list with show only capability', () => {
|
|||
},
|
||||
]);
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -311,18 +326,15 @@ describe('actions_connectors_list with show only capability', () => {
|
|||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': false,
|
||||
'actions:delete': false,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'actions:show': true,
|
||||
'actions:save': false,
|
||||
'actions:delete': false,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: {
|
||||
|
|
|
@ -26,13 +26,9 @@ import { hasDeleteActionsCapability, hasSaveActionsCapability } from '../../../l
|
|||
import { DeleteConnectorsModal } from '../../../components/delete_connectors_modal';
|
||||
|
||||
export const ActionsConnectorsList: React.FunctionComponent = () => {
|
||||
const {
|
||||
http,
|
||||
toastNotifications,
|
||||
legacy: { capabilities },
|
||||
} = useAppDependencies();
|
||||
const canDelete = hasDeleteActionsCapability(capabilities.get());
|
||||
const canSave = hasSaveActionsCapability(capabilities.get());
|
||||
const { http, toastNotifications, capabilities } = useAppDependencies();
|
||||
const canDelete = hasDeleteActionsCapability(capabilities);
|
||||
const canSave = hasSaveActionsCapability(capabilities);
|
||||
|
||||
const [actionTypesIndex, setActionTypesIndex] = useState<ActionTypeIndex | undefined>(undefined);
|
||||
const [actions, setActions] = useState<ActionConnector[]>([]);
|
||||
|
|
|
@ -70,7 +70,13 @@ describe('alerts_list component empty', () => {
|
|||
});
|
||||
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -84,18 +90,15 @@ describe('alerts_list component empty', () => {
|
|||
} as any,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': true,
|
||||
'alerting:delete': true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': true,
|
||||
'alerting:delete': true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
@ -193,7 +196,13 @@ describe('alerts_list component with items', () => {
|
|||
data: [],
|
||||
});
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -207,18 +216,15 @@ describe('alerts_list component with items', () => {
|
|||
} as any,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': true,
|
||||
'alerting:delete': true,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': true,
|
||||
'alerting:delete': true,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
@ -277,7 +283,13 @@ describe('alerts_list component empty with show only capability', () => {
|
|||
data: [],
|
||||
});
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -291,18 +303,15 @@ describe('alerts_list component empty with show only capability', () => {
|
|||
} as any,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': false,
|
||||
'alerting:delete': false,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': false,
|
||||
'alerting:delete': false,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: {
|
||||
|
@ -396,7 +405,13 @@ describe('alerts_list with show only capability', () => {
|
|||
data: [],
|
||||
});
|
||||
const mockes = coreMock.createSetup();
|
||||
const [{ chrome, docLinks }] = await mockes.getStartServices();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
const deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
|
@ -410,18 +425,15 @@ describe('alerts_list with show only capability', () => {
|
|||
} as any,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': false,
|
||||
'alerting:delete': false,
|
||||
},
|
||||
},
|
||||
legacy: {
|
||||
capabilities: {
|
||||
get() {
|
||||
return {
|
||||
siem: {
|
||||
'alerting:show': true,
|
||||
'alerting:save': false,
|
||||
'alerting:delete': false,
|
||||
},
|
||||
};
|
||||
},
|
||||
} as any,
|
||||
MANAGEMENT_BREADCRUMB: { set: () => {} } as any,
|
||||
},
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
|
|
|
@ -43,14 +43,9 @@ interface AlertState {
|
|||
}
|
||||
|
||||
export const AlertsList: React.FunctionComponent = () => {
|
||||
const {
|
||||
http,
|
||||
injectedMetadata,
|
||||
toastNotifications,
|
||||
legacy: { capabilities },
|
||||
} = useAppDependencies();
|
||||
const canDelete = hasDeleteAlertsCapability(capabilities.get());
|
||||
const canSave = hasSaveAlertsCapability(capabilities.get());
|
||||
const { http, injectedMetadata, toastNotifications, capabilities } = useAppDependencies();
|
||||
const canDelete = hasDeleteAlertsCapability(capabilities);
|
||||
const canSave = hasSaveAlertsCapability(capabilities);
|
||||
const createAlertUiEnabled = injectedMetadata.getInjectedVar('createAlertUiEnabled');
|
||||
|
||||
const [actionTypes, setActionTypes] = useState<ActionType[]>([]);
|
||||
|
|
|
@ -36,13 +36,10 @@ export const CollapsedItemActions: React.FunctionComponent<ComponentOpts> = ({
|
|||
item,
|
||||
onAlertChanged,
|
||||
}: ComponentOpts) => {
|
||||
const {
|
||||
http,
|
||||
legacy: { capabilities },
|
||||
} = useAppDependencies();
|
||||
const { http, capabilities } = useAppDependencies();
|
||||
|
||||
const canDelete = hasDeleteAlertsCapability(capabilities.get());
|
||||
const canSave = hasSaveAlertsCapability(capabilities.get());
|
||||
const canDelete = hasDeleteAlertsCapability(capabilities);
|
||||
const canSave = hasSaveAlertsCapability(capabilities);
|
||||
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ export class Plugin implements CorePlugin<Setup, Start> {
|
|||
{ application, notifications, http, uiSettings, injectedMetadata }: CoreSetup,
|
||||
{ __LEGACY }: LegacyPlugins
|
||||
): Setup {
|
||||
const canShowActions = hasShowActionsCapability(__LEGACY.capabilities.get());
|
||||
const canShowAlerts = hasShowAlertsCapability(__LEGACY.capabilities.get());
|
||||
|
||||
if (!canShowActions && !canShowAlerts) {
|
||||
return;
|
||||
}
|
||||
registerBuiltInActionTypes({
|
||||
actionTypeRegistry: this.actionTypeRegistry,
|
||||
});
|
||||
|
@ -61,6 +55,7 @@ export class Plugin implements CorePlugin<Setup, Start> {
|
|||
mount: async (
|
||||
{
|
||||
core: {
|
||||
application: applicationStart,
|
||||
docLinks,
|
||||
chrome,
|
||||
// Waiting for types to be updated.
|
||||
|
@ -71,6 +66,16 @@ export class Plugin implements CorePlugin<Setup, Start> {
|
|||
},
|
||||
{ element }
|
||||
) => {
|
||||
const { capabilities } = applicationStart;
|
||||
|
||||
const canShowActions = hasShowActionsCapability(capabilities);
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities);
|
||||
|
||||
if (!canShowActions && !canShowAlerts) {
|
||||
// Render nothing
|
||||
return () => {};
|
||||
}
|
||||
|
||||
const { boot } = await import('./application/boot');
|
||||
return boot({
|
||||
element,
|
||||
|
@ -85,6 +90,7 @@ export class Plugin implements CorePlugin<Setup, Start> {
|
|||
legacy: {
|
||||
...__LEGACY,
|
||||
},
|
||||
capabilities,
|
||||
actionTypeRegistry: this.actionTypeRegistry,
|
||||
alertTypeRegistry: this.alertTypeRegistry,
|
||||
});
|
||||
|
@ -93,9 +99,10 @@ export class Plugin implements CorePlugin<Setup, Start> {
|
|||
}
|
||||
|
||||
public start(core: CoreStart, { __LEGACY }: LegacyPlugins) {
|
||||
const { capabilities } = __LEGACY;
|
||||
const canShowActions = hasShowActionsCapability(capabilities.get());
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities.get());
|
||||
const { capabilities } = core.application;
|
||||
|
||||
const canShowActions = hasShowActionsCapability(capabilities);
|
||||
const canShowAlerts = hasShowAlertsCapability(capabilities);
|
||||
|
||||
// Don't register routes when user doesn't have access to the application
|
||||
if (!canShowActions && !canShowAlerts) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { capabilities } from 'ui/capabilities';
|
||||
import { TypeRegistry } from './application/type_registry';
|
||||
import { SanitizedAlert as Alert } from '../../../alerting/common';
|
||||
export { SanitizedAlert as Alert, AlertAction } from '../../../alerting/common';
|
||||
|
@ -94,5 +93,4 @@ export interface IErrorObject {
|
|||
|
||||
export interface LegacyDependencies {
|
||||
MANAGEMENT_BREADCRUMB: { text: string; href?: string };
|
||||
capabilities: typeof capabilities;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ routes.when(`${BASE_PATH}:section?/:subsection?/:view?/:id?`, {
|
|||
...(npSetup.plugins as typeof npSetup.plugins),
|
||||
__LEGACY: {
|
||||
MANAGEMENT_BREADCRUMB,
|
||||
capabilities,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -75,7 +74,6 @@ routes.when(`${BASE_PATH}:section?/:subsection?/:view?/:id?`, {
|
|||
...(npSetup.plugins as typeof npSetup.plugins),
|
||||
__LEGACY: {
|
||||
MANAGEMENT_BREADCRUMB,
|
||||
capabilities,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue