Skip to content

Commit f9b10c1

Browse files
committed
use management feature control across all plugins
1 parent 47a4b93 commit f9b10c1

File tree

11 files changed

+72
-57
lines changed

11 files changed

+72
-57
lines changed

examples/alerting_example/server/plugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export class AlertingExamplePlugin implements Plugin<void, void, AlertingExample
4444
defaultMessage: 'Alerts Example',
4545
}),
4646
app: [],
47+
management: {
48+
insightsAndAlerting: ['triggersActions'],
49+
},
4750
privileges: {
4851
all: {
4952
alerting: {
@@ -53,7 +56,10 @@ export class AlertingExamplePlugin implements Plugin<void, void, AlertingExample
5356
all: [],
5457
read: [],
5558
},
56-
ui: ['alerting:show'],
59+
management: {
60+
insightsAndAlerting: ['triggersActions'],
61+
},
62+
ui: [],
5763
},
5864
read: {
5965
alerting: {
@@ -63,7 +69,10 @@ export class AlertingExamplePlugin implements Plugin<void, void, AlertingExample
6369
all: [],
6470
read: [],
6571
},
66-
ui: ['alerting:show'],
72+
management: {
73+
insightsAndAlerting: ['triggersActions'],
74+
},
75+
ui: [],
6776
},
6877
},
6978
});

x-pack/plugins/alerting_builtins/server/feature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const BUILT_IN_ALERTS_FEATURE = {
3434
read: [],
3535
},
3636
api: [],
37-
ui: ['alerting:show'],
37+
ui: [],
3838
},
3939
read: {
4040
app: [],
@@ -51,7 +51,7 @@ export const BUILT_IN_ALERTS_FEATURE = {
5151
read: [],
5252
},
5353
api: [],
54-
ui: ['alerting:show'],
54+
ui: [],
5555
},
5656
},
5757
};

