From 6a9e976978dff4bdf004931bedf98aaed8ff06e6 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Fri, 10 Jan 2025 07:47:54 -0800 Subject: [PATCH] Separate locator display from other action contexts --- packages/trace-viewer/src/ui/actionList.css | 9 +++++- packages/trace-viewer/src/ui/actionList.tsx | 31 +++++++++++++++++---- packages/trace-viewer/src/ui/string.ts | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/packages/trace-viewer/src/ui/actionList.css b/packages/trace-viewer/src/ui/actionList.css index 10e3c39f98..0d246b7d45 100644 --- a/packages/trace-viewer/src/ui/actionList.css +++ b/packages/trace-viewer/src/ui/actionList.css @@ -70,13 +70,20 @@ flex: none; } -.action-selector { +.action-context { display: inline; flex: none; padding-left: 5px; +} + +.action-locator-context { color: var(--vscode-charts-orange); } +.action-generic-context { + color: var(--vscode-charts-purple); +} + .action-url { display: inline; flex: none; diff --git a/packages/trace-viewer/src/ui/actionList.tsx b/packages/trace-viewer/src/ui/actionList.tsx index c740fe9c33..9ab1bf147f 100644 --- a/packages/trace-viewer/src/ui/actionList.tsx +++ b/packages/trace-viewer/src/ui/actionList.tsx @@ -15,18 +15,17 @@ */ import type { ActionTraceEvent, AfterActionTraceEventAttachment } from '@trace/trace'; -import { msToString } from '@web/uiUtils'; +import { clsx, msToString } from '@web/uiUtils'; import * as React from 'react'; import './actionList.css'; import * as modelUtil from './modelUtil'; -import { asLocator } from '@isomorphic/locatorGenerators'; import type { Language } from '@isomorphic/locatorGenerators'; import type { TreeState } from '@web/components/treeView'; import { TreeView } from '@web/components/treeView'; import type { ActionTraceEventInContext, ActionTreeItem } from './modelUtil'; import type { Boundaries } from './geometry'; import { ToolbarButton } from '@web/components/toolbarButton'; -import { commandContextString } from './string'; +import { actionContextString } from './string'; export interface ActionListProps { actions: ActionTraceEventInContext[], @@ -105,6 +104,29 @@ export const ActionList: React.FC = ({ ; }; +const ActionContext: React.FC<{ + action: ActionTraceEvent; + sdkLanguage: Language; +}> = ({ action, sdkLanguage }) => { + const contextString = actionContextString(action, sdkLanguage); + + if (contextString === undefined) + return null; + + return ( +
+ {contextString} +
+ ); +}; + export const renderAction = ( action: ActionTraceEvent, options: { @@ -117,7 +139,6 @@ export const renderAction = ( }) => { const { sdkLanguage, revealConsole, revealAttachment, isLive, showDuration, showBadges } = options; const { errors, warnings } = modelUtil.stats(action); - const locator = commandContextString(action, sdkLanguage || 'javascript'); const showAttachments = !!action.attachments?.length && !!revealAttachment; let time: string = ''; @@ -130,7 +151,7 @@ export const renderAction = ( return <>
{action.apiName} - {locator &&
{locator}
} + {action.method === 'goto' && action.params.url &&
{action.params.url}
} {action.class === 'APIRequestContext' && action.params.url &&
{excludeOrigin(action.params.url)}
}
diff --git a/packages/trace-viewer/src/ui/string.ts b/packages/trace-viewer/src/ui/string.ts index 4227880d8e..785930a32a 100644 --- a/packages/trace-viewer/src/ui/string.ts +++ b/packages/trace-viewer/src/ui/string.ts @@ -92,7 +92,7 @@ const formatTouchscreenParams = (params: { return undefined; }; -export const commandContextString = ( +export const actionContextString = ( action: ActionTraceEvent, sdkLanguage: Language, ): string | undefined => {