1- import { Skeleton , Tag , Alert , Spin } from "antd" ;
1+ import { Alert , Spin } from "antd" ;
22import React from "react" ;
3- import { Link } from "react-router-dom " ;
4- import { Language , RepoIdentity } from "models " ;
5- import DetailsCard from "./details- card" ;
3+ import { RepoIdentity } from "models " ;
4+ import CardCommon from "./card-common " ;
5+ import CardCollaborators from "./card-collaborators " ;
66import { useRepoDetailsQuery } from "./queries.gen" ;
77import "./index.scss" ;
88
9- // !!! FIXME: decompose
10-
119type Props = {
1210 /** repo identity */
1311 repo : RepoIdentity ;
1412} ;
1513
16- // FIXME: move to models
17- type Collaborator = {
18- /** id */
19- id : string ;
20- /** Имя пользователя */
21- name : string ;
22- /** Логин пользователя */
23- login : string ;
24- /** Аватар */
25- avatarUrl : string ;
26- } ;
27-
2814/**
2915 * @feature Информация по репозиторию
3016 */
@@ -38,56 +24,10 @@ const RepoDetails = ({ repo: identity }: Props) => {
3824 } ) ;
3925 const repository = data ?. repository ;
4026
41- const languages = repository ?. languages ?. nodes ?. filter ( ( lang ) : lang is Language => ! ! lang ) ;
42- const collaborators = repository ?. collaborators ?. nodes ?. filter (
43- ( collaborator ) : collaborator is Collaborator => ! ! collaborator ,
44- ) ;
45-
4627 return (
4728 < div className = "flex flex-col" >
48- < DetailsCard className = "common-details" title = { identity . name } >
49- { loading && (
50- < Skeleton
51- paragraph = { { rows : 1 } }
52- className = "common-details__placeholder"
53- active
54- />
55- ) }
56- { repository ?. description !== null ? (
57- < div > { repository ?. description } </ div >
58- ) : (
59- < p > No description, website, or topics provided.</ p >
60- ) }
61- < br />
62- { repository ?. homepageUrl && (
63- < a
64- href = { repository . homepageUrl }
65- target = "_blank"
66- rel = "noopener noreferrer"
67- className = "homepage-link"
68- title = { repository . homepageUrl }
69- >
70- { repository . homepageUrl }
71- </ a >
72- ) }
73- { languages ?. map ( ( { id, name, color } ) => (
74- < Tag className = "language-tag" key = { id } color = { color || "#165694" } >
75- { name }
76- </ Tag >
77- ) ) }
78- </ DetailsCard >
79- { collaborators && (
80- < DetailsCard className = "mt-4" title = "Collaborators" primary >
81- { collaborators ?. map ( ( { id, login, avatarUrl } ) => (
82- < div key = { id } className = "collaborator" >
83- < img src = { avatarUrl } alt = "avatar" />
84- < Link className = "name" to = { `/${ login } ` } >
85- { login }
86- </ Link >
87- </ div >
88- ) ) }
89- </ DetailsCard >
90- ) }
29+ < CardCommon identity = { identity } loading = { loading } repository = { repository } />
30+ < CardCollaborators repository = { repository } />
9131 < Spin spinning = { loading } >
9232 < Alert
9333 style = { { borderRadius : 6 , marginTop : 10 } }
0 commit comments