Skip to content

Commit

Permalink
Merge branch 'main' into ad-datafeed-counts-hidden-refresh-button
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtj authored Dec 19, 2024
2 parents f7df8ef + ddb34ae commit 2176e96
Show file tree
Hide file tree
Showing 141 changed files with 2,548 additions and 1,347 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ packages/kbn-capture-oas-snapshot-cli @elastic/kibana-core
packages/kbn-cases-components @elastic/response-ops
packages/kbn-cbor @elastic/kibana-operations
packages/kbn-chart-icons @elastic/kibana-visualizations
packages/kbn-charts-theme @elastic/kibana-visualizations
packages/kbn-check-mappings-update-cli @elastic/kibana-core
packages/kbn-check-prod-native-modules-cli @elastic/kibana-operations
packages/kbn-ci-stats-core @elastic/kibana-operations
Expand Down
2 changes: 1 addition & 1 deletion docs/user/dashboard/lens.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ For area, line, and bar charts, press Shift, then click the series in the legend
.*How do I visualize saved Discover sessions?*
[%collapsible]
====
Visualizing saved Discover sessions in unsupported.
Visualizing saved Discover sessions is unsupported.
====

[discrete]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@elastic/apm-rum": "^5.16.1",
"@elastic/apm-rum-core": "^5.21.1",
"@elastic/apm-rum-react": "^2.0.3",
"@elastic/charts": "68.0.3",
"@elastic/charts": "68.0.4",
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "^1.1.1",
"@elastic/ecs": "^8.11.1",
Expand Down Expand Up @@ -209,6 +209,7 @@
"@kbn/chart-expressions-common": "link:src/plugins/chart_expressions/common",
"@kbn/chart-icons": "link:packages/kbn-chart-icons",
"@kbn/charts-plugin": "link:src/plugins/charts",
"@kbn/charts-theme": "link:packages/kbn-charts-theme",
"@kbn/cloud": "link:packages/cloud",
"@kbn/cloud-chat-plugin": "link:x-pack/plugins/cloud_integrations/cloud_chat",
"@kbn/cloud-data-migration-plugin": "link:x-pack/platform/plugins/private/cloud_integrations/cloud_data_migration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
*/

import React from 'react';
import { Chart, Settings, DARK_THEME, LIGHT_THEME, BarSeries, Axis } from '@elastic/charts';
import { formatDate, useEuiTheme } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import moment from 'moment';

import { Chart, Settings, BarSeries, Axis } from '@elastic/charts';
import { formatDate } from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import { useElasticChartsTheme } from '@kbn/charts-theme';

const dateFormatter = (d: Date) => formatDate(d, `MM/DD`);

const seriesName = i18n.translate('contentManagement.contentEditor.viewsStats.viewsLabel', {
Expand All @@ -26,20 +29,15 @@ const weekOfFormatter = (date: Date) =>
});

