Skip to content

Commit

Permalink
Merge branch '7.9' into backport/7.9/pr-72086
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 27, 2020
2 parents 3a69a99 + 8ea0417 commit d20ef52
Show file tree
Hide file tree
Showing 21 changed files with 160 additions and 53 deletions.
3 changes: 1 addition & 2 deletions test/functional/apps/dashboard/embeddable_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export default function ({ getService, getPageObjects }) {
await dashboardExpect.vegaTextsDoNotExist(['5,000']);
};

// FLAKY: https://github.com/elastic/kibana/issues/46305
describe.skip('dashboard embeddable rendering', function describeIndexTests() {
describe('dashboard embeddable rendering', function describeIndexTests() {
before(async () => {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/public/state/selectors/workpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export function getRenderedWorkpad(state: State) {
const workpad = getWorkpad(state);

// eslint-disable-next-line no-unused-vars
const { pages, ...rest } = workpad;
const { pages, variables, ...rest } = workpad;

return {
pages: renderedPages,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/shareable_runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ There are a number of options for the build script:

### Prerequisite

Before testing or running this PR locally, you **must** run `node scripts/runtime` from `/canvas` _after_ `yarn kbn bootstrap` and _before_ starting Kibana. It is only built automatically when Kibana is built to avoid slowing down other development activities.
Before testing or running this PR locally, you **must** run `node scripts/shareable_runtime` from `/canvas` _after_ `yarn kbn bootstrap` and _before_ starting Kibana. It is only built automatically when Kibana is built to avoid slowing down other development activities.

### Webpack Dev Server

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/shareable_runtime/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module.exports = {
options: {
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
},
sideEffects: false,
},
{
test: /\.tsx?$/,
Expand Down Expand Up @@ -92,6 +91,7 @@ module.exports = {
},
},
],
sideEffects: true,
},
{
test: /\.module\.s(a|c)ss$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4203,6 +4203,7 @@
"FAILED",
"STOPPING",
"STOPPED",
"DEGRADED",
"DATA_DUMP",
"ACKNOWLEDGED",
"UNKNOWN"
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface NewAgentEvent {
| 'FAILED'
| 'STOPPING'
| 'STOPPED'
| 'DEGRADED'
// Action results
| 'DATA_DUMP'
// Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ export const StepDefinePackageConfig: React.FunctionComponent<{
.sort();

updatePackageConfig({
name: `${packageInfo.name}-${
dsWithMatchingNames.length ? dsWithMatchingNames[dsWithMatchingNames.length - 1] + 1 : 1
}`,
name:
// For Endpoint packages, the user must fill in the name, thus we don't attempt to generate
// a default one here.
// FIXME: Improve package configs name uniqueness - https://github.com/elastic/kibana/issues/72948
packageInfo.name !== 'endpoint'
? `${packageInfo.name}-${
dsWithMatchingNames.length
? dsWithMatchingNames[dsWithMatchingNames.length - 1] + 1
: 1
}`
: '',
package: {
name: packageInfo.name,
title: packageInfo.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export const SUBTYPE_LABEL: { [key in AgentEvent['subtype']]: JSX.Element } = {
/>
</EuiBadge>
),
DEGRADED: (
<EuiBadge color="hollow">
<FormattedMessage
id="xpack.ingestManager.agentEventSubtype.degradedLabel"
defaultMessage="Degraded"
/>
</EuiBadge>
),
DATA_DUMP: (
<EuiBadge color="hollow">
<FormattedMessage
Expand Down
17 changes: 10 additions & 7 deletions x-pack/plugins/ingest_manager/server/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ const AgentEventBase = {
]),
subtype: schema.oneOf([
// State
schema.literal('RUNNING'),
schema.literal('STARTING'),
schema.literal('IN_PROGRESS'),
schema.literal('CONFIG'),
schema.literal('FAILED'),
schema.literal('STOPPING'),
schema.literal('STOPPED'),
schema.oneOf([
schema.literal('RUNNING'),
schema.literal('STARTING'),
schema.literal('IN_PROGRESS'),
schema.literal('CONFIG'),
schema.literal('FAILED'),
schema.literal('STOPPING'),
schema.literal('STOPPED'),
schema.literal('DEGRADED'),
]),
// Action results
schema.literal('DATA_DUMP'),
// Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,17 @@ export const EXCEPTION_OPERATORS: OperatorOption[] = [
isInListOperator,
isNotInListOperator,
];

export const EXCEPTION_OPERATORS_SANS_LISTS: OperatorOption[] = [
isOperator,
isNotOperator,
isOneOfOperator,
isNotOneOfOperator,
existsOperator,
doesNotExistOperator,
];

export const EXCEPTION_OPERATORS_ONLY_LISTS: OperatorOption[] = [
isInListOperator,
isNotInListOperator,
];
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ export const AddExceptionModal = memo(function AddExceptionModal({
signalIndexName,
]);

const isSubmitButtonDisabled = useCallback(
() => fetchOrCreateListError || exceptionItemsToAdd.length === 0,
const isSubmitButtonDisabled = useMemo(
() => fetchOrCreateListError || exceptionItemsToAdd.every((item) => item.entries.length === 0),
[fetchOrCreateListError, exceptionItemsToAdd]
);

Expand Down Expand Up @@ -377,7 +377,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
<EuiButton
onClick={onAddExceptionConfirm}
isLoading={addExceptionIsLoading}
isDisabled={isSubmitButtonDisabled()}
isDisabled={isSubmitButtonDisabled}
fill
>
{i18n.ADD_EXCEPTION}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('BuilderEntryItem', () => {
title: 'logstash-*',
fields,
}}
showLabel={false}
showLabel={true}
listType="detection"
addNested={false}
onChange={jest.fn()}
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('BuilderEntryItem', () => {
title: 'logstash-*',
fields,
}}
showLabel={false}
showLabel={true}
listType="detection"
addNested={false}
onChange={jest.fn()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
getEntryOnMatchAnyChange,
getEntryOnListChange,
} from './helpers';
import { EXCEPTION_OPERATORS_ONLY_LISTS } from '../../autocomplete/operators';

interface EntryItemProps {
entry: FormattedBuilderEntry;
Expand All @@ -35,6 +36,7 @@ interface EntryItemProps {
listType: ExceptionListType;
addNested: boolean;
onChange: (arg: BuilderEntry, i: number) => void;
onlyShowListOperators?: boolean;
}

export const BuilderEntryItem: React.FC<EntryItemProps> = ({
Expand All @@ -44,6 +46,7 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
addNested,
showLabel,
onChange,
onlyShowListOperators = false,
}): JSX.Element => {
const handleFieldChange = useCallback(
([newField]: IFieldType[]): void => {
Expand Down Expand Up @@ -124,11 +127,14 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
);

const renderOperatorInput = (isFirst: boolean): JSX.Element => {
const operatorOptions = getOperatorOptions(
entry,
listType,
entry.field != null && entry.field.type === 'boolean'
);
const operatorOptions = onlyShowListOperators
? EXCEPTION_OPERATORS_ONLY_LISTS
: getOperatorOptions(
entry,
listType,
entry.field != null && entry.field.type === 'boolean',
isFirst
);
const comboBox = (
<OperatorComponent
placeholder={i18n.EXCEPTION_OPERATOR_PLACEHOLDER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface ExceptionListItemProps {
addNested: boolean;
onDeleteExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
onChangeExceptionItem: (item: ExceptionsBuilderExceptionItem, index: number) => void;
onlyShowListOperators?: boolean;
}

export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
Expand All @@ -58,6 +59,7 @@ export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
andLogicIncluded,
onDeleteExceptionItem,
onChangeExceptionItem,
onlyShowListOperators = false,
}) => {
const handleEntryChange = useCallback(
(entry: BuilderEntry, entryIndex: number): void => {
Expand Down Expand Up @@ -169,6 +171,7 @@ export const ExceptionListItemComponent = React.memo<ExceptionListItemProps>(
exceptionItemIndex === 0 && index === 0 && item.nested !== 'child'
}
onChange={handleEntryChange}
onlyShowListOperators={onlyShowListOperators}
/>
</EuiFlexItem>
{getDeleteButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,33 @@ import { getEntryExistsMock } from '../../../../../../lists/common/schemas/types
import { getExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/exception_list_item_schema.mock';
import { getListResponseMock } from '../../../../../../lists/common/schemas/response/list_schema.mock';
import {
isOperator,
isOneOfOperator,
isNotOperator,
isNotOneOfOperator,
existsOperator,
doesNotExistOperator,
isInListOperator,
EXCEPTION_OPERATORS,
EXCEPTION_OPERATORS_SANS_LISTS,
existsOperator,
isInListOperator,
isNotOneOfOperator,
isNotOperator,
isOneOfOperator,
isOperator,
} from '../../autocomplete/operators';
import { FormattedBuilderEntry, BuilderEntry, ExceptionsBuilderExceptionItem } from '../types';
import { IIndexPattern, IFieldType } from '../../../../../../../../src/plugins/data/common';
import { EntryNested, Entry } from '../../../../lists_plugin_deps';
import { BuilderEntry, ExceptionsBuilderExceptionItem, FormattedBuilderEntry } from '../types';
import { IFieldType, IIndexPattern } from '../../../../../../../../src/plugins/data/common';
import { Entry, EntryNested } from '../../../../lists_plugin_deps';

import {
getFilteredIndexPatterns,
getFormattedBuilderEntry,
isEntryNested,
getFormattedBuilderEntries,
getUpdatedEntriesOnDelete,
getEntryFromOperator,
getOperatorOptions,
getEntryOnFieldChange,
getEntryOnOperatorChange,
getEntryOnMatchChange,
getEntryOnMatchAnyChange,
getEntryOnListChange,
getEntryOnMatchAnyChange,
getEntryOnMatchChange,
getEntryOnOperatorChange,
getFilteredIndexPatterns,
getFormattedBuilderEntries,
getFormattedBuilderEntry,
getOperatorOptions,
getUpdatedEntriesOnDelete,
isEntryNested,
} from './helpers';
import { OperatorOption } from '../../autocomplete/types';

Expand Down Expand Up @@ -672,6 +673,18 @@ describe('Exception builder helpers', () => {
const expected: OperatorOption[] = [isOperator, existsOperator];
expect(output).toEqual(expected);
});

test('it returns list operators if specified to', () => {
const payloadItem: FormattedBuilderEntry = getMockBuilderEntry();
const output = getOperatorOptions(payloadItem, 'detection', false, true);
expect(output).toEqual(EXCEPTION_OPERATORS);
});

test('it does not return list operators if specified not to', () => {
const payloadItem: FormattedBuilderEntry = getMockBuilderEntry();
const output = getOperatorOptions(payloadItem, 'detection', false, false);
expect(output).toEqual(EXCEPTION_OPERATORS_SANS_LISTS);
});
});

describe('#getEntryOnFieldChange', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
existsOperator,
isOneOfOperator,
EXCEPTION_OPERATORS,
EXCEPTION_OPERATORS_SANS_LISTS,
} from '../../autocomplete/operators';
import { OperatorOption } from '../../autocomplete/types';
import {
Expand All @@ -40,7 +41,6 @@ import { getEntryValue, getExceptionOperatorSelect } from '../helpers';
*
* @param patterns IIndexPattern containing available fields on rule index
* @param item exception item entry
* @param addNested boolean noting whether or not UI is currently
* set to add a nested field
*/
export const getFilteredIndexPatterns = (
Expand Down Expand Up @@ -295,12 +295,14 @@ export const getEntryFromOperator = (
*
* @param item
* @param listType
*
* @param isBoolean
* @param includeValueListOperators whether or not to include the 'is in list' and 'is not in list' operators
*/
export const getOperatorOptions = (
item: FormattedBuilderEntry,
listType: ExceptionListType,
isBoolean: boolean
isBoolean: boolean,
includeValueListOperators = true
): OperatorOption[] => {
if (item.nested === 'parent' || item.field == null) {
return [isOperator];
Expand All @@ -309,7 +311,11 @@ export const getOperatorOptions = (
} else if (item.nested != null && listType === 'detection') {
return isBoolean ? [isOperator, existsOperator] : [isOperator, isOneOfOperator, existsOperator];
} else {
return isBoolean ? [isOperator, existsOperator] : EXCEPTION_OPERATORS;
return isBoolean
? [isOperator, existsOperator]
: includeValueListOperators
? EXCEPTION_OPERATORS
: EXCEPTION_OPERATORS_SANS_LISTS;
}
};

Expand Down Expand Up @@ -547,3 +553,6 @@ export const getDefaultNestedEmptyEntry = (): EmptyNestedEntry => ({
type: OperatorTypeEnum.NESTED,
entries: [],
});

export const containsValueListEntry = (items: ExceptionsBuilderExceptionItem[]): boolean =>
items.some((item) => item.entries.some((entry) => entry.type === OperatorTypeEnum.LIST));
Loading

0 comments on commit d20ef52

Please sign in to comment.