mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(web): hide browse affordances unless a machine reports workspace roots
This commit is contained in:
+9
-1
@@ -175,6 +175,12 @@ function SessionsPage() {
|
|||||||
}
|
}
|
||||||
return byId
|
return byId
|
||||||
}, [machines])
|
}, [machines])
|
||||||
|
// Workspace browsing is opt-in per runner (`--workspace-root`); only show
|
||||||
|
// browse affordances when at least one machine reported roots.
|
||||||
|
const canBrowse = useMemo(
|
||||||
|
() => machines.some(m => (m.metadata?.workspaceRoots?.length ?? 0) > 0),
|
||||||
|
[machines]
|
||||||
|
)
|
||||||
const sessionMatch = matchRoute({ to: '/sessions/$sessionId', fuzzy: true })
|
const sessionMatch = matchRoute({ to: '/sessions/$sessionId', fuzzy: true })
|
||||||
const selectedSessionId = sessionMatch && sessionMatch.sessionId !== 'new' ? sessionMatch.sessionId : null
|
const selectedSessionId = sessionMatch && sessionMatch.sessionId !== 'new' ? sessionMatch.sessionId : null
|
||||||
const selectedSession = useMemo(
|
const selectedSession = useMemo(
|
||||||
@@ -220,12 +226,13 @@ function SessionsPage() {
|
|||||||
})}
|
})}
|
||||||
onNewSession={() => navigate({ to: '/sessions/new' })}
|
onNewSession={() => navigate({ to: '/sessions/new' })}
|
||||||
onNewSessionInDirectory={handleNewSessionInDirectory}
|
onNewSessionInDirectory={handleNewSessionInDirectory}
|
||||||
onBrowse={() => navigate({ to: '/browse' })}
|
onBrowse={canBrowse ? () => navigate({ to: '/browse' }) : undefined}
|
||||||
onRefresh={handleRefresh}
|
onRefresh={handleRefresh}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
renderHeader={false}
|
renderHeader={false}
|
||||||
headerActions={(
|
headerActions={(
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
{canBrowse && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => navigate({ to: '/browse' })}
|
onClick={() => navigate({ to: '/browse' })}
|
||||||
@@ -234,6 +241,7 @@ function SessionsPage() {
|
|||||||
>
|
>
|
||||||
<FolderOpenIcon className="h-5 w-5" />
|
<FolderOpenIcon className="h-5 w-5" />
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => navigate({ to: '/settings' })}
|
onClick={() => navigate({ to: '/settings' })}
|
||||||
|
|||||||
Reference in New Issue
Block a user