Skip to content

Feature/26 repository card url #31

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

Merged
merged 2 commits into from
Jan 12, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion src/client/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CurrencyType, CurrencyType1, CurrencyType3, EntityType} from "./models";
import {CurrencyType, CurrencyType1, CurrencyType3, EntityType, User} from "./models";

export class ProjectModel {
guid?: string;
Expand Down Expand Up @@ -156,3 +156,12 @@ export interface WithdrawalRequest {
paid?: boolean;
created_at?: string;
}

export interface Repository {
guid?: string;
creator?: User;
title?: string;
repo_url?: string;
origin_id?: string;
created_at?: string;
}
49 changes: 49 additions & 0 deletions src/components/external/repo/card/RepoCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from "react";
import {ProjectModel} from "../../../../client/bindings";
import {Button, Card, Icon, Row} from "antd";
import {handleApiError} from "../../../../classes/notification/errorHandler/errorHandler";

interface IProps {
project: ProjectModel,
}

interface IState {
isLoaded: boolean,
repository_url: string
}

class RepoCard extends React.Component<IProps, IState> {
constructor(props: IProps) {
super(props);
this.state = {
isLoaded: false,
repository_url: "#"
}
}

componentDidMount(): void {
window.App.apiClient.getRepo(this.props.project.repository_guid!)
.then((res) => {
let json = JSON.parse(res._response.bodyAsText);
console.log(json.data.repository);
this.setState({
isLoaded: true,
repository_url: json.data.repository.repo_url
});
})
.catch((error) => handleApiError(error.response));
}

render() {
return <Card>
<h3 className={"ant-typography"}><Icon type={"github"}/> Repository</h3>
<Row>
<a target="_blank" rel="noopener noreferrer" href={this.state.repository_url}>
<Button type={"default"}>View on GitHub</Button>
</a>
</Row>
</Card>
}
}

export default RepoCard;
141 changes: 0 additions & 141 deletions src/layouts/entity/project/page/ProjectPage.tsx

This file was deleted.

11 changes: 2 additions & 9 deletions src/layouts/entity/project/view/ProjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BoardCard from "../../../../components/entity/board/single/card/BoardCart
import PermissionCheckLink from "../../../../components/link/withChecks/PermissionCheckLink";
import AuthCheck from "../../../../components/check/auth_check/AuthCheck";
import AddToLibrary from "../../../../components/entity/my_library/single/action/AddToLibrary";
import RepoCard from "../../../../components/external/repo/card/RepoCard";

interface IProps {
match: {
Expand Down Expand Up @@ -113,15 +114,7 @@ class ProjectPage extends React.Component<IProps, IState> {
</div>
</Col>
<Col md={12} xs={24} className="margin-sm-top">
{/* TODO: extract into repository card */}
<Card>
<h3 className={"ant-typography"}><Icon type={"github"}/> Repository</h3>
<Row>
<a target="_blank" rel="noopener noreferrer" href={`https://github.com/${project.base_uri}`}>
<Button type={"default"}>View on GitHub</Button>
</a>
</Row>
</Card>
<RepoCard project={project}/>
</Col>
</Row>

Expand Down
2 changes: 1 addition & 1 deletion src/layouts/repos/external/default/ExternalRepoLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import FullPageWithSideBar from "../../../../components/layout/simple/fullpagewithsidebar/FullPageWithSidebar";
import {Col, Icon, notification, Row} from "antd";
import {handleApiError} from "../../../../classes/notification/errorHandler/errorHandler";
import ExternalRepoCard from "../../../../components/external/repo/card/ExternalRepoCard";
import ExternalRepoCard from "../../../../components/external/external_repo/card/ExternalRepoCard";

interface IProps {
match: {
Expand Down