-
Notifications
You must be signed in to change notification settings - Fork 148
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
🔮 [HADXVI-53] Browser SDK extension search bar improvement #2771
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2771 +/- ##
==========================================
- Coverage 93.61% 93.04% -0.58%
==========================================
Files 243 244 +1
Lines 7098 7161 +63
Branches 1583 1598 +15
==========================================
+ Hits 6645 6663 +18
- Misses 453 498 +45 ☔ View full report in Codecov by Sentry. |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
@@ -75,18 +75,42 @@ function filterOutdatedVersions(events: SdkEvent[]): SdkEvent[] { | |||
|
|||
function parseQuery(query: string) { | |||
const queryParts = query | |||
.split(' ') | |||
.split(/(?<!\\)\s/gm) // Hack it to escape whitespace with backslashes |
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.
👏 praise: nice!
@@ -256,6 +259,7 @@ function JsonText({ | |||
menuItems = ( | |||
<> | |||
<CopyMenuItem value={descriptor.value}>Copy value</CopyMenuItem> | |||
<CopyMenuItem value={getSearchQuery(descriptor, columnPath)}>Copy search query</CopyMenuItem> |
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.
💭 thought: I don't think it makes sense to have this menu everywhere Json
is used (like, in the Info tab). What about moving this item in getMenuItemsForPath
function in eventRow.tsx
? This would also remove the need to have the columnPath
in Json
.
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 created the item with getCopyMenuItemsForPath
for copying search query, separating the two for the ease of understanding, because column.path and path might be too mixed up. wdyt?
@@ -75,18 +75,42 @@ function filterOutdatedVersions(events: SdkEvent[]): SdkEvent[] { | |||
|
|||
function parseQuery(query: string) { |
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.
💬 suggestion: it could be nice to have a few unit tests for that this 😄
Co-authored-by: Benoît <benoit.zugmeyer@datadoghq.com>
Co-authored-by: Benoît <benoit.zugmeyer@datadoghq.com>
return ( | ||
<Menu.Item | ||
onClick={() => { | ||
copy(JSON.stringify(value, null, 2)) | ||
// Remove the outer quotation marks from copied string |
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: this comment isn't accurate anymore
return ( | ||
<> | ||
{getMenuItemsForPath(fullPath)} | ||
{typeof value === 'string' ? getCopyMenuItemsForPath(column.path, value) : 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.
💬 suggestion: move this code to getMenuItemsForPath
. It could look like this:
function getMenuItemsForPath(path: string, value: unknown) {
const menuItems: React.ChildNode[] = []
const newColumn: EventListColumn = { type: 'field', path }
if (path && !includesColumn(columns, newColumn)) {
menuItems.push(
<Menu.Item
key="add-column"
onClick={() => {
onColumnsChange(addColumn(columns, newColumn))
}}
leftSection={<IconColumnInsertRight size={14} />}
>
Add column
</Menu.Item>
)
}
if (typeof value === "string") {
const searchTerm = String(value).replace(/ /g, '\\ ')
menuItems.push(
<CopyMenuItem value={`${path}:${searchTerm}`}>Copy search query</CopyMenuItem>
)
}
return <>{menuItems}</>
}
Motivation
The search bar living in the event tab has only minimal support now. We want to improve it for a better user experience. This PR is an experiment on one of the approaches.
Changes
Testing
I have gone over the contributing documentation.