x-pack/plugins/apm/server/feature.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const APM_FEATURE = {
1717
navLinkId: 'apm',
1818
app: ['apm', 'kibana'],
1919
catalogue: ['apm'],
20+
management: {
21+
insightsAndAlerting: ['triggersActions'],
22+
},
2023
// see x-pack/plugins/features/common/feature_kibana_privileges.ts
2124
privileges: {
2225
all: {
@@ -30,6 +33,9 @@ export const APM_FEATURE = {
3033
alerting: {
3134
all: Object.values(AlertType),
3235
},
36+
management: {
37+
insightsAndAlerting: ['triggersActions'],
38+
},
3339
ui: ['show', 'save', 'alerting:show', 'alerting:save'],
3440
},
3541
read: {
@@ -43,6 +49,9 @@ export const APM_FEATURE = {
4349
alerting: {
4450
all: Object.values(AlertType),
4551
},
52+
management: {
53+
insightsAndAlerting: ['triggersActions'],
54+
},
4655
ui: ['show', 'alerting:show', 'alerting:save'],
4756
},
4857
},

x-pack/plugins/infra/server/features.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export const METRICS_FEATURE = {
1919
navLinkId: 'metrics',
2020
app: ['infra', 'kibana'],
2121
catalogue: ['infraops'],
22+
management: {
23+
insightsAndAlerting: ['triggersActions'],
24+
},
2225
privileges: {
2326
all: {
2427
app: ['infra', 'kibana'],
@@ -31,7 +34,10 @@ export const METRICS_FEATURE = {
3134
alerting: {
3235
all: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
3336
},
34-
ui: ['show', 'configureSource', 'save', 'alerting:show'],
37+
management: {
38+
insightsAndAlerting: ['triggersActions'],
39+
},
40+
ui: ['show', 'configureSource', 'save'],
3541
},
3642
read: {
3743
app: ['infra', 'kibana'],
@@ -44,7 +50,10 @@ export const METRICS_FEATURE = {
4450
alerting: {
4551
all: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
4652
},
47-
ui: ['show', 'alerting:show'],
53+
management: {
54+
insightsAndAlerting: ['triggersActions'],
55+
},
56+
ui: ['show'],
4857
},
4958
},
5059
};

x-pack/plugins/security_solution/server/plugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
170170
navLinkId: APP_ID,
171171
app: [...securitySubPlugins, 'kibana'],
172172
catalogue: ['securitySolution'],
173+
management: {
174+
insightsAndAlerting: ['triggersActions'],
175+
},
173176
privileges: {
174177
all: {
175178
app: [...securitySubPlugins, 'kibana'],
@@ -189,7 +192,10 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
189192
alerting: {
190193
all: [SIGNALS_ID, NOTIFICATIONS_ID],
191194
},
192-
ui: ['show', 'crud', 'alerting:show'],
195+
management: {
196+
insightsAndAlerting: ['triggersActions'],
197+
},
198+
ui: ['show', 'crud'],
193199
},
194200
read: {
195201
app: [...securitySubPlugins, 'kibana'],
@@ -209,7 +215,10 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
209215
alerting: {
210216
all: [SIGNALS_ID, NOTIFICATIONS_ID],
211217
},
212-
ui: ['show', 'alerting:show'],
218+
management: {
219+
insightsAndAlerting: ['triggersActions'],
220+
},
221+
ui: ['show'],
213222
},
214223
},
215224
});

x-pack/plugins/triggers_actions_ui/public/application/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Section, routeToConnectors, routeToAlerts } from './constants';
2525
import { getCurrentBreadcrumb } from './lib/breadcrumb';
2626
import { getCurrentDocTitle } from './lib/doc_title';
2727
import { useAppDependencies } from './app_context';
28-
import { hasShowActionsCapability, hasShowAlertsCapability } from './lib/capabilities';
28+
import { hasShowActionsCapability } from './lib/capabilities';
2929

3030
import { ActionsConnectorsList } from './sections/actions_connectors_list/components/actions_connectors_list';
3131
import { AlertsList } from './sections/alerts_list/components/alerts_list';

x-pack/plugins/triggers_actions_ui/public/application/lib/capabilities.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ import { Alert, AlertType } from '../../types';
1515

1616
type Capabilities = Record<string, any>;
1717

18-
const apps = ['apm', 'siem', 'uptime', 'infrastructure', 'actions', BUILT_IN_ALERTS_FEATURE_ID];
19-
20-
function hasCapability(capabilities: Capabilities, capability: string) {
21-
return apps.some((app) => capabilities[app]?.[capability]);
22-
}
23-
24-
export const hasShowAlertsCapability = (capabilities: Capabilities) =>
25-
hasCapability(capabilities, 'alerting:show');
26-
2718
export const hasShowActionsCapability = (capabilities: Capabilities) => capabilities?.actions?.show;
2819
export const hasSaveActionsCapability = (capabilities: Capabilities) => capabilities?.actions?.save;
2920
export const hasExecuteActionsCapability = (capabilities: Capabilities) =>

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ jest.mock('../../../app_context', () => ({
2929
http: jest.fn(),
3030
capabilities: {
3131
get: jest.fn(() => ({})),
32-
securitySolution: {
33-
'alerting:show': true,
34-
},
3532
},
3633
actionTypeRegistry: jest.fn(),
3734
alertTypeRegistry: {

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,7 @@ export const AlertForm = ({
244244
) : null}
245245
</EuiFlexGroup>
246246
{AlertParamsExpressionComponent ? (
247-
<Suspense
248-
fallback={
249-
<EuiFlexGroup justifyContent="center">
250-
<EuiFlexItem grow={false}>
251-
<EuiLoadingSpinner size="m" />
252-
</EuiFlexItem>
253-
</EuiFlexGroup>
254-
}
255-
>
247+
<Suspense fallback={CenterJustifiedSpinner}>
256248
<AlertParamsExpressionComponent
257249
alertParams={alert.params}
258250
alertInterval={`${alertInterval ?? 1}${alertIntervalUnit}`}
@@ -509,13 +501,23 @@ export const AlertForm = ({
509501
{alertTypeNodes}
510502
</EuiFlexGroup>
511503
</Fragment>
512-
) : (
504+
) : alertTypesIndex ? (
513505
<NoAuthorizedAlertTypes operation={operation} />
506+
) : (
507+
<CenterJustifiedSpinner />
514508
)}
515509
</EuiForm>
516510
);
517511
};
518512

513+
const CenterJustifiedSpinner = () => (
514+
<EuiFlexGroup justifyContent="center">
515+
<EuiFlexItem grow={false}>
516+
<EuiLoadingSpinner size="m" />
517+
</EuiFlexItem>
518+
</EuiFlexGroup>
519+
);
520+
519521
const NoAuthorizedAlertTypes = ({ operation }: { operation: string }) => (
520522
<EuiEmptyPrompt
521523
iconType="lock"

x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,7 @@ describe('alerts_list component empty', () => {
106106
http: mockes.http,
107107
uiSettings: mockes.uiSettings,
108108
navigateToApp,
109-
capabilities: {
110-
...capabilities,
111-
securitySolution: {
112-
'alerting:show': true,
113-
},
114-
},
109+
capabilities,
115110
history: scopedHistoryMock.create(),
116111
setBreadcrumbs: jest.fn(),
117112
actionTypeRegistry: actionTypeRegistry as any,
@@ -223,12 +218,7 @@ describe('alerts_list component with items', () => {
223218
http: mockes.http,
224219
uiSettings: mockes.uiSettings,
225220
navigateToApp,
226-
capabilities: {
227-
...capabilities,
228-
securitySolution: {
229-
'alerting:show': true,
230-
},
231-
},
221+
capabilities,
232222
history: scopedHistoryMock.create(),
233223
setBreadcrumbs: jest.fn(),
234224
actionTypeRegistry: actionTypeRegistry as any,
@@ -303,12 +293,7 @@ describe('alerts_list component empty with show only capability', () => {
303293
http: mockes.http,
304294
uiSettings: mockes.uiSettings,
305295
navigateToApp,
306-
capabilities: {
307-
...capabilities,
308-
securitySolution: {
309-
'alerting:show': true,
310-
},
311-
},
296+
capabilities,
312297
history: scopedHistoryMock.create(),
313298
setBreadcrumbs: jest.fn(),
314299
actionTypeRegistry: {
@@ -417,12 +402,7 @@ describe('alerts_list with show only capability', () => {
417402
http: mockes.http,
418403
uiSettings: mockes.uiSettings,
419404
navigateToApp,
420-
capabilities: {
421-
...capabilities,
422-
securitySolution: {
423-
'alerting:show': true,
424-
},
425-
},
405+
capabilities,
426406
history: scopedHistoryMock.create(),
427407
setBreadcrumbs: jest.fn(),
428408
actionTypeRegistry: actionTypeRegistry as any,

0 commit comments

Comments
 (0)