Skip to content

Commit

Permalink
Merge branch 'master' into runtime-links
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 26, 2021
2 parents 909a413 + b7d84ab commit 5b6bd1d
Show file tree
Hide file tree
Showing 38 changed files with 988 additions and 590 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"@cypress/webpack-preprocessor": "^5.5.0",
"@elastic/apm-rum": "^5.6.1",
"@elastic/apm-rum-react": "^1.2.5",
"@elastic/charts": "25.3.0",
"@elastic/charts": "26.0.0",
"@elastic/eslint-config-kibana": "link:packages/elastic-eslint-config-kibana",
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,14 @@ describe('AppLogic', () => {
expect(AppLogic.values.account.canCreatePersonalSources).toEqual(true);
});
});

describe('setOrgName', () => {
it('sets property', () => {
const NAME = 'new name';
mount(DEFAULT_INITIAL_APP_DATA);
AppLogic.actions.setOrgName(NAME);

expect(AppLogic.values.organization.name).toEqual(NAME);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface AppValues extends WorkplaceSearchInitialData {
interface AppActions {
initializeAppData(props: InitialAppData): InitialAppData;
setContext(isOrganization: boolean): boolean;
setOrgName(name: string): string;
setSourceRestriction(canCreatePersonalSources: boolean): boolean;
}

Expand All @@ -36,6 +37,7 @@ export const AppLogic = kea<MakeLogicType<AppValues, AppActions>>({
isFederatedAuth,
}),
setContext: (isOrganization) => isOrganization,
setOrgName: (name: string) => name,
setSourceRestriction: (canCreatePersonalSources: boolean) => canCreatePersonalSources,
},
reducers: {
Expand All @@ -61,6 +63,10 @@ export const AppLogic = kea<MakeLogicType<AppValues, AppActions>>({
emptyOrg,
{
initializeAppData: (_, { workplaceSearch }) => workplaceSearch?.organization || emptyOrg,
setOrgName: (state, name) => ({
...state,
name,
}),
},
],
account: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../../../shared/flash_messages';
import { HttpLogic } from '../../../shared/http';
import { KibanaLogic } from '../../../shared/kibana';
import { AppLogic } from '../../app_logic';
import { ORG_UPDATED_MESSAGE, OAUTH_APP_UPDATED_MESSAGE } from '../../constants';
import { ORG_SETTINGS_CONNECTORS_PATH } from '../../routes';
import { Connector } from '../../types';
Expand Down Expand Up @@ -150,6 +151,7 @@ export const SettingsLogic = kea<MakeLogicType<SettingsValues, SettingsActions>>
const response = await http.put(route, { body });
actions.setUpdatedName(response);
setSuccessMessage(ORG_UPDATED_MESSAGE);
AppLogic.actions.setOrgName(name);
} catch (e) {
flashAPIErrors(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,37 @@ export const getGenericRules = (genericMessageFields: string[]) => [
];

const createGenericRulesForField = (fieldName: string) => [
{
when: {
exists: ['event.dataset', 'log.level', fieldName, 'error.stack_trace.text'],
},
format: [
{
constant: '[',
},
{
field: 'event.dataset',
},
{
constant: '][',
},
{
field: 'log.level',
},
{
constant: '] ',
},
{
field: fieldName,
},
{
constant: '\n',
},
{
field: 'error.stack_trace.text',
},
],
},
{
when: {
exists: ['event.dataset', 'log.level', fieldName],
Expand All @@ -70,6 +101,31 @@ const createGenericRulesForField = (fieldName: string) => [
},
],
},
{
when: {
exists: ['log.level', fieldName, 'error.stack_trace.text'],
},
format: [
{
constant: '[',
},
{
field: 'log.level',
},
{
constant: '] ',
},
{
field: fieldName,
},
{
constant: '\n',
},
{
field: 'error.stack_trace.text',
},
],
},
{
when: {
exists: ['log.level', fieldName],
Expand All @@ -89,6 +145,22 @@ const createGenericRulesForField = (fieldName: string) => [
},
],
},
{
when: {
exists: [fieldName, 'error.stack_trace.text'],
},
format: [
{
field: fieldName,
},
{
constant: '\n',
},
{
field: 'error.stack_trace.text',
},
],
},
{
when: {
exists: [fieldName],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
* 2.0.
*/

import React, { useState } from 'react';
import React from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiFormRow,
EuiSelect,
EuiSwitch,
EuiSwitchEvent,
EuiSpacer,
EuiPopover,
EuiButtonEmpty,
EuiText,
EuiAccordion,
EuiIconTip,
} from '@elastic/eui';
import { AggFunctionsMapping } from '../../../../../../../../src/plugins/data/public';
Expand All @@ -24,7 +22,7 @@ import { updateColumnParam, isReferenced } from '../../layer_helpers';
import { DataType } from '../../../../types';
import { OperationDefinition } from '../index';
import { FieldBasedIndexPatternColumn } from '../column_types';
import { ValuesRangeInput } from './values_range_input';
import { ValuesInput } from './values_input';
import { getEsAggsSuffix, getInvalidFieldMessage } from '../helpers';
import type { IndexPatternLayer } from '../../../types';

Expand Down Expand Up @@ -193,8 +191,6 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
paramEditor: function ParamEditor({ layer, updateLayer, currentColumn, columnId, indexPattern }) {
const hasRestrictions = indexPattern.hasRestrictions;

const [popoverOpen, setPopoverOpen] = useState(false);

const SEPARATOR = '$$$';
function toValue(orderBy: TermsIndexPatternColumn['params']['orderBy']) {
if (orderBy.type === 'alphabetical') {
Expand Down Expand Up @@ -237,7 +233,7 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
display="columnCompressed"
fullWidth
>
<ValuesRangeInput
<ValuesInput
value={currentColumn.params.size}
onChange={(value) => {
updateLayer(
Expand All @@ -251,71 +247,6 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
}}
/>
</EuiFormRow>
{!hasRestrictions && (
<EuiText textAlign="right">
<EuiPopover
ownFocus
button={
<EuiButtonEmpty
size="xs"
iconType="arrowDown"
iconSide="right"
onClick={() => {
setPopoverOpen(!popoverOpen);
}}
>
{i18n.translate('xpack.lens.indexPattern.terms.advancedSettings', {
defaultMessage: 'Advanced',
})}
</EuiButtonEmpty>
}
isOpen={popoverOpen}
closePopover={() => {
setPopoverOpen(false);
}}
>
<EuiSwitch
label={i18n.translate('xpack.lens.indexPattern.terms.otherBucketDescription', {
defaultMessage: 'Group other values as "Other"',
})}
compressed
data-test-subj="indexPattern-terms-other-bucket"
checked={Boolean(currentColumn.params.otherBucket)}
onChange={(e: EuiSwitchEvent) =>
updateLayer(
updateColumnParam({
layer,
columnId,
paramName: 'otherBucket',
value: e.target.checked,
})
)
}
/>
<EuiSpacer size="m" />
<EuiSwitch
label={i18n.translate('xpack.lens.indexPattern.terms.missingBucketDescription', {
defaultMessage: 'Include documents without this field',
})}
compressed
disabled={!currentColumn.params.otherBucket}
data-test-subj="indexPattern-terms-missing-bucket"
checked={Boolean(currentColumn.params.missingBucket)}
onChange={(e: EuiSwitchEvent) =>
updateLayer(
updateColumnParam({
layer,
columnId,
paramName: 'missingBucket',
value: e.target.checked,
})
)
}
/>
</EuiPopover>
<EuiSpacer size="s" />
</EuiText>
)}
<EuiFormRow
label={
<>
Expand Down Expand Up @@ -415,6 +346,57 @@ export const termsOperation: OperationDefinition<TermsIndexPatternColumn, 'field
})}
/>
</EuiFormRow>
{!hasRestrictions && (
<>
<EuiSpacer size="s" />
<EuiAccordion
id="lnsTermsAdvanced"
buttonContent={i18n.translate('xpack.lens.indexPattern.terms.advancedSettings', {
defaultMessage: 'Advanced',
})}
>
<EuiSpacer size="m" />
<EuiSwitch
label={i18n.translate('xpack.lens.indexPattern.terms.otherBucketDescription', {
defaultMessage: 'Group other values as "Other"',
})}
compressed
data-test-subj="indexPattern-terms-other-bucket"
checked={Boolean(currentColumn.params.otherBucket)}
onChange={(e: EuiSwitchEvent) =>
updateLayer(
updateColumnParam({
layer,
columnId,
paramName: 'otherBucket',
value: e.target.checked,
})
)
}
/>
<EuiSpacer size="m" />
<EuiSwitch
label={i18n.translate('xpack.lens.indexPattern.terms.missingBucketDescription', {
defaultMessage: 'Include documents without this field',
})}
compressed
disabled={!currentColumn.params.otherBucket}
data-test-subj="indexPattern-terms-missing-bucket"
checked={Boolean(currentColumn.params.missingBucket)}
onChange={(e: EuiSwitchEvent) =>
updateLayer(
updateColumnParam({
layer,
columnId,
paramName: 'missingBucket',
value: e.target.checked,
})
)
}
/>
</EuiAccordion>
</>
)}
</>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { shallow, mount } from 'enzyme';
import { EuiRange, EuiSelect, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
import { EuiFieldNumber, EuiSelect, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
import type { IUiSettingsClient, SavedObjectsClientContract, HttpSetup } from 'kibana/public';
import type { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { dataPluginMock } from '../../../../../../../../src/plugins/data/public/mocks';
import { createMockedIndexPattern } from '../../../mocks';
import { ValuesRangeInput } from './values_range_input';
import { ValuesInput } from './values_input';
import type { TermsIndexPatternColumn } from '.';
import { termsOperation } from '../index';
import { IndexPattern, IndexPatternLayer } from '../../../types';
Expand Down Expand Up @@ -888,7 +888,7 @@ describe('terms', () => {
/>
);

expect(instance.find(EuiRange).prop('value')).toEqual('3');
expect(instance.find(EuiFieldNumber).prop('value')).toEqual('3');
});

it('should update state with the size value', () => {
Expand All @@ -904,7 +904,7 @@ describe('terms', () => {
);

act(() => {
instance.find(ValuesRangeInput).prop('onChange')!(7);
instance.find(ValuesInput).prop('onChange')!(7);
});

expect(updateLayerSpy).toHaveBeenCalledWith({
Expand Down
Loading

0 comments on commit 5b6bd1d

Please sign in to comment.