Skip to content

Commit

Permalink
Merge branch '7.12' into backport/7.12/pr-91638
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 25, 2021
2 parents f42fb22 + 97cdee6 commit ccdc725
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function isFieldFiltered(
const scriptedOrMissing =
!filterState.missing ||
field.type === '_source' ||
field.type === 'unknown_selected' ||
field.scripted ||
fieldCounts[field.name] > 0;
const needle = filterState.name ? filterState.name.toLowerCase() : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ describe('group_fields', function () {
]);
});

it('should filter fields by a given name', function () {
const fieldFilterState = { ...getDefaultFieldFilter(), ...{ name: 'curr' } };

const actual1 = groupFields(
fields as IndexPatternField[],
['customer_birth_date', 'currency', 'unknown'],
5,
fieldCounts,
fieldFilterState,
false
);
expect(actual1.selected.map((field) => field.name)).toEqual(['currency']);
});

it('excludes unmapped fields if showUnmappedFields set to false', function () {
const fieldFilterState = getDefaultFieldFilter();
const fieldsWithUnmappedField = [...fields];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ export function groupFields(
}
}
}
// add columns, that are not part of the index pattern, to be removeable
// add selected columns, that are not part of the index pattern, to be removeable
for (const column of columns) {
if (!result.selected.find((field) => field.name === column)) {
result.selected.push({ name: column, displayName: column } as IndexPatternField);
const tmpField = {
name: column,
displayName: column,
type: 'unknown_selected',
} as IndexPatternField;
if (
!result.selected.find((field) => field.name === column) &&
isFieldFiltered(tmpField, fieldFilterState, fieldCounts)
) {
result.selected.push(tmpField);
}
}
result.selected.sort((a, b) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { Ast } from '@kbn/interpreter/common';
import { i18n } from '@kbn/i18n';
import {
EuiEmptyPrompt,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiText,
EuiButtonEmpty,
EuiLink,
Expand Down Expand Up @@ -389,72 +389,84 @@ export const InnerVisualizationWrapper = ({

if (localState.configurationValidationError?.length) {
let showExtraErrors = null;
let showExtraErrorsAction = null;

if (localState.configurationValidationError.length > 1) {
if (localState.expandError) {
showExtraErrors = localState.configurationValidationError
.slice(1)
.map(({ longMessage }) => (
<EuiFlexItem
<p
key={longMessage}
className="eui-textBreakAll"
data-test-subj="configuration-failure-error"
>
{longMessage}
</EuiFlexItem>
</p>
));
} else {
showExtraErrors = (
<EuiFlexItem>
<EuiButtonEmpty
onClick={() => {
setLocalState((prevState: WorkspaceState) => ({
...prevState,
expandError: !prevState.expandError,
}));
}}
data-test-subj="configuration-failure-more-errors"
>
{i18n.translate('xpack.lens.editorFrame.configurationFailureMoreErrors', {
defaultMessage: ` +{errors} {errors, plural, one {error} other {errors}}`,
values: { errors: localState.configurationValidationError.length - 1 },
})}
</EuiButtonEmpty>
</EuiFlexItem>
showExtraErrorsAction = (
<EuiButtonEmpty
onClick={() => {
setLocalState((prevState: WorkspaceState) => ({
...prevState,
expandError: !prevState.expandError,
}));
}}
data-test-subj="configuration-failure-more-errors"
>
{i18n.translate('xpack.lens.editorFrame.configurationFailureMoreErrors', {
defaultMessage: ` +{errors} {errors, plural, one {error} other {errors}}`,
values: { errors: localState.configurationValidationError.length - 1 },
})}
</EuiButtonEmpty>
);
}
}

return (
<EuiFlexGroup
style={{ maxWidth: '100%' }}
direction="column"
alignItems="center"
data-test-subj="configuration-failure"
>
<EuiFlexGroup data-test-subj="configuration-failure">
<EuiFlexItem>
<EuiIcon type="alert" size="xl" color="danger" />
</EuiFlexItem>
<EuiFlexItem className="eui-textBreakAll" data-test-subj="configuration-failure-error">
{localState.configurationValidationError[0].longMessage}
<EuiEmptyPrompt
actions={showExtraErrorsAction}
body={
<>
<p className="eui-textBreakAll" data-test-subj="configuration-failure-error">
{localState.configurationValidationError[0].longMessage}
</p>

{showExtraErrors}
</>
}
iconColor="danger"
iconType="alert"
/>
</EuiFlexItem>
{showExtraErrors}
</EuiFlexGroup>
);
}

if (localState.expressionBuildError?.length) {
return (
<EuiFlexGroup style={{ maxWidth: '100%' }} direction="column" alignItems="center">
<EuiFlexGroup>
<EuiFlexItem>
<EuiIcon type="alert" size="xl" color="danger" />
</EuiFlexItem>
<EuiFlexItem data-test-subj="expression-failure">
<FormattedMessage
id="xpack.lens.editorFrame.expressionFailure"
defaultMessage="An error occurred in the expression"
<EuiEmptyPrompt
body={
<>
<p data-test-subj="expression-failure">
<FormattedMessage
id="xpack.lens.editorFrame.expressionFailure"
defaultMessage="An error occurred in the expression"
/>
</p>

<p>{localState.expressionBuildError[0].longMessage}</p>
</>
}
iconColor="danger"
iconType="alert"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>{localState.expressionBuildError[0].longMessage}</EuiFlexItem>
</EuiFlexGroup>
);
}
Expand All @@ -474,34 +486,43 @@ export const InnerVisualizationWrapper = ({
const visibleErrorMessage = getOriginalRequestErrorMessage(error) || errorMessage;

return (
<EuiFlexGroup style={{ maxWidth: '100%' }} direction="column" alignItems="center">
<EuiFlexGroup>
<EuiFlexItem>
<EuiIcon type="alert" size="xl" color="danger" />
</EuiFlexItem>
<EuiFlexItem data-test-subj="expression-failure">
<FormattedMessage
id="xpack.lens.editorFrame.dataFailure"
defaultMessage="An error occurred when loading data."
<EuiEmptyPrompt
actions={
visibleErrorMessage ? (
<EuiButtonEmpty
onClick={() => {
setLocalState((prevState: WorkspaceState) => ({
...prevState,
expandError: !prevState.expandError,
}));
}}
>
{i18n.translate('xpack.lens.editorFrame.expandRenderingErrorButton', {
defaultMessage: 'Show details of error',
})}
</EuiButtonEmpty>
) : null
}
body={
<>
<p data-test-subj="expression-failure">
<FormattedMessage
id="xpack.lens.editorFrame.dataFailure"
defaultMessage="An error occurred when loading data."
/>
</p>

{localState.expandError ? (
<p className="eui-textBreakAll">visibleErrorMessage</p>
) : null}
</>
}
iconColor="danger"
iconType="alert"
/>
</EuiFlexItem>
{visibleErrorMessage ? (
<EuiFlexItem className="eui-textBreakAll" grow={false}>
<EuiButtonEmpty
onClick={() => {
setLocalState((prevState: WorkspaceState) => ({
...prevState,
expandError: !prevState.expandError,
}));
}}
>
{i18n.translate('xpack.lens.editorFrame.expandRenderingErrorButton', {
defaultMessage: 'Show details of error',
})}
</EuiButtonEmpty>

{localState.expandError ? visibleErrorMessage : null}
</EuiFlexItem>
) : null}
</EuiFlexGroup>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
EuiIconTip,
EuiSelect,
EuiSpacer,
EuiSwitch,
Expand Down Expand Up @@ -57,6 +58,24 @@ const TOGGLE_OFF = i18n.translate('xpack.ml.splom.toggleOff', {

const sampleSizeOptions = [100, 1000, 10000].map((d) => ({ value: d, text: '' + d }));

interface OptionLabelWithIconTipProps {
label: string;
tooltip: string;
}

const OptionLabelWithIconTip: FC<OptionLabelWithIconTipProps> = ({ label, tooltip }) => (
<>
{label}
<EuiIconTip
content={tooltip}
iconProps={{
className: 'eui-alignTop',
}}
size="s"
/>
</>
);

export interface ScatterplotMatrixProps {
fields: string[];
index: string;
Expand Down Expand Up @@ -252,9 +271,16 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
label={i18n.translate('xpack.ml.splom.fieldSelectionLabel', {
defaultMessage: 'Fields',
})}
label={
<OptionLabelWithIconTip
label={i18n.translate('xpack.ml.splom.fieldSelectionLabel', {
defaultMessage: 'Fields',
})}
tooltip={i18n.translate('xpack.ml.splom.fieldSelectionInfoTooltip', {
defaultMessage: 'Pick fields to explore their relationships.',
})}
/>
}
display="rowCompressed"
fullWidth
>
Expand All @@ -276,9 +302,16 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
</EuiFlexItem>
<EuiFlexItem style={{ width: '200px' }} grow={false}>
<EuiFormRow
label={i18n.translate('xpack.ml.splom.sampleSizeLabel', {
defaultMessage: 'Sample size',
})}
label={
<OptionLabelWithIconTip
label={i18n.translate('xpack.ml.splom.sampleSizeLabel', {
defaultMessage: 'Sample size',
})}
tooltip={i18n.translate('xpack.ml.splom.sampleSizeInfoTooltip', {
defaultMessage: 'Amount of documents to display in the scatterplot matrix.',
})}
/>
}
display="rowCompressed"
fullWidth
>
Expand All @@ -292,9 +325,17 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
</EuiFlexItem>
<EuiFlexItem style={{ width: '120px' }} grow={false}>
<EuiFormRow
label={i18n.translate('xpack.ml.splom.randomScoringLabel', {
defaultMessage: 'Random scoring',
})}
label={
<OptionLabelWithIconTip
label={i18n.translate('xpack.ml.splom.randomScoringLabel', {
defaultMessage: 'Random scoring',
})}
tooltip={i18n.translate('xpack.ml.splom.randomScoringInfoTooltip', {
defaultMessage:
'Uses a function score query to get randomly selected documents as the sample.',
})}
/>
}
display="rowCompressed"
fullWidth
>
Expand All @@ -310,9 +351,16 @@ export const ScatterplotMatrix: FC<ScatterplotMatrixProps> = ({
{resultsField !== undefined && legendType === undefined && (
<EuiFlexItem style={{ width: '120px' }} grow={false}>
<EuiFormRow
label={i18n.translate('xpack.ml.splom.dynamicSizeLabel', {
defaultMessage: 'Dynamic size',
})}
label={
<OptionLabelWithIconTip
label={i18n.translate('xpack.ml.splom.dynamicSizeLabel', {
defaultMessage: 'Dynamic size',
})}
tooltip={i18n.translate('xpack.ml.splom.dynamicSizeInfoTooltip', {
defaultMessage: 'Scales the size of each point by its outlier score.',
})}
/>
}
display="rowCompressed"
fullWidth
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}
.body {
display: block;
height: 315px;
}
}
& > li.has-body.active {
Expand Down

0 comments on commit ccdc725

Please sign in to comment.