Skip to content
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
@@ -0,0 +1,8 @@
/*
* 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.
*/

export const APP_ID = 'alerting_v2';
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 type { FeaturesPluginSetup } from '@kbn/features-plugin/server';
import type { AppCategory } from '@kbn/core/types';
import { APP_ID } from '../constants';
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path uses '../constants' but the file is at '../lib/constants'. This will cause a module resolution error. Update the import to: import { APP_ID } from './constants'; since both files are in the same lib directory.

Copilot generated this review using guidance from repository custom instructions.

const ALERTS_FEATURE_ID = 'alerting_v2_alerts';
const RULES_FEATURE_ID = 'alerting_v2_rules';
const CATEGORY_ID = 'alerting';

const getPrivileges = () => ({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty for the moment until we have the SOs and APIs.

all: {
app: [APP_ID],
savedObject: {
all: [],
read: [],
},
ui: [],
api: [],
},
read: {
app: [APP_ID],
savedObject: {
all: [],
read: [],
},
ui: [],
api: [],
},
});

const category: AppCategory = {
id: CATEGORY_ID,
label: 'Alerting',
order: 1000,
euiIconType: 'watchesApp',
};
Comment on lines +37 to +42
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The category object is duplicated across both feature definitions. Since the same category is shared, it should be reused in both alertsFeature and rulesFeature rather than being inline. This is already done correctly; however, consider extracting the euiIconType value to a constant for better maintainability if this icon type is used elsewhere in the alerting v2 codebase.

Copilot uses AI. Check for mistakes.

const alertsFeature = {
id: ALERTS_FEATURE_ID,
name: 'Alerts',
category,
app: [APP_ID],
privileges: getPrivileges(),
};

const rulesFeature = {
id: RULES_FEATURE_ID,
name: 'Rules',
category,
app: [APP_ID],
privileges: getPrivileges(),
};

export const registerFeaturePrivileges = (features: FeaturesPluginSetup) => {
features.registerKibanaFeature(alertsFeature);
features.registerKibanaFeature(rulesFeature);
};
3 changes: 2 additions & 1 deletion x-pack/platform/plugins/shared/alerting_v2/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
AlertingServerSetupDependencies,
AlertingServerStartDependencies,
} from './types';
import { registerFeaturePrivileges } from './lib/security/privileges';

export class AlertingPlugin
implements
Expand All @@ -37,7 +38,7 @@ export class AlertingPlugin
}

public setup(core: CoreSetup, plugins: AlertingServerSetupDependencies) {
return;
registerFeaturePrivileges(plugins.features);
}

public start(core: CoreStart, plugins: AlertingServerStartDependencies) {
Expand Down