Skip to content

Commit

Permalink
Merge branch '7.6' into scripted-metric-count
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Feb 24, 2020
2 parents afeaf31 + caee69a commit e305bec
Show file tree
Hide file tree
Showing 26 changed files with 179 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"leaflet.heat": "0.2.0",
"less": "^2.7.3",
"less-loader": "5.0.0",
"lodash": "npm:@elastic/lodash@3.10.1-kibana3",
"lodash": "npm:@elastic/lodash@3.10.1-kibana4",
"lodash.clonedeep": "^4.5.0",
"lru-cache": "4.1.5",
"markdown-it": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@babel/runtime": "^7.5.5",
"@kbn/i18n": "1.0.0",
"lodash": "npm:@elastic/lodash@3.10.1-kibana3",
"lodash": "npm:@elastic/lodash@3.10.1-kibana4",
"lodash.clone": "^4.5.0",
"uuid": "3.3.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"classnames": "2.2.6",
"focus-trap-react": "^3.1.1",
"lodash": "npm:@elastic/lodash@3.10.1-kibana3",
"lodash": "npm:@elastic/lodash@3.10.1-kibana4",
"prop-types": "15.6.0",
"react": "^16.12.0",
"react-ace": "^5.9.0",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/dev/i18n/extract_default_translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export async function matchEntriesWithExctractors(inputPath, options = {}) {
const ignore = [
'**/node_modules/**',
'**/__tests__/**',
'**/dist/**',
'**/target/**',
'**/vendor/**',
'**/*.test.{js,jsx,ts,tsx}',
'**/*.d.ts',
].concat(additionalIgnore);
Expand Down
3 changes: 2 additions & 1 deletion src/dev/i18n/serializers/__snapshots__/json.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dev/i18n/serializers/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export const serializeToJson: Serializer = (messages, formats = i18n.formats) =>
}
}

return JSON.stringify(resultJsonObject, undefined, 2);
return JSON.stringify(resultJsonObject, undefined, 2).concat('\n');
};
1 change: 0 additions & 1 deletion src/plugins/data/common/field_formats/converters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

export { UrlFormat } from './url';
export { BytesFormat } from './bytes';
export { DateFormat } from './date_server';
export { DateNanosFormat } from './date_nanos';
export { RelativeDateFormat } from './relative_date';
export { DurationFormat } from './duration';
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from './timefilter/types';
export * from './query/types';
export * from './kbn_field_types/types';
export * from './index_patterns/types';
export { TextContextTypeConvert } from './field_formats/types';
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@

import { memoize, noop } from 'lodash';
import moment from 'moment';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
import {
FieldFormat,
KBN_FIELD_TYPES,
TextContextTypeConvert,
FIELD_FORMAT_IDS,
} from '../../../common';

export class DateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DATE;
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/data/public/field_formats/converters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { DateFormat } from './date';
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
BoolFormat,
BytesFormat,
ColorFormat,
DateFormat,
DateNanosFormat,
DurationFormat,
IpFormat,
Expand All @@ -38,6 +37,8 @@ import {
UrlFormat,
} from '../../common/';

import { DateFormat } from '../field_formats/converters';

