Skip to content

Commit 299c13f

Browse files
feat(tables): scope group-header run menu to the active filter
1 parent 84604eb commit 299c13f

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/headers/workflow-group-meta-cell.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ import type { DisplayColumn } from '../types'
3737
* surfaces stay in sync. */
3838
const LIMITED_RUN_PRESETS = [10, 1000] as const
3939

40+
/** Labels for the table-scoped run items. With an active filter the run is
41+
* scoped to matching rows, so the labels say "filtered rows" to make the
42+
* narrowed target visible. Shared by both menu surfaces. */
43+
function runMenuLabels(hasActiveFilter: boolean) {
44+
const rows = hasActiveFilter ? 'filtered rows' : 'rows'
45+
return {
46+
all: `Run all ${rows}`,
47+
incomplete: `Run empty ${rows}`,
48+
limited: (max: number) => `Run ${max.toLocaleString()} empty ${rows}`,
49+
}
50+
}
51+
4052
interface ColumnOptionsMenuProps {
4153
open: boolean
4254
onOpenChange: (open: boolean) => void
@@ -65,6 +77,9 @@ interface ColumnOptionsMenuProps {
6577
/** When set, surfaces a "Run N selected rows" item above Run all. */
6678
onRunColumnSelected?: () => void
6779
selectedRowCount?: number
80+
/** Table-scoped run items honor the active filter; when true the labels say
81+
* "filtered rows" so the narrowed scope is visible. */
82+
hasActiveFilter?: boolean
6883
/** When set, the menu surfaces a "View workflow" item that opens a popup
6984
* preview of the configured workflow. */
7085
onViewWorkflow?: () => void
@@ -97,12 +112,14 @@ export function ColumnOptionsMenu({
97112
onRunColumnLimited,
98113
onRunColumnSelected,
99114
selectedRowCount = 0,
115+
hasActiveFilter = false,
100116
onViewWorkflow,
101117
isPinned,
102118
onPinToggle,
103119
}: ColumnOptionsMenuProps) {
104120
const showRunActions = Boolean(onRunColumnAll && onRunColumnIncomplete)
105121
const showRunSelected = Boolean(onRunColumnSelected) && selectedRowCount > 0
122+
const runLabels = runMenuLabels(hasActiveFilter)
106123
return (
107124
<DropdownMenu open={open} onOpenChange={onOpenChange}>
108125
<DropdownMenuTrigger asChild>
@@ -140,15 +157,15 @@ export function ColumnOptionsMenu({
140157
</DropdownMenuItem>
141158
)}
142159
<DropdownMenuItem onSelect={() => onRunColumnAll?.()}>
143-
Run all rows
160+
{runLabels.all}
144161
</DropdownMenuItem>
145162
<DropdownMenuItem onSelect={() => onRunColumnIncomplete?.()}>
146-
Run empty rows
163+
{runLabels.incomplete}
147164
</DropdownMenuItem>
148165
{onRunColumnLimited &&
149166
LIMITED_RUN_PRESETS.map((max) => (
150167
<DropdownMenuItem key={max} onSelect={() => onRunColumnLimited(max)}>
151-
{`Run ${max.toLocaleString()} empty rows`}
168+
{runLabels.limited(max)}
152169
</DropdownMenuItem>
153170
))}
154171
</DropdownMenuSubContent>
@@ -221,6 +238,9 @@ interface WorkflowGroupMetaCellProps {
221238
/** Row ids in the user's current multi-row selection; when non-empty the
222239
* run menu adds a "Run N selected rows" option. */
223240
selectedRowIds?: string[] | null
241+
/** True when the grid has an active filter — table-scoped run items apply
242+
* only to matching rows and are labeled "filtered rows". */
243+
hasActiveFilter?: boolean
224244
/** Opens a popup preview of the underlying workflow. */
225245
onViewWorkflow?: (workflowId: string) => void
226246
/** When set, the meta cell becomes draggable and forwards events through
@@ -267,6 +287,7 @@ export function WorkflowGroupMetaCell({
267287
onDeleteColumn,
268288
onDeleteGroup,
269289
selectedRowIds,
290+
hasActiveFilter = false,
270291
onViewWorkflow,
271292
onDragStart,
272293
onDragOver,
@@ -292,6 +313,7 @@ export function WorkflowGroupMetaCell({
292313
const didDragRef = useRef(false)
293314

294315
const selectedCount = selectedRowIds?.length ?? 0
316+
const runLabels = runMenuLabels(hasActiveFilter)
295317

296318
function handleRunAll() {
297319
if (groupId) onRunColumn?.(groupId, 'all')
@@ -443,11 +465,13 @@ export function WorkflowGroupMetaCell({
443465
{`Run ${selectedCount} selected ${selectedCount === 1 ? 'row' : 'rows'}`}
444466
</DropdownMenuItem>
445467
)}
446-
<DropdownMenuItem onSelect={handleRunAll}>Run all rows</DropdownMenuItem>
447-
<DropdownMenuItem onSelect={handleRunIncomplete}>Run empty rows</DropdownMenuItem>
468+
<DropdownMenuItem onSelect={handleRunAll}>{runLabels.all}</DropdownMenuItem>
469+
<DropdownMenuItem onSelect={handleRunIncomplete}>
470+
{runLabels.incomplete}
471+
</DropdownMenuItem>
448472
{LIMITED_RUN_PRESETS.map((max) => (
449473
<DropdownMenuItem key={max} onSelect={() => handleRunLimited(max)}>
450-
{`Run ${max.toLocaleString()} empty rows`}
474+
{runLabels.limited(max)}
451475
</DropdownMenuItem>
452476
))}
453477
</DropdownMenuContent>
@@ -470,6 +494,7 @@ export function WorkflowGroupMetaCell({
470494
onRunColumnLimited={onRunColumn ? handleRunLimited : undefined}
471495
onRunColumnSelected={onRunColumn && selectedCount > 0 ? handleRunSelected : undefined}
472496
selectedRowCount={selectedCount}
497+
hasActiveFilter={hasActiveFilter}
473498
onViewWorkflow={onViewWorkflow ? () => onViewWorkflow(workflowId) : undefined}
474499
isPinned={isPinned}
475500
onPinToggle={onPinToggle}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,10 @@ export function TableGrid({
503503
rowIds?: string[],
504504
limit?: RunLimit
505505
) {
506-
onRunColumn(groupId, runMode, rowIds, limit)
506+
// Table-scoped runs (Run all / Run empty / Run N empty) honor the active
507+
// filter; an explicit rowIds scope (Run selected) already names its rows.
508+
const filter = rowIds ? undefined : (queryOptions.filter ?? undefined)
509+
onRunColumn(groupId, runMode, rowIds, limit, filter)
507510
}
508511

509512
const handleViewWorkflow = useCallback(
@@ -3643,6 +3646,7 @@ export function TableGrid({
36433646
onSelectGroup={handleGroupSelect}
36443647
onOpenConfig={() => handleConfigureWorkflowGroup(g.groupId)}
36453648
onRunColumn={userPermissions.canEdit ? handleRunColumn : undefined}
3649+
hasActiveFilter={Boolean(queryOptions.filter)}
36463650
selectedRowIds={selectedRowIds}
36473651
onInsertLeft={
36483652
userPermissions.canEdit ? handleInsertColumnLeft : undefined

0 commit comments

Comments
 (0)