Skip to content

Commit 5d308b3

Browse files
committed
fix(mothership): fix hardcoded workflow color, tables drag line overflowing
1 parent 0bb756b commit 5d308b3

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

apps/sim/app/api/workflows/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { z } from 'zod'
77
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
88
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
99
import { generateRequestId } from '@/lib/core/utils/request'
10+
import { getNextWorkflowColor } from '@/lib/workflows/colors'
1011
import { getUserEntityPermissions, workspaceExists } from '@/lib/workspaces/permissions/utils'
1112
import { verifyWorkspaceMembership } from '@/app/api/workflows/utils'
1213

@@ -16,7 +17,10 @@ const CreateWorkflowSchema = z.object({
1617
id: z.string().uuid().optional(),
1718
name: z.string().min(1, 'Name is required'),
1819
description: z.string().optional().default(''),
19-
color: z.string().optional().default('#3972F6'),
20+
color: z
21+
.string()
22+
.optional()
23+
.transform((c) => c || getNextWorkflowColor()),
2024
workspaceId: z.string().optional(),
2125
folderId: z.string().nullable().optional(),
2226
sortOrder: z.number().int().optional(),

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ export function Table({
12591259
)}
12601260
data-table-scroll
12611261
>
1262-
<div className='relative' style={{ width: `${tableWidth}px` }}>
1262+
<div className='relative h-fit' style={{ width: `${tableWidth}px` }}>
12631263
<table
12641264
className='table-fixed border-separate border-spacing-0 text-[13px]'
12651265
style={{ width: `${tableWidth}px` }}
@@ -1386,9 +1386,6 @@ export function Table({
13861386
</React.Fragment>
13871387
)
13881388
})}
1389-
{userPermissions.canEdit && (
1390-
<AddRowButton colSpan={columns.length + 2} onClick={handleAppendRow} />
1391-
)}
13921389
</>
13931390
)}
13941391
</tbody>
@@ -1400,6 +1397,9 @@ export function Table({
14001397
/>
14011398
)}
14021399
</div>
1400+
{!isLoadingTable && !isLoadingRows && userPermissions.canEdit && (
1401+
<AddRowButton onClick={handleAppendRow} />
1402+
)}
14031403
</div>
14041404

14051405
{editingRow && tableData && (
@@ -2378,26 +2378,18 @@ const AddColumnButton = React.memo(function AddColumnButton({
23782378
)
23792379
})
23802380

2381-
const AddRowButton = React.memo(function AddRowButton({
2382-
colSpan,
2383-
onClick,
2384-
}: {
2385-
colSpan: number
2386-
onClick: () => void
2387-
}) {
2381+
const AddRowButton = React.memo(function AddRowButton({ onClick }: { onClick: () => void }) {
23882382
return (
2389-
<tr>
2390-
<td colSpan={colSpan} className='px-[8px] py-[7px]'>
2391-
<button
2392-
type='button'
2393-
className='flex h-[20px] cursor-pointer items-center gap-[8px]'
2394-
onClick={onClick}
2395-
>
2396-
<Plus className='h-[14px] w-[14px] shrink-0 text-[var(--text-icon)]' />
2397-
<span className='font-medium text-[13px] text-[var(--text-body)]'>New row</span>
2398-
</button>
2399-
</td>
2400-
</tr>
2383+
<div className='px-[8px] py-[7px]'>
2384+
<button
2385+
type='button'
2386+
className='flex h-[20px] cursor-pointer items-center gap-[8px]'
2387+
onClick={onClick}
2388+
>
2389+
<Plus className='h-[14px] w-[14px] shrink-0 text-[var(--text-icon)]' />
2390+
<span className='font-medium text-[13px] text-[var(--text-body)]'>New row</span>
2391+
</button>
2392+
</div>
24012393
)
24022394
})
24032395

apps/sim/lib/workflows/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createLogger } from '@sim/logger'
55
import { and, asc, eq, inArray, isNull, max } from 'drizzle-orm'
66
import { NextResponse } from 'next/server'
77
import { getSession } from '@/lib/auth'
8+
import { getNextWorkflowColor } from '@/lib/workflows/colors'
89
import { buildDefaultWorkflowArtifacts } from '@/lib/workflows/defaults'
910
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/persistence/utils'
1011
import type { PermissionType } from '@/lib/workspaces/permissions/utils'
@@ -346,7 +347,7 @@ export async function createWorkflowRecord(params: CreateWorkflowInput) {
346347
workspaceId,
347348
name,
348349
description = null,
349-
color = '#7F2FFF',
350+
color = getNextWorkflowColor(),
350351
folderId = null,
351352
} = params
352353
const workflowId = crypto.randomUUID()

0 commit comments

Comments
 (0)