[Security] remove kbn-alerts package (unused.) (#157737)

## Summary

Remove the unused kbn-alerts package

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Robert Austin 2023-05-15 19:38:10 -04:00 committed by GitHub
parent b9f05dffd0
commit 0c88d3ae04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 0 additions and 424 deletions

1
.github/CODEOWNERS vendored
View file

@ -19,7 +19,6 @@ x-pack/examples/alerting_example @elastic/response-ops
x-pack/test/functional_with_es_ssl/plugins/alerts @elastic/response-ops
x-pack/plugins/alerting @elastic/response-ops
x-pack/packages/kbn-alerting-state-types @elastic/response-ops
packages/kbn-alerts @elastic/security-solution
packages/kbn-alerts-as-data-utils @elastic/response-ops
x-pack/test/alerting_api_integration/common/plugins/alerts_restricted @elastic/response-ops
packages/kbn-alerts-ui-shared @elastic/response-ops

View file

@ -135,7 +135,6 @@
"@kbn/alerting-fixture-plugin": "link:x-pack/test/functional_with_es_ssl/plugins/alerts",
"@kbn/alerting-plugin": "link:x-pack/plugins/alerting",
"@kbn/alerting-state-types": "link:x-pack/packages/kbn-alerting-state-types",
"@kbn/alerts": "link:packages/kbn-alerts",
"@kbn/alerts-as-data-utils": "link:packages/kbn-alerts-as-data-utils",
"@kbn/alerts-restricted-fixtures-plugin": "link:x-pack/test/alerting_api_integration/common/plugins/alerts_restricted",
"@kbn/alerts-ui-shared": "link:packages/kbn-alerts-ui-shared",

View file

@ -1,7 +0,0 @@
# AlertsFeatureNoPermissions
Component displayed when a user with alerts permissions of `none` attempts to access alerts page.
## useGetUserAlertsPermissions
This hook parses through the uiCapabilities Kibana object to determine if the user has Kibana `read` or `crud` permissions for alerts.

View file

@ -1,9 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export * from './src/hooks';
export * from './src/features_no_permissions';

View file

@ -1,13 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-alerts'],
};

View file

@ -1,5 +0,0 @@
{
"type": "shared-common",
"id": "@kbn/alerts",
"owner": "@elastic/security-solution"
}

View file

@ -1,7 +0,0 @@
{
"name": "@kbn/alerts",
"version": "1.0.0",
"description": "Alerts components and hooks",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
}

View file

