Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add github link to public code and contract #254

Merged
merged 4 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#254](https://github.com/alleslabs/celatone-frontend/pull/254) Add GiHub link to public code and contract detail pages
- [#230](https://github.com/alleslabs/celatone-frontend/pull/230) Add cw2info to code table

### Improvements
Expand Down
31 changes: 31 additions & 0 deletions src/lib/components/links/GitHubLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Flex, Text } from "@chakra-ui/react";

import { CustomIcon } from "../icon";
import { AmpTrackSocial } from "lib/services/amplitude";

interface GitHubLinkProps {
github: string;
}

export const GitHubLink = ({ github }: GitHubLinkProps) => {
const [, , , org, repo] = github.split("/");
return (
<Flex gap={2}>
<Text fontWeight={500} color="text.dark" variant="body2">
GitHub:
</Text>
<a
href={github}
onClick={() => AmpTrackSocial(github)}
target="_blank"
rel="noreferrer"
tansawit marked this conversation as resolved.
Show resolved Hide resolved
style={{ display: "flex" }}
songwongtp marked this conversation as resolved.
Show resolved Hide resolved
>
<Text color="lilac.main" variant="body2" wordBreak="break-all">
{org}/{repo}
</Text>
<CustomIcon name="external" boxSize="12px" marginLeft="8px" />
</a>
</Flex>
);
};
1 change: 1 addition & 0 deletions src/lib/components/links/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./GitHubLink";
4 changes: 4 additions & 0 deletions src/lib/pages/code-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useEffect } from "react";
import { BackButton } from "lib/components/button";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import { GitHubLink } from "lib/components/links";
import { Loading } from "lib/components/Loading";
import PageContainer from "lib/components/PageContainer";
import { PublicDescription } from "lib/components/PublicDescription";
Expand Down Expand Up @@ -84,6 +85,9 @@ const CodeDetailsBody = observer(
{cw2Info ?? "N/A"}
</Text>
</Flex>
{publicProject.publicCodeData?.github && (
<GitHubLink github={publicProject.publicCodeData.github} />
)}
</Flex>
<CTASection
id={codeId}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/pages/contract-details/components/ContractTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useInternalNavigate } from "lib/app-provider";
import { AdminButton } from "lib/components/button";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import { GitHubLink } from "lib/components/links";
import {
AddToOtherListModal,
EditContractDetailsModal,
Expand Down Expand Up @@ -143,6 +144,9 @@ export const ContractTop = ({ contractData }: ContractTopProps) => {
</Text>
</Flex>
)}
{publicProject.publicInfo?.github && (
<GitHubLink github={publicProject.publicInfo?.github} />
)}
</Flex>
<Flex gap={4}>
<AdminButton
Expand Down
1 change: 1 addition & 0 deletions src/lib/services/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface PublicInfoResponse {
name: string;
address: ContractAddr;
description: string;
github: string;
}

export interface InstantiateInfo {
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ export interface PublicInfo {
name: string;
contractAddress: ContractAddr;
description: string;
github: string;
}