-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Split up dimension panel code #80423
[Lens] Split up dimension panel code #80423
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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,
];
@@ -91,25 +90,29 @@ export function changeColumn<C extends IndexPatternColumn>({ | |||
updatedColumn.label = oldColumn.label; | |||
} | |||
|
|||
const layer = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used below with the spread operator: maybe it can be saved here?
const layer = state.layers[layerId];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
layer
object instead ofcolumns
. This lets us use different parts of the layer in the future.dimension_panel
into three files:a.
dimension_panel
keeps only the UI components, and only UI testsb.
droppable
deals with only dragging and dropping logic, including what happens on dropc.
operation_support
is 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