Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(soup/tasks): add quick sort click to column headers (#3214)
Seamusd1a55194b700
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListHeader.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListHeader.tsxindex b27ea60121..95411c8596 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListHeader.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/TaskListHeader.tsx@@ -1,16 +1,19 @@+import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';import { useListLayout } from '@entity/composed/list-entity/shared';+import ArrowDownIcon from '@icon/regular/arrow-down.svg';import UsersIcon from '@icon/regular/users.svg';import StatusInProgress from '@macro-icons/square/task-in-progress-circle.svg';import PriorityHigh from '@macro-icons/wide/priority-high.svg';-import { Tooltip } from '@ui';import { cn } from '@ui/utils/classname';-import { For, type JSX, Show } from 'solid-js';+import { createMemo, For, type JSX, Show } from 'solid-js';import {TASK_GRID_COLUMNS,TASK_GRID_TEMPLATE_AREAS_WIDE,TASK_GRID_TEMPLATE_COLUMNS_WIDE,} from './task-grid-template';import './list-property-value.css';+import { Tooltip } from '@ui';const HEADER_ICON_CLASS = 'size-3 text-ink-muted';@@ -21,6 +24,12 @@ const COLUMN_ICONS: Record<string, () => JSX.Element> = {assignees: () => <UsersIcon class={HEADER_ICON_CLASS} />,};+/** Which `TASK_GRID_COLUMNS.id` values map to a sort key (others are read-only). */+const COLUMN_SORT_KEYS: Partial<Record<string, SystemSortOption>> = {+ status: 'status',+ priority: 'priority',+};+/*** Responsive wrapper that only shows the header when layout is wide.* Must be used inside a ListLayoutProvider.@@ -39,12 +48,18 @@ export function ResponsiveTaskListHeader(props: { class?: string }) {/*** Sticky table header that mirrors the column template of TaskGridLayout* so the column labels line up with the property values in each row.+ *+ * Status, Priority, and Updated columns are clickable to set the active sort.*/export function TaskListHeader(props: { class?: string }) {+ const { soup } = useSoupView();+ const activeSortId = createMemo(() => soup.sort.active()[0]?.id);+ const setSort = (id: SystemSortOption) => soup.sort.setAll([id]);+return (<divclass={cn(- 'task-grid-row z-10 w-full grid items-center gap-2 px-2 h-10',+ 'task-grid-row w-full grid items-center gap-2 px-2 h-10','text-xs font-medium text-ink-extra-muted','bg-panel border-b border-edge-muted',props.class@@ -59,30 +74,100 @@ export function TaskListHeader(props: { class?: string }) {Task</div><For each={TASK_GRID_COLUMNS}>- {(col) => (- <div- style={{ 'grid-area': col.id }}- class="truncate flex items-center min-w-0"- >- {/* Wide: show label, Narrow: hide */}- <span class="truncate @max-[840px]/u-list:hidden">{col.label}</span>- {/* Narrow: show icon with tooltip */}- <div class="hidden @max-[840px]/u-list:flex @max-[840px]/u-list:px-1.5">- <Tooltip label={col.label}>{COLUMN_ICONS[col.id]?.()}</Tooltip>- </div>- </div>- )}+ {(col) => {+ const sortKey = COLUMN_SORT_KEYS[col.id];+ return (+ <HeaderCell+ gridArea={col.id}+ label={col.label}+ sortKey={sortKey}+ active={sortKey !== undefined && activeSortId() === sortKey}+ onSort={setSort}+ narrowIcon={COLUMN_ICONS[col.id]}+ />+ );+ }}</For>{/* Created By column - only shown on wide containers (>1220px) */}- <div- style={{ 'grid-area': 'createdBy' }}- class="truncate hidden @min-[1221px]/u-list:block"+ <HeaderCell+ gridArea="createdBy"+ label="Created By"+ class="hidden @min-[1221px]/u-list:flex truncate"+ />+ <HeaderCell+ gridArea="timestamp"+ label="Updated"+ sortKey="updated_at"+ active={activeSortId() === 'updated_at'}+ onSort={setSort}+ align="end"+ />+ </div>+ );+}++function HeaderCell(props: {+ gridArea: string;+ label: string;+ sortKey?: SystemSortOption;+ active?: boolean;+ onSort?: (id: SystemSortOption) => void;+ narrowIcon?: () => JSX.Element;+ align?: 'start' | 'end';+ class?: string;+}) {+ const justify = () =>+ props.align === 'end' ? 'justify-end' : 'justify-start';++ return (+ <div+ style={{ 'grid-area': props.gridArea }}+ class={cn('flex items-center min-w-0', props.class)}+ >+ <Show+ when={props.sortKey}+ fallback={+ <div class={cn('flex items-center min-w-0 w-full', justify())}>+ <Show when={props.narrowIcon}>+ <span class="truncate @max-[840px]/u-list:hidden">+ {props.label}+ </span>+ <span class="hidden @max-[840px]/u-list:flex @max-[840px]/u-list:px-1.5">+ {props.narrowIcon?.()}+ </span>+ </Show>+ <Show when={!props.narrowIcon}>+ <span class="truncate">{props.label}</span>+ </Show>+ </div>+ }>- Created By- </div>- <div style={{ 'grid-area': 'timestamp' }} class="text-right">- Updated- </div>+ {(sortKey) => (+ <button+ type="button"+ onClick={() => props.onSort?.(sortKey())}+ class={cn(+ 'flex items-center gap-1 min-w-0 w-full h-full',+ 'hover:text-ink transition-colors cursor-pointer',+ props.active && 'text-ink',+ justify()+ )}+ >+ <Show when={props.narrowIcon}>+ <Tooltip label={props.label}>{props.narrowIcon?.()}</Tooltip>+ </Show>+ <span class="truncate @max-[840px]/u-list:hidden">+ {props.label}+ </span>+ <ArrowDownIcon+ class={cn(+ 'size-3 shrink-0 @max-[840px]/u-list:hidden',+ props.active ? 'text-ink' : 'text-ink-extra-muted'+ )}+ />+ </button>+ )}+ </Show></div>);}diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-grid-template.ts b/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-grid-template.tsindex c9e42a8511..c4c95aaa59 100644--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-grid-template.ts+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/task-grid-template.ts@@ -10,6 +10,7 @@ export const TASK_GRID_COLUMNS = [dataType: DataType.SELECT_STRING,isMultiSelect: false,specificEntityType: null,+ sortKey: 'status',// CSS variable with fallback - updated by container queries in task-grid.csswidth: 'var(--task-col-status, 7rem)',},@@ -20,6 +21,7 @@ export const TASK_GRID_COLUMNS = [dataType: DataType.SELECT_STRING,isMultiSelect: false,specificEntityType: null,+ sortKey: 'priority',width: 'var(--task-col-priority, 7rem)',},{