Skip to content

Commit 619be07

Browse files
authored
Merge pull request #5423 from parca-dev/ui-improvements
Parca UI improvements
2 parents e92cda4 + bc19a47 commit 619be07

File tree

6 files changed

+46
-16
lines changed

6 files changed

+46
-16
lines changed

ui/packages/shared/profile/src/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ const ColorStackLegend = ({compareMode = false}: Props): JSX.Element => {
7171
}}
7272
>
7373
<div className="flex items-center">
74-
<div className="mr-1 inline-block h-4 w-4" style={{backgroundColor: color}} />
74+
<div
75+
className="mr-1 inline-block h-4 w-4 rounded-[4px]"
76+
style={{backgroundColor: color}}
77+
/>
7578
<span className="text-sm">{feature}</span>
7679
</div>
7780
{isHighlighted ? (

ui/packages/shared/profile/src/ProfileView/components/ColorStackLegend.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const ColorStackLegend = ({mappings, compareMode = false, loading}: Props): Reac
8888
className={cx(
8989
'flex-no-wrap mb-1 flex w-[19.25%] items-center justify-between text-ellipsis p-1',
9090
{
91-
'cursor-pointer': filteringAllowed,
91+
'cursor-pointer': filteringAllowed && colorBy === 'binary',
9292
'bg-gray-200 dark:bg-gray-800': isHighlighted,
9393
}
9494
)}
@@ -105,7 +105,10 @@ const ColorStackLegend = ({mappings, compareMode = false, loading}: Props): Reac
105105
>
106106
<div className="flex w-11/12 items-center justify-start">
107107
<div className="flex w-5 items-center">
108-
<div className="mr-1 inline-block h-4 w-4" style={{backgroundColor: color}} />
108+
<div
109+
className="mr-1 inline-block h-4 w-4 rounded-[4px]"
110+
style={{backgroundColor: color}}
111+
/>
109112
</div>
110113
<div className="shrink overflow-hidden text-ellipsis whitespace-nowrap text-sm hover:whitespace-normal">
111114
{feature}

ui/packages/shared/profile/src/ProfileView/hooks/useProfileMetadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const useProfileMetadata = ({
4747
const mappingsList = useMappingList(metadataMappingFiles);
4848
const filenamesList = useFilenamesList(table);
4949

50-
const colorMappings = colorBy === 'binary' ? mappingsList : filenamesList;
50+
const colorMappings = colorBy === 'binary' || colorBy === '' ? mappingsList : filenamesList;
5151

5252
return {
5353
table,

ui/packages/shared/profile/src/SimpleMatchers/Select.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ const CustomSelect: React.FC<CustomSelectProps> = ({
183183
}
184184
};
185185

186+
const moveCaretToEnd = (e: React.FocusEvent<HTMLTextAreaElement>): void => {
187+
const value = e.target.value;
188+
e.target.value = '';
189+
e.target.value = value;
190+
};
191+
186192
return (
187193
<div ref={containerRef} className="relative" onKeyDown={handleKeyDown} onClick={onButtonClick}>
188194
<div
@@ -232,6 +238,7 @@ const CustomSelect: React.FC<CustomSelectProps> = ({
232238
placeholder="Type a RegEx to add"
233239
value={searchTerm}
234240
onChange={e => setSearchTerm(e.target.value)}
241+
onFocus={e => moveCaretToEnd(e)}
235242
/>
236243
{editable && searchTerm.length > 0 && (
237244
<div className="p-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800">

ui/packages/shared/profile/src/Table/index.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
import {Int64, Vector, tableFromIPC, vectorFromArray} from 'apache-arrow';
2525
import cx from 'classnames';
2626
import {AnimatePresence, motion} from 'framer-motion';
27+
import {Tooltip} from 'react-tooltip';
2728

2829
import {
2930
Table as TableComponent,
@@ -34,7 +35,7 @@ import {
3435
import {type RowRendererProps} from '@parca/components/dist/Table';
3536
import {useCurrentColorProfile} from '@parca/hooks';
3637
import {ProfileType} from '@parca/parser';
37-
import {isSearchMatch, valueFormatter} from '@parca/utilities';
38+
import {getLastItem, isSearchMatch, valueFormatter} from '@parca/utilities';
3839

3940
import {getFilenameColors, getMappingColors} from '../ProfileIcicleGraph/IcicleGraphArrow/';
4041
import {colorByColors} from '../ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes';
@@ -303,12 +304,22 @@ export const Table = React.memo(function Table({
303304

304305
const columns = useMemo<Array<ColumnDef<Row>>>(() => {
305306
return [
306-
columnHelper.accessor('color', {
307+
columnHelper.accessor('colorProperty', {
307308
id: 'color',
308309
header: '',
309310
cell: info => {
310-
const color = info.getValue() as string;
311-
return <div className="w-4 h-4 rounded-[4px]" style={{backgroundColor: color}} />;
311+
const color = info.getValue() as {color: string; mappingFile: string};
312+
return (
313+
<>
314+
<div
315+
className="w-4 h-4 rounded-[4px]"
316+
style={{backgroundColor: color.color}}
317+
data-tooltip-id="table-color-tooltip"
318+
data-tooltip-content={getLastItem(color.mappingFile)}
319+
/>
320+
<Tooltip id="table-color-tooltip" />
321+
</>
322+
);
312323
},
313324
size: 10,
314325
}),
@@ -577,13 +588,16 @@ export const Table = React.memo(function Table({
577588

578589
return {
579590
id: i,
580-
color: getRowColor(
581-
colorByColors,
582-
mappingFileColumn,
583-
i,
584-
functionFileNameColumn,
585-
colorBy as string
586-
),
591+
colorProperty: {
592+
color: getRowColor(
593+
colorByColors,
594+
mappingFileColumn,
595+
i,
596+
functionFileNameColumn,
597+
colorBy as string
598+
),
599+
mappingFile,
600+
},
587601
name: RowName(mappingFileColumn, locationAddressColumn, functionNameColumn, i),
588602
flat,
589603
flatDiff,

ui/packages/shared/profile/src/Table/utils/functions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import {hexifyAddress} from '../../utils';
2121

2222
export interface DataRow {
2323
id: number;
24-
color: string;
24+
colorProperty: {
25+
color: string;
26+
mappingFile: string;
27+
};
2528
name: string;
2629
flat: bigint;
2730
flatDiff: bigint;

0 commit comments

Comments
 (0)