Moved priority level constants into rendeer interface

This commit is contained in:
Brian Vaughn
2019-05-16 14:51:58 -07:00
parent 9a6a19456f
commit 16a81feb72
6 changed files with 77 additions and 75 deletions
@@ -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}>
+1 -2
View File
@@ -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 -30
View File
@@ -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) =>