File size: 1,584 Bytes
f0743f4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | import { Spinner } from '@librechat/client';
import type { VersionContext } from './types';
import VersionItem from './VersionItem';
import { useLocalize } from '~/hooks';
type VersionContentProps = {
selectedAgentId: string;
isLoading: boolean;
error: unknown;
versionContext: VersionContext;
onRestore: (index: number) => void;
};
export default function VersionContent({
selectedAgentId,
isLoading,
error,
versionContext,
onRestore,
}: VersionContentProps) {
const { versions, versionIds } = versionContext;
const localize = useLocalize();
if (!selectedAgentId) {
return (
<div className="py-8 text-center text-text-secondary">
{localize('com_ui_agent_version_no_agent')}
</div>
);
}
if (isLoading) {
return (
<div className="flex items-center justify-center py-8">
<Spinner className="h-6 w-6" />
</div>
);
}
if (error) {
return (
<div className="py-8 text-center text-red-500">{localize('com_ui_agent_version_error')}</div>
);
}
if (versionIds.length > 0) {
return (
<div className="flex flex-col gap-2">
{versionIds.map(({ id, version, isActive }) => (
<VersionItem
key={id}
version={version}
index={id}
isActive={isActive}
versionsLength={versions.length}
onRestore={onRestore}
/>
))}
</div>
);
}
return (
<div className="py-8 text-center text-text-secondary">
{localize('com_ui_agent_version_empty')}
</div>
);
}
|