From 7698345e3175fd7047ce79c89c98a268dda63f28 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sun, 30 Aug 2020 14:40:13 -0500 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E2=9C=A8=F0=9F=9A=A7=20re-enable?= =?UTF-8?q?=20list=20info=20drawer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listInfoDrawer/ListInfoDrawer.tsx | 67 ++++++++++++------- .../components/listsTable/ListsTableHoc.tsx | 10 +-- web/src/interfaces/ListDetails.ts | 10 ++- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/web/src/components/listInfoDrawer/ListInfoDrawer.tsx b/web/src/components/listInfoDrawer/ListInfoDrawer.tsx index ee26ae002..3a262b423 100644 --- a/web/src/components/listInfoDrawer/ListInfoDrawer.tsx +++ b/web/src/components/listInfoDrawer/ListInfoDrawer.tsx @@ -23,7 +23,6 @@ import { Maintainers } from "../maintainers"; import { RouteComponentProps } from "react-router-dom"; import { SoftwareCloud } from "../softwareCloud"; import { SubscribeButtons } from "../SubscribeButtons"; -import { SyntaxTag } from "../SyntaxTag"; import { TagCloud } from "../tagCloud"; import { useListDetails, @@ -34,6 +33,7 @@ import { useSyntaxes, useTags, } from "../../hooks"; +import { SyntaxCloud } from "../syntaxCloud"; interface Props { listId: number; @@ -47,6 +47,20 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => { const software = useSoftware(); const syntaxes = useSyntaxes(); const tags = useTags(); + + const listLanguage = languages.filter((l) => + list?.languageIso6391s.includes(l.iso6391) + ); + const listTags = tags.filter((t) => list?.tagIds.includes(t.id)); + const listLicense = licenses.find((l) => l.id === list?.id); + const listSyntaxes = syntaxes.filter((s) => list?.syntaxIds.includes(s.id)); + const listSoftware = software.filter((s) => + s.syntaxIds.some((sid) => list?.syntaxIds.includes(sid)) + ); + const listMaintainers = maintainers.filter((m) => + list?.maintainerIds.includes(m.id) + ); + const [originalTitle] = useState(document.title); useEffect(() => { const updateTitle = () => @@ -56,6 +70,9 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => { document.title = originalTitle; }; }, [list, originalTitle, list?.name]); + const viewUrl = list?.viewUrls.find( + (u) => u.primariness === 1 && u.segmentNumber === 1 + )?.url; return list ? ( { onClose={() => props.history.push("/")} > - - - {/* {list.license && ( + + + {listLicense && ( )} - {list.syntax && ( - - )} */} - - + {listSyntaxes && } + + - {/* - } - /> */} + {viewUrl && ( + + )} + {viewUrl && ( + } + /> + )} { tags={tags} {...props} /> - {/* */} + ); }; diff --git a/web/src/interfaces/ListDetails.ts b/web/src/interfaces/ListDetails.ts index 2208df90e..fb06b5e3d 100644 --- a/web/src/interfaces/ListDetails.ts +++ b/web/src/interfaces/ListDetails.ts @@ -4,9 +4,9 @@ description: string; licenseId: number; syntaxIds: number[]; - languageIso6391s: number[]; + languageIso6391s: string[]; tagIds: number[]; - viewUrls: unknown[]; + viewUrls: ViewUrl[]; homeUrl: string; onionUrl: string; policyUrl: string; @@ -24,3 +24,9 @@ dependencyFilterListIds: number[]; dependentFilterListIds: number[]; } + +export interface ViewUrl { + segmentNumber: number; + primariness: number; + url: string; +}