From e0e4ca6d15af53f0f359b3493544a5c8418967c0 Mon Sep 17 00:00:00 2001 From: Ryan Rosello Date: Tue, 2 Jul 2024 20:25:48 +1000 Subject: [PATCH] feat(trace-viewer) apply updates as per code review https://github.com/microsoft/playwright/pull/31394 --- packages/trace-viewer/src/ui/sourceTab.css | 2 +- packages/trace-viewer/src/ui/sourceTab.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/trace-viewer/src/ui/sourceTab.css b/packages/trace-viewer/src/ui/sourceTab.css index 61045135a3..e4e43d80b6 100644 --- a/packages/trace-viewer/src/ui/sourceTab.css +++ b/packages/trace-viewer/src/ui/sourceTab.css @@ -32,7 +32,7 @@ z-index: 10; } -.copy-icon.codicon { +.source-tab-file-name .copy-icon.codicon { display: block; cursor: pointer; } diff --git a/packages/trace-viewer/src/ui/sourceTab.tsx b/packages/trace-viewer/src/ui/sourceTab.tsx index 2601f9b6ac..f8952849cb 100644 --- a/packages/trace-viewer/src/ui/sourceTab.tsx +++ b/packages/trace-viewer/src/ui/sourceTab.tsx @@ -81,14 +81,6 @@ export const SourceTab: React.FunctionComponent<{ const showStackFrames = (stack?.length ?? 0) > 1; - const getFileName = (fullPath?: string, lineNum?: number) => { - if (!fullPath) - return ''; - const pathSep = fullPath?.includes('/') ? '/' : '\\'; - const fileName = fullPath?.split(pathSep).pop() ?? ''; - return lineNum ? `${fileName}:${lineNum}` : fileName; - }; - return
{fileName && ( @@ -116,3 +108,11 @@ export async function calculateSha1(text: string): Promise { } return hexCodes.join(''); } + +function getFileName(fullPath?: string, lineNum?: number): string { + if (!fullPath) + return ''; + const pathSep = fullPath?.includes('/') ? '/' : '\\'; + const fileName = fullPath?.split(pathSep).pop() ?? ''; + return lineNum ? `${fileName}:${lineNum}` : fileName; +}