Skip to content
Merged
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
Expand Up @@ -25,6 +25,10 @@ import {
FieldError,
RequiredLabel,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields'
import {
TableSidebarHeader,
TableSidebarHeaderAction,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-sidebar-header/table-sidebar-header'
import { useAddTableColumn, useUpdateColumn } from '@/hooks/queries/tables'
import { SelectOptionsEditor } from '../select-field'
import { columnTypeOptionsForTable } from './column-types'
Expand Down Expand Up @@ -263,19 +267,12 @@ function ColumnConfigBody({

return (
<div className='flex h-full flex-col'>
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<TableSidebarHeader>
<h2 className='text-[var(--text-primary)] text-small'>Configure column</h2>
<Button
variant='ghost'
size='sm'
onClick={onClose}
iconPadding='sm'
className='size-7'
aria-label='Close'
>
<TableSidebarHeaderAction onClick={onClose} aria-label='Close'>
<X className='size-[14px]' />
</Button>
</div>
</TableSidebarHeaderAction>
</TableSidebarHeader>

<div className='flex-1 overflow-y-auto overflow-x-hidden px-2 pt-3 pb-2 [overflow-anchor:none]'>
{/* `disabled` on the fieldset reaches every native control inside,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import type { ColumnDefinition, WorkflowGroup, WorkflowGroupOutput } from '@/lib
import { columnMatchesRef, getColumnId } from '@/lib/table/column-keys'
import { deriveOutputColumnName } from '@/lib/table/column-naming'
import { FieldError } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields'
import {
TableSidebarHeader,
TableSidebarHeaderAction,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-sidebar-header/table-sidebar-header'
import type { EnrichmentConfig as EnrichmentDef } from '@/enrichments/types'
import {
useAddWorkflowGroup,
Expand Down Expand Up @@ -232,31 +236,21 @@ export function EnrichmentConfig({

return (
<div className='flex h-full flex-col'>
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<TableSidebarHeader>
<div className='flex min-w-0 items-center gap-1.5'>
<Button
variant='ghost'
size='sm'
<TableSidebarHeaderAction
onClick={onBack}
iconPadding='sm'
className='size-7 flex-none'
className='flex-none'
aria-label='Back to enrichments'
>
<ArrowLeft className='size-[14px]' />
</Button>
</TableSidebarHeaderAction>
<OverflowText label={enrichment.name} className='text-[var(--text-primary)] text-small' />
</div>
<Button
variant='ghost'
size='sm'
onClick={onClose}
iconPadding='sm'
className='size-7 flex-none'
aria-label='Close'
>
<TableSidebarHeaderAction onClick={onClose} className='flex-none' aria-label='Close'>
<X className='size-[14px]' />
</Button>
</div>
</TableSidebarHeaderAction>
</TableSidebarHeader>

<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]'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use client'

import { useState } from 'react'
import { Button, ChipInput, cn } from '@sim/emcn'
import { ChipInput, cn } from '@sim/emcn'
import { Search, X } from '@sim/emcn/icons'
import type { ColumnDefinition, WorkflowGroup } from '@/lib/table'
import {
TableSidebarHeader,
TableSidebarHeaderAction,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-sidebar-header/table-sidebar-header'
import { ALL_ENRICHMENTS } from '@/enrichments'
import { getEnrichment } from '@/enrichments/registry'
import type { EnrichmentConfig as EnrichmentDef } from '@/enrichments/types'
Expand Down Expand Up @@ -71,19 +75,12 @@ function EnrichmentsSidebarBody({
if (editGroup && !editEnrichment) {
return (
<div className='flex h-full flex-col'>
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<TableSidebarHeader>
<h2 className='text-[var(--text-primary)] text-small'>Enrichment</h2>
<Button
variant='ghost'
size='sm'
onClick={onClose}
iconPadding='sm'
className='size-7 flex-none'
aria-label='Close'
>
<TableSidebarHeaderAction onClick={onClose} className='flex-none' aria-label='Close'>
<X className='size-[14px]' />
</Button>
</div>
</TableSidebarHeaderAction>
</TableSidebarHeader>
<div className='flex flex-1 items-center justify-center px-6 text-center'>
<p className='text-[var(--text-tertiary)] text-small'>
This enrichment ("{editGroup.enrichmentId}") is no longer available. Delete the column
Expand Down Expand Up @@ -118,19 +115,12 @@ function EnrichmentsSidebarBody({

return (
<div className='flex h-full flex-col'>
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<TableSidebarHeader>
<h2 className='text-[var(--text-primary)] text-small'>Enrichments</h2>
<Button
variant='ghost'
size='sm'
onClick={onClose}
iconPadding='sm'
className='size-7 flex-none'
aria-label='Close'
>
<TableSidebarHeaderAction onClick={onClose} className='flex-none' aria-label='Close'>
<X className='size-[14px]' />
</Button>
</div>
</TableSidebarHeaderAction>
</TableSidebarHeader>

<div className='px-2 pt-3'>
<ChipInput
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { type ButtonHTMLAttributes, forwardRef, type ReactNode } from 'react'
import { Button, cn } from '@sim/emcn'

interface TableSidebarHeaderProps {
children: ReactNode
}

export function TableSidebarHeader({ children }: TableSidebarHeaderProps) {
return (
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
{children}
</div>
)
}

interface TableSidebarHeaderActionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
'aria-label': string
}

export const TableSidebarHeaderAction = forwardRef<
HTMLButtonElement,
TableSidebarHeaderActionProps
>(({ className, ...props }, ref) => (
<Button
{...props}
ref={ref}
variant='ghost'
size='sm'
iconPadding='sm'
className={cn(
'size-7 focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--text-muted)_30%,transparent)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)]',
className
)}
/>
))

TableSidebarHeaderAction.displayName = 'TableSidebarHeaderAction'
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import {
FieldError,
RequiredLabel,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields'
import {
TableSidebarHeader,
TableSidebarHeaderAction,
} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-sidebar-header/table-sidebar-header'
import { PreviewWorkflow } from '@/app/workspace/[workspaceId]/w/components/preview'
import { BlockTile } from '@/blocks/block-tile'
import { useDeployedWorkflowState } from '@/hooks/queries/deployments'
Expand Down Expand Up @@ -630,35 +634,25 @@ export function WorkflowSidebarBody({

return (
<div className='flex h-full flex-col'>
<div className='flex min-h-[48px] items-center justify-between border-[var(--border)] border-b px-3 py-[8.5px]'>
<TableSidebarHeader>
<div className='flex min-w-0 items-center gap-1.5'>
{showBackButton && (
<Button
variant='ghost'
size='sm'
<TableSidebarHeaderAction
onClick={onBack}
iconPadding='sm'
className='size-7 flex-none'
className='flex-none'
aria-label='Back to enrichments'
>
<ArrowLeft className='size-[14px]' />
</Button>
</TableSidebarHeaderAction>
)}
<h2 className='flex min-w-0'>
<OverflowText label={title} className='text-[var(--text-primary)] text-small' />
</h2>
</div>
<Button
variant='ghost'
size='sm'
onClick={onClose}
iconPadding='sm'
className='size-7 flex-none'
aria-label='Close'
>
<TableSidebarHeaderAction onClick={onClose} className='flex-none' aria-label='Close'>
<X className='size-[14px]' />
</Button>
</div>
</TableSidebarHeaderAction>
</TableSidebarHeader>

<div className='flex-1 overflow-y-auto overflow-x-hidden px-2 pt-3 pb-2 [overflow-anchor:none]'>
{/* Single-output mode renames this column directly. */}
Expand Down
Loading