export class FieldFormatsService {
private readonly fieldFormats: FieldFormatRegisty = new FieldFormatRegisty();

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export {
TimeRange,
} from '../common';

export { DateFormat } from './field_formats/converters';

/**
* Static code to be shared externally
* @public
Expand All @@ -68,7 +70,6 @@ export {
BoolFormat,
BytesFormat,
ColorFormat,
DateFormat,
DateNanosFormat,
DEFAULT_CONVERTER_COLOR,
DurationFormat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

import { memoize, noop } from 'lodash';
import moment from 'moment-timezone';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat, IFieldFormatMetaParams } from '../field_format';
import { TextContextTypeConvert, FIELD_FORMAT_IDS } from '../types';

import {
FieldFormat,
KBN_FIELD_TYPES,
TextContextTypeConvert,
FIELD_FORMAT_IDS,
IFieldFormatMetaParams,
} from '../../../common';

export class DateFormat extends FieldFormat {
static id = FIELD_FORMAT_IDS.DATE;
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/data/server/field_formats/converters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { DateFormat } from './date_server';
3 changes: 2 additions & 1 deletion src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export {
BoolFormat,
BytesFormat,
ColorFormat,
DateFormat,
DateNanosFormat,
DEFAULT_CONVERTER_COLOR,
DurationFormat,
Expand All @@ -94,4 +93,6 @@ export {
getKbnTypeNames,
} from '../common';

export { DateFormat } from './field_formats/converters';

export { DataServerPlugin as Plugin, DataPluginSetup as PluginSetup };
38 changes: 35 additions & 3 deletions x-pack/legacy/plugins/canvas/public/lib/workpad_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ import {
} from '../../common/lib/constants';
import { fetch } from '../../common/lib/fetch';
import { getCoreStart } from '../legacy';
/*
Remove any top level keys from the workpad which will be rejected by validation
*/
const validKeys = [
'@created',
'@timestamp',
'assets',
'colors',
'css',
'height',
'id',
'isWriteable',
'name',
'page',
'pages',
'width',
];

const sanitizeWorkpad = function(workpad) {
const workpadKeys = Object.keys(workpad);

for (const key of workpadKeys) {
if (!validKeys.includes(key)) {
delete workpad[key];
}
}

return workpad;
};

const getApiPath = function() {
const basePath = getCoreStart().http.basePath.get();
Expand All @@ -29,7 +58,10 @@ const getApiPathAssets = function() {
};

export function create(workpad) {
return fetch.post(getApiPath(), { ...workpad, assets: workpad.assets || {} });
return fetch.post(getApiPath(), {
...sanitizeWorkpad({ ...workpad }),
assets: workpad.assets || {},
});
}

export function get(workpadId) {
Expand All @@ -41,11 +73,11 @@ export function get(workpadId) {

// TODO: I think this function is never used. Look into and remove the corresponding route as well
export function update(id, workpad) {
return fetch.put(`${getApiPath()}/${id}`, workpad);
return fetch.put(`${getApiPath()}/${id}`, sanitizeWorkpad({ ...workpad }));
}

export function updateWorkpad(id, workpad) {
return fetch.put(`${getApiPathStructures()}/${id}`, workpad);
return fetch.put(`${getApiPathStructures()}/${id}`, sanitizeWorkpad({ ...workpad }));
}

export function updateAssets(id, workpadAssets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
}
}

&--toggle {
padding-left: 0;
&--multiField {
padding-left: $euiSizeL;
}

&--multiField {
padding-left: $euiSizeS;
&--toggle {
padding-left: 0;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCallOut, EuiCode } from '@elastic/eui';

export const ChainedMultifieldsWarning = () => (
<EuiCallOut
title={i18n.translate('xpack.idxMgmt.mappingsEditor.nestedMultifieldsDeprecatedCallOutTitle', {
defaultMessage: 'Chained multi-fields are deprecated',
})}
iconType="alert"
color="warning"
data-test-subj="nestedMultifieldsDeprecatedCallout"
>
<p>
<FormattedMessage
id="xpack.idxMgmt.mappingsEditor.nestedMultifieldsDeprecatedCallOutDescription"
defaultMessage="Defining chained multi-fields was deprecated in 7.3 and is now no longer supported. Consider flattening the chained fields blocks into a single level, or switching to {copyTo} if appropriate."
values={{
copyTo: <EuiCode>copy_to</EuiCode>,
}}
/>
</p>
</EuiCallOut>
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
CHILD_FIELD_INDENT_SIZE,
LEFT_PADDING_SIZE_FIELD_ITEM_WRAPPER,
} from '../../../constants';
import { ChainedMultifieldsWarning } from '../../chained_multifields_warning';
import { FieldsList } from './fields_list';
import { CreateField } from './create_field';
import { DeleteFieldProvider } from './delete_field_provider';
Expand All @@ -33,6 +34,7 @@ interface Props {
isHighlighted: boolean;
isDimmed: boolean;
isLastItem: boolean;
isChainedMultifieldsWarningVisible: boolean;
childFieldsArray: NormalizedField[];
maxNestedDepth: number;
addField(): void;
Expand All @@ -49,6 +51,7 @@ function FieldListItemComponent(
isDimmed,
isCreateFieldFormVisible,
areActionButtonsVisible,
isChainedMultifieldsWarningVisible,
isLastItem,
childFieldsArray,
maxNestedDepth,
Expand Down Expand Up @@ -274,6 +277,8 @@ function FieldListItemComponent(
</div>
</div>

{isExpanded && isChainedMultifieldsWarningVisible && <ChainedMultifieldsWarning />}

{Boolean(childFieldsArray.length) && isExpanded && (
<FieldsList fields={childFieldsArray} treeDepth={treeDepth + 1} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ export const FieldsListItemContainer = ({ fieldId, treeDepth, isLastItem }: Prop
const getField = (id: string) => byId[id];

const field: NormalizedField = getField(fieldId);
const parentField: NormalizedField | undefined =
field.parentId === undefined ? undefined : getField(field.parentId);
const { childFields } = field;
const isHighlighted = fieldToEdit === fieldId;
const isDimmed = status === 'editingField' && fieldToEdit !== fieldId;
const isCreateFieldFormVisible = status === 'creatingField' && fieldToAddFieldTo === fieldId;
const areActionButtonsVisible = status === 'idle';

let isChainedMultifieldsWarningVisible = false;
// We add "!Boolean(parentField?.hasMultiFields)" as we only want to show a callOut at the "root" of the nested multi-fields
if (field.hasMultiFields && !Boolean(parentField?.hasMultiFields)) {
isChainedMultifieldsWarningVisible = field
.childFields!.map(getField)
.some(childField => Boolean(childField?.hasMultiFields));
}

const childFieldsArray = useMemo(
() => (childFields !== undefined ? childFields.map(getField) : []),
[childFields]
Expand Down Expand Up @@ -64,6 +75,7 @@ export const FieldsListItemContainer = ({ fieldId, treeDepth, isLastItem }: Prop
isDimmed={isDimmed}
isCreateFieldFormVisible={isCreateFieldFormVisible}
areActionButtonsVisible={areActionButtonsVisible}
isChainedMultifieldsWarningVisible={isChainedMultifieldsWarningVisible}
isLastItem={isLastItem}
childFieldsArray={childFieldsArray}
maxNestedDepth={maxNestedDepth}
Expand Down
Loading

0 comments on commit e305bec

Please sign in to comment.