-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Add ability to target headers by name #360
Conversation
2a7228f
to
2083453
Compare
const [isSidebarExpanded, setIsSidebarExpanded] = useLocalStorage( | ||
'isSidebarExpanded', | ||
true | ||
) |
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.
Not related to the feature, but added this as QoL to avoid closing the sidebar every time I did cmd+r to refresh the app.
export function createCorrelationRuleInstance( | ||
rule: CorrelationRule, | ||
idGenerator: Generator<number> | ||
idGenerator: IdGenerator |
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.
Cleaning up some "unsafe any" warnings
import { ChevronDownIcon, ThickCheckIcon } from '@radix-ui/themes' | ||
import { getStylesConfig, getThemeConfig } from './StyledReactSelect.styles' | ||
|
||
export function StyledReactSelect<Option>( |
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.
Far from ideal integration of ReactSelect into Radix, it doesn't support all the props Radix's select does and has static size, but this iteration I've focused on blending it into Radix styles.
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 🚢
export function StyledReactSelect<Option>( | ||
props: ComponentProps<typeof Select<Option>> | ||
) { | ||
const styles = useMemo(() => getStylesConfig<Option>(), []) |
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.
Can this be moved to just before the component function? useMemo
won't be needed then.
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 only reason is passing that generic type, was getting TS errors without it :(
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.
One minor comment regarding some options in the dropdown, otherwise it looks great! 🚀
const headers = filteredRequests.flatMap( | ||
(request) => request?.[extractFrom]?.headers ?? [] | ||
) |
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 noticed some headers are listed in the dropdown but not generated in the script so selecting them doesn't have any effect. We could exclude them from the dropdown as well to keep consistency.
k6-studio/src/codegen/codegen.ts
Lines 189 to 191 in 5faa040
const headersToExclude = ['Cookie', 'User-Agent', 'Host', 'Content-Length'] | |
const headers = request.headers | |
.filter(([name]) => !headersToExclude.includes(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.
Good call! Updated 👌
d3ed6c3
Description
Add ability to target header by name in selectors, works both in correlation and parameterization rules.
I've added and styled ReactSelect to add searchable dropdowns, and used it to show header suggestions from recorded requests.
How to Test
Checklist
npm run lint
) and all checks pass.npm test
) and all tests pass.Screenshots (if appropriate):
Related PR(s)/Issue(s)
Resolves #307