Skip to content

Commit

Permalink
Merge branch '8.5' into backport/8.5/pr-142278
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 7, 2022
2 parents 329060a + ba69977 commit 21c379f
Show file tree
Hide file tree
Showing 41 changed files with 543 additions and 480 deletions.
302 changes: 81 additions & 221 deletions docs/concepts/kuery.asciidoc

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@
"@types/intl-relativeformat": "^2.1.0",
"@types/jest": "^26.0.22",
"@types/jest-axe": "^3.5.3",
"@types/joi": "^17.2.3",
"@types/jquery": "^3.3.31",
"@types/js-levenshtein": "^1.1.0",
"@types/js-search": "^1.4.0",
Expand Down Expand Up @@ -1149,7 +1148,6 @@
"@types/mocha": "^9.1.1",
"@types/mock-fs": "^4.13.1",
"@types/moment-duration-format": "^2.2.3",
"@types/moment-timezone": "^0.5.30",
"@types/mustache": "^0.8.31",
"@types/nock": "^10.0.3",
"@types/node": "16.11.41",
Expand All @@ -1167,7 +1165,6 @@
"@types/pixelmatch": "^5.2.4",
"@types/pngjs": "^3.4.0",
"@types/prettier": "^2.3.2",
"@types/pretty-ms": "^5.0.0",
"@types/prop-types": "^15.7.5",
"@types/rbush": "^3.0.0",
"@types/react": "^17.0.45",
Expand All @@ -1176,19 +1173,16 @@
"@types/react-grid-layout": "^1.3.2",
"@types/react-intl": "^2.3.15",
"@types/react-is": "^17.0.3",
"@types/react-resize-detector": "^6.1.0",
"@types/react-router": "^5.1.7",
"@types/react-router-config": "^5.0.2",
"@types/react-router-dom": "^5.1.5",
"@types/react-test-renderer": "^17.0.2",
"@types/react-virtualized": "^9.21.21",
"@types/react-vis": "^1.11.9",
"@types/recompose": "^0.30.10",
"@types/reduce-reducers": "^1.0.0",
"@types/redux-actions": "^2.6.1",
"@types/redux-logger": "^3.0.8",
"@types/resolve": "^1.20.1",
"@types/rrule": "^2.2.9",
"@types/seedrandom": ">=2.0.0 <4.0.0",
"@types/selenium-webdriver": "^4.1.5",
"@types/semver": "^7",
Expand All @@ -1197,7 +1191,6 @@
"@types/sinon": "^7.0.13",
"@types/source-map-support": "^0.5.3",
"@types/stats-lite": "^2.2.0",
"@types/strip-ansi": "^5.2.1",
"@types/styled-components": "^5.1.0",
"@types/supertest": "^2.0.5",
"@types/tapable": "^1.0.6",
Expand Down Expand Up @@ -1403,7 +1396,7 @@
"webpack-dev-server": "^4.9.3",
"webpack-merge": "^4.2.2",
"webpack-sources": "^1.4.1",
"xml-crypto": "^3.0.0",
"xml-crypto": "^3.0.1",
"xmlbuilder": "13.0.2",
"yargs": "^15.4.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//rxjs",
"//packages/core/base/core-base-browser-internal:npm_module_types",
"//packages/core/ui-settings/core-ui-settings-browser:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TYPES_DEPS = [
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//rxjs",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//elastic-apm-node",
"//packages/kbn-safer-lodash-set:npm_module_types",
"//packages/kbn-logging:npm_module_types",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/logging/core-logging-server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//rxjs",
"//packages/kbn-logging:npm_module_types",
"//packages/kbn-config-schema:npm_module_types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/semver",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//lodash",
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
"//packages/kbn-logging:npm_module_types",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-analytics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"@npm//moment",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//@types/node",
]

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TYPES_DEPS = [
"@npm//moment",
"@npm//tsd",
"@npm//@types/jest",
"@npm//@types/joi",
"@npm//joi",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/type-detect",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TYPES_DEPS = [
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/moment-timezone",
"@npm//moment-timezone",
"@npm//@types/node",
]

