diff --git a/.changeset/dull-pandas-exercise.md b/.changeset/dull-pandas-exercise.md new file mode 100644 index 0000000..00d7e01 --- /dev/null +++ b/.changeset/dull-pandas-exercise.md @@ -0,0 +1,5 @@ +--- +'@envyjs/webui': patch +--- + +Update style of trace detail diff --git a/packages/webui/src/components/Authorization.tsx b/packages/webui/src/components/Authorization.tsx index 015304b..8a0aee6 100644 --- a/packages/webui/src/components/Authorization.tsx +++ b/packages/webui/src/components/Authorization.tsx @@ -91,7 +91,7 @@ export default function Authorization({ value }: AuthorizationProps) { {type} {token}
- +
); diff --git a/packages/webui/src/components/Badge.stories.ts b/packages/webui/src/components/Badge.stories.ts new file mode 100644 index 0000000..c636534 --- /dev/null +++ b/packages/webui/src/components/Badge.stories.ts @@ -0,0 +1,21 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import Badge from './Badge'; + +const meta = { + title: 'Components/Badge', + component: Badge, + parameters: { + layout: 'centered', + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Standard: Story = { + args: { + children: 'Label', + className: 'bg-gray-100', + }, +}; diff --git a/packages/webui/src/components/Badge.tsx b/packages/webui/src/components/Badge.tsx new file mode 100644 index 0000000..134443a --- /dev/null +++ b/packages/webui/src/components/Badge.tsx @@ -0,0 +1,14 @@ +import { tw } from '@/utils'; + +export default function Badge({ className, children }: { className?: string; children: React.ReactNode }) { + return ( + + {children} + + ); +} diff --git a/packages/webui/src/components/Button.stories.ts b/packages/webui/src/components/Button.stories.ts index 39d5036..6c9516e 100644 --- a/packages/webui/src/components/Button.stories.ts +++ b/packages/webui/src/components/Button.stories.ts @@ -9,8 +9,12 @@ const meta = { layout: 'centered', }, argTypes: { - type: { - options: ['standard', 'action', 'ghost', 'danger'], + size: { + options: ['small', 'standard', 'large'], + control: { type: 'select' }, + }, + border: { + options: ['standard', 'ghost'], control: { type: 'select' }, }, }, @@ -22,5 +26,7 @@ type Story = StoryObj; export const Standard: Story = { args: { children: 'Standard Button', + size: 'standard', + border: 'standard', }, }; diff --git a/packages/webui/src/components/Button.tsx b/packages/webui/src/components/Button.tsx index 1b7f250..366e544 100644 --- a/packages/webui/src/components/Button.tsx +++ b/packages/webui/src/components/Button.tsx @@ -2,9 +2,15 @@ import { MouseEvent, Ref, RefObject, forwardRef, useRef } from 'react'; import { tw } from '@/utils'; -export type ButtonProps = React.ButtonHTMLAttributes; +export type ButtonProps = React.ButtonHTMLAttributes & { + size?: 'small' | 'standard' | 'large'; + border?: 'standard' | 'ghost'; +}; -function Button({ onClick, className, children, ...props }: ButtonProps, ref: Ref) { +function Button( + { onClick, className, size = 'standard', border = 'standard', children, ...props }: ButtonProps, + ref: Ref, +) { const buttonRef = useRef(null); const finalRef = (ref || buttonRef) as RefObject; @@ -17,7 +23,10 @@ function Button({ onClick, className, children, ...props }: ButtonProps, ref: Re ); } diff --git a/packages/webui/src/components/KeyValueList.stories.ts b/packages/webui/src/components/KeyValueList.stories.ts index 0587fed..1c357bc 100644 --- a/packages/webui/src/components/KeyValueList.stories.ts +++ b/packages/webui/src/components/KeyValueList.stories.ts @@ -15,8 +15,7 @@ type Story = StoryObj; export const Standard: Story = { args: { - label: 'Some Label', - keyValuePairs: [ + values: [ ['Key 1', 'Value 1'], ['Key 2', 'Value 2'], ], diff --git a/packages/webui/src/components/KeyValueList.test.tsx b/packages/webui/src/components/KeyValueList.test.tsx index d545ef0..685e0bd 100644 --- a/packages/webui/src/components/KeyValueList.test.tsx +++ b/packages/webui/src/components/KeyValueList.test.tsx @@ -1,113 +1,65 @@ -import { cleanup, render, within } from '@testing-library/react'; +import { cleanup, render } from '@testing-library/react'; import KeyValueList, { KeyValuePair } from './KeyValueList'; -jest.mock('@/components/Fields', () => ({ - Field: function MockField({ label, children }: React.PropsWithChildren<{ label: string }>) { - return ( -
-
{label}
-
{children}
-
- ); - }, -})); - describe('KeyValueList', () => { afterEach(() => { cleanup(); }); - it('should render without error', () => { - const data: KeyValuePair[] = [ - ['foo', 'bar'], - ['baz', 'qux'], - ]; - - render(); - }); - - it('should render a single Field component even when multiple key-value pairs are supplied', () => { - const data: KeyValuePair[] = [ - ['foo', 'bar'], - ['baz', 'qux'], - ]; - - const { getAllByTestId } = render(); - const fieldComponents = getAllByTestId('mock-field'); - - expect(fieldComponents).toHaveLength(1); - }); - - it('should pass the label to the Field component', () => { - const data: KeyValuePair[] = [ - ['foo', 'bar'], - ['baz', 'qux'], - ]; - - const { getByTestId } = render(); - const label = getByTestId('mock-field-label'); - - expect(label).toHaveTextContent('Foo'); - }); - it('should render all key value pairs', () => { const data: KeyValuePair[] = [ - ['foo', 'bar'], - ['baz', 'qux'], + ['foo:', 'bar'], + ['baz:', 'qux'], ]; - const { getByTestId } = render(); - const content = getByTestId('mock-field-children'); - const items = within(content).getAllByTestId('key-value-item'); + const { getAllByTestId } = render(); + const items = getAllByTestId('key-value-item'); expect(items).toHaveLength(2); - expect(items.at(0)!).toHaveTextContent('foo: bar'); - expect(items.at(1)!).toHaveTextContent('baz: qux'); + expect(items.at(0)!).toHaveTextContent('foo:bar'); + expect(items.at(1)!).toHaveTextContent('baz:qux'); }); it('should URI decode any string value for a key value pair', () => { - const data: KeyValuePair[] = [['foo', 'this%20is%20%22encoded%22']]; + const data: KeyValuePair[] = [['foo:', 'this%20is%20%22encoded%22']]; - const { getByTestId } = render(); - const content = getByTestId('mock-field-children'); - const items = within(content).getAllByTestId('key-value-item'); + const { getAllByTestId } = render(); + const items = getAllByTestId('key-value-item'); expect(items).toHaveLength(1); - expect(items.at(0)!).toHaveTextContent('foo: this is "encoded"'); + expect(items.at(0)!).toHaveTextContent('foo:this is "encoded"'); }); it('should render non-string primitive values for a key value pair', () => { const data: KeyValuePair[] = [ - ['number', 0], - ['boolean', true], + ['number:', 0], + ['boolean:', true], ]; - const { getByTestId } = render(); - const content = getByTestId('mock-field-children'); - const items = within(content).getAllByTestId('key-value-item'); + const { getAllByTestId } = render(); + const items = getAllByTestId('key-value-item'); expect(items).toHaveLength(2); - expect(items.at(0)!).toHaveTextContent('number: 0'); - expect(items.at(1)!).toHaveTextContent('boolean: true'); + expect(items.at(0)!).toHaveTextContent('number:0'); + expect(items.at(1)!).toHaveTextContent('boolean:true'); }); it('should allow components to be rendered as values for a key value pair', () => { function Component() { return
Mock value component
; } - const data: KeyValuePair[] = [['component', ]]; + const data: KeyValuePair[] = [['component:', ]]; - const { getByTestId } = render(); - const content = getByTestId('mock-field-children'); - const items = within(content).getAllByTestId('key-value-item'); + const { getAllByTestId } = render(); + const items = getAllByTestId('key-value-item'); expect(items).toHaveLength(1); - expect(items.at(0)!).toHaveTextContent('component: Mock value component'); + expect(items.at(0)!).toHaveTextContent('component:Mock value component'); }); it('should render nothing if no key-value pairs are supplied', () => { - const { container } = render(); + const { container } = render(); expect(container).toBeEmptyDOMElement(); }); }); diff --git a/packages/webui/src/components/KeyValueList.tsx b/packages/webui/src/components/KeyValueList.tsx index 3265e4e..0576e47 100644 --- a/packages/webui/src/components/KeyValueList.tsx +++ b/packages/webui/src/components/KeyValueList.tsx @@ -1,19 +1,16 @@ -import { Field } from './Fields'; +export type KeyValuePair = [string, React.ReactNode]; -export type KeyValuePair = [string, any]; - -type KeyValueListProps = { - label: string; - keyValuePairs: [string, any][]; +type KeyValueList = { + values: KeyValuePair[]; }; -export default function KeyValueList({ label, keyValuePairs }: KeyValueListProps) { - if (!keyValuePairs.length) return null; +export default function KeyValueList({ values }: KeyValueList) { + if (!values.length) return null; return ( - -
- {keyValuePairs.map(([k, v]) => { + + + {values.map(([k, v]) => { let value: React.ReactNode = v; switch (typeof v) { case 'string': { @@ -26,15 +23,14 @@ export default function KeyValueList({ label, keyValuePairs }: KeyValueListProps break; } } - return ( - - {k}: - {value} - + + + + ); })} - - + +
{k}{value}
); } diff --git a/packages/webui/src/components/Section.tsx b/packages/webui/src/components/Section.tsx index f28f41b..ac90d71 100644 --- a/packages/webui/src/components/Section.tsx +++ b/packages/webui/src/components/Section.tsx @@ -10,30 +10,30 @@ type SectionProps = React.HTMLAttributes & { export default function Section({ title, collapsible = true, className, children, ...props }: SectionProps) { const [expanded, setExpanded] = useState(true); - const Icon = expanded ? ChevronUp : ChevronDown; + const Icon = expanded ? ChevronDown : ChevronUp; return ( <> {title && (
{ if (collapsible) setExpanded(x => !x); }} {...props} > - {title} - {collapsible && } +
{title}
+ {collapsible && }
)} {children && expanded && ( -
+
{children}
)} diff --git a/packages/webui/src/components/index.ts b/packages/webui/src/components/index.ts index ffa87e7..0d3b73b 100644 --- a/packages/webui/src/components/index.ts +++ b/packages/webui/src/components/index.ts @@ -1,10 +1,10 @@ /* istanbul ignore file */ export { default as Authorization } from './Authorization'; +export { default as Badge } from './Badge'; export { default as Button } from './Button'; export { default as Code } from './Code'; export { default as DateTime } from './DateTime'; -export { default as DropDown } from './DropDown'; export { default as Fields, Field } from './Fields'; export { default as IconButton } from './IconButton'; export { default as Input } from './Input'; diff --git a/packages/webui/src/components/ui/CopyAsCurlButton.test.tsx b/packages/webui/src/components/ui/CopyAsCurlButton.test.tsx index 4281e28..bc0764e 100644 --- a/packages/webui/src/components/ui/CopyAsCurlButton.test.tsx +++ b/packages/webui/src/components/ui/CopyAsCurlButton.test.tsx @@ -46,21 +46,12 @@ describe('CopyAsCurlButton', () => { render(); }); - it('should render a button with the expected label', () => { - const { getByRole } = render(); - - const button = getByRole('button'); - expect(button).toHaveTextContent('Copy as cURL snippet'); - }); - describe('cURL snippet', () => { it('should copy cURL snippet to clipboard when clicked', async () => { const { getByRole } = render(); await act(async () => { const button = getByRole('button'); - expect(button).toHaveTextContent('Copy as cURL snippet'); - await userEvent.click(button); }); @@ -85,8 +76,6 @@ describe('CopyAsCurlButton', () => { await act(async () => { const button = getByRole('button'); - expect(button).toHaveTextContent('Copy as cURL snippet'); - await userEvent.click(button); }); @@ -110,8 +99,6 @@ describe('CopyAsCurlButton', () => { await act(async () => { const button = getByRole('button'); - expect(button).toHaveTextContent('Copy as cURL snippet'); - await userEvent.click(button); }); @@ -128,8 +115,6 @@ describe('CopyAsCurlButton', () => { await act(async () => { const button = getByRole('button'); - expect(button).toHaveTextContent('Copy as cURL snippet'); - await userEvent.click(button); }); diff --git a/packages/webui/src/components/ui/CopyAsCurlButton.tsx b/packages/webui/src/components/ui/CopyAsCurlButton.tsx index 97e3279..fc9566f 100644 --- a/packages/webui/src/components/ui/CopyAsCurlButton.tsx +++ b/packages/webui/src/components/ui/CopyAsCurlButton.tsx @@ -31,8 +31,6 @@ export default function CopyAsCurlButton({ trace, ...props }: CopyAsCurlButtonPr } return ( - await copyAsCurl()}> - Copy as cURL snippet - + await copyAsCurl()} /> ); } diff --git a/packages/webui/src/components/ui/Header.tsx b/packages/webui/src/components/ui/Header.tsx index b93e10b..51b725f 100644 --- a/packages/webui/src/components/ui/Header.tsx +++ b/packages/webui/src/components/ui/Header.tsx @@ -12,7 +12,7 @@ export default function Header() { const isDebugMode = process.env.NODE_ENV !== 'production'; return ( -
+
diff --git a/packages/webui/src/components/ui/QueryParams.test.tsx b/packages/webui/src/components/ui/QueryParams.test.tsx index d8aab57..1078147 100644 --- a/packages/webui/src/components/ui/QueryParams.test.tsx +++ b/packages/webui/src/components/ui/QueryParams.test.tsx @@ -28,21 +28,7 @@ describe('QueryParams', () => { render(); }); - it('should pass `label` "Query params" to KeyValueList component', () => { - const trace = {} as Trace; - render(); - - expect(mockKeyValueListComponent).lastCalledWith(expect.objectContaining({ label: 'Query params' })); - }); - - it('should pass empty `keyValuePairs` if trace has no query params', () => { - const trace = {} as Trace; - render(); - - expect(mockKeyValueListComponent).lastCalledWith(expect.objectContaining({ keyValuePairs: [] })); - }); - - it('should pass trace query params as `keyValuePairs`', () => { + it('should pass trace query params as `values`', () => { const trace = { http: { path: '/page?foo=bar&baz=qux', @@ -52,7 +38,7 @@ describe('QueryParams', () => { expect(mockKeyValueListComponent).lastCalledWith( expect.objectContaining({ - keyValuePairs: [ + values: [ ['foo', 'bar'], ['baz', 'qux'], ], diff --git a/packages/webui/src/components/ui/QueryParams.tsx b/packages/webui/src/components/ui/QueryParams.tsx index 40f5d5b..98e18dd 100644 --- a/packages/webui/src/components/ui/QueryParams.tsx +++ b/packages/webui/src/components/ui/QueryParams.tsx @@ -1,14 +1,21 @@ import KeyValueList from '@/components/KeyValueList'; +import Section from '@/components/Section'; import { Trace } from '@/types'; import { pathAndQuery } from '@/utils'; export default function QueryParams({ trace }: { trace: Trace }) { const [, qs] = pathAndQuery(trace); + if (!qs) return null; + const urlSearchParams = new URLSearchParams(qs); - const queryParams: [string, string | null][] = []; + const queryParams: [string, string][] = []; urlSearchParams.forEach((value, key) => { queryParams.push([key, value]); }); - return ; + return ( +
+ +
+ ); } diff --git a/packages/webui/src/components/ui/RequestHeaders.test.tsx b/packages/webui/src/components/ui/RequestHeaders.test.tsx index 7d55e59..14a22d0 100644 --- a/packages/webui/src/components/ui/RequestHeaders.test.tsx +++ b/packages/webui/src/components/ui/RequestHeaders.test.tsx @@ -36,20 +36,6 @@ describe('RequestHeaders', () => { expect(container).toBeEmptyDOMElement(); }); - it('should pass `label` "Headers" to KeyValueList component', () => { - const trace = { - http: { - requestHeaders: { - foo: 'bar', - baz: 'qux', - } as Record, - }, - } as Trace; - render(); - - expect(mockKeyValueListComponent).lastCalledWith(expect.objectContaining({ label: 'Headers' })); - }); - it('should pass trace request headers as `keyValuePairs`', () => { const trace = { http: { @@ -63,7 +49,7 @@ describe('RequestHeaders', () => { expect(mockKeyValueListComponent).lastCalledWith( expect.objectContaining({ - keyValuePairs: [ + values: [ ['foo', 'bar'], ['baz', 'qux'], ], @@ -71,7 +57,7 @@ describe('RequestHeaders', () => { ); }); - it('should pass Authorizatin component for "authorization" header`', () => { + it('should pass Authorization component for "authorization" header`', () => { const trace = { http: { requestHeaders: { @@ -81,7 +67,7 @@ describe('RequestHeaders', () => { } as Trace; render(); - const [key, value] = mockKeyValueListComponent.mock.lastCall[0].keyValuePairs[0]; + const [key, value] = mockKeyValueListComponent.mock.lastCall[0].values[0]; expect(key).toEqual('authorization'); expect(value.type).toEqual(Authorization); expect(value.props).toEqual({ value: 'some_auth_token' }); diff --git a/packages/webui/src/components/ui/RequestHeaders.tsx b/packages/webui/src/components/ui/RequestHeaders.tsx index d11363c..a46047e 100644 --- a/packages/webui/src/components/ui/RequestHeaders.tsx +++ b/packages/webui/src/components/ui/RequestHeaders.tsx @@ -10,5 +10,5 @@ export default function RequestHeaders({ trace }: { trace: Trace }) { const headers = cloneHeaders(requestHeaders) as Record; if (headers.authorization) headers.authorization = ; - return ; + return ; } diff --git a/packages/webui/src/components/ui/ResponseHeaders.test.tsx b/packages/webui/src/components/ui/ResponseHeaders.test.tsx index c40afae..369cfd7 100644 --- a/packages/webui/src/components/ui/ResponseHeaders.test.tsx +++ b/packages/webui/src/components/ui/ResponseHeaders.test.tsx @@ -36,20 +36,6 @@ describe('ResponseHeaders', () => { expect(container).toBeEmptyDOMElement(); }); - it('should pass `label` "Headers" to KeyValueList component', () => { - const trace = { - http: { - responseHeaders: { - foo: 'bar', - baz: 'qux', - } as Record, - }, - } as Trace; - render(); - - expect(mockKeyValueListComponent).lastCalledWith(expect.objectContaining({ label: 'Headers' })); - }); - it('should pass trace request headers as `keyValuePairs`', () => { const trace = { http: { @@ -63,7 +49,7 @@ describe('ResponseHeaders', () => { expect(mockKeyValueListComponent).lastCalledWith( expect.objectContaining({ - keyValuePairs: [ + values: [ ['foo', 'bar'], ['baz', 'qux'], ], @@ -71,7 +57,7 @@ describe('ResponseHeaders', () => { ); }); - it('should pass Authorizatin component for "authorization" header`', () => { + it('should pass Authorization component for "authorization" header`', () => { const trace = { http: { responseHeaders: { @@ -81,7 +67,7 @@ describe('ResponseHeaders', () => { } as Trace; render(); - const [key, value] = mockKeyValueListComponent.mock.lastCall[0].keyValuePairs[0]; + const [key, value] = mockKeyValueListComponent.mock.lastCall[0].values[0]; expect(key).toEqual('authorization'); expect(value.type).toEqual(Authorization); expect(value.props).toEqual({ value: 'some_auth_token' }); diff --git a/packages/webui/src/components/ui/ResponseHeaders.tsx b/packages/webui/src/components/ui/ResponseHeaders.tsx index 2b14ec4..8b0eeee 100644 --- a/packages/webui/src/components/ui/ResponseHeaders.tsx +++ b/packages/webui/src/components/ui/ResponseHeaders.tsx @@ -10,5 +10,5 @@ export default function ResponseHeaders({ trace }: { trace: Trace }) { const headers = cloneHeaders(responseHeaders) as Record; if (headers.authorization) headers.authorization = ; - return ; + return ; } diff --git a/packages/webui/src/components/ui/Tabs.tsx b/packages/webui/src/components/ui/Tabs.tsx index 6186663..7b2a452 100644 --- a/packages/webui/src/components/ui/Tabs.tsx +++ b/packages/webui/src/components/ui/Tabs.tsx @@ -3,8 +3,8 @@ import { tw } from '@/utils'; export function TabList({ children }: { children: React.ReactNode }) { return ( -
-
    {children}
+
+
    {children}
); } diff --git a/packages/webui/src/components/ui/TraceDetail.test.tsx b/packages/webui/src/components/ui/TraceDetail.test.tsx index 022e079..e83c0d8 100644 --- a/packages/webui/src/components/ui/TraceDetail.test.tsx +++ b/packages/webui/src/components/ui/TraceDetail.test.tsx @@ -16,6 +16,9 @@ import { Trace } from '@/types'; import TraceDetail from './TraceDetail'; jest.mock('@/components', () => ({ + Badge: function ({ children }: any) { + return <>Mock Badge component: {children}; + }, Code: function ({ children }: any) { return <>Mock Code component: {children}; }, @@ -119,7 +122,7 @@ describe('TraceDetail', () => { cleanup(); }); - it('should render without error', () => { + fit('should render without error', () => { render(); }); diff --git a/packages/webui/src/components/ui/TraceDetail.tsx b/packages/webui/src/components/ui/TraceDetail.tsx index ae3efe9..e7c9259 100644 --- a/packages/webui/src/components/ui/TraceDetail.tsx +++ b/packages/webui/src/components/ui/TraceDetail.tsx @@ -2,7 +2,18 @@ import { HttpRequestState } from '@envyjs/core'; import { X } from 'lucide-react'; import { useCallback, useEffect, useRef } from 'react'; -import { Code, DateTime, Field, Fields, IconButton, JsonDisplay, Loading, Section, XmlDisplay } from '@/components'; +import { + Badge, + Code, + DateTime, + Field, + Fields, + IconButton, + JsonDisplay, + Loading, + Section, + XmlDisplay, +} from '@/components'; import useApplication from '@/hooks/useApplication'; import { RequestDetailsComponent, @@ -80,53 +91,39 @@ export default function TraceDetail() { const [path] = pathAndQuery(trace); const requestBody = getRequestBody(trace); const responseBody = getResponseBody(trace); - - function statusCodeStyle(code: number) { - let style = 'bg-transparent'; - if (code >= 500) style = 'bg-purple-500'; - else if (code >= 400) style = 'bg-red-500'; - else if (code >= 300) style = 'bg-yellow-500'; - else if (code >= 200) style = 'bg-green-500'; - else if (code === -1) style = 'bg-gray-500'; - return `inline-block rounded-full h-3 w-3 ${style}`; - } + const httpStatusLabel = `${statusCode && statusCode > -1 ? statusCode : ''} ${statusMessage}`; return ( -
-
-
-
-
- -
-
-
- - - {method} - - - - clearSelectedTrace()} data-test-id="close-trace" /> - - - - {url} - -
-
- Sent from {serviceName} -
+
+
+
+
+
+
+ {method} + {statusCode && ( + + {httpStatusLabel} + + )} + {serviceName} +
+
+ + clearSelectedTrace()} + size="small" + border="ghost" + data-test-id="close-trace" + />
- {responseComplete && statusCode && ( -
- - {`${statusCode > -1 ? statusCode : ''} ${statusMessage}`} -
- )} +
+ {url} +
@@ -137,7 +134,7 @@ export default function TraceDetail() {
-
+
@@ -148,13 +145,17 @@ export default function TraceDetail() { {path} - - - -
+ + +
+ +
+ + +
{responseComplete && duration ? ( <> @@ -165,27 +166,10 @@ export default function TraceDetail() { {statusCode && statusCode > -1 ? statusCode : ''} {statusMessage} - + {numberFormat(duration)}ms - {trace.http?.timingsBlockedByCors && ( - - - Disabled by CORS policy - - - )} - {trace.http?.timings && ( - - - - )} @@ -196,6 +180,34 @@ export default function TraceDetail() { )}
+ + {responseComplete && duration && ( + <> +
+ +
+ +
+ {trace.http?.timingsBlockedByCors && ( + + )} + {trace.http?.timings && ( +
+ +
+ )} +
+ + )} @@ -215,3 +227,12 @@ export default function TraceDetail() {
); } + +function statusCodeStyle(code: number) { + let style = 'bg-gray-500'; + if (code >= 500) style = 'bg-purple-500'; + else if (code >= 400) style = 'bg-red-500'; + else if (code >= 300) style = 'bg-yellow-500'; + else if (code >= 200) style = 'bg-green-500'; + return style; +} diff --git a/packages/webui/src/components/ui/TraceList.test.tsx b/packages/webui/src/components/ui/TraceList.test.tsx index 674c95d..950b2d2 100644 --- a/packages/webui/src/components/ui/TraceList.test.tsx +++ b/packages/webui/src/components/ui/TraceList.test.tsx @@ -282,7 +282,7 @@ describe('TraceList', () => { const { getByTestId } = render(); const traceRow = getByTestId('trace'); - const methodData = within(traceRow).getByTestId('column-data-duration'); + const methodData = within(traceRow).getByTestId('column-data-time'); expect(methodData).toHaveTextContent('Mock Loading component'); }); @@ -301,7 +301,7 @@ describe('TraceList', () => { const { getByTestId } = render(); const traceRow = getByTestId('trace'); - const methodData = within(traceRow).getByTestId('column-data-duration'); + const methodData = within(traceRow).getByTestId('column-data-time'); expect(methodData).toHaveTextContent('1.23s'); }); @@ -320,7 +320,7 @@ describe('TraceList', () => { const { getByTestId } = render(); const traceRow = getByTestId('trace'); - const methodData = within(traceRow).getByTestId('column-data-duration'); + const methodData = within(traceRow).getByTestId('column-data-time'); expect(methodData).toHaveTextContent('1.24s'); }); diff --git a/packages/webui/src/components/ui/TraceList.tsx b/packages/webui/src/components/ui/TraceList.tsx index 34cdfb8..4f3cc4d 100644 --- a/packages/webui/src/components/ui/TraceList.tsx +++ b/packages/webui/src/components/ui/TraceList.tsx @@ -50,7 +50,7 @@ function getRequestDuration(trace: Trace) { const columns: [string, (x: Trace) => string | number | React.ReactNode, string, (x: Trace) => string][] = [ ['Method', getMethodAndStatus, 'w-[40px] md:w-[125px] overflow-hidden text-center', pillStyle], ['Request', getRequestURI, '', () => 'whitespace-nowrap overflow-hidden overflow-ellipsis'], - ['Duration', getRequestDuration, 'text-right', () => 'text-sm'], + ['Time', getRequestDuration, 'text-right w-[65px]', () => 'text-sm'], ]; type TraceListProps = React.HTMLAttributes & { diff --git a/packages/webui/src/styles/base.css b/packages/webui/src/styles/base.css index d8ffec7..3c6c710 100644 --- a/packages/webui/src/styles/base.css +++ b/packages/webui/src/styles/base.css @@ -87,7 +87,7 @@ input[type='search']::-webkit-search-results-decoration { */ .p-default { - @apply py-4 px-6; + @apply py-4 px-3; } .m-default {