revert componentID

This commit is contained in:
Simon Knott 2024-11-19 17:07:47 +01:00
parent 3730900546
commit dcf885fcf6
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
3 changed files with 4 additions and 12 deletions

View file

@ -22,7 +22,6 @@ import { CopyToClipboard } from './copyToClipboard';
import './links.css'; import './links.css';
import { linkifyText } from '@web/renderUtils'; import { linkifyText } from '@web/renderUtils';
import { clsx } from '@web/uiUtils'; import { clsx } from '@web/uiUtils';
import { componentID } from './testResultView';
export function navigate(href: string) { export function navigate(href: string) {
window.history.pushState({}, '', href); window.history.pushState({}, '', href);
@ -78,7 +77,7 @@ export const AttachmentLink: React.FunctionComponent<{
linkName?: string, linkName?: string,
openInNewTab?: boolean, openInNewTab?: boolean,
}> = ({ attachment, href, linkName, openInNewTab }) => { }> = ({ attachment, href, linkName, openInNewTab }) => {
return <TreeItem id={componentID(params => params.set('attachment', attachment.name))} title={<span> return <TreeItem title={<span>
{attachment.contentType === kMissingContentType ? icons.warning() : icons.attachment()} {attachment.contentType === kMissingContentType ? icons.warning() : icons.attachment()}
{attachment.path && <a href={href || attachment.path} download={downloadFileNameForAttachment(attachment)}>{linkName || attachment.name}</a>} {attachment.path && <a href={href || attachment.path} download={downloadFileNameForAttachment(attachment)}>{linkName || attachment.name}</a>}
{!attachment.path && ( {!attachment.path && (

View file

@ -174,12 +174,6 @@ function classifyErrors(testErrors: string[], diffs: ImageDiff[]) {
}); });
} }
export function componentID(cb: (params: URLSearchParams) => void) {
const searchParams = new URLSearchParams(window.location.hash.slice(1));
cb(searchParams);
return '?' + searchParams;
}
const StepTreeItem: React.FC<{ const StepTreeItem: React.FC<{
step: TestStep; step: TestStep;
depth: number, depth: number,
@ -187,7 +181,7 @@ const StepTreeItem: React.FC<{
const attachmentName = step.title.match(/^attach "(.*)"$/)?.[1]; const attachmentName = step.title.match(/^attach "(.*)"$/)?.[1];
return <TreeItem title={<span aria-label={step.title}> return <TreeItem title={<span aria-label={step.title}>
<span style={{ float: 'right' }}>{msToString(step.duration)}</span> <span style={{ float: 'right' }}>{msToString(step.duration)}</span>
{attachmentName && <a style={{ float: 'right' }} title='link to attachment' href={'#' + componentID(params => params.set('attachment', attachmentName))} onClick={evt => { evt.stopPropagation(); }}>{icons.attachment()}</a>} {attachmentName && <a style={{ float: 'right' }} title='link to attachment' href='TODO' onClick={evt => { evt.stopPropagation(); }}>{icons.attachment()}</a>}
{statusIcon(step.error || step.duration === -1 ? 'failed' : 'passed')} {statusIcon(step.error || step.duration === -1 ? 'failed' : 'passed')}
<span>{step.title}</span> <span>{step.title}</span>
{step.count > 1 && <> <span className='test-result-counter'>{step.count}</span></>} {step.count > 1 && <> <span className='test-result-counter'>{step.count}</span></>}

View file

@ -26,11 +26,10 @@ export const TreeItem: React.FunctionComponent<{
depth: number, depth: number,
selected?: boolean, selected?: boolean,
style?: React.CSSProperties, style?: React.CSSProperties,
id?: string, }> = ({ title, loadChildren, onClick, expandByDefault, depth, selected, style }) => {
}> = ({ title, loadChildren, onClick, expandByDefault, depth, selected, style, id }) => {
const [expanded, setExpanded] = React.useState(expandByDefault || false); const [expanded, setExpanded] = React.useState(expandByDefault || false);
const className = selected ? 'tree-item-title selected' : 'tree-item-title'; const className = selected ? 'tree-item-title selected' : 'tree-item-title';
return <div className={'tree-item'} id={id} style={style}> return <div className={'tree-item'} style={style}>
<span className={className} style={{ whiteSpace: 'nowrap', paddingLeft: depth * 22 + 4 }} onClick={() => { onClick?.(); setExpanded(!expanded); }} > <span className={className} style={{ whiteSpace: 'nowrap', paddingLeft: depth * 22 + 4 }} onClick={() => { onClick?.(); setExpanded(!expanded); }} >
{loadChildren && !!expanded && icons.downArrow()} {loadChildren && !!expanded && icons.downArrow()}
{loadChildren && !expanded && icons.rightArrow()} {loadChildren && !expanded && icons.rightArrow()}