Expand Down
1 change: 0 additions & 1 deletion packages/kbn-server-http-tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ TYPES_DEPS = [
"@npm//moment",
"@npm//@types/hapi__hapi",
"@npm//@types/jest",
"@npm//@types/joi",
"@npm//@types/node",
"@npm//@types/uuid",
]
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test-jest-helpers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TYPES_DEPS = [
"@npm//@types/history",
"@npm//@types/jest",
"@npm//@types/jest-axe",
"@npm//@types/joi",
"@npm//joi",
"@npm//@types/lodash",
"@npm//@types/mustache",
"@npm//@types/normalize-path",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TYPES_DEPS = [
"@npm//@types/history",
"@npm//@types/jest",
"@npm//@types/js-yaml",
"@npm//@types/joi",
"@npm//joi",
"@npm//@types/lodash",
"@npm//@types/minimatch",
"@npm//@types/mustache",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export class OptionsListEmbeddableFactory

public isFieldCompatible = (dataControlField: DataControlField) => {
if (
(dataControlField.field.aggregatable && dataControlField.field.type === 'string') ||
dataControlField.field.type === 'boolean'
!dataControlField.field.spec.scripted &&
((dataControlField.field.aggregatable && dataControlField.field.type === 'string') ||
dataControlField.field.type === 'boolean')
) {
dataControlField.compatibleControlTypes.push(this.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboard.clearUnsavedChanges();
});

it('cannot create options list for scripted field', async () => {
expect(await dashboardControls.optionsListEditorGetCurrentDataView(true)).to.eql(
'animals-*'
);
await dashboardControls.openCreateControlFlyout();
await testSubjects.missingOrFail('field-picker-select-isDog');
await dashboardControls.controlEditorCancel(true);
});

after(async () => {
await dashboardControls.clearAllControls();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { hasUserCRUDPermission } from '.';

describe('privileges utils', () => {
describe('hasUserCRUDPermission', () => {
test("returns true when user's CRUD operations are null", () => {
const result = hasUserCRUDPermission(null);

expect(result).toBeTruthy();
});

test('returns false when user cannot CRUD', () => {
const result = hasUserCRUDPermission(false);

expect(result).toBeFalsy();
});

test('returns true when user can CRUD', () => {
const result = hasUserCRUDPermission(true);

expect(result).toBeTruthy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { Rule } from '../../../detections/containers/detection_engine/rules';
import * as i18n from '../../../detections/pages/detection_engine/rules/translations';
import * as i18nActions from '../../../detections/pages/detection_engine/rules/translations';
import { isMlRule } from '../../../../common/machine_learning/helpers';
import * as detectionI18n from '../../../detections/pages/detection_engine/translations';

Expand All @@ -29,21 +29,28 @@ export const canEditRuleWithActions = (
return true;
};

export const getToolTipContent = (
// typed as null not undefined as the initial state for this value is null.
export const hasUserCRUDPermission = (canUserCRUD: boolean | null): boolean =>
canUserCRUD != null ? canUserCRUD : true;

export const explainLackOfPermission = (
rule: Rule | null | undefined,
hasMlPermissions: boolean,
hasReadActionsPrivileges:
| boolean
| Readonly<{
[x: string]: boolean;
}>
}>,
canUserCRUD: boolean | null
): string | undefined => {
if (rule == null) {
return undefined;
} else if (isMlRule(rule.type) && !hasMlPermissions) {
return detectionI18n.ML_RULES_DISABLED_MESSAGE;
} else if (!canEditRuleWithActions(rule, hasReadActionsPrivileges)) {
return i18n.EDIT_RULE_SETTINGS_TOOLTIP;
return i18nActions.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES;
} else if (!hasUserCRUDPermission(canUserCRUD)) {
return i18nActions.LACK_OF_KIBANA_SECURITY_PRIVILEGES;
} else {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useBoolState } from '../../../../common/hooks/use_bool_state';
import { SINGLE_RULE_ACTIONS } from '../../../../common/lib/apm/user_actions';
import { useStartTransaction } from '../../../../common/lib/apm/use_start_transaction';
import { useKibana } from '../../../../common/lib/kibana';
import { getToolTipContent } from '../../../../common/utils/privileges';
import { canEditRuleWithActions } from '../../../../common/utils/privileges';
import type { Rule } from '../../../containers/detection_engine/rules';
import {
executeRulesBulkAction,
Expand Down Expand Up @@ -96,7 +96,11 @@ const RuleActionsOverflowComponent = ({
>
<EuiToolTip
position="left"
content={getToolTipContent(rule, true, canDuplicateRuleWithActions)}
content={
!canEditRuleWithActions(rule, canDuplicateRuleWithActions)
? i18nActions.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined
}
>
<>{i18nActions.DUPLICATE_RULE}</>
</EuiToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ export const useBulkActions = ({
disabled:
missingActionPrivileges || containsLoading || (!containsDisabled && !isAllSelected),
onClick: handleEnableAction,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand All @@ -342,7 +344,9 @@ export const useBulkActions = ({
'data-test-subj': 'duplicateRuleBulk',
disabled: isEditDisabled,
onClick: handleDuplicateAction,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand All @@ -366,7 +370,9 @@ export const useBulkActions = ({
'data-test-subj': 'addRuleActionsBulk',
disabled: !hasActionsPrivileges || isEditDisabled,
onClick: handleBulkEdit(BulkActionEditType.add_rule_actions),
toolTipContent: !hasActionsPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: !hasActionsPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand All @@ -376,7 +382,9 @@ export const useBulkActions = ({
'data-test-subj': 'setScheduleBulk',
disabled: isEditDisabled,
onClick: handleBulkEdit(BulkActionEditType.set_schedule),
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand All @@ -386,7 +394,9 @@ export const useBulkActions = ({
'data-test-subj': 'applyTimelineTemplateBulk',
disabled: isEditDisabled,
onClick: handleBulkEdit(BulkActionEditType.set_timeline),
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand All @@ -405,7 +415,9 @@ export const useBulkActions = ({
disabled:
missingActionPrivileges || containsLoading || (!containsEnabled && !isAllSelected),
onClick: handleDisableActions,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
icon: undefined,
},
Expand Down Expand Up @@ -439,7 +451,9 @@ export const useBulkActions = ({
'data-test-subj': 'addTagsBulkEditRule',
onClick: handleBulkEdit(BulkActionEditType.add_tags),
disabled: isEditDisabled,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
},
{
Expand All @@ -448,7 +462,9 @@ export const useBulkActions = ({
'data-test-subj': 'deleteTagsBulkEditRule',
onClick: handleBulkEdit(BulkActionEditType.delete_tags),
disabled: isEditDisabled,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
},
],
Expand All @@ -463,7 +479,9 @@ export const useBulkActions = ({
'data-test-subj': 'addIndexPatternsBulkEditRule',
onClick: handleBulkEdit(BulkActionEditType.add_index_patterns),
disabled: isEditDisabled,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
},
{
Expand All @@ -472,7 +490,9 @@ export const useBulkActions = ({
'data-test-subj': 'deleteIndexPatternsBulkEditRule',
onClick: handleBulkEdit(BulkActionEditType.delete_index_patterns),
disabled: isEditDisabled,
toolTipContent: missingActionPrivileges ? i18n.EDIT_RULE_SETTINGS_TOOLTIP : undefined,
toolTipContent: missingActionPrivileges
? i18n.LACK_OF_KIBANA_ACTIONS_FEATURE_PRIVILEGES
: undefined,
toolTipPosition: 'right',
},
],
Expand Down
Loading

0 comments on commit 21c379f

Please sign in to comment.