-
Notifications
You must be signed in to change notification settings - Fork 129
Implement Timestamp/Duration columns in view-event-list.tsx #174
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
Open
Sugavanas
wants to merge
11
commits into
httptoolkit:main
Choose a base branch
from
Sugavanas:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a26f926
Add visibleViewColumns setting to uiStore
Sugavanas 8a70117
Add getHeaderContextMenuCallback to ViewEventContextMenuBuilder
Sugavanas 6e2af0a
Add Timestamp column to ViewEventList and fix formatting
Sugavanas dbd98c9
Add Duration column to ViewEventList
Sugavanas 02d16c6
Add header context menu - ViewEventList
Sugavanas 3bd35c5
Add timestamp and duration to rest of the lists
Sugavanas cb0231e
Add ColumnVisibilityToggle
Sugavanas fe2aee4
Remove size column temporarily
Sugavanas 53546a4
Merge remote-tracking branch 'upstream/main'
Sugavanas 3789ee2
Fix conflicts
Sugavanas e6d2721
Update ui-store.ts - Remove default columns from list temporarily
Sugavanas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,12 @@ | ||
import * as React from 'react'; | ||
import { observer } from 'mobx-react'; | ||
|
||
import { TimingEvents } from '../../types'; | ||
import { observableClock } from '../../util/observable'; | ||
|
||
import { Pill } from './pill'; | ||
import { formatDuration } from '../../util/text'; | ||
|
||
function sigFig(num: number, figs: number): string { | ||
return num.toFixed(figs); | ||
} | ||
|
||
type DurationPillProps = { className?: string } & ( | ||
| { durationMs: number } | ||
| { timingEvents: Partial<TimingEvents> } | ||
); | ||
|
||
const calculateDuration = (timingEvents: Partial<TimingEvents>) => { | ||
const doneTimestamp = timingEvents.responseSentTimestamp ?? timingEvents.abortedTimestamp; | ||
|
||
if (timingEvents.startTimestamp !== undefined && doneTimestamp !== undefined) { | ||
return doneTimestamp - timingEvents.startTimestamp; | ||
} | ||
import { calculateAndFormatDuration, FormattedDurationProps } from "../../util/utils"; | ||
|
||
if (timingEvents.startTime !== undefined) { | ||
// This may not be perfect - note that startTime comes from the server so we might be | ||
// mildly out of sync (ehhhh, in theory) but this is only for pending requests where | ||
// that's unlikely to be an issue - the final time will be correct regardless. | ||
return observableClock.getTime() - timingEvents.startTime; | ||
} | ||
} | ||
type DurationPillProps = { className?: string } & FormattedDurationProps; | ||
|
||
export const DurationPill = observer((p: DurationPillProps) => { | ||
let duration: number | undefined; | ||
|
||
if ('durationMs' in p) { | ||
duration = p.durationMs; | ||
} else if (p.timingEvents) { | ||
duration = calculateDuration(p.timingEvents); | ||
} | ||
|
||
if (duration === undefined) return null; | ||
|
||
return <Pill className={p.className}>{formatDuration(duration)}</Pill>; | ||
return <Pill className={p.className}>{calculateAndFormatDuration(p)}</Pill>; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't think this should take any arguments. This class is already storing the
uiStore
, it should just read the current columns and set them directly. That also means we don't need theonHeaderColumnOptionChange
constructor argument either.