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] Carry over filter extra fields with in incomplete state #102509

Merged
merged 4 commits into from
Jun 22, 2021

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Jun 17, 2021

Summary

Fix #102202

This PR saves in the incomplete state the operation filters, and when the current operation conflicts get resolved, moves them within the newly created column.

The actual transition is a two step phase:

  • The user transition from a calculation to a simple operation
    • Internally an incompleteColumn is created and stored as the field type is conflicting with the new operation
  • The user solves the conflict via the Field select
    • This PR adds an extra parameter in the insertNewColumn here to know about the previous filters params

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@dej611 dej611 added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 Feature:Lens v7.14.0 auto-backport Deprecated - use backport:version if exact versions are needed labels Jun 17, 2021
@dej611 dej611 marked this pull request as ready for review June 18, 2021 08:45
@dej611 dej611 requested a review from a team June 18, 2021 08:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

if (referencedOperation.shiftable) {
column.timeShift = (previousColumn as ReferenceBasedIndexPatternColumn).timeShift;
}
return column;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is returning the column but also mutating it. We had issues with this kind of functions before - could we make this immutable so a new column with filter/timeshift is returned?

@@ -30,6 +32,11 @@ import { generateId } from '../../id_generator';
import { ReferenceBasedIndexPatternColumn } from './definitions/column_types';
import { FormulaIndexPatternColumn, regenerateLayerFromAst } from './definitions/formula';

interface ColumnFilters {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole PR is using "filters" as a name of the extra params passed around like this. While they are just filters for now, it's more about additional params - could we rename this to incompleteParams, ColumnParams and so on?

const incompleteColumn: {
operationType: OperationType;
filter?: unknown;
timeShift?: unknown;
Copy link
Contributor

@flash1293 flash1293 Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeScale should probably be treated in the same way (another reason for not calling it filters0

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once one nit is addressed

@@ -141,6 +151,24 @@ export function insertOrReplaceColumn(args: ColumnChange): IndexPatternLayer {
return insertNewColumn(args);
}

function ensureCompatibleFiltersAreMoved<T extends ColumnAdvancedParams>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ensureCompatibleParamsAreMoved

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.5MB 1.5MB +553.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dej611 dej611 merged commit 1d59abc into elastic:master Jun 22, 2021
@dej611 dej611 deleted the fix/102202 branch June 22, 2021 12:19
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 22, 2021
…ic#102509)

* 🐛 Carry over filter extra fields with in incomplete state

* 👌 Integrated feedback

* 👌 Integrated feedback

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 22, 2021
…) (#102899)

* 🐛 Carry over filter extra fields with in incomplete state

* 👌 Integrated feedback

* 👌 Integrated feedback

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Filters get lost when transitioning from a calculation to incomplete regular operation
4 participants