Skip to content

Commit

Permalink
feat(ui): add freight contents to stage node tooltip (#2212)
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <[email protected]>
  • Loading branch information
rbreeze authored Jun 28, 2024
1 parent 71e20f0 commit c6ddffa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
21 changes: 19 additions & 2 deletions ui/src/features/common/freight-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import { useEffect, useState } from 'react';

import { Freight } from '@ui/gen/v1alpha1/generated_pb';

import { FreightContents } from '../freightline/freight-contents';

import { getAlias } from './utils';

export const FreightLabel = ({
freight,
showTimestamp,
breakOnHyphen
breakOnHyphen,
showContents
}: {
freight?: Freight;
showTimestamp?: boolean;
breakOnHyphen?: boolean;
showContents?: boolean;
}) => {
const [copied, setCopied] = useState<boolean>(false);

Expand Down Expand Up @@ -50,15 +54,18 @@ export const FreightLabel = ({
return (
<div
className='cursor-pointer font-mono font-semibold min-w-0 w-full'
onClick={() => {
onClick={(e) => {
if (alias || id) {
e.preventDefault();
e.stopPropagation();
navigator.clipboard.writeText(alias || id || '');
setCopied(true);
}
}}
>
{alias || id ? (
<Tooltip
overlayStyle={{ maxWidth: '320px' }}
placement='right'
title={
<>
Expand All @@ -78,6 +85,16 @@ export const FreightLabel = ({
</div>
</Info>
)}
{showContents && (
<div className='mt-2'>
<FreightContents
freight={freight}
horizontal={true}
highlighted={false}
dark={true}
/>
</div>
)}
</>
}
>
Expand Down
20 changes: 10 additions & 10 deletions ui/src/features/freightline/freight-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export const FreightContents = (props: {
freight?: Freight;
highlighted: boolean;
horizontal?: boolean;
dark?: boolean;
}) => {
const { freight, highlighted, horizontal } = props;
const linkClass = `${highlighted ? 'text-blue-600' : 'text-gray-400'} hover:text-blue-500 underline hover:underline max-w-full`;
const { freight, highlighted, horizontal, dark } = props;
const linkClass = `${highlighted ? 'text-blue-600' : 'text-gray-400'} hover:text-blue-500 underline hover:underline max-w-full min-w-0 flex-shrink`;

const FreightContentItem = (props: {
icon: IconDefinition;
Expand All @@ -25,13 +26,12 @@ export const FreightContents = (props: {
children?: string;
}) => (
<Tooltip
className={classNames(
'min-w-0 flex items-center justify-center my-1 bg-neutral-300 rounded',
{
'flex-col p-1 w-full': !horizontal,
'mr-2 p-2 max-w-60 flex-shrink': horizontal
}
)}
className={classNames('min-w-0 flex items-center justify-center my-1 rounded', {
'flex-col p-1 w-full': !horizontal,
'mr-2 p-2 max-w-60 flex-shrink': horizontal,
'bg-black text-white': dark,
'bg-neutral-300': !dark
})}
overlay={props.overlay}
title={props.title}
>
Expand All @@ -55,7 +55,7 @@ export const FreightContents = (props: {
return (
<div
className={classNames(
'flex justify-start items-center font-mono text-xs flex-shrink max-h-full max-w-full',
'flex justify-start items-center font-mono text-xs flex-shrink max-h-full max-w-full flex-wrap',
{
'text-gray-700 hover:text-gray-800': highlighted,
'text-gray-400 hover:text-gray-500': !highlighted,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/features/project/pipelines/nodes/stage-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const StageNode = ({
) : (
<div className='text-sm h-full flex flex-col items-center justify-center -mt-1'>
<div className={styles.freightLabel}>CURRENT FREIGHT</div>
<FreightLabel freight={currentFreight} showTimestamp={true} />
<FreightLabel freight={currentFreight} showTimestamp={true} showContents={true} />
</div>
)}
</div>
Expand Down

0 comments on commit c6ddffa

Please sign in to comment.