mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Moved priority level constants into rendeer interface
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import React, { Fragment, useCallback, useContext, useState } from 'react';
|
||||
import { ProfilerContext } from './ProfilerContext';
|
||||
import { formatDuration, formatPriorityLevel, formatTime } from './utils';
|
||||
import { formatDuration, formatTime } from './utils';
|
||||
import { StoreContext } from '../context';
|
||||
|
||||
import styles from './SidebarCommitInfo.css';
|
||||
@@ -75,9 +75,7 @@ export default function SidebarCommitInfo(_: Props) {
|
||||
{priorityLevel !== null && (
|
||||
<li className={styles.ListItem}>
|
||||
<label className={styles.Label}>Priority</label>:{' '}
|
||||
<span className={styles.Value}>
|
||||
{formatPriorityLevel(priorityLevel)}
|
||||
</span>
|
||||
<span className={styles.Value}>{priorityLevel}</span>
|
||||
</li>
|
||||
)}
|
||||
<li className={styles.ListItem}>
|
||||
|
||||
@@ -5,7 +5,6 @@ import type {
|
||||
CommitDetailsBackend,
|
||||
InteractionsBackend,
|
||||
ProfilingSummaryBackend,
|
||||
ReactPriorityLevel,
|
||||
} from 'src/backend/types';
|
||||
|
||||
export type CommitTreeNodeFrontend = {|
|
||||
@@ -43,7 +42,7 @@ export type CommitDetailsFrontend = {|
|
||||
actualDurations: Map<number, number>,
|
||||
commitIndex: number,
|
||||
interactions: Array<InteractionFrontend>,
|
||||
priorityLevel: ReactPriorityLevel | null,
|
||||
priorityLevel: string | null,
|
||||
rootID: number,
|
||||
selfDurations: Map<number, number>,
|
||||
|};
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import { PROFILER_EXPORT_VERSION } from 'src/constants';
|
||||
import {
|
||||
ImmediatePriority,
|
||||
UserBlockingPriority,
|
||||
NormalPriority,
|
||||
LowPriority,
|
||||
IdlePriority,
|
||||
NoPriority,
|
||||
} from 'src/backend/types';
|
||||
|
||||
import type {
|
||||
ExportedProfilingSummaryFromFrontend,
|
||||
@@ -17,10 +9,7 @@ import type {
|
||||
ProfilingSnapshotNode,
|
||||
} from './types';
|
||||
|
||||
import type {
|
||||
ExportedProfilingDataFromRenderer,
|
||||
ReactPriorityLevel,
|
||||
} from 'src/backend/types';
|
||||
import type { ExportedProfilingDataFromRenderer } from 'src/backend/types';
|
||||
|
||||
const commitGradient = [
|
||||
'var(--color-commit-gradient-0)',
|
||||
@@ -196,24 +185,6 @@ export const getGradientColor = (value: number) => {
|
||||
return commitGradient[Math.round(index)];
|
||||
};
|
||||
|
||||
export const formatPriorityLevel = (priorityLevel: ReactPriorityLevel) => {
|
||||
switch (priorityLevel) {
|
||||
case ImmediatePriority:
|
||||
return 'Immediate';
|
||||
case UserBlockingPriority:
|
||||
return 'User-Blocking';
|
||||
case NormalPriority:
|
||||
return 'Normal';
|
||||
case LowPriority:
|
||||
return 'Low';
|
||||
case IdlePriority:
|
||||
return 'Idle';
|
||||
case NoPriority:
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
};
|
||||
|
||||
export const formatDuration = (duration: number) =>
|
||||
Math.round(duration * 10) / 10 || '<0.1';
|
||||
export const formatPercentage = (percentage: number) =>
|
||||
|
||||
Reference in New Issue
Block a user