import type { ReactView } from "@ethicdevs/react-monolith";
import React from "react";
import { Organization, Repository, ResourceVisibility } from "@prisma/client";
import type { CommonProps } from "../../types";
import { Layout, PageWrapper } from "../../components";
import RepositoryForkForm from "../../islands/RepositoryForkForm";
export interface RepositoryForkViewProps extends CommonProps {
availableParentOrgs: Organization[];
sourceParentOrg: Organization;
sourceRepo: Repository;
errorMessage?: null | string;
initialValues?: {
target_org_slug: string;
target_repo_display_name: string;
target_repo_slug: string;
target_repo_visibility: ResourceVisibility;
};
}
const RepositoryForkView: ReactView<RepositoryForkViewProps> = ({
availableParentOrgs,
commonProps,
sourceParentOrg,
sourceRepo,
errorMessage = undefined,
initialValues = undefined,
}) => {
return (
<Layout {...commonProps}>
<PageWrapper>
<h1>
<a href={`/${sourceParentOrg.slug}`}>
{sourceParentOrg.displayName || sourceParentOrg.slug}
</a>
{" / "}
<a href={`/${sourceParentOrg.slug}/${sourceRepo.slug}`}>
{sourceRepo.displayName || sourceRepo.slug}
</a>
{" / "}
<span>Fork</span>
</h1>
<div style={{ height: 32 }} />
{errorMessage && (
<div className={"error_message"}>
<p>{errorMessage}</p>
</div>
)}
<form
action={`/${sourceParentOrg.slug}/${sourceRepo.slug}/fork`}
method={"POST"}
>
<div data-islandid={`${RepositoryForkForm.name}$$0`}>
<RepositoryForkForm
availableParentOrgs={availableParentOrgs}
initialValues={initialValues}
/>
</div>
</form>
</PageWrapper>
</Layout>
);
};
RepositoryForkView.displayName = "RepositoryForkView";
export default RepositoryForkView;