-
Notifications
You must be signed in to change notification settings - Fork 0
Code Review Bench PR #19951 - feat(ui-v2): improve task run details page parity with Vue #12
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
Changes from all commits
332dd34
41d13e9
c9cb7c3
98e305d
73405db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { useEffect } from "react"; | ||
|
|
||
| type StateType = | ||
| | "SCHEDULED" | ||
| | "PENDING" | ||
| | "RUNNING" | ||
| | "COMPLETED" | ||
| | "FAILED" | ||
| | "CANCELLED" | ||
| | "CANCELLING" | ||
| | "CRASHED" | ||
| | "PAUSED"; | ||
|
|
||
| function getPreferredColorScheme(): "dark" | "light" | "no-preference" { | ||
| if (window.matchMedia("(prefers-color-scheme: dark)").matches) { | ||
| return "dark"; | ||
| } | ||
| if (window.matchMedia("(prefers-color-scheme: light)").matches) { | ||
| return "light"; | ||
| } | ||
| return "no-preference"; | ||
| } | ||
|
|
||
| /** | ||
| * A hook that sets the browser favicon based on the provided state type. | ||
| * Resets the favicon to the default when the component unmounts. | ||
| * | ||
| * @param stateType - The state type to display in the favicon (e.g., "COMPLETED", "FAILED") | ||
| * @returns void | ||
| * | ||
| * @example | ||
| * ```tsx | ||
| * // Set favicon based on task run state | ||
| * useStateFavicon(taskRun.state_type); | ||
| * ``` | ||
| */ | ||
| export function useStateFavicon(stateType: StateType | null | undefined): void { | ||
| useEffect(() => { | ||
| const colorScheme = getPreferredColorScheme(); | ||
| const favicon16 = | ||
| colorScheme === "dark" | ||
| ? document.getElementById("favicon-16-dark") | ||
| : document.getElementById("favicon-16"); | ||
| const favicon32 = | ||
| colorScheme === "dark" | ||
| ? document.getElementById("favicon-32-dark") | ||
| : document.getElementById("favicon-32"); | ||
|
|
||
| if (stateType) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const faviconPath = `/${stateType.toLowerCase()}.svg`; | ||
| favicon16?.setAttribute("href", faviconPath); | ||
| favicon32?.setAttribute("href", faviconPath); | ||
| } | ||
|
|
||
| return () => { | ||
| // Reset to default favicon on unmount | ||
| if (colorScheme === "dark") { | ||
| favicon16?.setAttribute("href", "/favicon-16x16-dark.png"); | ||
| favicon32?.setAttribute("href", "/favicon-32x32-dark.png"); | ||
| } else { | ||
| favicon16?.setAttribute("href", "/favicon-16x16.png"); | ||
| favicon32?.setAttribute("href", "/favicon-32x32.png"); | ||
| } | ||
| }; | ||
| }, [stateType]); | ||
| } | ||
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.
retry_jitter_factorvalue of 0The expression
taskRun.empirical_policy?.retry_jitter_factor ? ... : "None"uses a truthy check. Ifretry_jitter_factoris0(a valid numeric value), it will be treated as falsy and display "None" instead of "0". The original code used explicit!== null && !== undefinedchecks to avoid this issue.This should use nullish coalescing or explicit null/undefined checks instead:
Was this helpful? React with 👍 / 👎