feat: update workspace sidebar create menu with native Silos names and improved document creation flow

This commit is contained in:
Anurag Jangid 2026-10-23 22:00:33 +05:30
parent eed9504a53
commit 75d4f1688f
2 changed files with 36 additions and 59 deletions

View file

@ -13,9 +13,6 @@ import {
Clock,
Star,
FolderOpen,
Folder,
Database,
ExternalLink,
Link2,
MoreHorizontal,
PenTool,
@ -38,7 +35,6 @@ import { getStoredUser } from '../../lib/api'
import type { CreateType } from '../../data/createData'
import { navItems, type NavItemId } from '../../data/dashboardData'
import CreateDropdown from '../create/CreateDropdown'
import { defaultSteadContent } from '../../data/steadData'
const typeIcons: Record<CreateType, typeof FileText> = {
silo: FileText,
@ -153,53 +149,38 @@ export default function WorkspaceSidebar({
}
async function createFromMenu(
source: DocumentRecord,
kind: 'live-doc' | 'page' | 'whiteboard' | 'database' | 'smart-link' | 'folder',
source: DocumentRecord,
kind: CreateType,
) {
setCreateMenuId(null)
setCreateMenuPosition(null)
const steadId = source.type === 'stead' ? source.id : source.steadId
const parentPageId = source.type === 'silo' ? source.id : undefined
if (kind === 'folder' || kind === 'database') {
setCreateMenuId(null)
setCreateMenuPosition(null)
if (kind === 'stead') {
navigate('/workspace/stead/new')
return
}
const steadId = source.type === 'stead' ? source.id : source.steadId
const parentPageId = source.type === 'stead' ? undefined : source.id
const content =
kind === 'shed'
? getDefaultShedContent('meeting-notes')
: kind === 'sketch'
? { elements: [] }
: { body: '', bodyHtml: '', status: 'draft' }
const created = await createDocument(
'stead',
kind === 'folder' ? 'Untitled Folder' : 'Untitled Database',
{ ...defaultSteadContent(), setupComplete: true },
undefined,
getStoredUser()?.full_name ?? 'You',
)
navigate(`/workspace/stead/${created.id}`)
return
}
if (kind === 'live-doc') {
const created = await createDocument(
'shed',
'Untitled Live Doc',
getDefaultShedContent('meeting-notes'),
'meeting-notes',
kind,
kind === 'shed'
? 'Untitled Live Doc'
: kind === 'sketch'
? 'Untitled Whiteboard'
: 'Untitled Page',
content,
kind === 'shed' ? 'meeting-notes' : undefined,
getStoredUser()?.full_name ?? 'You',
steadId,
parentPageId,
)
navigate(`/workspace/shed/${created.id}`)
return
}
const type = kind === 'whiteboard' ? 'sketch' : 'silo'
const content =
kind === 'whiteboard'
? { elements: [] }
: kind === 'smart-link'
? { body: 'Paste a link here', bodyHtml: '<p>Paste a link here</p>', status: 'draft' }
: { body: '', bodyHtml: '', status: 'draft' }
const created = await createDocument(
type,
kind === 'whiteboard' ? 'Untitled Whiteboard' : kind === 'smart-link' ? 'Untitled Smart Link' : 'Untitled Page',
content,
undefined,
getStoredUser()?.full_name ?? 'You',
steadId,
parentPageId,
)
navigate(`/workspace/${type}/${created.id}`)
navigate(`/workspace/${kind}/${created.id}`)
}
function startRename(doc: DocumentRecord) {
@ -397,21 +378,17 @@ export default function WorkspaceSidebar({
aria-label={`Create content under ${doc.title}`}
>
{[
{ kind: 'live-doc' as const, label: 'Live Doc', icon: Zap },
{ kind: 'page' as const, label: 'Page', icon: FileText },
{ kind: 'whiteboard' as const, label: 'Whiteboard', icon: PenTool },
{ kind: 'database' as const, label: 'Database', icon: Database },
{ kind: 'smart-link' as const, label: 'Smart Link', icon: ExternalLink },
{ kind: 'folder' as const, label: 'Folder', icon: Folder },
].map(({ kind, label, icon: MenuIcon }, index) => (
{ kind: 'silo' as const, label: 'Silo', icon: FileText },
{ kind: 'stead' as const, label: 'Stead', icon: LayoutGrid },
{ kind: 'sketch' as const, label: 'Sketch', icon: PenTool },
{ kind: 'shed' as const, label: 'Shed', icon: Zap },
].map(({ kind, label, icon: MenuIcon }) => (
<button
key={kind}
type="button"
role="menuitem"
onClick={() => void createFromMenu(doc, kind)}
className={`flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm text-silos-text hover:bg-silos-cream ${
index === 5 ? 'mt-1 border-t border-silos-cream-dark pt-3' : ''
}`}
className="flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm text-silos-text hover:bg-silos-cream"
>
<MenuIcon className="h-5 w-5 text-silos-muted" />
{label}