Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Provide single-value functions to show the "Last" value of some field #83437

Merged
merged 34 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e2354f5
feat: last value sketch
mbondyra Nov 16, 2020
6a6dd4e
feat: rollup indices
mbondyra Nov 17, 2020
f807858
added disabledStatus
mbondyra Nov 18, 2020
4555d51
update old tests
mbondyra Nov 18, 2020
2e3708f
tests added
mbondyra Nov 18, 2020
1f7b713
Merge branch 'master' into lens/last_value
kibanamachine Nov 18, 2020
df8c5ee
fix i18n message
mbondyra Nov 18, 2020
0c14e4c
cr
mbondyra Nov 20, 2020
dba38a5
(experimental) don't add icon
mbondyra Nov 20, 2020
1357868
fix transferable
mbondyra Nov 23, 2020
b6f3be9
Merge branch 'master' into lens/last_value
kibanamachine Nov 23, 2020
3c76ab4
error handling, tests in progress
mbondyra Nov 23, 2020
7ee756f
tests for hasInvalidReferences
mbondyra Nov 23, 2020
3f1991e
change name
mbondyra Nov 23, 2020
de88213
correct displayName
mbondyra Nov 23, 2020
a4b76d6
test corrected last value
mbondyra Nov 23, 2020
86ee016
fix tests and types
mbondyra Nov 24, 2020
3455a7d
no need to make a function obligatory
mbondyra Nov 24, 2020
b54c73d
hasInvalidreferenced not necessary
mbondyra Nov 24, 2020
8b90db7
eslint
mbondyra Nov 24, 2020
71e8264
addded warnings for pie and xy
mbondyra Nov 24, 2020
3e4b5f7
Update x-pack/plugins/lens/public/indexpattern_datasource/dimension_p…
mbondyra Nov 24, 2020
b3218a6
Merge branch 'master' into lens/last_value
kibanamachine Nov 25, 2020
5be70e4
Merge branch 'lens/accessibility-suggestions-name-focus' into lens/la…
mbondyra Nov 26, 2020
2f844b8
refactor hasInvalidReferences to getErrorMessage
mbondyra Nov 26, 2020
85f3503
ts
mbondyra Nov 26, 2020
f79cafa
Merge branch 'master' into lens/last_value
kibanamachine Nov 30, 2020
808bc29
copy change to more human
mbondyra Nov 30, 2020
8f1ea88
Merge commit '67564b9776abd608434c95375968598bfa082849' into lens/las…
mbondyra Dec 1, 2020
15ba028
design changes
mbondyra Dec 1, 2020
b42d0c5
designs
mbondyra Dec 1, 2020
af5f00e
design
mbondyra Dec 2, 2020
f84c9b5
remove sortOrder
mbondyra Dec 2, 2020
51e0830
Merge commit 'c73de2677337e4054954c068744f8b29ab3ce29c' into lens/las…
mbondyra Dec 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
column-gap: $euiSizeXL;
}

.lnsIndexPatternDimensionEditor__operation .euiListGroupItem__label {
mbondyra marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
}

.lnsIndexPatternDimensionEditor__operation > button {
padding-top: 0;
padding-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
EuiSpacer,
EuiListGroupItemProps,
EuiFormLabel,
EuiFlexGroup,
EuiFlexItem,
EuiToolTip,
EuiIcon,
} from '@elastic/eui';
import { IndexPatternDimensionEditorProps } from './dimension_panel';
import { OperationSupportMatrix } from './operation_support';
Expand Down Expand Up @@ -122,6 +126,9 @@ export function DimensionEditor(props: DimensionEditorProps) {
definition.input === 'field' &&
fieldByOperation[operationType]?.has(selectedColumn.sourceField)) ||
(selectedColumn && !hasField(selectedColumn) && definition.input !== 'field'),
disabledStatus:
definition.getDisabledStatus &&
definition.getDisabledStatus(state.indexPatterns[state.currentIndexPatternId]),
};
});

