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";
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,
}) => {
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"}
>
<pre>
<code>{JSON.stringify(availableParentOrgs, null, 2)}</code>
</pre>
<pre>
<code>{JSON.stringify(sourceParentOrg, null, 2)}</code>
</pre>
<pre>
<code>{JSON.stringify(sourceRepo, null, 2)}</code>
</pre>
{}
</form>
</PageWrapper>
</Layout>
);
};
RepositoryForkView.displayName = "RepositoryForkView";
export default RepositoryForkView;