Files
pterodactyl-panel/resources/scripts/components/admin/eggs/ImportEggButton.tsx
T

40 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-10-05 18:10:18 -04:00
import { useNavigate } from '@tanstack/react-router';
import { Upload } from 'lucide-react';
import { importAdminEggInput, useImportAdminEgg } from '@/api/admin/eggs/queries';
import EggFileDialog from '@/components/admin/eggs/EggFileDialog';
import { Dialog } from '@/components/elements/dialog';
import { NewButton } from '@/components/elements/NewButton';
export default function ImportEggButton() {
const navigate = useNavigate();
const importEgg = useImportAdminEgg();
const submit = async (file: File) => {
const egg = await importEgg.mutateAsync(importAdminEggInput({ import_file: file }));
2026-10-08 16:53:20 -04:00
2026-10-05 18:10:18 -04:00
void navigate({ to: '/panel/eggs/$eggId', params: { eggId: egg.attributes.id } });
};
return (
<Dialog.Trigger
trigger={({ onClick }) => (
<NewButton isSecondary icon={Upload} onClick={onClick}>
Import egg
</NewButton>
)}
>
{({ open, onClose }) => (
<EggFileDialog
open={open}
onClose={onClose}
2026-10-08 16:53:20 -04:00
title='Import egg'
description='Upload an egg JSON file to add a server template.'
submitLabel='Import Egg'
2026-10-05 18:10:18 -04:00
submitting={importEgg.isPending}
onSubmit={submit}
/>
)}
</Dialog.Trigger>
);
}