-
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] Fix indexpattern checks for missing references #88840
Changes from 2 commits
89f6cb4
ada6d2a
3732196
5281956
92cbb3b
9314ff7
f1e1d81
650469a
726f085
16c5e8a
c188539
ad51514
4ae7fb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -864,18 +864,24 @@ export function updateLayerIndexPattern( | |
* - All column references are valid | ||
* - All prerequisites are met | ||
*/ | ||
export function getErrorMessages(layer: IndexPatternLayer): string[] | undefined { | ||
const errors: string[] = []; | ||
Object.entries(layer.columns).forEach(([columnId, column]) => { | ||
// If we're transitioning to another operation, check for "new" incompleteColumns rather | ||
// than "old" saved operation on the layer | ||
const columnFinalRef = | ||
layer.incompleteColumns?.[columnId]?.operationType || column.operationType; | ||
const def = operationDefinitionMap[columnFinalRef]; | ||
if (def.getErrorMessage) { | ||
errors.push(...(def.getErrorMessage(layer, columnId) ?? [])); | ||
} | ||
}); | ||
export function getErrorMessages( | ||
layer: IndexPatternLayer, | ||
indexPattern?: IndexPattern | ||
): string[] | undefined { | ||
const errors: string[] = Object.entries(layer.columns) | ||
.flatMap(([columnId, column]) => { | ||
// If we're transitioning to another operation, check for "new" incompleteColumns rather | ||
// than "old" saved operation on the layer | ||
const columnFinalRef = | ||
layer.incompleteColumns?.[columnId]?.operationType || column.operationType; | ||
const def = operationDefinitionMap[columnFinalRef]; | ||
Comment on lines
+873
to
+877
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This chunk could cause a merge conflict with my other open PR, but it should be fine to merge as-is and then fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this is unchanged from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, checked your PR #88916 together with this one and it works as expected in all the various scenarios. So I'll skip to refactor this and approve your so the merge will provide a fix for both issues. |
||
|
||
if (def.getErrorMessage) { | ||
return def.getErrorMessage(layer, columnId, indexPattern); | ||
} | ||
}) | ||
// remove the undefined values | ||
.filter((v: string | undefined): v is string => v != null); | ||
|
||
return errors.length ? errors : undefined; | ||
} | ||
|
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.
So in terms of style, you're using
flatMap
and thenfilter
as opposed toforEach
- seems fine.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 was just hoping to use a simple
.filter(Boolean)
at the end, but Typescript wasn't happy about that., therefore I had to god for an explicit typeguard.