diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cc8e188080b3ec..1be2087cc35017 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -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 diff --git a/package.json b/package.json index 5a1e897b65be4b..ff193d3d9391fd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/kbn-alerts/README.md b/packages/kbn-alerts/README.md deleted file mode 100644 index 6c545d2e44dfbe..00000000000000 --- a/packages/kbn-alerts/README.md +++ /dev/null @@ -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. diff --git a/packages/kbn-alerts/index.ts b/packages/kbn-alerts/index.ts deleted file mode 100644 index faa4b8077a08a1..00000000000000 --- a/packages/kbn-alerts/index.ts +++ /dev/null @@ -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'; diff --git a/packages/kbn-alerts/jest.config.js b/packages/kbn-alerts/jest.config.js deleted file mode 100644 index 6ef365679ef74b..00000000000000 --- a/packages/kbn-alerts/jest.config.js +++ /dev/null @@ -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: ['/packages/kbn-alerts'], -}; diff --git a/packages/kbn-alerts/kibana.jsonc b/packages/kbn-alerts/kibana.jsonc deleted file mode 100644 index d801aa493acf91..00000000000000 --- a/packages/kbn-alerts/kibana.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "shared-common", - "id": "@kbn/alerts", - "owner": "@elastic/security-solution" -} diff --git a/packages/kbn-alerts/package.json b/packages/kbn-alerts/package.json deleted file mode 100644 index 3246bcfb5b3e05..00000000000000 --- a/packages/kbn-alerts/package.json +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/packages/kbn-alerts/src/empty_page/__snapshots__/index.test.tsx.snap b/packages/kbn-alerts/src/empty_page/__snapshots__/index.test.tsx.snap deleted file mode 100644 index 9891aa39498f17..00000000000000 --- a/packages/kbn-alerts/src/empty_page/__snapshots__/index.test.tsx.snap +++ /dev/null @@ -1,74 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EmptyPage component renders actions with descriptions 1`] = ` - - - - Do Something - - } - title={false} - /> - - - } - title={ -

- My Super Title -

- } -/> -`; - -exports[`EmptyPage component renders actions without descriptions 1`] = ` - - - - Do Something - - - - } - title={ -

- My Super Title -

- } -/> -`; diff --git a/packages/kbn-alerts/src/empty_page/index.test.tsx b/packages/kbn-alerts/src/empty_page/index.test.tsx deleted file mode 100644 index ca329ffde3fe29..00000000000000 --- a/packages/kbn-alerts/src/empty_page/index.test.tsx +++ /dev/null @@ -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(); - 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(); - expect(EmptyComponent).toMatchSnapshot(); - }); -}); diff --git a/packages/kbn-alerts/src/empty_page/index.tsx b/packages/kbn-alerts/src/empty_page/index.tsx deleted file mode 100644 index 186f4c898309b1..00000000000000 --- a/packages/kbn-alerts/src/empty_page/index.tsx +++ /dev/null @@ -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; -} - -export type EmptyPageActionsProps = Record; - -interface EmptyPageProps { - actions: EmptyPageActionsProps; - 'data-test-subj'?: string; - message?: ReactNode; - title: string; - iconType?: IconType; -} - -const EmptyPageComponent = React.memo( - ({ 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 ? ( - - - {label} - - } - /> - - ) : ( - - {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} - - {label} - - - ) - ), - [actions, titles] - ); - - return ( - {title}} - body={message &&

{message}

} - actions={{renderActions}} - {...rest} - /> - ); - } -); - -EmptyPageComponent.displayName = 'EmptyPageComponent'; - -export const EmptyPage = React.memo(EmptyPageComponent); -EmptyPage.displayName = 'EmptyPage'; diff --git a/packages/kbn-alerts/src/features_no_permissions/index.tsx b/packages/kbn-alerts/src/features_no_permissions/index.tsx deleted file mode 100644 index 6dabf06e87c475..00000000000000 --- a/packages/kbn-alerts/src/features_no_permissions/index.tsx +++ /dev/null @@ -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 = ({ - documentationUrl, - iconType, -}): JSX.Element => { - const actions = useMemo( - () => ({ - feature: { - icon: 'documents', - label: i18n.GO_TO_DOCUMENTATION, - url: documentationUrl, - target: '_blank', - }, - }), - [documentationUrl] - ); - - return ( - - ); -}; - -AlertsFeatureNoPermissions.displayName = 'AlertsFeatureNoPermissions'; diff --git a/packages/kbn-alerts/src/hooks/index.ts b/packages/kbn-alerts/src/hooks/index.ts deleted file mode 100644 index aed5e979926860..00000000000000 --- a/packages/kbn-alerts/src/hooks/index.ts +++ /dev/null @@ -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'; diff --git a/packages/kbn-alerts/src/hooks/use_get_alerts_permissions/index.ts b/packages/kbn-alerts/src/hooks/use_get_alerts_permissions/index.ts deleted file mode 100644 index dc9e3f8ccee57e..00000000000000 --- a/packages/kbn-alerts/src/hooks/use_get_alerts_permissions/index.ts +++ /dev/null @@ -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({ - 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; -}; diff --git a/packages/kbn-alerts/src/translations/index.ts b/packages/kbn-alerts/src/translations/index.ts deleted file mode 100644 index 2d540ba1452d91..00000000000000 --- a/packages/kbn-alerts/src/translations/index.ts +++ /dev/null @@ -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', -}); diff --git a/packages/kbn-alerts/tsconfig.json b/packages/kbn-alerts/tsconfig.json deleted file mode 100644 index 91f7ce820b25e3..00000000000000 --- a/packages/kbn-alerts/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types", - "types": ["jest", "node"] - }, - "include": [ - "**/*.ts", - "**/*.tsx" - ], - "kbn_references": [ - "@kbn/i18n", - ], - "exclude": [ - "target/**/*", - ], -} diff --git a/tsconfig.base.json b/tsconfig.base.json index 01e7276e6bb869..04a43a915a5869 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -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"], diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index a29132d6757a65..f2d39db78cea30 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -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é", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 263b975b1f9315..c36cf65aa236c8 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -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": "回復済み", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 2d638509c048f9..bd4cdc9eef4a51 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -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": "已恢复", diff --git a/yarn.lock b/yarn.lock index 2cdef7d615a7ae..f6e00388c7b167 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 ""