Skip to content
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

Make alerting UI use application capabilities provided by Kibana Platform #56070

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ToastsSetup,
HttpSetup,
IUiSettingsClient,
ApplicationStart,
} from 'kibana/public';
import { BASE_PATH, Section } from './constants';
import { TriggersActionsUIHome } from './home';
Expand All @@ -27,6 +28,7 @@ export interface AppDeps {
http: HttpSetup;
uiSettings: IUiSettingsClient;
legacy: LegacyDependencies;
capabilities: ApplicationStart['capabilities'];
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
}
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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,
Expand Down Expand Up @@ -136,26 +139,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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: {
Expand Down Expand Up @@ -217,26 +223,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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: {
Expand Down Expand Up @@ -303,26 +312,29 @@ 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,
toastNotifications: mockes.notifications.toasts,
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: {
Expand Down
Loading