Expand All @@ -135,7 +142,7 @@ export function DimensionEditor(props: DimensionEditorProps) {
);

const sideNavItems: EuiListGroupItemProps[] = operationsWithCompatibility.map(
({ operationType, compatibleWithCurrentField }) => {
({ operationType, compatibleWithCurrentField, disabledStatus }) => {
const isActive = Boolean(
incompatibleSelectedOperationType === operationType ||
(!incompatibleSelectedOperationType &&
Expand All @@ -151,7 +158,18 @@ export function DimensionEditor(props: DimensionEditorProps) {
}

let label: EuiListGroupItemProps['label'] = operationPanels[operationType].displayName;
if (isActive) {
if (disabledStatus) {
label = (
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem>{operationPanels[operationType].displayName}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip position="top" content={disabledStatus}>
<EuiIcon type="questionInCircle" size="m" />
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
);
} else if (isActive) {
label = <strong>{operationPanels[operationType].displayName}</strong>;
}

Expand All @@ -161,6 +179,7 @@ export function DimensionEditor(props: DimensionEditorProps) {
color,
isActive,
size: 's',
isDisabled: !!disabledStatus,
className: 'lnsIndexPatternDimensionEditor__operation',
'data-test-subj': `lns-indexPatternDimension-${operationType}${
compatibleWithCurrentField ? '' : ' incompatible'
Expand Down Expand Up @@ -220,7 +239,6 @@ export function DimensionEditor(props: DimensionEditorProps) {
? currentIndexPattern.getFieldByName(selectedColumn.sourceField)
: undefined,
});

setState(mergeLayer({ state, layerId, newLayer }));
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,12 +975,12 @@ describe('IndexPatternDimensionEditorPanel', () => {
expect(items.map(({ label }: { label: React.ReactNode }) => label)).toEqual([
'Average',
'Count',
'Last value',
'Maximum',
'Median',
'Minimum',
'Sum',
'Unique count',
'\u00a0',
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from './metrics';
import { dateHistogramOperation, DateHistogramIndexPatternColumn } from './date_histogram';
import { countOperation, CountIndexPatternColumn } from './count';
import { lastValueOperation, LastValueIndexPatternColumn } from './last_value';
import { StateSetter, OperationMetadata } from '../../../types';
import { BaseIndexPatternColumn } from './column_types';
import { IndexPatternPrivateState, IndexPattern, IndexPatternField } from '../../types';
Expand All @@ -46,7 +47,8 @@ export type IndexPatternColumn =
| CardinalityIndexPatternColumn
| SumIndexPatternColumn
| MedianIndexPatternColumn
| CountIndexPatternColumn;
| CountIndexPatternColumn
| LastValueIndexPatternColumn;

export type FieldBasedIndexPatternColumn = Extract<IndexPatternColumn, { sourceField: string }>;

Expand All @@ -63,6 +65,7 @@ const internalOperationDefinitions = [
cardinalityOperation,
sumOperation,
medianOperation,
lastValueOperation,
countOperation,
rangeOperation,
];
Expand All @@ -73,6 +76,7 @@ export { filtersOperation } from './filters';
export { dateHistogramOperation } from './date_histogram';
export { minOperation, averageOperation, sumOperation, maxOperation } from './metrics';
export { countOperation } from './count';
export { lastValueOperation } from './last_value';

/**
* Properties passed to the operation-specific part of the popover editor
Expand Down Expand Up @@ -135,6 +139,12 @@ interface BaseOperationDefinitionProps<C extends BaseIndexPatternColumn> {
* present on the new index pattern.
*/
transfer?: (column: C, newIndexPattern: IndexPattern) => C;
/**
* if there is some reason to display the operation in the operations list
* but disable it from usage, this function returns the string describing
* the status. Otherwise it returns undefined
*/
getDisabledStatus?: (indexPattern: IndexPattern) => string | undefined;
}

interface BaseBuildColumnArgs {
Expand Down
Loading