[Lens] Split up dimension panel code#80423
Conversation
|
Pinging @elastic/kibana-app (Team:KibanaApp) |
dej611
left a comment
There was a problem hiding this comment.
The code looks ok 👍 . Useful mergeLayer function, we should normalize the whole lens codebase with it!
I've left only some minor comments here and there.
|
|
||
| // Time to replace | ||
| props.setState({ | ||
| ...props.state, |
There was a problem hiding this comment.
nit: can you use mergeLayer here?
| if (supportedOperationsByField[operation.field]) { | ||
| supportedOperationsByField[operation.field]!.push(operation.operationType); | ||
| } else { | ||
| supportedOperationsByField[operation.field] = [operation.operationType]; | ||
| } | ||
|
|
||
| if (supportedFieldsByOperation[operation.operationType]) { | ||
| supportedFieldsByOperation[operation.operationType]!.push(operation.field); | ||
| } else { | ||
| supportedFieldsByOperation[operation.operationType] = [operation.field]; | ||
| } |
There was a problem hiding this comment.
nitpick: I always find a bit harder to read these conditionals that handles add or create in different ways. What about check the existence of the entry and just push?
supportedOperationsByField[operation.field] = supportedOperationsByField[operation.field] || [];
supportedOperationsByField[operation.field].push(operation.operationType);
supportedFieldsByOperation[operation.operationType] = supportedFieldsByOperation[operation.operationType] || [];
supportedFieldsByOperation[operation.operationType].push(operation.field);There was a problem hiding this comment.
I think I understand your point, but I'm not sure your proposal is more clear. I'm going to try using the spread operator, but maybe this is just as bad?
supportedFieldsByOperation[operation.operationType] = [
...(supportedFieldsByOperation[operation.operationType] ?? []),
operation.field,
];
| updatedColumn.label = oldColumn.label; | ||
| } | ||
|
|
||
| const layer = { |
There was a problem hiding this comment.
This is used below with the spread operator: maybe it can be saved here?
const layer = state.layers[layerId];
flash1293
left a comment
There was a problem hiding this comment.
LGTM, tested in Chrome and didn't notice any regressions.
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
History
To update your PR or re-run it, just comment with: |
* [Lens] Split up dimension panel code * Fix test failures * Style updates Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
There are three main changes in this PR, all refactorings that I found important as part of creating a reference-based editor for operations:
layerobject instead ofcolumns. This lets us use different parts of the layer in the future.dimension_panelinto three files:a.
dimension_panelkeeps only the UI components, and only UI testsb.
droppabledeals with only dragging and dropping logic, including what happens on dropc.
operation_supportis the function which is used to show functions + fields in the panels. Splitting it into a separate file so that it can be mocked.Checklist