Skip to content

Commit 3979476

Browse files
authored
improvement(workspace): allocate more space to name column in resource tables (#4645)
1 parent 42bbb8a commit 3979476

8 files changed

Lines changed: 48 additions & 40 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export interface ResourceColumn {
2323
id: string
2424
header: string
2525
widthMultiplier?: number
26+
/** Fixed pixel width. When set, the column is excluded from proportional sizing. */
27+
widthPx?: number
2628
}
2729

2830
export interface ResourceCell {
@@ -649,26 +651,32 @@ const ResourceColGroup = memo(function ResourceColGroup({
649651
columns,
650652
hasCheckbox,
651653
}: ResourceColGroupProps) {
652-
const weights = columns.map(
653-
(col, colIdx) => (colIdx === 0 ? 2.5 : 1.0) * (col.widthMultiplier ?? 1)
654+
const fixedPxTotal = columns.reduce((sum, col) => sum + (col.widthPx ?? 0), 0)
655+
const flexibleWeights = columns.map((col, colIdx) =>
656+
col.widthPx ? 0 : (colIdx === 0 ? 2.5 : 1.0) * (col.widthMultiplier ?? 1)
654657
)
655-
const total = weights.reduce((s, w) => s + w, 0)
658+
const flexibleTotal = flexibleWeights.reduce((s, w) => s + w, 0)
659+
const reservedPx = fixedPxTotal + (hasCheckbox ? CHECKBOX_COLUMN_WIDTH_PX : 0)
656660

657661
return (
658662
<colgroup>
659663
{hasCheckbox && <col style={{ width: CHECKBOX_COLUMN_WIDTH }} />}
660664
{columns.map((col, colIdx) => {
661-
const columnRatio = weights[colIdx] / total
665+
if (col.widthPx) {
666+
return <col key={col.id} style={{ width: `${col.widthPx}px` }} />
667+
}
668+
const columnRatio = flexibleTotal > 0 ? flexibleWeights[colIdx] / flexibleTotal : 0
662669
const columnPercent = columnRatio * 100
663-
const checkboxOffset = CHECKBOX_COLUMN_WIDTH_PX * columnRatio
670+
const reservedOffset = reservedPx * columnRatio
664671

665672
return (
666673
<col
667674
key={col.id}
668675
style={{
669-
width: hasCheckbox
670-
? `calc(${columnPercent}% - ${checkboxOffset}px)`
671-
: `${columnPercent}%`,
676+
width:
677+
reservedOffset > 0
678+
? `calc(${columnPercent}% - ${reservedOffset}px)`
679+
: `${columnPercent}%`,
672680
}}
673681
/>
674682
)

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ const ACCEPT_ATTR = SUPPORTED_EXTENSIONS.map((ext) => `.${ext}`).join(',')
113113

114114
const COLUMNS: ResourceColumn[] = [
115115
{ id: 'name', header: 'Name' },
116-
{ id: 'size', header: 'Size' },
117-
{ id: 'type', header: 'Type' },
118-
{ id: 'created', header: 'Created' },
119-
{ id: 'owner', header: 'Owner' },
120-
{ id: 'updated', header: 'Last Updated' },
116+
{ id: 'size', header: 'Size', widthPx: 110 },
117+
{ id: 'type', header: 'Type', widthPx: 120 },
118+
{ id: 'created', header: 'Created', widthPx: 150 },
119+
{ id: 'owner', header: 'Owner', widthPx: 160 },
120+
{ id: 'updated', header: 'Last Updated', widthPx: 150 },
121121
]
122122

123123
const MIME_TYPE_LABELS: Record<string, string> = {

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ function truncateContent(content: string, maxLength = 150, searchQuery = ''): st
127127

128128
const CHUNK_COLUMNS: ResourceColumn[] = [
129129
{ id: 'content', header: 'Content' },
130-
{ id: 'index', header: 'Index' },
131-
{ id: 'tokens', header: 'Tokens' },
132-
{ id: 'status', header: 'Status' },
130+
{ id: 'index', header: 'Index', widthPx: 100 },
131+
{ id: 'tokens', header: 'Tokens', widthPx: 100 },
132+
{ id: 'status', header: 'Status', widthPx: 120 },
133133
]
134134

135135
export function Document({

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ const DOCUMENTS_PER_PAGE = 50
8686

8787
const DOCUMENT_COLUMNS: ResourceColumn[] = [
8888
{ id: 'name', header: 'Name' },
89-
{ id: 'size', header: 'Size' },
90-
{ id: 'tokens', header: 'Tokens' },
91-
{ id: 'chunks', header: 'Chunks' },
92-
{ id: 'uploaded', header: 'Uploaded' },
93-
{ id: 'status', header: 'Status' },
94-
{ id: 'tags', header: 'Tags' },
89+
{ id: 'size', header: 'Size', widthPx: 90 },
90+
{ id: 'tokens', header: 'Tokens', widthPx: 90 },
91+
{ id: 'chunks', header: 'Chunks', widthPx: 90 },
92+
{ id: 'uploaded', header: 'Uploaded', widthPx: 140 },
93+
{ id: 'status', header: 'Status', widthPx: 110 },
94+
{ id: 'tags', header: 'Tags', widthPx: 160 },
9595
]
9696

9797
interface KnowledgeBaseProps {

apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ interface KnowledgeBaseWithDocCount extends KnowledgeBaseData {
4343

4444
const COLUMNS: ResourceColumn[] = [
4545
{ id: 'name', header: 'Name' },
46-
{ id: 'documents', header: 'Documents' },
47-
{ id: 'tokens', header: 'Tokens' },
48-
{ id: 'connectors', header: 'Connectors' },
49-
{ id: 'created', header: 'Created' },
50-
{ id: 'owner', header: 'Owner' },
51-
{ id: 'updated', header: 'Last Updated' },
46+
{ id: 'documents', header: 'Documents', widthPx: 110 },
47+
{ id: 'tokens', header: 'Tokens', widthPx: 90 },
48+
{ id: 'connectors', header: 'Connectors', widthPx: 130 },
49+
{ id: 'created', header: 'Created', widthPx: 140 },
50+
{ id: 'owner', header: 'Owner', widthPx: 150 },
51+
{ id: 'updated', header: 'Last Updated', widthPx: 140 },
5252
]
5353

5454
const DATABASE_ICON = <Database className='size-[14px]' />

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ const REFRESH_SPINNER_DURATION_MS = 1000 as const
106106

107107
const LOG_COLUMNS: ResourceColumn[] = [
108108
{ id: 'workflow', header: 'Workflow' },
109-
{ id: 'date', header: 'Date' },
110-
{ id: 'status', header: 'Status' },
111-
{ id: 'cost', header: 'Cost' },
112-
{ id: 'trigger', header: 'Trigger' },
113-
{ id: 'duration', header: 'Duration' },
109+
{ id: 'date', header: 'Date', widthPx: 160 },
110+
{ id: 'status', header: 'Status', widthPx: 120 },
111+
{ id: 'cost', header: 'Cost', widthPx: 100 },
112+
{ id: 'trigger', header: 'Trigger', widthPx: 140 },
113+
{ id: 'duration', header: 'Duration', widthPx: 110 },
114114
]
115115

116116
interface LogSelectionState {

apps/sim/app/workspace/[workspaceId]/scheduled-tasks/scheduled-tasks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function getScheduleDescription(s: WorkspaceScheduleData) {
5050
const COLUMNS: ResourceColumn[] = [
5151
{ id: 'task', header: 'Task' },
5252
{ id: 'schedule', header: 'Schedule', widthMultiplier: 1.5 },
53-
{ id: 'nextRun', header: 'Next Run' },
54-
{ id: 'lastRun', header: 'Last Run' },
53+
{ id: 'nextRun', header: 'Next Run', widthPx: 160 },
54+
{ id: 'lastRun', header: 'Last Run', widthPx: 160 },
5555
]
5656

5757
export function ScheduledTasks() {

apps/sim/app/workspace/[workspaceId]/tables/tables.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ const logger = createLogger('Tables')
4949

5050
const COLUMNS: ResourceColumn[] = [
5151
{ id: 'name', header: 'Name' },
52-
{ id: 'columns', header: 'Columns' },
53-
{ id: 'rows', header: 'Rows' },
54-
{ id: 'created', header: 'Created' },
55-
{ id: 'owner', header: 'Owner' },
56-
{ id: 'updated', header: 'Last Updated' },
52+
{ id: 'columns', header: 'Columns', widthPx: 110 },
53+
{ id: 'rows', header: 'Rows', widthPx: 100 },
54+
{ id: 'created', header: 'Created', widthPx: 150 },
55+
{ id: 'owner', header: 'Owner', widthPx: 160 },
56+
{ id: 'updated', header: 'Last Updated', widthPx: 150 },
5757
]
5858

5959
export function Tables() {

0 commit comments

Comments
 (0)