From 663f9264d6f67466e7f427d61d838cc1031a934d Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sat, 29 Aug 2020 17:11:44 -0500 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E2=99=BB=20comment=20some=20stuff?= =?UTF-8?q?=20to=20get=20web=20to=20compile=20with=20new=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listInfoDrawer/ListInfoDrawer.tsx | 113 +++++++++--------- web/src/components/listsTable/ListDrawer.tsx | 50 +------- web/src/components/listsTable/ListsTable.tsx | 17 ++- .../components/listsTable/ListsTableHoc.tsx | 4 +- 4 files changed, 68 insertions(+), 116 deletions(-) diff --git a/web/src/components/listInfoDrawer/ListInfoDrawer.tsx b/web/src/components/listInfoDrawer/ListInfoDrawer.tsx index dcdb6f176..ee26ae002 100644 --- a/web/src/components/listInfoDrawer/ListInfoDrawer.tsx +++ b/web/src/components/listInfoDrawer/ListInfoDrawer.tsx @@ -16,136 +16,139 @@ import React, { useEffect, useState } from "react"; import ButtonGroup from "antd/lib/button/button-group"; import { Description } from "../Description"; -import { Language } from "../../interfaces/Language"; import { LanguageCloud } from "../languageCloud"; -import { License } from "../../interfaces/License"; import { LicenseTag } from "../LicenseTag"; import { LinkButton } from "../LinkButton"; -import { List } from "../../interfaces/List"; -import { Maintainer } from "../../interfaces/Maintainer"; import { Maintainers } from "../maintainers"; import { RouteComponentProps } from "react-router-dom"; -import { Software } from "../../interfaces/Software"; import { SoftwareCloud } from "../softwareCloud"; import { SubscribeButtons } from "../SubscribeButtons"; -import { Syntax } from "../../interfaces/Syntax"; import { SyntaxTag } from "../SyntaxTag"; -import { Tag } from "../../interfaces/Tag"; import { TagCloud } from "../tagCloud"; +import { + useListDetails, + useLanguages, + useLicenses, + useMaintainers, + useSoftware, + useSyntaxes, + useTags, +} from "../../hooks"; interface Props { - list: List; - languages: Language[]; - license: License | undefined; - maintainers: Maintainer[]; - software: Software[]; - syntax: Syntax | undefined; - tags: Tag[]; + listId: number; } export const ListInfoDrawer = (props: RouteComponentProps & Props) => { + const list = useListDetails(props.listId); + const languages = useLanguages(); + const licenses = useLicenses(); + const maintainers = useMaintainers(); + const software = useSoftware(); + const syntaxes = useSyntaxes(); + const tags = useTags(); const [originalTitle] = useState(document.title); useEffect(() => { const updateTitle = () => - (document.title = props.list.name + " | " + originalTitle); + (document.title = list?.name + " | " + originalTitle); updateTitle(); return () => { document.title = originalTitle; }; - }, [props.list, originalTitle]); - return ( + }, [list, originalTitle, list?.name]); + return list ? ( props.history.push("/")} > - - - - {props.license && ( + + + + {/* {list.license && ( )} - {props.syntax && ( + {list.syntax && ( - )} - - + )} */} + + - } - /> + /> */} } /> } /> - {props.list.emailAddress && ( + {list.emailAddress && ( } /> )} } /> } /> } /> } /> } /> - ); + ) : null; }; diff --git a/web/src/components/listsTable/ListDrawer.tsx b/web/src/components/listsTable/ListDrawer.tsx index 0baac49b6..46b0edd97 100644 --- a/web/src/components/listsTable/ListDrawer.tsx +++ b/web/src/components/listsTable/ListDrawer.tsx @@ -6,66 +6,18 @@ import { StaticContext, } from "react-router"; -import { Language } from "../../interfaces/Language"; -import { License } from "../../interfaces/License"; import { List } from "../../interfaces/List"; -import { Maintainer } from "../../interfaces/Maintainer"; -import { Software } from "../../interfaces/Software"; -import { Syntax } from "../../interfaces/Syntax"; -import { Tag } from "../../interfaces/Tag"; import { ListInfoDrawer } from "../listInfoDrawer"; interface Props { lists: List[]; - languages: Language[]; - licenses: License[]; - maintainers: Maintainer[]; - software: Software[]; - syntaxes: Syntax[]; - tags: Tag[]; } export const ListDrawer = (props: Props) => { const renderDrawer = (rp: RouteComponentProps) => { const list = props.lists.find((l) => l.slug === rp.match.params.listSlug); return list ? ( - - list.languageIso6391s.includes(l.id) - ) - } - license={ - list.licenseId - ? props.licenses.find((l: License) => list.licenseId === l.id) - : props.licenses.find((l: License) => l.id === 5) - } - maintainers={ - list.maintainerIds && - props.maintainers.filter((m: Maintainer) => - list.maintainerIds.includes(m.id) - ) - } - software={ - list.syntaxId - ? props.software.filter((s: Software) => - s.syntaxIds.includes(list.syntaxId) - ) - : [] - } - syntax={ - list.syntaxId - ? props.syntaxes.find((s) => s.id === list.syntaxId) - : undefined - } - tags={ - list.tagIds && - props.tags.filter((t: Tag) => list.tagIds.includes(t.id)) - } - {...rp} - /> + ) : props.lists && props.lists.length ? ( ) : null; diff --git a/web/src/components/listsTable/ListsTable.tsx b/web/src/components/listsTable/ListsTable.tsx index f6c8d01ab..d10457085 100644 --- a/web/src/components/listsTable/ListsTable.tsx +++ b/web/src/components/listsTable/ListsTable.tsx @@ -125,14 +125,11 @@ export const ListsTable = (props: RouteComponentProps & Props) => { filterIcon={searchDescriptionColumn.filterIcon} onFilter={searchDescriptionColumn.onFilter} render={(description: string, list: List) => ( - + )} /> )} - {tablePageSize.isNarrowWindow ? null : ( + {/* {tablePageSize.isNarrowWindow ? null : ( title="Software" key="Software" @@ -181,8 +178,8 @@ export const ListsTable = (props: RouteComponentProps & Props) => { ) : null } /> - )} - {tablePageSize.isNarrowWindow ? null : ( + )} */} + {/* {tablePageSize.isNarrowWindow ? null : ( title="Syntax" key="Syntax" @@ -221,8 +218,8 @@ export const ListsTable = (props: RouteComponentProps & Props) => { ) : null; }} /> - )} - {tablePageSize.isNarrowWindow ? null : ( + )} */} + {/* {tablePageSize.isNarrowWindow ? null : ( title="Languages" key="Languages" @@ -263,7 +260,7 @@ export const ListsTable = (props: RouteComponentProps & Props) => { ) : null } /> - )} + )} */} {tablePageSize.isNarrowWindow ? null : ( title="Tags" diff --git a/web/src/components/listsTable/ListsTableHoc.tsx b/web/src/components/listsTable/ListsTableHoc.tsx index 6c4b4c72a..d68ed6354 100644 --- a/web/src/components/listsTable/ListsTableHoc.tsx +++ b/web/src/components/listsTable/ListsTableHoc.tsx @@ -33,7 +33,7 @@ export const ListsTableHoc = (props: RouteComponentProps) => { tags={tags} {...props} /> - { software={software} syntaxes={syntaxes} tags={tags} - /> + /> */} ); };