refactor(cloud-secrets): adopt shared Skeleton, InlineError and SettingsGroupHeader

This commit is contained in:
Neil
2026-11-09 07:21:05 -08:00
parent 168b4b81e9
commit 7b5e8d760d
3 changed files with 32 additions and 35 deletions
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
import { Check, ClipboardPaste, KeyRound, Plus, RefreshCw } from 'lucide-react'
import { Check, ClipboardPaste, KeyRound, Plus } from 'lucide-react'
import { useTranslate } from '@/i18n/use-translate'
import { formatUiRelativeTime } from '@/i18n/relative-time-format'
import type {
@@ -7,6 +7,8 @@ import type {
CloudSecretsErrorCode
} from '../../../../../shared/cloud-secrets/cloud-secrets-wire'
import { Badge } from '../../ui/badge'
import { InlineError } from '../../ui/inline-error'
import { Skeleton } from '../../ui/skeleton'
import { Button } from '../../ui/button'
import { cloudSecretKindLabel, cloudSecretsErrorCopy } from './cloud-secrets-copy'
import { CloudSecretEditor, type CloudSecretEditorTarget } from './CloudSecretEditor'
@@ -235,8 +237,8 @@ export function CloudSecretList({
<div className="space-y-px rounded-md border border-border/60" aria-busy="true">
{[0, 1, 2].map((row) => (
<div key={row} className="flex items-center gap-3 px-3 py-2.5">
<div className="h-3 w-40 rounded bg-muted motion-safe:animate-pulse" />
<div className="ml-auto h-3 w-12 rounded bg-muted motion-safe:animate-pulse" />
<Skeleton className="h-3 w-40" />
<Skeleton className="ml-auto h-3 w-12" />
</div>
))}
<span className="sr-only">{t('cloudSecrets.list.loading', 'Loading secrets…')}</span>
@@ -246,17 +248,15 @@ export function CloudSecretList({
if (model.list.status === 'failed') {
return (
<div className="flex items-center justify-between gap-3 rounded-md border border-border/60 px-3 py-3">
<p role="alert" className="text-xs text-muted-foreground">
{model.list.error === 'unauthorized' || model.list.error === 'not_configured'
<InlineError
title={
model.list.error === 'unauthorized' || model.list.error === 'not_configured'
? cloudSecretsErrorCopy(model.list.error, t)
: t('cloudSecrets.list.loadFailed', 'Couldn’t load secrets.')}
</p>
<Button variant="outline" size="xs" onClick={model.reload}>
<RefreshCw />
{t('cloudSecrets.list.retry', 'Try again')}
</Button>
</div>
: t('cloudSecrets.list.loadFailed', 'Couldn’t load secrets.')
}
retryLabel={t('cloudSecrets.list.retry', 'Try again')}
onRetry={model.reload}
/>
)
}
@@ -1,11 +1,12 @@
import { KeyRound, RefreshCw } from 'lucide-react'
import { KeyRound } from 'lucide-react'
import { useTranslate, type Translate } from '@/i18n/use-translate'
import type {
CloudSecretScope,
CloudSecretsEffective
} from '../../../../../shared/cloud-secrets/cloud-secrets-wire'
import { Badge } from '../../ui/badge'
import { Button } from '../../ui/button'
import { InlineError } from '../../ui/inline-error'
import { Skeleton } from '../../ui/skeleton'
import {
cloudSecretKindLabel,
cloudSecretScopeLabel,
@@ -69,8 +70,8 @@ export function CloudSecretsEffectiveView({
<div className="space-y-px rounded-md border border-border/60" aria-busy="true">
{[0, 1].map((row) => (
<div key={row} className="flex items-center gap-3 px-3 py-2.5">
<div className="h-3 w-40 rounded bg-muted motion-safe:animate-pulse" />
<div className="ml-auto h-3 w-20 rounded bg-muted motion-safe:animate-pulse" />
<Skeleton className="h-3 w-40" />
<Skeleton className="ml-auto h-3 w-20" />
</div>
))}
<span className="sr-only">{t('cloudSecrets.list.loading', 'Loading secrets…')}</span>
@@ -79,15 +80,11 @@ export function CloudSecretsEffectiveView({
}
if (effective.status === 'failed') {
return (
<div className="flex items-center justify-between gap-3 rounded-md border border-border/60 px-3 py-3">
<p role="alert" className="text-xs text-muted-foreground">
{cloudSecretsErrorCopy(effective.error, t)}
</p>
<Button variant="outline" size="xs" onClick={onRetry}>
<RefreshCw />
{t('cloudSecrets.list.retry', 'Try again')}
</Button>
</div>
<InlineError
title={cloudSecretsErrorCopy(effective.error, t)}
retryLabel={t('cloudSecrets.list.retry', 'Try again')}
onRetry={onRetry}
/>
)
}
const { secrets, precedence } = effective.value
@@ -6,6 +6,7 @@ import { Button } from '../../ui/button'
import { Label } from '../../ui/label'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../ui/select'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs'
import { SettingsGroupHeader } from '../section-layout/SettingsGroup'
import { cloudSecretScopeLabel } from './cloud-secrets-copy'
import { CloudSecretList, type CloudSecretPeople } from './CloudSecretList'
import { CloudSecretsEffectiveView } from './CloudSecretsEffectiveView'
@@ -161,15 +162,14 @@ export function CloudSecretsPane({
return (
<div className="space-y-4 border-t border-border/60 pt-5" data-settings-section="cloud-secrets">
<div className="space-y-1">
<h3 className="text-sm font-medium">{t('cloudSecrets.title', 'Cloud secrets')}</h3>
<p className="max-w-xl text-xs leading-5 text-muted-foreground">
{t(
'cloudSecrets.description',
'API keys you add to Orca are never written to the sandbox. Agents and terminals get them as environment variables.'
)}
</p>
</div>
<SettingsGroupHeader
className="px-0"
title={t('cloudSecrets.title', 'Cloud secrets')}
description={t(
'cloudSecrets.description',
'API keys you add to Orca are never written to the sandbox. Agents and terminals get them as environment variables.'
)}
/>
<Tabs
value={tab}