diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d6d3175777038..99a2e30a6dc7e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -779,7 +779,6 @@ x-pack/platform/packages/private/ml/inference_integration_flyout @elastic/ml-ui x-pack/platform/packages/private/ml/is_defined @elastic/ml-ui x-pack/platform/packages/private/ml/is_populated_object @elastic/ml-ui x-pack/platform/packages/private/ml/json_schemas @elastic/ml-ui -x-pack/platform/packages/private/ml/kibana_theme @elastic/ml-ui x-pack/platform/packages/private/ml/local_storage @elastic/ml-ui x-pack/platform/packages/private/ml/nested_property @elastic/ml-ui x-pack/platform/packages/private/ml/number_utils @elastic/ml-ui @@ -3171,7 +3170,6 @@ x-pack/platform/packages/private/ml/inference_integration_flyout @elastic/ml-ui x-pack/platform/packages/private/ml/is_defined @elastic/ml-ui x-pack/platform/packages/private/ml/is_populated_object @elastic/ml-ui x-pack/platform/packages/private/ml/json_schemas @elastic/ml-ui -x-pack/platform/packages/private/ml/kibana_theme @elastic/ml-ui x-pack/platform/packages/private/ml/local_storage @elastic/ml-ui x-pack/platform/packages/private/ml/nested_property @elastic/ml-ui x-pack/platform/packages/private/ml/number_utils @elastic/ml-ui diff --git a/package.json b/package.json index 8120533f58762..7907db0ca46af 100644 --- a/package.json +++ b/package.json @@ -665,7 +665,6 @@ "@kbn/ml-in-memory-table": "link:x-pack/platform/packages/private/ml/in_memory_table", "@kbn/ml-is-defined": "link:x-pack/platform/packages/private/ml/is_defined", "@kbn/ml-is-populated-object": "link:x-pack/platform/packages/private/ml/is_populated_object", - "@kbn/ml-kibana-theme": "link:x-pack/platform/packages/private/ml/kibana_theme", "@kbn/ml-local-storage": "link:x-pack/platform/packages/private/ml/local_storage", "@kbn/ml-nested-property": "link:x-pack/platform/packages/private/ml/nested_property", "@kbn/ml-number-utils": "link:x-pack/platform/packages/private/ml/number_utils", diff --git a/tsconfig.base.json b/tsconfig.base.json index 8e2f158802d1a..494cad07b8ceb 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1260,8 +1260,6 @@ "@kbn/ml-is-defined/*": ["x-pack/platform/packages/private/ml/is_defined/*"], "@kbn/ml-is-populated-object": ["x-pack/platform/packages/private/ml/is_populated_object"], "@kbn/ml-is-populated-object/*": ["x-pack/platform/packages/private/ml/is_populated_object/*"], - "@kbn/ml-kibana-theme": ["x-pack/platform/packages/private/ml/kibana_theme"], - "@kbn/ml-kibana-theme/*": ["x-pack/platform/packages/private/ml/kibana_theme/*"], "@kbn/ml-local-storage": ["x-pack/platform/packages/private/ml/local_storage"], "@kbn/ml-local-storage/*": ["x-pack/platform/packages/private/ml/local_storage/*"], "@kbn/ml-nested-property": ["x-pack/platform/packages/private/ml/nested_property"], diff --git a/x-pack/platform/packages/private/ml/kibana_theme/README.md b/x-pack/platform/packages/private/ml/kibana_theme/README.md deleted file mode 100644 index a61492e4e7b8d..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @kbn/ml-kibana-theme - -Provides hooks to retrieve currently applied theme and EUI theme variables. diff --git a/x-pack/platform/packages/private/ml/kibana_theme/index.ts b/x-pack/platform/packages/private/ml/kibana_theme/index.ts deleted file mode 100644 index daa5b6ad8964c..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/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 { useIsDarkTheme } from './src/hooks'; diff --git a/x-pack/platform/packages/private/ml/kibana_theme/jest.config.js b/x-pack/platform/packages/private/ml/kibana_theme/jest.config.js deleted file mode 100644 index 98e6c95b278b3..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/jest.config.js +++ /dev/null @@ -1,12 +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/jest_node', - rootDir: '../../../../../..', - roots: ['/x-pack/platform/packages/private/ml/kibana_theme'], -}; diff --git a/x-pack/platform/packages/private/ml/kibana_theme/kibana.jsonc b/x-pack/platform/packages/private/ml/kibana_theme/kibana.jsonc deleted file mode 100644 index cbd58ef1489a6..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/kibana.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "type": "shared-common", - "id": "@kbn/ml-kibana-theme", - "owner": [ - "@elastic/ml-ui" - ], - "group": "platform", - "visibility": "private" -} \ No newline at end of file diff --git a/x-pack/platform/packages/private/ml/kibana_theme/package.json b/x-pack/platform/packages/private/ml/kibana_theme/package.json deleted file mode 100644 index 02eb5de15712f..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "@kbn/ml-kibana-theme", - "private": true, - "version": "1.0.0", - "license": "Elastic License 2.0" -} \ No newline at end of file diff --git a/x-pack/platform/packages/private/ml/kibana_theme/src/hooks.ts b/x-pack/platform/packages/private/ml/kibana_theme/src/hooks.ts deleted file mode 100644 index 68aa5bb4129a5..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/src/hooks.ts +++ /dev/null @@ -1,27 +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 { useMemo } from 'react'; -import { of } from 'rxjs'; -import useObservable from 'react-use/lib/useObservable'; -import type { ThemeServiceStart } from '@kbn/core-theme-browser'; - -const themeDefault = { darkMode: false }; - -/** - * Indicates if the currently applied theme is either dark or light. - * @return {boolean} - Returns true if the currently applied theme is dark. - */ -export function useIsDarkTheme(theme: ThemeServiceStart): boolean { - const themeObservable$ = useMemo(() => { - return theme?.theme$ ?? of(themeDefault); - }, [theme]); - - const { darkMode } = useObservable(themeObservable$, themeDefault); - - return darkMode; -} diff --git a/x-pack/platform/packages/private/ml/kibana_theme/tsconfig.json b/x-pack/platform/packages/private/ml/kibana_theme/tsconfig.json deleted file mode 100644 index 1342e03481c51..0000000000000 --- a/x-pack/platform/packages/private/ml/kibana_theme/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../../../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types", - "types": [ - "jest", - "node" - ] - }, - "include": [ - "**/*.ts", - ], - "exclude": [ - "target/**/*" - ], - "kbn_references": [ - "@kbn/core-theme-browser", - ] -} diff --git a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.test.tsx b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.test.tsx index fa2d7830de3f3..97469547a7e5d 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.test.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.test.tsx @@ -9,10 +9,6 @@ import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; import { useCreateFormattedExample } from './format_category'; import { renderHook } from '@testing-library/react'; -jest.mock('../../hooks/use_is_dark_theme', () => ({ - useIsDarkTheme: () => false, -})); - const categoryData: Array<{ category: Category; elementCount: number; diff --git a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.tsx b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.tsx index bd8c16f8f8f76..bb2c7f6206ca4 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/log_categorization/format_category.tsx @@ -7,11 +7,10 @@ import type { FC, PropsWithChildren } from 'react'; import React, { useCallback, useMemo } from 'react'; -import { EuiText, EuiHorizontalRule } from '@elastic/eui'; +import { useEuiTheme, EuiText, EuiHorizontalRule } from '@elastic/eui'; import type { SerializedStyles } from '@emotion/react'; import { css } from '@emotion/react'; import type { Category } from '@kbn/aiops-log-pattern-analysis/types'; -import { useIsDarkTheme } from '../../hooks/use_is_dark_theme'; interface Props { category: Category; @@ -38,7 +37,8 @@ interface Styles { } const useStyles = (): Styles => { - const isDarkTheme = useIsDarkTheme(); + const { colorMode } = useEuiTheme(); + const isDarkTheme = colorMode === 'DARK'; return useMemo( () => diff --git a/x-pack/platform/plugins/shared/aiops/public/hooks/use_is_dark_theme.ts b/x-pack/platform/plugins/shared/aiops/public/hooks/use_is_dark_theme.ts deleted file mode 100644 index 6dc15ffa9e25f..0000000000000 --- a/x-pack/platform/plugins/shared/aiops/public/hooks/use_is_dark_theme.ts +++ /dev/null @@ -1,14 +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 { useIsDarkTheme as useIsDarkThemeMl } from '@kbn/ml-kibana-theme'; -import { useAiopsAppContext } from './use_aiops_app_context'; - -export function useIsDarkTheme() { - const { theme } = useAiopsAppContext(); - return useIsDarkThemeMl(theme); -} diff --git a/x-pack/platform/plugins/shared/aiops/tsconfig.json b/x-pack/platform/plugins/shared/aiops/tsconfig.json index 1069dfde96226..08b9f8720e814 100644 --- a/x-pack/platform/plugins/shared/aiops/tsconfig.json +++ b/x-pack/platform/plugins/shared/aiops/tsconfig.json @@ -49,7 +49,6 @@ "@kbn/ml-in-memory-table", "@kbn/ml-is-defined", "@kbn/ml-is-populated-object", - "@kbn/ml-kibana-theme", "@kbn/ml-local-storage", "@kbn/ml-number-utils", "@kbn/ml-query-utils", diff --git a/x-pack/platform/plugins/shared/ml/public/application/explorer/swimlane_container.tsx b/x-pack/platform/plugins/shared/ml/public/application/explorer/swimlane_container.tsx index 7c1118b33cb6d..b0bd6270c205f 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/explorer/swimlane_container.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/explorer/swimlane_container.tsx @@ -51,7 +51,6 @@ import { ML_SEVERITY_COLORS, } from '@kbn/ml-anomaly-utils'; import { formatHumanReadableDateTime } from '@kbn/ml-date-utils'; -import { useIsDarkTheme } from '@kbn/ml-kibana-theme'; import type { TimeBuckets as TimeBucketsClass } from '@kbn/ml-time-buckets'; import { SwimLanePagination } from './swimlane_pagination'; import type { @@ -66,7 +65,6 @@ import { FormattedTooltip } from '../components/chart_tooltip/chart_tooltip'; import './_explorer.scss'; import { EMPTY_FIELD_VALUE_LABEL } from '../timeseriesexplorer/components/entity_control/entity_control'; import { SWIM_LANE_LABEL_WIDTH, Y_AXIS_LABEL_PADDING } from './constants'; -import { useMlKibana } from '../contexts/kibana'; declare global { interface Window { @@ -204,12 +202,8 @@ export const SwimlaneContainer: FC = ({ }) => { const [chartWidth, setChartWidth] = useState(0); - const { - services: { theme: themeService }, - } = useMlKibana(); - - const isDarkTheme = useIsDarkTheme(themeService); - const { euiTheme } = useEuiTheme(); + const { colorMode, euiTheme } = useEuiTheme(); + const isDarkTheme = colorMode === 'DARK'; // Holds the container height for previously fetched data const containerHeightRef = useRef(); diff --git a/x-pack/platform/plugins/shared/ml/tsconfig.json b/x-pack/platform/plugins/shared/ml/tsconfig.json index 4d5a3668403eb..03656667353cf 100644 --- a/x-pack/platform/plugins/shared/ml/tsconfig.json +++ b/x-pack/platform/plugins/shared/ml/tsconfig.json @@ -86,7 +86,6 @@ "@kbn/ml-in-memory-table", "@kbn/ml-is-defined", "@kbn/ml-is-populated-object", - "@kbn/ml-kibana-theme", "@kbn/ml-local-storage", "@kbn/ml-nested-property", "@kbn/ml-number-utils", diff --git a/yarn.lock b/yarn.lock index 1b9c5de4070f9..fd9a8badaa5e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6373,10 +6373,6 @@ version "0.0.0" uid "" -"@kbn/ml-kibana-theme@link:x-pack/platform/packages/private/ml/kibana_theme": - version "0.0.0" - uid "" - "@kbn/ml-local-storage@link:x-pack/platform/packages/private/ml/local_storage": version "0.0.0" uid ""