Skip to content

Commit

Permalink
Merge branch '8.16' into backport/8.16/pr-196656
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Oct 18, 2024
2 parents aa9ed3d + 8094dd6 commit 40f427f
Show file tree
Hide file tree
Showing 36 changed files with 286 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"ingest-agent-policies": "5e95e539826a40ad08fd0c1d161da0a4d86ffc6d",
"ingest-download-sources": "279a68147e62e4d8858c09ad1cf03bd5551ce58d",
"ingest-outputs": "daafff49255ab700e07491376fe89f04fc998b91",
"ingest-package-policies": "dc2af447c335215be2d6f7b7b8d437d05d6a1188",
"ingest-package-policies": "53a94064674835fdb35e5186233bcd7052eabd22",
"ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505",
"inventory-view": "b8683c8e352a286b4aca1ab21003115a4800af83",
"kql-telemetry": "93c1d16c1a0dfca9c8842062cf5ef8f62ae401ad",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const convertToCumulativeSumColumns = (
// lens supports cumulative sum for count and sum as quick function
// and everything else as formula
if (subFunctionMetric.type !== 'count' && pipelineAgg.name !== 'sum') {
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
formula = getPipelineSeriesFormula(metric, metrics, subFunctionMetric, {
metaValue,
reducedTimeRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const convertFormulaScriptForPercentileAggs = (
) => {
variables.forEach((variable) => {
const [_, meta] = variable?.field?.split('[') ?? [];
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
if (!metaValue) {
return;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ export const convertOtherAggsToFormulaColumn = (
const metric = metrics[metrics.length - 1];
const [fieldId, meta] = metric?.field?.split('[') ?? [];
const subFunctionMetric = metrics.find(({ id }) => id === fieldId);
const metaValue = meta ? Number(meta?.replace(']', '')) : undefined;
const metaValue = meta ? Number(meta?.replace(/\]/g, '')) : undefined;

if (!subFunctionMetric) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const convertMovingAvgOrDerivativeToColumns = (
if (!pipelineAgg) {
return null;
}
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
const subMetricField = subFunctionMetric.field;
const [nestedFieldId, _] = subMetricField?.split('[') ?? [];
// support nested aggs with formula
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addAdditionalArgs } from '.';
import { AdditionalArgs } from '../../types';

const escapeQuotes = (str: string) => {
return str?.replace(/'/g, "\\'");
return str?.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
};

const constructFilterRationFormula = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const getFormulaEquivalent = (
}

return getPipelineSeriesFormula(currentMetric, metrics, subFunctionMetric, {
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(']', '')) : undefined,
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(/\]/g, '')) : undefined,
reducedTimeRange,
timeShift,
});
Expand Down
14 changes: 8 additions & 6 deletions x-pack/packages/ml/data_grid/hooks/use_data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ES_CLIENT_TOTAL_HITS_RELATION } from '@kbn/ml-query-utils';
import { INDEX_STATUS } from '../lib/common';
import type { ChartData } from '../lib/field_histograms';
import { ColumnChart } from '../components/column_chart';
import { COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD, INIT_MAX_COLUMNS } from '../lib/common';
import { MAX_ROW_COUNT, INIT_MAX_COLUMNS } from '../lib/common';
import type {
ChartsVisible,
ColumnId,
Expand Down Expand Up @@ -62,6 +62,11 @@ export const useDataGrid = (

const { rowCount, rowCountRelation } = rowCountInfo;

const setLimitedRowCountInfo = useCallback((info: RowCountInfo) => {
const limitedRowCount = Math.min(info.rowCount, MAX_ROW_COUNT);
setRowCountInfo({ rowCount: limitedRowCount, rowCountRelation: info.rowCountRelation });
}, []);

const toggleChartVisibility = () => {
if (chartsVisible !== undefined) {
setChartsVisible(!chartsVisible);
Expand Down Expand Up @@ -161,10 +166,7 @@ export const useDataGrid = (
// we decide whether to show or hide the charts by default.
useEffect(() => {
if (chartsVisible === undefined && rowCount > 0 && rowCountRelation !== undefined) {
setChartsVisible(
rowCount <= COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD &&
rowCountRelation !== ES_CLIENT_TOTAL_HITS_RELATION.GTE
);
setChartsVisible(rowCountRelation !== ES_CLIENT_TOTAL_HITS_RELATION.GTE);
}
}, [chartsVisible, rowCount, rowCountRelation]);

Expand All @@ -189,7 +191,7 @@ export const useDataGrid = (
setErrorMessage,
setNoDataMessage,
setPagination,
setRowCountInfo,
setRowCountInfo: setLimitedRowCountInfo,
setSortingColumns,
setStatus,
setTableItems,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/packages/ml/data_grid/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ import type { DataGridItem, IndexPagination, RenderCellValue } from './types';
export const INIT_MAX_COLUMNS = 10;

/**
* The default threshold value for the number of rows at which the column chart visibility is set to true.
* The default maximum row count value, set to 10000 due to ES limitations.
*/
export const COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD = 10000;
export const MAX_ROW_COUNT = 10000;

/**
* Enum for index status
Expand Down
2 changes: 1 addition & 1 deletion x-pack/packages/ml/data_grid/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export interface UseDataGridReturnType {
/**
* Setter function for the row count info.
*/
setRowCountInfo: Dispatch<SetStateAction<RowCountInfo>>;
setRowCountInfo: (info: RowCountInfo) => void;
/**
* Setter function for the sorting columns.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import type { ProductFeatureParams } from '../types';
import { getAssistantBaseKibanaFeature } from './kibana_features';
import {
getAssistantBaseKibanaSubFeatureIds,
assistantSubFeaturesMap,
getAssistantSubFeaturesMap,
} from './kibana_sub_features';

export const getAssistantFeature = (): ProductFeatureParams<AssistantSubFeatureId> => ({
export const getAssistantFeature = (
experimentalFeatures: Record<string, boolean>
): ProductFeatureParams<AssistantSubFeatureId> => ({
baseKibanaFeature: getAssistantBaseKibanaFeature(),
baseKibanaSubFeatureIds: getAssistantBaseKibanaSubFeatureIds(),
subFeaturesMap: assistantSubFeaturesMap,
subFeaturesMap: getAssistantSubFeaturesMap(experimentalFeatures),
});
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,28 @@ export const getAssistantBaseKibanaSubFeatureIds = (): AssistantSubFeatureId[] =
* Defines all the Security Assistant subFeatures available.
* The order of the subFeatures is the order they will be displayed
*/
export const assistantSubFeaturesMap = Object.freeze(
new Map<AssistantSubFeatureId, SubFeatureConfig>([
export const getAssistantSubFeaturesMap = (
experimentalFeatures: Record<string, boolean>
): Map<AssistantSubFeatureId, SubFeatureConfig> => {
const assistantSubFeaturesList: Array<[AssistantSubFeatureId, SubFeatureConfig]> = [
[AssistantSubFeatureId.updateAnonymization, updateAnonymizationSubFeature],
[AssistantSubFeatureId.manageGlobalKnowledgeBase, manageGlobalKnowledgeBaseSubFeature],
])
);
];

// Use the following code to add feature based on feature flag
// if (experimentalFeatures.featureFlagName) {
// assistantSubFeaturesList.push([AssistantSubFeatureId.featureId, featureSubFeature]);
// }

if (experimentalFeatures.assistantKnowledgeBaseByDefault) {
assistantSubFeaturesList.push([
AssistantSubFeatureId.manageGlobalKnowledgeBase,
manageGlobalKnowledgeBaseSubFeature,
]);
}

const assistantSubFeaturesMap = new Map<AssistantSubFeatureId, SubFeatureConfig>(
assistantSubFeaturesList
);

return Object.freeze(assistantSubFeaturesMap);
};
9 changes: 0 additions & 9 deletions x-pack/plugins/fleet/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import {
migratePackagePolicySetRequiresRootToV8150,
} from './migrations/to_v8_15_0';
import { backfillAgentPolicyToV4 } from './model_versions/agent_policy_v4';
import { packagePolicyV15AdvancedFieldsForEndpointV816 } from './model_versions/security_solution/v15_advanced_package_policy_fields';

/*
* Saved object types and mappings
Expand Down Expand Up @@ -751,14 +750,6 @@ export const getSavedObjectTypes = (
},
],
},
'15': {
changes: [
{
type: 'data_backfill',
backfillFn: packagePolicyV15AdvancedFieldsForEndpointV816,
},
],
},
},
migrations: {
'7.10.0': migratePackagePolicyToV7100,
Expand Down

This file was deleted.

Loading

0 comments on commit 40f427f

Please sign in to comment.