Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
'use client'

import type React from 'react'
import { useState } from 'react'
import { toError } from '@sim/utils/errors'
import { X } from 'lucide-react'
import { Button, ChipCombobox, FieldDivider, Input, Label, Switch, toast } from '@/components/emcn'
import {
Button,
ChipCombobox,
ChipInput,
FieldDivider,
Label,
Switch,
toast,
} from '@/components/emcn'
import { X } from '@/components/emcn/icons'
import { findValidationIssue, isValidationError } from '@/lib/api/client/errors'
import { cn } from '@/lib/core/utils/cn'
import type { ColumnDefinition } from '@/lib/table'
import {
FieldError,
RequiredLabel,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields'
import { useAddTableColumn, useUpdateColumn } from '@/hooks/queries/tables'
import { PLAIN_COLUMN_TYPE_OPTIONS } from './column-types'

Expand Down Expand Up @@ -169,7 +180,7 @@ function ColumnConfigBody({
<div className='flex-1 overflow-y-auto overflow-x-hidden px-2 pt-3 pb-2 [overflow-anchor:none]'>
<div className='flex flex-col gap-[9.5px]'>
<RequiredLabel htmlFor='column-sidebar-name'>Column name</RequiredLabel>
<Input
<ChipInput
id='column-sidebar-name'
value={nameInput}
onChange={(e) => {
Expand All @@ -178,6 +189,7 @@ function ColumnConfigBody({
}}
spellCheck={false}
autoComplete='off'
error={Boolean((showValidation && !trimmedName) || nameError)}
aria-invalid={(showValidation && !trimmedName) || nameError ? true : undefined}
/>
{showValidation && !trimmedName && <FieldError message='Column name is required' />}
Expand Down Expand Up @@ -228,16 +240,3 @@ function ColumnConfigBody({
</div>
)
}

function RequiredLabel({ htmlFor, children }: { htmlFor?: string; children: React.ReactNode }) {
return (
<Label htmlFor={htmlFor} className='flex items-baseline gap-1.5 whitespace-nowrap pl-0.5'>
{children}
<span className='ml-0.5'>*</span>
</Label>
)
}

function FieldError({ message }: { message: string }) {
return <p className='pl-0.5 text-caption text-destructive'>{message}</p>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import {
Badge,
Button,
ChipCombobox,
ChipInput,
CollapsibleCard,
FieldDivider,
Input,
Label,
Switch,
toast,
} from '@/components/emcn'
import { ArrowLeft, X } from '@/components/emcn/icons'
import type { AddWorkflowGroupBodyInput } from '@/lib/api/contracts/tables'
import { cn } from '@/lib/core/utils/cn'
import type { ColumnDefinition, WorkflowGroup, WorkflowGroupOutput } from '@/lib/table'
import { deriveOutputColumnName } from '@/lib/table/column-naming'
import type { EnrichmentConfig as EnrichmentDef } from '@/enrichments/types'
Expand Down Expand Up @@ -280,12 +279,10 @@ export function EnrichmentConfig({
onChange={(columnName: string) =>
setInputMappings((prev) => ({ ...prev, [input.id]: columnName }))
}
error={
showValidation && input.required && !inputMappings[input.id]
? 'Required'
: null
}
/>
{showValidation && input.required && !inputMappings[input.id] && (
<p className='text-[var(--text-error)] text-caption'>Required</p>
)}
Comment on lines +283 to +285

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The inline error paragraph for input mapping validation is missing the pl-0.5 left-padding that the shared FieldError component applies. Using FieldError here would keep spacing consistent across all sidebar field errors.

Suggested change
{showValidation && input.required && !inputMappings[input.id] && (
<p className='text-[var(--text-error)] text-caption'>Required</p>
)}
{showValidation && input.required && !inputMappings[input.id] && (
<FieldError message='Required' />
)}

</CollapsibleCard>
))}
</div>
Expand Down Expand Up @@ -317,14 +314,14 @@ export function EnrichmentConfig({
}
>
<Label className='text-small'>Column name</Label>
<Input
<ChipInput
value={outputNames[output.id] ?? ''}
onChange={(e) =>
setOutputNames((prev) => ({ ...prev, [output.id]: e.target.value }))
}
spellCheck={false}
autoComplete='off'
className={cn(outErr && 'border-[var(--text-error)]')}
error={Boolean(outErr)}
/>
{outErr && <p className='text-[var(--text-error)] text-caption'>{outErr}</p>}
</CollapsibleCard>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useState } from 'react'
import { Input } from '@/components/emcn'
import { Button, ChipInput } from '@/components/emcn'
import { Search, X } from '@/components/emcn/icons'
import { cn } from '@/lib/core/utils/cn'
import type { ColumnDefinition, WorkflowGroup } from '@/lib/table'
Expand Down Expand Up @@ -74,14 +74,15 @@ function EnrichmentsSidebarBody({
<div className='flex h-full flex-col'>
<div className='flex items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<h2 className='font-medium text-[var(--text-primary)] text-small'>Enrichment</h2>
<button
type='button'
<Button
variant='ghost'
size='sm'
onClick={onClose}
className='flex size-7 flex-none items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover-hover:bg-[var(--surface-hover)] hover-hover:text-[var(--text-primary)]'
className='!p-1 size-7 flex-none'
aria-label='Close'
>
<X className='size-[14px]' />
</button>
</Button>
</div>
<div className='flex flex-1 items-center justify-center px-6 text-center'>
<p className='text-[var(--text-tertiary)] text-small'>
Expand Down Expand Up @@ -119,28 +120,26 @@ function EnrichmentsSidebarBody({
<div className='flex h-full flex-col'>
<div className='flex items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<h2 className='font-medium text-[var(--text-primary)] text-small'>Enrichments</h2>
<button
type='button'
<Button
variant='ghost'
size='sm'
onClick={onClose}
className='flex size-7 flex-none items-center justify-center rounded-md text-[var(--text-muted)] transition-colors hover-hover:bg-[var(--surface-hover)] hover-hover:text-[var(--text-primary)]'
className='!p-1 size-7 flex-none'
aria-label='Close'
>
<X className='size-[14px]' />
</button>
</Button>
</div>

<div className='px-2 pt-3'>
<div className='relative'>
<Search className='-translate-y-1/2 pointer-events-none absolute top-1/2 left-2 size-[14px] text-[var(--text-muted)]' />
<Input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder='Search'
spellCheck={false}
autoComplete='off'
className='pl-7'
/>
</div>
<ChipInput
icon={Search}
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder='Search'
spellCheck={false}
autoComplete='off'
/>
</div>

<div className='flex-1 overflow-y-auto overflow-x-hidden px-2 py-3 [overflow-anchor:none]'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './enrichments-sidebar'
export * from './new-column-dropdown'
export * from './row-modal'
export * from './run-status-control'
export * from './sidebar-fields'
export * from './table-action-bar'
export * from './table-filter'
export * from './table-grid'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { FieldError, RequiredLabel } from './sidebar-fields'
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client'

import type React from 'react'
import { Label } from '@/components/emcn'

/**
* Field label with a trailing required marker, matching the sidebar field
* rhythm shared by the column-config and workflow sidebars.
*/
export function RequiredLabel({
htmlFor,
children,
}: {
htmlFor?: string
children: React.ReactNode
}) {
return (
<Label htmlFor={htmlFor} className='flex items-baseline gap-1.5 whitespace-nowrap pl-0.5'>
{children}
<span className='ml-0.5'>*</span>
</Label>
)
}

/**
* Inline validation error rendered under a sidebar field.
*/
export function FieldError({ message }: { message: string }) {
return <p className='pl-0.5 text-[var(--text-error)] text-caption'>{message}</p>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client'

import type React from 'react'
import { AnimatePresence, domAnimation, LazyMotion, m } from 'framer-motion'
import { Button, Tooltip } from '@/components/emcn'
import { Eye, PlayOutline, RefreshCw, Square } from '@/components/emcn/icons'
Expand Down Expand Up @@ -98,71 +99,35 @@ export function TableActionBar({

<div className='flex items-center gap-[5px]'>
{showPlay && (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button
variant='ghost'
onClick={onPlay}
disabled={isLoading}
className='hover-hover:!text-[var(--text-inverse)] size-[28px] rounded-lg bg-[var(--surface-5)] p-0 text-[var(--text-secondary)] hover-hover:bg-[var(--brand-secondary)]'
aria-label={playLabel}
>
<PlayOutline className='size-[12px]' />
</Button>
</Tooltip.Trigger>
<Tooltip.Content side='top'>{playLabel}</Tooltip.Content>
</Tooltip.Root>
<ActionIconButton label={playLabel} onClick={onPlay} disabled={isLoading}>
<PlayOutline className='size-[12px]' />
</ActionIconButton>
)}

{showRefresh && (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button
variant='ghost'
onClick={onRefresh}
disabled={isLoading}
className='hover-hover:!text-[var(--text-inverse)] size-[28px] rounded-lg bg-[var(--surface-5)] p-0 text-[var(--text-secondary)] hover-hover:bg-[var(--brand-secondary)]'
aria-label={refreshLabel}
>
<RefreshCw className='size-[12px]' />
</Button>
</Tooltip.Trigger>
<Tooltip.Content side='top'>{refreshLabel}</Tooltip.Content>
</Tooltip.Root>
<ActionIconButton label={refreshLabel} onClick={onRefresh} disabled={isLoading}>
<RefreshCw className='size-[12px]' />
</ActionIconButton>
)}

{runningCount > 0 && (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button
variant='ghost'
onClick={onStopWorkflows}
disabled={isLoading}
className='hover-hover:!text-[var(--text-inverse)] size-[28px] rounded-lg bg-[var(--surface-5)] p-0 text-[var(--text-secondary)] hover-hover:bg-[var(--brand-secondary)]'
aria-label={stopLabel}
>
<Square className='size-[12px]' />
</Button>
</Tooltip.Trigger>
<Tooltip.Content side='top'>{stopLabel}</Tooltip.Content>
</Tooltip.Root>
<ActionIconButton
label={stopLabel}
onClick={onStopWorkflows}
disabled={isLoading}
>
<Square className='size-[12px]' />
</ActionIconButton>
)}

{onViewExecution && (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button
variant='ghost'
onClick={onViewExecution}
disabled={isLoading}
className='hover-hover:!text-[var(--text-inverse)] size-[28px] rounded-lg bg-[var(--surface-5)] p-0 text-[var(--text-secondary)] hover-hover:bg-[var(--brand-secondary)]'
aria-label='View execution'
>
<Eye className='size-[12px]' />
</Button>
</Tooltip.Trigger>
<Tooltip.Content side='top'>View execution</Tooltip.Content>
</Tooltip.Root>
<ActionIconButton
label='View execution'
onClick={onViewExecution}
disabled={isLoading}
>
<Eye className='size-[12px]' />
</ActionIconButton>
)}
</div>
</div>
Expand All @@ -172,3 +137,34 @@ export function TableActionBar({
</LazyMotion>
)
}

interface ActionIconButtonProps {
/** Tooltip text, also used as the button's accessible label. */
label: string
onClick: () => void
disabled: boolean
children: React.ReactNode
}

/**
* Tooltip-wrapped icon button sharing the action bar's brand-hover chrome,
* so the chrome string lives in one place.
*/
function ActionIconButton({ label, onClick, disabled, children }: ActionIconButtonProps) {
return (
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Button
variant='ghost'
onClick={onClick}
disabled={disabled}
className='hover-hover:!text-[var(--text-inverse)] size-[28px] rounded-lg bg-[var(--surface-5)] p-0 text-[var(--text-secondary)] hover-hover:bg-[var(--brand-secondary)]'
aria-label={label}
>
{children}
</Button>
</Tooltip.Trigger>
<Tooltip.Content side='top'>{label}</Tooltip.Content>
</Tooltip.Root>
)
}
Loading
Loading