export const ViewsChart = ({ data }: { data: Array<[week: number, views: number]> }) => {
const { colorMode } = useEuiTheme();

const baseTheme = useElasticChartsTheme();
const momentDow = moment().localeData().firstDayOfWeek(); // configured from advanced settings
const isoDow = momentDow === 0 ? 7 : momentDow;

const momentTz = moment().tz(); // configured from advanced settings

return (
<Chart size={{ height: 240 }}>
<Settings
baseTheme={colorMode === 'DARK' ? DARK_THEME : LIGHT_THEME}
showLegend={false}
dow={isoDow}
/>
<Settings baseTheme={baseTheme} showLegend={false} dow={isoDow} />
<BarSeries
id="viewsOverTime"
name={seriesName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"@kbn/core-http-browser",
"@kbn/content-management-content-insights-server",
"@kbn/content-management-table-list-view-common",
"@kbn/charts-theme",
]
}
24 changes: 24 additions & 0 deletions packages/kbn-charts-theme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @kbn/charts-theme

A temporary package to provide a hook for getting `@elastic/charts` theme based on `@elastic/eui` theme.

To be refactored to be consumed from `ElasticChartsProvider`.

```tsx
import { useElasticChartsTheme } from '@kbn/charts-theme';
import { Chart, Settings } from '@elastic/charts';

export function MyComponent() {
const baseTheme = useElasticChartsTheme();

return (
<Chart>
<Settings
baseTheme={baseTheme}
{/* ... */}
/>
{/* ... */}
</Chart>
)
}
```
23 changes: 23 additions & 0 deletions packages/kbn-charts-theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { type Theme, getChartsTheme } from '@elastic/charts';
import { useEuiTheme } from '@elastic/eui';
import { useMemo } from 'react';

/**
* A hook used to get the `@elastic/charts` theme based on the current eui theme.
*/
export function useElasticChartsTheme(): Theme {
const { euiTheme, colorMode } = useEuiTheme();
return useMemo(
() => getChartsTheme(euiTheme.themeName, colorMode),
[colorMode, euiTheme.themeName]
);
}
14 changes: 14 additions & 0 deletions packages/kbn-charts-theme/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-charts-theme'],
};
5 changes: 5 additions & 0 deletions packages/kbn-charts-theme/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/charts-theme",
"owner": "@elastic/kibana-visualizations"
}
6 changes: 6 additions & 0 deletions packages/kbn-charts-theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/charts-theme",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}
19 changes: 19 additions & 0 deletions packages/kbn-charts-theme/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": []
}
6 changes: 6 additions & 0 deletions packages/kbn-scout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ npx playwright test --config <plugin-path>/ui_tests/playwright.config.ts
We welcome contributions to improve and extend `kbn-scout`. This guide will help you get started, add new features, and align with existing project standards.
Make sure to run unit tests before opening the PR:
```bash
node scripts/jest --config packages/kbn-scout/jest.config.js
```
#### Setting Up the Environment
Ensure you have the latest local copy of the Kibana repository.
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-scout/src/common/services/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { KbnClient, createEsClientForTesting } from '@kbn/test';
import type { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { ScoutTestConfig } from '../../types';
import { serviceLoadedMsg } from '../../playwright/utils';

interface ClientOptions {
Expand All @@ -29,7 +29,7 @@ function createClientUrlWithAuth({ serviceName, url, username, password, log }:
return clientUrl.toString();
}

export function createEsClient(config: ScoutServerConfig, log: ToolingLog) {
export function createEsClient(config: ScoutTestConfig, log: ToolingLog) {
const { username, password } = config.auth;
const elasticsearchUrl = createClientUrlWithAuth({
serviceName: 'Es',
Expand All @@ -45,7 +45,7 @@ export function createEsClient(config: ScoutServerConfig, log: ToolingLog) {
});
}

export function createKbnClient(config: ScoutServerConfig, log: ToolingLog) {
export function createKbnClient(config: ScoutTestConfig, log: ToolingLog) {
const kibanaUrl = createClientUrlWithAuth({
serviceName: 'Kbn',
url: config.hosts.kibana,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-scout/src/common/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import path from 'path';
import fs from 'fs';
import { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { ScoutTestConfig } from '../../types';
import { serviceLoadedMsg } from '../../playwright/utils';

export function createScoutConfig(configDir: string, configName: string, log: ToolingLog) {
Expand All @@ -21,7 +21,7 @@ export function createScoutConfig(configDir: string, configName: string, log: To
const configPath = path.join(configDir, `${configName}.json`);
log.info(`Reading test servers confiuration from file: ${configPath}`);

const config = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as ScoutServerConfig;
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8')) as ScoutTestConfig;

log.debug(serviceLoadedMsg('config'));

Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-scout/src/common/services/kibana_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { ScoutTestConfig } from '../../types';
import { serviceLoadedMsg } from '../../playwright/utils';

export interface PathOptions {
Expand Down Expand Up @@ -64,7 +64,7 @@ export class KibanaUrl {
}
}

export function createKbnUrl(scoutConfig: ScoutServerConfig, log: ToolingLog) {
export function createKbnUrl(scoutConfig: ScoutTestConfig, log: ToolingLog) {
const kbnUrl = new KibanaUrl(new URL(scoutConfig.hosts.kibana));

log.debug(serviceLoadedMsg('kbnUrl'));
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-scout/src/common/services/saml_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import {
import { REPO_ROOT } from '@kbn/repo-info';
import { HostOptions, SamlSessionManager } from '@kbn/test';
import { ToolingLog } from '@kbn/tooling-log';
import { ScoutServerConfig } from '../../types';
import { ScoutTestConfig } from '../../types';
import { Protocol } from '../../playwright/types';
import { serviceLoadedMsg } from '../../playwright/utils';

const getResourceDirPath = (config: ScoutServerConfig) => {
const getResourceDirPath = (config: ScoutTestConfig) => {
return config.serverless
? path.resolve(SERVERLESS_ROLES_ROOT_PATH, config.projectType!)
: path.resolve(REPO_ROOT, STATEFUL_ROLES_ROOT_PATH);
};

const createKibanaHostOptions = (config: ScoutServerConfig): HostOptions => {
const createKibanaHostOptions = (config: ScoutTestConfig): HostOptions => {
const kibanaUrl = new URL(config.hosts.kibana);
kibanaUrl.username = config.auth.username;
kibanaUrl.password = config.auth.password;
Expand All @@ -42,7 +42,7 @@ const createKibanaHostOptions = (config: ScoutServerConfig): HostOptions => {
};

export const createSamlSessionManager = (
config: ScoutServerConfig,
config: ScoutTestConfig,
log: ToolingLog
): SamlSessionManager => {
const resourceDirPath = getResourceDirPath(config);
Expand Down
Loading

0 comments on commit 2176e96

Please sign in to comment.