-
Notifications
You must be signed in to change notification settings - Fork 20
feat: (LogPanelTable) - sync the display fields and urlColumns between the logs panel and table #1189
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
Conversation
@L2D2Grafana that is much closer to what I expect, except at the [0:29-0:33] timestamp in your video, I would expect the panel in Explore to have the same columns as the panel in Logs Drilldown |
|
…n the logs panel and table
4df791f
to
7390701
Compare
onActivateSyncDisplayedFieldsWithUrlColumns = () => { | ||
const searchParams = new URLSearchParams(locationService.getLocation().search); | ||
const urlColumnsParam = searchParams.get('urlColumns'); | ||
const urlColumnsUrl = urlColumnsParam ? (JSON.parse(decodeURIComponent(urlColumnsParam)) as string[]) : null; |
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 seems like a good candidate to use https://github.com/grafana/logs-drilldown/blob/main/src/services/narrowing.ts that was introduced by @gtk-grafana to have more confidence on the actual type of stuff like user input, parsed json, etc.
We could add a narrowArray(type: string) or narrowStringArray().
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.
Updated! Interesting concept, I took a look they all kind of seem like type validations. I wonder about naming them isValidType or isEmpty.
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.
Definitely. Not a huge fan of the "narrow" prefix. ´assert[Type]´ could also be an option.
This is super cool! It makes a huge difference going back and forth between visualizations. |
src/services/narrowing.ts
Outdated
@@ -123,4 +123,19 @@ export function narrowFilterOperator(op: string): LabelFilterOp | NumericFilterO | |||
} | |||
} | |||
|
|||
export function narrowUrlParam(param: unknown): string[] | null { |
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.
Excellent! My only suggestion would be to make it generic so we can reuse this narrowing elsewhere, maybe like:
export function narrowUrlParam(param: unknown): string[] | null { | |
export function narrowStringsArray(param: unknown): string[] | null { |
I wanted to make it generic but I couldn't find an easy way.
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.
Yeah if there was a generic narrowing strategy it would be the most imported typescript npm package, I think this is something that needs a bit of hand-holding
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.
there is a unknownToStrings
method in narrowing already tho
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 tried unknownToStrings
but it's a slightly different use case where the param are passed in as strings and not an array so it never gets past
if (Array.isArray(a)) {
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.
Updated the func name.
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 can't decide whether we should not include the body in the table unless the user explicitly set it in the Logs view, but I think this is a huge improvement already. Other than making the narrowing generic, LGTM. Great work!
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.
☄️
Screen.Recording.2025-04-10.at.3.59.25.PM.mov