GitFOSS
.ts
TypeScript
(application/typescript)
// 1st-party
import type { ReactView } from "@ethicdevs/react-monolith";
// 3rd-party
import React from "react";
// generated via script[generate:prisma]
import { Organization, Repository, ResourceVisibility } from "@prisma/client";
// app
import type { CommonProps } from "../../types";
import { Layout, PageWrapper } from "../../components";
// app islands
// import RepositoryCreateForm from "../../islands/RepositoryCreateForm";

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>
          {/*<div data-islandid={`${RepositoryCreateForm.name}$$0`}>
            <RepositoryCreateForm
              availableParentOrgs={availableParentOrgs}
              initialValues={initialValues}
            />
          </div>*/}
        </form>
      </PageWrapper>
    </Layout>
  );
};

RepositoryForkView.displayName = "RepositoryForkView";
export default RepositoryForkView;