From cb761e78038b263dacce5b5554d5b819abbdecb7 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Thu, 3 Oct 2024 13:37:47 +0200 Subject: [PATCH] Clean up `cloud_chat` (#194571) ## Summary Close https://github.com/elastic/kibana-team/issues/1017 This PR removes the unused Cloud Chat functionality from Kibana. The chat was not used for some time. Moreover, we've seen some issues with it where users saw it when it wasn't expected. Given the absence of automated tests and the fact that the feature is no longer needed, we are removing it to improve the overall maintainability and reliability of the codebase. This will also decrease the amount of code loaded for trial users of Kibana in cloud making the app slightly faster. (cherry picked from commit 568e40accaaee06a6dadfec2028263889cf7104a) --- .../steps/storybooks/build_and_upload.ts | 1 - docs/developer/plugin-list.asciidoc | 3 +- packages/kbn-optimizer/limits.yml | 1 - src/dev/storybook/aliases.ts | 1 - test/plugin_functional/config.ts | 2 - .../test_suites/core_plugins/rendering.ts | 2 - x-pack/.i18nrc.json | 1 - .../cloud_chat/.storybook/decorator.tsx | 38 -- .../cloud_chat/.storybook/index.ts | 8 - .../cloud_chat/.storybook/main.ts | 10 - .../cloud_chat/.storybook/manager.ts | 20 - .../cloud_chat/.storybook/preview.ts | 11 - .../cloud_integrations/cloud_chat/README.md | 5 +- .../cloud_chat/common/constants.ts | 9 - .../cloud_chat/common/types.ts | 15 - .../cloud_chat/common/util.ts | 19 - .../cloud_chat/jest.config.js | 18 - .../cloud_chat/kibana.jsonc | 2 +- .../public/components/chat/chat.tsx | 70 ---- .../components/chat/get_chat_context.test.ts | 65 --- .../components/chat/get_chat_context.ts | 36 -- .../public/components/chat/index.tsx | 28 -- .../public/components/chat/use_chat_config.ts | 213 ---------- .../public/components/chat/when_idle.tsx | 34 -- .../chat_experiment_switcher/index.tsx | 40 -- .../chat_floating_bubble/chat.stories.tsx | 123 ------ .../chat_floating_bubble.tsx | 101 ----- .../components/chat_floating_bubble/index.tsx | 30 -- .../chat_header_menu_items.tsx | 109 ------ .../chat_header_menu_item/chat_icon_dark.svg | 5 - .../chat_header_menu_item/chat_icon_light.svg | 5 - .../components/chat_header_menu_item/index.ts | 8 - .../cloud_chat/public/components/index.tsx | 9 - .../cloud_chat/public/index.ts | 13 - .../cloud_chat/public/plugin.test.ts | 103 ----- .../cloud_chat/public/plugin.tsx | 139 ------- .../cloud_chat/public/services/index.tsx | 45 --- .../cloud_chat/server/config.ts | 81 +--- .../cloud_chat/server/index.ts | 18 +- .../cloud_chat/server/plugin.ts | 45 --- .../cloud_chat/server/routes/chat.test.ts | 369 ------------------ .../cloud_chat/server/routes/chat.ts | 100 ----- .../cloud_chat/server/routes/index.ts | 8 - .../server/util/generate_jwt.test.ts | 23 -- .../cloud_chat/server/util/generate_jwt.ts | 24 -- .../cloud_chat/tsconfig.json | 9 +- .../translations/translations/fr-FR.json | 5 - .../translations/translations/ja-JP.json | 5 - .../translations/translations/zh-CN.json | 5 - x-pack/test/cloud_integration/config.ts | 20 +- x-pack/test/cloud_integration/tests/chat.ts | 31 -- 51 files changed, 41 insertions(+), 2044 deletions(-) delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/.storybook/decorator.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/.storybook/index.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/.storybook/main.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/.storybook/manager.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/.storybook/preview.ts delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat/common/constants.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/common/types.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/common/util.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/jest.config.js delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/get_chat_context.test.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/get_chat_context.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/index.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/use_chat_config.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/when_idle.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_experiment_switcher/index.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_floating_bubble/chat.stories.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_floating_bubble/chat_floating_bubble.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_floating_bubble/index.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_header_menu_item/chat_header_menu_items.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_header_menu_item/chat_icon_dark.svg delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_header_menu_item/chat_icon_light.svg delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat_header_menu_item/index.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/components/index.tsx delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat/public/index.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.test.ts delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/services/index.tsx delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat/server/plugin.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/server/routes/chat.test.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/server/routes/chat.ts delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat/server/routes/index.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/server/util/generate_jwt.test.ts delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/server/util/generate_jwt.ts delete mode 100644 x-pack/test/cloud_integration/tests/chat.ts diff --git a/.buildkite/scripts/steps/storybooks/build_and_upload.ts b/.buildkite/scripts/steps/storybooks/build_and_upload.ts index 13b346794f7b4..10128470005ce 100644 --- a/.buildkite/scripts/steps/storybooks/build_and_upload.ts +++ b/.buildkite/scripts/steps/storybooks/build_and_upload.ts @@ -18,7 +18,6 @@ const STORYBOOKS = [ 'canvas', 'cases', 'cell_actions', - 'cloud_chat', 'coloring', 'chart_icons', 'content_management_examples', diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 55a2a19040aec..a99e030a4adc1 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -487,7 +487,8 @@ The plugin exposes the static DefaultEditorController class to consume. |{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_chat/README.md[cloudChat] -|Integrates with DriftChat in order to provide live support to our Elastic Cloud users. This plugin should only run on Elastic Cloud. +|The plugin was meant to integrate with DriftChat in order to provide live support to our Elastic Cloud users. +It was removed, but the plugin was left behind to register no longer used config keys. |{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_data_migration/README.md[cloudDataMigration] diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index da5ba0500eeb9..8af1cb4460ecb 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -11,7 +11,6 @@ pageLoadAssetSize: cases: 180037 charts: 55000 cloud: 21076 - cloudChat: 19894 cloudDataMigration: 19170 cloudDefend: 18697 cloudExperiments: 109746 diff --git a/src/dev/storybook/aliases.ts b/src/dev/storybook/aliases.ts index 4d52c77fc8e20..07e92a23f9bc5 100644 --- a/src/dev/storybook/aliases.ts +++ b/src/dev/storybook/aliases.ts @@ -16,7 +16,6 @@ export const storybookAliases = { canvas: 'x-pack/plugins/canvas/storybook', cases: 'packages/kbn-cases-components/.storybook', cell_actions: 'packages/kbn-cell-actions/.storybook', - cloud_chat: 'x-pack/plugins/cloud_integrations/cloud_chat/.storybook', cloud: 'packages/cloud/.storybook', coloring: 'packages/kbn-coloring/.storybook', language_documentation_popover: 'packages/kbn-language-documentation/.storybook', diff --git a/test/plugin_functional/config.ts b/test/plugin_functional/config.ts index 88eef1ff3ee15..dbdf8f033848a 100644 --- a/test/plugin_functional/config.ts +++ b/test/plugin_functional/config.ts @@ -59,8 +59,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { // We want to test when the banner is shown '--telemetry.banner=true', // explicitly enable the cloud integration plugins to validate the rendered config keys - '--xpack.cloud_integrations.chat.enabled=true', - '--xpack.cloud_integrations.chat.chatURL=a_string', '--xpack.cloud_integrations.experiments.enabled=true', '--xpack.cloud_integrations.experiments.launch_darkly.sdk_key=a_string', '--xpack.cloud_integrations.experiments.launch_darkly.client_id=a_string', diff --git a/test/plugin_functional/test_suites/core_plugins/rendering.ts b/test/plugin_functional/test_suites/core_plugins/rendering.ts index 568a006a9751f..88013d0e8d97b 100644 --- a/test/plugin_functional/test_suites/core_plugins/rendering.ts +++ b/test/plugin_functional/test_suites/core_plugins/rendering.ts @@ -233,8 +233,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) { 'xpack.cloud.deployments_url (string?)', 'xpack.cloud.is_elastic_staff_owned (boolean?)', 'xpack.cloud.trial_end_date (string?)', - 'xpack.cloud_integrations.chat.chatURL (string?)', - 'xpack.cloud_integrations.chat.trialBuffer (number?)', // Commented because it's inside a schema conditional, and the test is not able to resolve it. But it's shared. // Added here for documentation purposes. // 'xpack.cloud_integrations.experiments.launch_darkly.client_id (string)', diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 97aa05deb4a42..40169fe334474 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -18,7 +18,6 @@ "xpack.canvas": "plugins/canvas", "xpack.cases": "plugins/cases", "xpack.cloud": "plugins/cloud", - "xpack.cloudChat": "plugins/cloud_integrations/cloud_chat", "xpack.cloudDefend": "plugins/cloud_defend", "xpack.cloudLinks": "plugins/cloud_integrations/cloud_links", "xpack.cloudDataMigration": "plugins/cloud_integrations/cloud_data_migration", diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/decorator.tsx b/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/decorator.tsx deleted file mode 100644 index 6331b82951bf0..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/decorator.tsx +++ /dev/null @@ -1,38 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { FC, PropsWithChildren } from 'react'; -import { DecoratorFn } from '@storybook/react'; -import { ServicesProvider, CloudChatServices } from '../public/services'; - -// TODO: move to a storybook implementation of the service using parameters. -const services: CloudChatServices = { - chat: { - chatURL: 'https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html', - chatVariant: 'bubble', - user: { - id: 'user-id', - email: 'test-user@elastic.co', - // this doesn't affect chat appearance, - // but a user identity in Drift only - jwt: 'identity-jwt', - trialEndDate: new Date(), - kbnVersion: '8.9.0', - kbnBuildNum: 12345, - }, - }, -}; - -export const getCloudContextProvider: () => FC> = - () => - ({ children }) => - {children}; - -export const getCloudContextDecorator: DecoratorFn = (storyFn) => { - const CloudContextProvider = getCloudContextProvider(); - return {storyFn()}; -}; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/index.ts b/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/index.ts deleted file mode 100644 index 321df983cb20d..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { getCloudContextDecorator, getCloudContextProvider } from './decorator'; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/main.ts b/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/main.ts deleted file mode 100644 index bf63e08d64c32..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/main.ts +++ /dev/null @@ -1,10 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { defaultConfig } from '@kbn/storybook'; - -module.exports = defaultConfig; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/manager.ts b/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/manager.ts deleted file mode 100644 index 54c3d31c2002f..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/manager.ts +++ /dev/null @@ -1,20 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { addons } from '@storybook/addons'; -import { create } from '@storybook/theming'; -import { PANEL_ID } from '@storybook/addon-actions'; - -addons.setConfig({ - theme: create({ - base: 'light', - brandTitle: 'Cloud Storybook', - brandUrl: 'https://github.com/elastic/kibana/tree/main/x-pack/plugins/cloud', - }), - showPanel: true.valueOf, - selectedPanel: PANEL_ID, -}); diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/preview.ts b/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/preview.ts deleted file mode 100644 index 83c512e516d5a..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/.storybook/preview.ts +++ /dev/null @@ -1,11 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { addDecorator } from '@storybook/react'; -import { getCloudContextDecorator } from './decorator'; - -addDecorator(getCloudContextDecorator); diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/README.md b/x-pack/plugins/cloud_integrations/cloud_chat/README.md index cee3d9f5a6671..edc102df9b7d3 100755 --- a/x-pack/plugins/cloud_integrations/cloud_chat/README.md +++ b/x-pack/plugins/cloud_integrations/cloud_chat/README.md @@ -1,3 +1,4 @@ -# Cloud Chat +# Cloud Chat - Deprecated / Removed -Integrates with DriftChat in order to provide live support to our Elastic Cloud users. This plugin should only run on Elastic Cloud. +The plugin was meant to integrate with DriftChat in order to provide live support to our Elastic Cloud users. +It was removed, but the plugin was left behind to register no longer used config keys. diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/common/constants.ts b/x-pack/plugins/cloud_integrations/cloud_chat/common/constants.ts deleted file mode 100755 index b196959a582d3..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/common/constants.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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export const GET_CHAT_USER_DATA_ROUTE_PATH = '/internal/cloud/chat_user'; -export const DEFAULT_TRIAL_BUFFER = 90; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/common/types.ts b/x-pack/plugins/cloud_integrations/cloud_chat/common/types.ts deleted file mode 100644 index 8b7d316ceedfa..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/common/types.ts +++ /dev/null @@ -1,15 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export type ChatVariant = 'header' | 'bubble'; - -export interface GetChatUserDataResponseBody { - token: string; - email: string; - id: string; - chatVariant: ChatVariant; -} diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/common/util.ts b/x-pack/plugins/cloud_integrations/cloud_chat/common/util.ts deleted file mode 100644 index 9d6cddac77f99..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/common/util.ts +++ /dev/null @@ -1,19 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -/** - * Returns true if today's date is within the an end date + buffer, false otherwise. - * - * @param endDate The end date of the trial. - * @param buffer The number of days to add to the end date. - * @returns true if today's date is within the an end date + buffer, false otherwise. - */ -export const isTodayInDateWindow = (endDate: Date, buffer: number) => { - const endDateWithBuffer = new Date(endDate); - endDateWithBuffer.setDate(endDateWithBuffer.getDate() + buffer); - return endDateWithBuffer > new Date(); -}; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/jest.config.js b/x-pack/plugins/cloud_integrations/cloud_chat/jest.config.js deleted file mode 100644 index 44f6f241d44d0..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/jest.config.js +++ /dev/null @@ -1,18 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -module.exports = { - preset: '@kbn/test', - rootDir: '../../../../', - roots: ['/x-pack/plugins/cloud_integrations/cloud_chat'], - coverageDirectory: - '/target/kibana-coverage/jest/x-pack/plugins/cloud_integrations/cloud_chat', - coverageReporters: ['text', 'html'], - collectCoverageFrom: [ - '/x-pack/plugins/cloud_integrations/cloud_chat/{common,public,server}/**/*.{ts,tsx}', - ], -}; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc index 6394ccc7b53f1..dad2a22752df1 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc +++ b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc @@ -6,7 +6,7 @@ "plugin": { "id": "cloudChat", "server": true, - "browser": true, + "browser": false, "configPath": [ "xpack", "cloud_integrations", diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx b/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx deleted file mode 100644 index debc600de80a7..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx +++ /dev/null @@ -1,70 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { i18n } from '@kbn/i18n'; -import { WhenIdle } from './when_idle'; -import { useChatConfig, ChatApi } from './use_chat_config'; -export type { ChatApi } from './use_chat_config'; - -export interface Props { - /** Handler invoked when the chat widget signals it is ready. */ - onReady?: (chatApi: ChatApi) => void; - /** Handler invoked when the chat widget signals to be resized. */ - onResize?: () => void; - /** Handler invoked when the playbook is fired. */ - onPlaybookFired?: () => void; - /** The offset from the top of the page to the chat widget. */ - topOffset?: number; -} - -/** - * A component that will display a trigger that will allow the user to chat with a human operator, - * when the service is enabled; otherwise, it renders nothing. - */ -export const Chat = ({ onReady, onResize, onPlaybookFired, topOffset = 0 }: Props) => { - const config = useChatConfig({ - onReady, - onResize, - onPlaybookFired, - }); - - if (!config.enabled) { - return null; - } - - return ( - -