Skip to content

Commit 1f0cd66

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
improvement(ui): share missing resource states
1 parent f8bafb5 commit 1f0cd66

8 files changed

Lines changed: 74 additions & 84 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/components/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export {
22
isResourceListEmpty,
33
resourceListState,
44
} from '@/app/workspace/[workspaceId]/components/resource/is-resource-list-empty'
5-
export { ResourceNotFound } from '@/app/workspace/[workspaceId]/components/resource/resource-not-found'
65
export { ConversationListItem } from './conversation-list-item'
76
export type { ErrorBoundaryProps, ErrorStateProps } from './error'
87
export { ErrorShell, ErrorState } from './error'

‎apps/sim/app/workspace/[workspaceId]/components/resource/resource-not-found.tsx‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx‎

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
'use client'
22

33
import { lazy, memo, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
4-
import { OverflowText, PlayOutline, Skeleton, TabStripAction, Tooltip, toast } from '@sim/emcn'
4+
import {
5+
OverflowText,
6+
PlayOutline,
7+
ResourceEmptyState,
8+
Skeleton,
9+
TabStripAction,
10+
Tooltip,
11+
toast,
12+
} from '@sim/emcn'
513
import {
614
Download,
715
FileX,
@@ -666,17 +674,11 @@ function EmbeddedWorkflow({ workspaceId, workflowId }: EmbeddedWorkflowProps) {
666674

667675
if (!workflowExists || hasLoadError) {
668676
return (
669-
<div className='flex h-full flex-col items-center justify-center gap-3'>
670-
<WorkflowX className='size-[32px] text-[var(--text-icon)]' />
671-
<div className='flex flex-col items-center gap-1'>
672-
<h2 className='text-[var(--text-primary)] text-xl leading-[inherit]'>
673-
Workflow not found
674-
</h2>
675-
<p className='text-[var(--text-body)] text-small'>
676-
This workflow may have been deleted or moved
677-
</p>
678-
</div>
679-
</div>
677+
<ResourceEmptyState
678+
icon={WorkflowX}
679+
title='Workflow not found'
680+
description='This workflow may have been deleted or moved'
681+
/>
680682
)
681683
}
682684

@@ -731,15 +733,11 @@ function EmbeddedFile({
731733

732734
if (!file) {
733735
return (
734-
<div className='flex h-full flex-col items-center justify-center gap-3'>
735-
<FileX className='size-[32px] text-[var(--text-icon)]' />
736-
<div className='flex flex-col items-center gap-1'>
737-
<h2 className='text-[var(--text-primary)] text-xl leading-[inherit]'>File not found</h2>
738-
<p className='text-[var(--text-body)] text-small'>
739-
This file may have been deleted or moved
740-
</p>
741-
</div>
742-
</div>
736+
<ResourceEmptyState
737+
icon={FileX}
738+
title='File not found'
739+
description='This file may have been deleted or moved'
740+
/>
743741
)
744742
}
745743

@@ -782,15 +780,11 @@ function EmbeddedFolder({ workspaceId, folderId }: EmbeddedFolderProps) {
782780

783781
if (!folder) {
784782
return (
785-
<div className='flex h-full flex-col items-center justify-center gap-3'>
786-
<FolderIcon className='size-[32px] text-[var(--text-icon)]' />
787-
<div className='flex flex-col items-center gap-1'>
788-
<h2 className='text-[var(--text-primary)] text-xl leading-[inherit]'>Folder not found</h2>
789-
<p className='text-[var(--text-body)] text-small'>
790-
This folder may have been deleted or moved
791-
</p>
792-
</div>
793-
</div>
783+
<ResourceEmptyState
784+
icon={FolderIcon}
785+
title='Folder not found'
786+
description='This folder may have been deleted or moved'
787+
/>
794788
)
795789
}
796790

@@ -840,15 +834,11 @@ function EmbeddedLog({ workspaceId, logId, onNotFound }: EmbeddedLogProps) {
840834

841835
if (!log) {
842836
return (
843-
<div className='flex h-full flex-col items-center justify-center gap-3'>
844-
<Library className='size-[32px] text-[var(--text-icon)]' />
845-
<div className='flex flex-col items-center gap-1'>
846-
<h2 className='text-[var(--text-primary)] text-xl leading-[inherit]'>Log not found</h2>
847-
<p className='text-[var(--text-body)] text-small'>
848-
This log may have been deleted or is no longer available
849-
</p>
850-
</div>
851-
</div>
837+
<ResourceEmptyState
838+
icon={Library}
839+
title='Log not found'
840+
description='This log may have been deleted or is no longer available'
841+
/>
852842
)
853843
}
854844

‎apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
'use client'
22

33
import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from 'react'
4-
import { Badge, ChipCombobox, ChipConfirmModal, chipContentLabelClass, cn } from '@sim/emcn'
4+
import {
5+
Badge,
6+
ChipCombobox,
7+
ChipConfirmModal,
8+
chipContentLabelClass,
9+
cn,
10+
ResourceEmptyState,
11+
} from '@sim/emcn'
512
import {
613
ChevronDown,
714
ChevronUp,
@@ -38,7 +45,6 @@ import type {
3845
import {
3946
EMPTY_CELL_PLACEHOLDER,
4047
Resource,
41-
ResourceNotFound,
4248
SearchHighlight,
4349
} from '@/app/workspace/[workspaceId]/components'
4450
import {
@@ -1163,7 +1169,7 @@ export function Document({
11631169
*/
11641170
if (documentError && !documentData) {
11651171
return (
1166-
<ResourceNotFound
1172+
<ResourceEmptyState
11671173
icon={FileX}
11681174
title='Document not found'
11691175
description='This document may have been deleted or moved'

‎apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
cn,
2020
FloatingTooltip,
2121
isTextClipped,
22+
ResourceEmptyState,
2223
Tooltip,
2324
useFloatingTooltip,
2425
} from '@sim/emcn'
@@ -72,7 +73,6 @@ import {
7273
FloatingOverflowText,
7374
isResourceListEmpty,
7475
Resource,
75-
ResourceNotFound,
7676
SearchHighlight,
7777
} from '@/app/workspace/[workspaceId]/components'
7878
import {
@@ -1310,7 +1310,7 @@ export function KnowledgeBase({
13101310

13111311
if (error && !knowledgeBase) {
13121312
return (
1313-
<ResourceNotFound
1313+
<ResourceEmptyState
13141314
icon={DatabaseX}
13151315
title='Knowledge base not found'
13161316
description='This knowledge base may have been deleted or moved'

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type React from 'react'
44
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
5-
import { cn, toast, useToast } from '@sim/emcn'
5+
import { cn, ResourceEmptyState, toast, useToast } from '@sim/emcn'
66
import { Loader, TableX } from '@sim/emcn/icons'
77
import { createLogger } from '@sim/logger'
88
import type { TableCellSelection } from '@sim/realtime-protocol/table-presence'
@@ -4695,17 +4695,11 @@ export function TableGrid({
46954695

46964696
if (!isLoadingTable && !tableData) {
46974697
return (
4698-
<div className='flex h-full flex-col items-center justify-center gap-3'>
4699-
<TableX className='size-[32px] text-[var(--text-muted)]' />
4700-
<div className='flex flex-col items-center gap-1'>
4701-
<h2 className='text-[var(--text-secondary)] text-xl leading-[inherit]'>
4702-
Table not found
4703-
</h2>
4704-
<p className='text-[var(--text-muted)] text-small'>
4705-
This table may have been deleted or moved
4706-
</p>
4707-
</div>
4708-
</div>
4698+
<ResourceEmptyState
4699+
icon={TableX}
4700+
title='Table not found'
4701+
description='This table may have been deleted or moved'
4702+
/>
47094703
)
47104704
}
47114705

‎packages/emcn/src/components/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ export {
209209
} from './popover/popover'
210210
export { POPOVER_ANIMATION_CLASSES } from './popover/popover-animation'
211211
export { ProgressItem } from './progress-item/progress-item'
212+
export {
213+
ResourceEmptyState,
214+
type ResourceEmptyStateProps,
215+
} from './resource-empty-state/resource-empty-state'
212216
export { SecretInput } from './secret-input/secret-input'
213217
export { SecretReveal } from './secret-reveal/secret-reveal'
214218
export { WORDMARK_PATHS, WORDMARK_VIEW_BOX } from './sim-wordmark/paths'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { ComponentType } from 'react'
2+
3+
export interface ResourceEmptyStateProps {
4+
icon: ComponentType<{ className?: string }>
5+
title: string
6+
description: string
7+
}
8+
9+
/**
10+
* Centered resource-empty state for a page or panel. The caller owns loading and
11+
* access decisions; this component only presents the unavailable-resource message.
12+
* @example <ResourceEmptyState icon={FileX} title='File not found' description='This file may have been deleted or moved' />
13+
*/
14+
export function ResourceEmptyState({ icon: Icon, title, description }: ResourceEmptyStateProps) {
15+
return (
16+
<div className='flex h-full flex-col items-center justify-center gap-3 text-center'>
17+
<Icon className='size-[32px] text-[var(--text-icon)]' />
18+
<div className='flex flex-col items-center gap-1'>
19+
<h2 className='text-[var(--text-primary)] text-xl leading-[inherit]'>{title}</h2>
20+
<p className='text-[var(--text-body)] text-small'>{description}</p>
21+
</div>
22+
</div>
23+
)
24+
}

0 commit comments

Comments
 (0)