-
Notifications
You must be signed in to change notification settings - Fork 0
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: Update WebLogView to handle common mime types #41
Conversation
- Update Remove padding from Drawer component - Update WebLogView/Row/SideBar layout - Add RequestDetails components - Add ResponseDetails components - Add a Tabs component to fill the height of the Allotment component
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 looks so much better 💯
There's some duplication in the code where I left comments, but overall looks good!
Few things regarding UI/UX:
- There's no longer a close button in the drawer - no way to hide it
- I think one important mime type missed is form data, that must be quite common. We have an example in test.k6.io:
- Can we add another label to the switch to make it more clear what it switches between?
export function Cookies({ data }: { data: ProxyData }) { | ||
const cookies = data.request.cookies || [] | ||
|
||
if (!cookies.length) { | ||
return ( | ||
<Flex height="200px" justify="center" align="center"> | ||
Cookies not available | ||
</Flex> | ||
) | ||
} | ||
|
||
return ( | ||
<Table.Root size="1" variant="surface"> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.ColumnHeaderCell>Name</Table.ColumnHeaderCell> | ||
<Table.ColumnHeaderCell>Value</Table.ColumnHeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
|
||
<Table.Body> | ||
{cookies.map(([name, value], index) => ( | ||
<Table.Row key={index}> | ||
<Table.Cell>{name}</Table.Cell> | ||
<Table.Cell>{value}</Table.Cell> | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table.Root> | ||
) | ||
} |
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.
Request and response Cookies components are almost the same, instead of passing ProxyData you could pass just the cookies (either request's or response's) and reuse the same component
const options: editor.IStandaloneEditorConstructionOptions = { | ||
automaticLayout: true, | ||
codeLens: false, | ||
contextmenu: false, | ||
domReadOnly: true, | ||
fixedOverflowWidgets: true, | ||
foldingMaximumRegions: 5, | ||
lineNumbers: 'off', | ||
minimap: { | ||
enabled: false, | ||
renderCharacters: false, | ||
}, | ||
overviewRulerBorder: false, | ||
readOnly: true, | ||
scrollbar: { | ||
alwaysConsumeMouseWheel: true, | ||
horizontalScrollbarSize: 3, | ||
verticalScrollbarSize: 3, | ||
}, | ||
scrollBeyondLastLine: false, | ||
tabSize: 1, | ||
wordWrap: 'off', | ||
} |
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.
Duplicate options and theme switching logic between Payload and Preview, that's a good candidate for a shared component
import { Tabs as RadixTabs } from '@radix-ui/themes' | ||
import { ComponentProps } from 'react' | ||
|
||
function Root({ children, ...props }: ComponentProps<typeof RadixTabs.Root>) { |
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.
Wasn't sure why we need tabs wrapper at a glance, maybe it would be useful to have a comment here?
- Consolidate Cookie component - Consolidate Read-only editor component - Update raw/preview switch to segmented controls
# Conflicts: # src/components/RequestDetails/RequestDetails.utils.ts
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.
export function Preview({ content, contentType, format }: PreviewProps) { | ||
if (format === 'image') { | ||
return ( | ||
<img |
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 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.
Looks like it's broken for PNGs and SVGs - I can share the HAR I used if you want
case 'plain': | ||
return safeAtob(content) | ||
case 'audio': | ||
case 'font': |
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.
variant="classic" | ||
onValueChange={(value) => setIsPreview(value === 'preview')} | ||
> | ||
<SegmentedControl.Item value="raw">Raw</SegmentedControl.Item> |
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 for some MIME types (like images), we shouldn't let the user see the raw response
- Disable raw content for media files
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!
Closes https://github.com/grafana/k6-cloud/issues/2389
This PR updates the WebLogView
Screen.Recording.2024-07-17.at.14.25.16.mov
Questions
emotion
for all styling?