@ -1,74 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EmptyPage component renders actions with descriptions 1`] = `
<EuiEmptyPrompt
actions={
<EuiFlexGroup
justifyContent="center"
>
<EuiFlexItem
grow={false}
style={
Object {
"maxWidth": 283,
}
}
>
<EuiCard
description="My Description"
footer={
<EuiButton
color="primary"
data-test-subj="empty-page-actions-action"
fill={true}
href="my/url/from/nowwhere"
size="m"
>
Do Something
</EuiButton>
}
title={false}
/>
</EuiFlexItem>
</EuiFlexGroup>
}
title={
<h2>
My Super Title
</h2>
}
/>
`;
exports[`EmptyPage component renders actions without descriptions 1`] = `
<EuiEmptyPrompt
actions={
<EuiFlexGroup
justifyContent="center"
>
<EuiFlexItem
grow={false}
style={
Object {
"maxWidth": 283,
}
}
>
<EuiButton
color="primary"
data-test-subj="empty-page-actions-action"
href="my/url/from/nowwhere"
size="m"
>
Do Something
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
}
title={
<h2>
My Super Title
</h2>
}
/>
`;

View file

@ -1,37 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { shallow } from 'enzyme';
import React from 'react';
import { EmptyPage } from '.';
describe('EmptyPage component', () => {
it('renders actions without descriptions', () => {
const actions = {
actions: {
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
});
it('renders actions with descriptions', () => {
const actions = {
actions: {
description: 'My Description',
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
});
});

View file

@ -1,114 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import {
EuiButton,
EuiEmptyPrompt,
EuiFlexGroup,
EuiFlexItem,
IconType,
EuiCard,
} from '@elastic/eui';
import React, { MouseEventHandler, ReactNode, useMemo } from 'react';
interface EmptyPageActions {
icon?: IconType;
label: string;
target?: string;
url: string;
descriptionTitle?: string;
description?: string;
fill?: boolean;
onClick?: MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
}
export type EmptyPageActionsProps = Record<string, EmptyPageActions>;
interface EmptyPageProps {
actions: EmptyPageActionsProps;
'data-test-subj'?: string;
message?: ReactNode;
title: string;
iconType?: IconType;
}
const EmptyPageComponent = React.memo<EmptyPageProps>(
({ actions, message, title, iconType, ...rest }) => {
const titles = Object.keys(actions);
const maxItemWidth = 283;
const renderActions = useMemo(
() =>
Object.values(actions)
.filter((a) => a.label && a.url)
.map(
(
{ icon, label, target, url, descriptionTitle, description, onClick, fill = true },
idx
) =>
descriptionTitle != null || description != null ? (
<EuiFlexItem
grow={false}
style={{ maxWidth: maxItemWidth }}
key={`empty-page-${titles[idx]}-action`}
>
<EuiCard
title={descriptionTitle ?? false}
description={description ?? false}
footer={
/* eslint-disable-next-line @elastic/eui/href-or-on-click */
<EuiButton
href={url}
onClick={onClick}
iconType={icon}
target={target}
fill={fill}
data-test-subj={`empty-page-${titles[idx]}-action`}
>
{label}
</EuiButton>
}
/>
</EuiFlexItem>
) : (
<EuiFlexItem
grow={false}
style={{ maxWidth: maxItemWidth }}
key={`empty-page-${titles[idx]}-action`}
>
{/* eslint-disable-next-line @elastic/eui/href-or-on-click */}
<EuiButton
href={url}
onClick={onClick}
iconType={icon}
target={target}
data-test-subj={`empty-page-${titles[idx]}-action`}
>
{label}
</EuiButton>
</EuiFlexItem>
)
),
[actions, titles]
);
return (
<EuiEmptyPrompt
iconType={iconType}
title={<h2>{title}</h2>}
body={message && <p>{message}</p>}
actions={<EuiFlexGroup justifyContent="center">{renderActions}</EuiFlexGroup>}
{...rest}
/>
);
}
);
EmptyPageComponent.displayName = 'EmptyPageComponent';
export const EmptyPage = React.memo(EmptyPageComponent);
EmptyPage.displayName = 'EmptyPage';

View file

@ -1,47 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { IconType } from '@elastic/eui';
import React, { useMemo } from 'react';
import { EmptyPage } from '../empty_page';
import * as i18n from '../translations';
interface AlertsFeatureNoPermissionsProps {
documentationUrl: string;
iconType: IconType;
}
export const AlertsFeatureNoPermissions: React.FC<AlertsFeatureNoPermissionsProps> = ({
documentationUrl,
iconType,
}): JSX.Element => {
const actions = useMemo(
() => ({
feature: {
icon: 'documents',
label: i18n.GO_TO_DOCUMENTATION,
url: documentationUrl,
target: '_blank',
},
}),
[documentationUrl]
);
return (
<EmptyPage
iconType={iconType}
actions={actions}
message={i18n.ALERTS_FEATURE_NO_PERMISSIONS_MSG}
data-test-subj="no_feature_permissions-alerts"
title={i18n.FEATURE_NO_PERMISSIONS_TITLE}
/>
);
};
AlertsFeatureNoPermissions.displayName = 'AlertsFeatureNoPermissions';

View file

@ -1,8 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export * from './use_get_alerts_permissions';

View file

@ -1,47 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { useEffect, useState } from 'react';
// TODO: I have to use any here for now, but once this is available below, we should use the correct types, https://github.com/elastic/kibana/issues/100715
// import { Capabilities } from '@kbn/core/public';
type Capabilities = any;
export interface UseGetUserAlertsPermissionsProps {
crud: boolean;
read: boolean;
loading: boolean;
}
export const useGetUserAlertsPermissions = (
uiCapabilities: Capabilities,
featureId: string
): UseGetUserAlertsPermissionsProps => {
const [alertsPermissions, setAlertsPermissions] = useState<UseGetUserAlertsPermissionsProps>({
crud: false,
read: false,
loading: true,
});
useEffect(() => {
const capabilitiesCanUserCRUD: boolean =
typeof uiCapabilities[featureId].crud_alerts === 'boolean'
? uiCapabilities[featureId].crud_alerts
: false;
const capabilitiesCanUserRead: boolean =
typeof uiCapabilities[featureId].read_alerts === 'boolean'
? uiCapabilities[featureId].read_alerts
: false;
setAlertsPermissions({
crud: capabilitiesCanUserCRUD,
read: capabilitiesCanUserRead,
loading: false,
});
}, [featureId, uiCapabilities]);
return alertsPermissions;
};

View file

@ -1,22 +0,0 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { i18n } from '@kbn/i18n';
export const FEATURE_NO_PERMISSIONS_TITLE = i18n.translate('alerts.noPermissionsTitle', {
defaultMessage: 'Kibana feature privileges required',
});
export const ALERTS_FEATURE_NO_PERMISSIONS_MSG = i18n.translate('alerts.noPermissionsMessage', {
defaultMessage:
'To view alerts, you must have privileges for the Alerts feature in the Kibana space. For more information, contact your Kibana administrator.',
});
export const GO_TO_DOCUMENTATION = i18n.translate('alerts.documentationTitle', {
defaultMessage: 'View documentation',
});

View file

@ -1,17 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node"]
},
"include": [
"**/*.ts",
"**/*.tsx"
],
"kbn_references": [
"@kbn/i18n",
],
"exclude": [
"target/**/*",
],
}

View file

@ -32,8 +32,6 @@
"@kbn/alerting-plugin/*": ["x-pack/plugins/alerting/*"],
"@kbn/alerting-state-types": ["x-pack/packages/kbn-alerting-state-types"],
"@kbn/alerting-state-types/*": ["x-pack/packages/kbn-alerting-state-types/*"],
"@kbn/alerts": ["packages/kbn-alerts"],
"@kbn/alerts/*": ["packages/kbn-alerts/*"],
"@kbn/alerts-as-data-utils": ["packages/kbn-alerts-as-data-utils"],
"@kbn/alerts-as-data-utils/*": ["packages/kbn-alerts-as-data-utils/*"],
"@kbn/alerts-restricted-fixtures-plugin": ["x-pack/test/alerting_api_integration/common/plugins/alerts_restricted"],

View file

@ -37196,9 +37196,6 @@
"xpack.watcher.watchActions.webhook.usernameIsRequiredIfPasswordValidationMessage": "Le nom d'utilisateur est requis.",
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "Ce champ est requis.",
"xpack.watcher.watcherDescription": "Détectez les modifications survenant dans vos données en créant, gérant et monitorant des alertes.",
"alerts.documentationTitle": "Afficher la documentation",
"alerts.noPermissionsMessage": "Pour consulter les alertes, vous devez disposer de privilèges pour la fonctionnalité Alertes dans l'espace Kibana. Pour en savoir plus, contactez votre administrateur Kibana.",
"alerts.noPermissionsTitle": "Privilèges de fonctionnalité Kibana requis",
"alertsUIShared.components.alertLifecycleStatusBadge.activeLabel": "Actif",
"alertsUIShared.components.alertLifecycleStatusBadge.flappingLabel": "Bagotement",
"alertsUIShared.components.alertLifecycleStatusBadge.recoveredLabel": "Récupéré",

View file

@ -37164,9 +37164,6 @@
"xpack.watcher.watchActions.webhook.usernameIsRequiredIfPasswordValidationMessage": "ユーザー名が必要です。",
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。",
"alerts.documentationTitle": "ドキュメンテーションを表示",
"alerts.noPermissionsMessage": "アラートを表示するには、Kibanaスペースでアラート機能の権限が必要です。詳細については、Kibana管理者に連絡してください。",
"alerts.noPermissionsTitle": "Kibana機能権限が必要です",
"alertsUIShared.components.alertLifecycleStatusBadge.activeLabel": "アクティブ",
"alertsUIShared.components.alertLifecycleStatusBadge.flappingLabel": "フラップ中",
"alertsUIShared.components.alertLifecycleStatusBadge.recoveredLabel": "回復済み",

View file

@ -37192,9 +37192,6 @@
"xpack.watcher.watchActions.webhook.usernameIsRequiredIfPasswordValidationMessage": "“用户名”必填。",
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。",
"alerts.documentationTitle": "查看文档",
"alerts.noPermissionsMessage": "要查看告警,必须对 Kibana 工作区中的告警功能有权限。有关详细信息,请联系您的 Kibana 管理员。",
"alerts.noPermissionsTitle": "需要 Kibana 功能权限",
"alertsUIShared.components.alertLifecycleStatusBadge.activeLabel": "活动",
"alertsUIShared.components.alertLifecycleStatusBadge.flappingLabel": "摆动",
"alertsUIShared.components.alertLifecycleStatusBadge.recoveredLabel": "已恢复",

View file

@ -2814,10 +2814,6 @@
version "0.0.0"
uid ""
"@kbn/alerts@link:packages/kbn-alerts":
version "0.0.0"
uid ""
"@kbn/ambient-common-types@link:packages/kbn-ambient-common-types":
version "0.0.0"
uid ""