Skip to content

Commit 06cd5bf

Browse files
committed
improvement(sim-links): match sibling resource pages (loading chrome, shared no-results, menu order, columns)
1 parent d672198 commit 06cd5bf

4 files changed

Lines changed: 52 additions & 24 deletions

File tree

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
'use client'
22

3-
import { Link } from '@sim/emcn/icons'
4-
import { ResourceChromeFallback } from '@/app/workspace/[workspaceId]/components/resource/components/resource-chrome-fallback'
3+
import { Link, Plus } from '@sim/emcn/icons'
4+
import {
5+
type ChromeActionSpec,
6+
ResourceChromeFallback,
7+
} from '@/app/workspace/[workspaceId]/components/resource/components/resource-chrome-fallback'
8+
9+
const COLUMNS = [
10+
{ id: 'name', header: 'Name' },
11+
{ id: 'destination', header: 'Destination', widthMultiplier: 1.6 },
12+
{ id: 'description', header: 'Description', widthMultiplier: 1.4 },
13+
{ id: 'owner', header: 'Created by' },
14+
{ id: 'opens', header: 'Opens' },
15+
{ id: 'access', header: 'Access' },
16+
{ id: 'updated', header: 'Updated' },
17+
]
18+
19+
const ACTIONS: ChromeActionSpec[] = [{ text: 'New link', icon: Plus, variant: 'primary' }]
520

621
export default function SimLinksLoading() {
7-
return <ResourceChromeFallback icon={Link} title='Sim Links' />
22+
return (
23+
<ResourceChromeFallback
24+
icon={Link}
25+
title='Sim Links'
26+
columns={COLUMNS}
27+
actions={ACTIONS}
28+
searchPlaceholder='Search Sim links...'
29+
hasSort
30+
/>
31+
)
832
}

‎apps/sim/app/o/[organizationId]/links/sim-link-context-menu.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ export function SimLinkContextMenu({
5757
<ArrowUpRight />
5858
Open
5959
</DropdownMenuItem>
60+
<DropdownMenuItem onSelect={onCopyLink}>
61+
<Duplicate />
62+
Copy link
63+
</DropdownMenuItem>
6064
{onEdit && (
6165
<DropdownMenuItem onSelect={onEdit}>
6266
<Pencil />
6367
Edit
6468
</DropdownMenuItem>
6569
)}
66-
<DropdownMenuItem onSelect={onCopyLink}>
67-
<Duplicate />
68-
Copy link
69-
</DropdownMenuItem>
7070
{onDelete && <DropdownMenuSeparator />}
7171
{onDelete && (
7272
<DropdownMenuItem onSelect={onDelete}>

‎apps/sim/app/o/[organizationId]/links/sim-links.tsx‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Avatar, Chip, ChipConfirmModal, ChipModalError, writeTextToClipboard }
55
import { Link, Plus } from '@sim/emcn/icons'
66
import { createLogger } from '@sim/logger'
77
import { useQueryStates } from 'nuqs'
8-
import { EmptyState } from '@/components/empty-state/empty-state'
98
import type { SimLink } from '@/lib/api/contracts/sim-links'
109
import { simLinkPath } from '@/lib/navigation/paths'
1110
import { SEARCH_DEBOUNCE_MS } from '@/lib/url-state'
@@ -17,7 +16,10 @@ import {
1716
import { SimLinkContextMenu } from '@/app/o/[organizationId]/links/sim-link-context-menu'
1817
import { SimLinkIcon } from '@/app/o/[organizationId]/links/sim-link-icon'
1918
import { SimLinkModal } from '@/app/o/[organizationId]/links/sim-link-modal'
20-
import { SimLinksEmptyState } from '@/app/workspace/[workspaceId]/components/resource/components/resource-empty-state'
19+
import {
20+
ResourceNoResults,
21+
SimLinksEmptyState,
22+
} from '@/app/workspace/[workspaceId]/components/resource/components/resource-empty-state'
2123
import type {
2224
SearchConfig,
2325
SortConfig,
@@ -37,13 +39,13 @@ import { useUrlSort } from '@/hooks/use-url-sort'
3739
const logger = createLogger('SimLinks')
3840

3941
const COLUMNS: ResourceColumn[] = [
40-
{ id: 'name', header: 'Name', widthMultiplier: 0.7 },
42+
{ id: 'name', header: 'Name' },
4143
{ id: 'destination', header: 'Destination', widthMultiplier: 1.6 },
4244
{ id: 'description', header: 'Description', widthMultiplier: 1.4 },
4345
{ id: 'owner', header: 'Created by' },
44-
{ id: 'opens', header: 'Opens', widthMultiplier: 0.7 },
46+
{ id: 'opens', header: 'Opens' },
4547
{ id: 'access', header: 'Access' },
46-
{ id: 'updated', header: 'Last updated' },
48+
{ id: 'updated', header: 'Updated' },
4749
]
4850

4951
const SORT_OPTIONS = [
@@ -165,14 +167,11 @@ export function SimLinks({ organizationId }: SimLinksProps) {
165167
<Chip onClick={() => void links.refetch()}>Retry</Chip>
166168
</div>
167169
) : !links.data ? undefined : searching ? (
168-
<EmptyState
169-
title={`No results for “${debouncedSearch.trim()}”`}
170-
description='Searched every Sim link in your organization.'
171-
action={
172-
<Chip variant='border' onClick={() => setSearch('')}>
173-
Clear search
174-
</Chip>
175-
}
170+
<ResourceNoResults
171+
search={debouncedSearch}
172+
filterCount={0}
173+
searchScope='Searched every Sim link in your organization.'
174+
onClear={() => setSearch('')}
176175
/>
177176
) : (
178177
<SimLinksEmptyState onCreate={startCreate} />

‎apps/sim/app/workspace/[workspaceId]/components/resource/components/resource-empty-state/resource-no-results.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ interface ResourceNoResultsProps {
1212
filterCount: number
1313
/** Clears the query and every filter, restoring the open folder's contents. */
1414
onClear: () => void
15+
/** Where a search looked, for a list that isn't foldered within a workspace. */
16+
searchScope?: string
1517
}
1618

1719
/**
@@ -27,14 +29,17 @@ interface ResourceNoResultsProps {
2729
* while filters narrow only the open folder. The search branch wins when both are set,
2830
* because the wider scope is the more surprising of the two.
2931
*/
30-
export function ResourceNoResults({ search, filterCount, onClear }: ResourceNoResultsProps) {
32+
export function ResourceNoResults({
33+
search,
34+
filterCount,
35+
onClear,
36+
searchScope = 'Searched every folder in this workspace.',
37+
}: ResourceNoResultsProps) {
3138
const trimmed = search.trim()
3239
return (
3340
<EmptyState
3441
title={trimmed ? `No results for “${trimmed}”` : 'No results'}
35-
description={
36-
trimmed ? 'Searched every folder in this workspace.' : 'Filters apply to this folder only.'
37-
}
42+
description={trimmed ? searchScope : 'Filters apply to this folder only.'}
3843
action={
3944
<Chip variant='border' onClick={onClear}>
4045
{trimmed && filterCount > 0

0 commit comments

Comments
 (0)