.ts
TypeScript
(application/typescript)
// 1st-party
import type { ReactView } from "@ethicdevs/react-monolith";
// 3rd-party
import React from "react";
// generated via script[prisma:generate]
import type { Organization, Repository, User } from "@prisma/client";
// app service
import type { LinguistFileInfos } from "../../services/codeAnalysis/types";
// app
import type { CommonProps, RepositoryFileContent } from "../../types";
import { Code, Layout, PageWrapper, getThemedCodeCss } from "../../components";

export interface RepositoryBrowserViewProps extends CommonProps {
  currentUser: null | User;
  fileContent: RepositoryFileContent;
  linguistInfos: LinguistFileInfos;
  parentOrg: Organization;
  path: string;
  ref: string;
  repo: Repository;
}

const RepositoryBrowserView: ReactView<RepositoryBrowserViewProps> = ({
  commonProps,
  fileContent,
  linguistInfos,
  parentOrg,
  path,
  ref,
  repo,
}) => {
  return (
    <Layout {...commonProps}>
      <PageWrapper>
        <h1>
          {parentOrg.displayName || parentOrg.slug}
          {" / "}
          {repo.displayName || repo.slug}
          {" / "}
          {ref}
          {" / "}
          {path}
        </h1>
        <div style={{ width: "100%" }}>
          <span>lang: {linguistInfos.language}</span>
          {getThemedCodeCss(commonProps.themeScheme)}
          <Code
            code={fileContent.content}
            language={linguistInfos.language}
            themeScheme={commonProps.themeScheme}
          />
        </div>
      </PageWrapper>
    </Layout>
  );
};

RepositoryBrowserView.displayName = "RepositoryBrowserView";
export default RepositoryBrowserView;