Skip to content

Commit

Permalink
feat(ui): EntryInfo - add CopyToClipboard to file names
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Sep 25, 2024
1 parent ece5364 commit 6b0e8d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/** header */
.header {
/** space for close icon */
padding-right: calc(var(--space-medium) + var(--space-xxxsmall) + var(--space-xsmall));
padding-right: calc(var(--space-xlarge) + var(--space-xxxsmall) + var(--space-xsmall));
border-bottom: 1px solid var(--color-outline);
}

Expand Down
32 changes: 23 additions & 9 deletions packages/ui/src/components/entry-info/entry-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { MetricRunInfo, ReportMetricRow } from '@bundle-stats/utils';
import { METRIC_TYPE_CONFIGS, getMetricRunInfo } from '@bundle-stats/utils';

import { Box } from '../../layout/box';
import { FlexStack } from '../../layout/flex-stack';
import { Stack } from '../../layout/stack';
import { FileName } from '../../ui/file-name';
import { Button } from '../../ui/button';
Expand All @@ -14,7 +15,7 @@ import { Table } from '../../ui/table';
import { RunInfo } from '../run-info';
import * as I18N from './entry-info.i18n';
import css from './entry-info.module.css';
import { Tooltip } from '../../ui';
import { CopyToClipboard, Tooltip } from '../../ui';

interface EntryInfoMetaLinkProps {
as?: ElementType;
Expand Down Expand Up @@ -102,10 +103,10 @@ export const EntryInfo = (props: EntryInfoProps & React.ComponentProps<'div'>) =
<Portal className={cx(css.root, className)}>
<Box padding="medium" as="header" className={css.header}>
<Stack space="small">
<h3 className={css.label}>
<FlexStack space="xxxsmall" alignItems="center" as="h3" className={css.label}>
<FileName as="code" name={itemTitle || item.label} className={css.fileName} />
</h3>

<CopyToClipboard text={item.label} />
</FlexStack>
<div>{renderRunInfo(item)}</div>
</Stack>
<Button
Expand Down Expand Up @@ -135,18 +136,31 @@ export const EntryInfo = (props: EntryInfoProps & React.ComponentProps<'div'>) =
<Table.TBody>
{item.runs.map((run, index) => {
const key = `info-${run?.name || index}-${index}`;
const rowRun = run as any;

return (
<Table.Tr key={key}>
<Table.Th className={cx(css.runsCell, css.runsColJob)}>
{labels[index]}
</Table.Th>
<Table.Td className={cx(css.runsCell, css.runsColName)}>
<FileName
className={css.fileName}
as="code"
name={(run as any)?.[runNameSelector] || '-'}
/>
{rowRun?.[runNameSelector] ? (
<FlexStack
space="xxxsmall"
alignItems="center"
as="h3"
className={css.label}
>
<FileName
as="code"
name={rowRun[runNameSelector]}
className={css.fileName}
/>
<CopyToClipboard text={item.label} />
</FlexStack>
) : (
'-'
)}
</Table.Td>
<Table.Td className={cx(css.runsCell, css.runsColSize)}>
<span className={css.size}>
Expand Down

0 comments on commit 6b0e8d5

Please sign in to comment.