Skip to content

Commit

Permalink
Merge branch 'main' into dg-sanity-ui-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gurevichdmitry committed Jul 9, 2024
2 parents deb8026 + f3e2395 commit fe9d162
Show file tree
Hide file tree
Showing 34 changed files with 793 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-approve-api-docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
pull_request_target:
branches:
- main
types:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-approve-backports.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
pull_request_target:
branches-ignore:
- main
types:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ test('generates gauge chart config', async () => {
"query": Object {
"esql": "from test | count=count()",
},
"timeField": undefined,
},
},
},
Expand Down Expand Up @@ -189,6 +190,7 @@ test('generates gauge chart config with goal and max', async () => {
"query": Object {
"esql": "from test | count=count() | eval max=1000 | eval goal=500",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ test('generates metric chart config', async () => {
"query": Object {
"esql": "from test | count=count() by @timestamp, category",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ test('generates metric chart config', async () => {
"query": Object {
"esql": "from test | count=count()",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ test('generates metric chart config', async () => {
"query": Object {
"esql": "from test | count=count() by @timestamp, category",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test('generates region map chart config', async () => {
"query": Object {
"esql": "from test | count=count() by category",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test('generates table config', async () => {
"query": Object {
"esql": "from test | count=count() by category",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test('generates tag cloud chart config', async () => {
"query": Object {
"esql": "from test | count=count() by category",
},
"timeField": undefined,
},
},
},
Expand All @@ -123,8 +124,8 @@ test('generates tag cloud chart config', async () => {
"minFontSize": 12,
"orientation": "single",
"showLabel": true,
"tagAccessor": "category",
"valueAccessor": "count",
"tagAccessor": "metric_formula_accessor_breakdown",
"valueAccessor": "metric_formula_accessor",
},
},
"title": "test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
buildDatasourceStates,
buildReferences,
getAdhocDataviews,
isFormulaDataset,
mapToFormula,
} from '../utils';
import { getBreakdownColumn, getFormulaColumn, getValueColumn } from '../columns';
Expand All @@ -31,18 +30,17 @@ function getAccessorName(type: 'breakdown') {

function buildVisualizationState(config: LensTagCloudConfig): TagcloudState {
const layer = config;
const isFormula = isFormulaDataset(config.dataset) || isFormulaDataset(layer.dataset);

return {
layerId: DEFAULT_LAYER_ID,
valueAccessor: !isFormula ? layer.value : ACCESSOR,
valueAccessor: ACCESSOR,
maxFontSize: 72,
minFontSize: 12,
orientation: 'single',
showLabel: true,
...(layer.breakdown
? {
tagAccessor: !isFormula ? (layer.breakdown as string) : getAccessorName('breakdown'),
tagAccessor: getAccessorName('breakdown'),
}
: {}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ test('generates xy chart config', async () => {
"query": Object {
"esql": "from test | count=count() by @timestamp",
},
"timeField": undefined,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class LensConfigBuilder {
async build(
config: LensConfig,
options: LensConfigOptions = {}
): Promise<LensAttributes | LensEmbeddableInput | undefined> {
): Promise<LensAttributes | LensEmbeddableInput> {
const { chartType } = config;
const chartConfig = await this.charts[chartType](config as any, {
formulaAPI: this.formulaAPI,
Expand All @@ -74,6 +74,6 @@ export class LensConfigBuilder {
} as LensEmbeddableInput;
}

return chartState;
return chartState as LensAttributes;
}
}
10 changes: 5 additions & 5 deletions packages/kbn-lens-embeddable-utils/config_builder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { FormulaPublicApi, TypedLensByValueInput } from '@kbn/lens-plugin/public';
import type { Filter, Query } from '@kbn/es-query';
import type { AggregateQuery, Filter, Query } from '@kbn/es-query';
import type { Datatable } from '@kbn/expressions-plugin/common';
import { DataViewsCommon } from './config_builder';

Expand Down Expand Up @@ -95,7 +95,7 @@ export interface LensConfigOptions {
/** optional time range override */
timeRange?: TimeRange;
filters?: Filter[];
query?: Query;
query?: Query | AggregateQuery;
}

export interface LensAxisTitleVisibilityConfig {
Expand Down Expand Up @@ -208,9 +208,9 @@ export type LensRegionMapConfig = Identity<
export interface LensMosaicConfigBase {
chartType: 'mosaic';
/** field name to apply breakdown based on field type or full breakdown configuration */
breakdown: LensBreakdownConfig;
breakdown: LensBreakdownConfig[];
/** field name to apply breakdown based on field type or full breakdown configuration */
xAxis: LensBreakdownConfig;
xAxis?: LensBreakdownConfig;
}

export type LensMosaicConfig = Identity<LensBaseConfig & LensBaseLayer & LensMosaicConfigBase>;
Expand All @@ -228,7 +228,7 @@ export type LensTableConfig = Identity<LensBaseConfig & LensBaseLayer & LensTabl
export interface LensHeatmapConfigBase {
chartType: 'heatmap';
/** field name to apply breakdown based on field type or full breakdown configuration */
breakdown: LensBreakdownConfig;
breakdown?: LensBreakdownConfig;
xAxis: LensBreakdownConfig;
legend?: Identity<LensLegendConfig>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ describe('buildDatasourceStates', () => {
"query": Object {
"esql": "from test | limit 10",
},
"timeField": undefined,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-lens-embeddable-utils/config_builder/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ function buildDatasourceStatesLayer(
const newLayer = {
index: dataView!.id!,
query: { esql: (dataset as LensESQLDataset).esql } as AggregateQuery,
timeField: dataView!.timeFieldName,
columns,
allColumns: columns,
};
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/dashboard/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"usageCollection",
"taskManager",
"serverless",
"noDataPage"
"noDataPage",
"observabilityAIAssistant"
],
"requiredBundles": [
"kibanaReact",
Expand Down
11 changes: 10 additions & 1 deletion src/plugins/dashboard/public/dashboard_app/dashboard_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { loadDashboardHistoryLocationState } from './locator/load_dashboard_hist
import type { DashboardCreationOptions } from '../dashboard_container/embeddable/dashboard_container_factory';
import { DashboardTopNav } from '../dashboard_top_nav';
import { DashboardTabTitleSetter } from './tab_title_setter/dashboard_tab_title_setter';
import { useObservabilityAIAssistantContext } from './hooks/use_observability_ai_assistant_context';

export interface DashboardAppProps {
history: History;
Expand Down Expand Up @@ -82,13 +83,21 @@ export function DashboardApp({
embeddable: { getStateTransfer },
notifications: { toasts },
settings: { uiSettings },
data: { search },
data: { search, dataViews },
customBranding,
share: { url },
observabilityAIAssistant,
} = pluginServices.getServices();
const showPlainSpinner = useObservable(customBranding.hasCustomBranding$, false);
const { scopedHistory: getScopedHistory } = useDashboardMountContext();

useObservabilityAIAssistantContext({
observabilityAIAssistant: observabilityAIAssistant.start,
dashboardAPI,
search,
dataViews,
});

useExecutionContext(executionContext, {
type: 'application',
page: 'app',
Expand Down
Loading

0 comments on commit fe9d162

Please sign in to comment.