|
| 1 | +"use client" |
| 2 | + |
| 3 | +import Link from "next/link" |
| 4 | +import { useSearchParams } from "next/navigation" |
| 5 | +import { useTranslation } from "react-i18next" |
| 6 | +import { RiArrowLeftLine } from "@remixicon/react" |
| 7 | +import { BucketList } from "@/components/buckets/list" |
| 8 | +import { OnDemandMigrationManagement } from "@/components/on-demand-migration/management" |
| 9 | +import { Page } from "@/components/page" |
| 10 | +import { PageHeader } from "@/components/page-header" |
| 11 | +import { Button } from "@/components/ui/button" |
| 12 | +import { buildModuleBucketPath } from "@/lib/module-bucket-route" |
| 13 | + |
| 14 | +export default function OnDemandMigrationPage() { |
| 15 | + const { t } = useTranslation() |
| 16 | + const searchParams = useSearchParams() |
| 17 | + const bucketName = searchParams.get("bucket") ?? "" |
| 18 | + |
| 19 | + if (!bucketName) { |
| 20 | + return ( |
| 21 | + <Page> |
| 22 | + <BucketList |
| 23 | + title={<h1 className="text-2xl font-bold">{t("On-demand migration")}</h1>} |
| 24 | + emptyDescription={t("Create a bucket before configuring an external migration source.")} |
| 25 | + getBucketHref={(name) => buildModuleBucketPath("/on-demand-migration", name)} |
| 26 | + /> |
| 27 | + </Page> |
| 28 | + ) |
| 29 | + } |
| 30 | + |
| 31 | + return ( |
| 32 | + <Page> |
| 33 | + <OnDemandMigrationManagement |
| 34 | + key={bucketName} |
| 35 | + bucketName={bucketName} |
| 36 | + renderHeader={(actions) => ( |
| 37 | + <PageHeader |
| 38 | + description={ |
| 39 | + <p className="text-sm text-muted-foreground"> |
| 40 | + {t("Bucket")}: <span className="break-all font-medium text-foreground">{bucketName}</span> |
| 41 | + </p> |
| 42 | + } |
| 43 | + actions={ |
| 44 | + <> |
| 45 | + <Button |
| 46 | + variant="outline" |
| 47 | + className="min-h-11 sm:min-h-0" |
| 48 | + nativeButton={false} |
| 49 | + render={<Link href="/on-demand-migration" />} |
| 50 | + > |
| 51 | + <RiArrowLeftLine data-icon="inline-start" aria-hidden /> |
| 52 | + <span>{t("Buckets")}</span> |
| 53 | + </Button> |
| 54 | + {actions} |
| 55 | + </> |
| 56 | + } |
| 57 | + > |
| 58 | + <h1 className="text-2xl font-bold">{t("On-demand migration")}</h1> |
| 59 | + </PageHeader> |
| 60 | + )} |
| 61 | + /> |
| 62 | + </Page> |
| 63 | + ) |
| 64 | +} |
0 commit comments