From 8c22f74116972071fcf63f4e9fd0a0fc52a63b9b Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Tue, 27 Aug 2019 12:57:24 -0500 Subject: [PATCH] add license to drawer --- src/FilterLists.Web.V2/package-lock.json | Bin 562449 -> 561905 bytes .../src/components/LicenseTag.tsx | 26 ++++++++++++++++++ .../src/components/ListInfoDrawer.tsx | 10 +++++-- .../src/components/listsTable/ListsTable.tsx | 15 ++++++---- .../src/components/tagCloud/TagCloud.tsx | 10 ++----- 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 src/FilterLists.Web.V2/src/components/LicenseTag.tsx diff --git a/src/FilterLists.Web.V2/package-lock.json b/src/FilterLists.Web.V2/package-lock.json index 1f6d43ece995aaf730ab3f40acbce16fb81f4419..877afcf52e40b4bdd0c8a2fc11c38c71caa56364 100644 GIT binary patch delta 248 zcmbQZO6lWLrG^&97N!>FEi6V^(=`N{WVh#MvGg!azre*LxBbsYMps6#==8eJjL#tQ z_wre0ac`ed&BDtFRyAGRlS6s>0Tw2u=?fH?xuz$Wuy9QO%gA&EBFoRrG#O&VhFTVu z=?e8Mk<%Myu;@;oC(g>geF6(p2h5G3Eg2k((~i#qtc|mhb#b zv%rF~+s{cb2{CVzVPa<5o-mUoj|F1FEi6V^(>LU@*lzdFV(DR;zJZI$Zu_5)jERPm4GxJ;4_L^; U+CF6t3lM{7w(V2qu*ZG_0BtTB+W-In diff --git a/src/FilterLists.Web.V2/src/components/LicenseTag.tsx b/src/FilterLists.Web.V2/src/components/LicenseTag.tsx new file mode 100644 index 000000000..a69cb9f2e --- /dev/null +++ b/src/FilterLists.Web.V2/src/components/LicenseTag.tsx @@ -0,0 +1,26 @@ +import { Tag } from 'antd'; +import * as React from 'react'; + +import { License } from '../interfaces/License'; + +interface Props { + license: License; + showLabel?: boolean +}; + +export const LicenseTag = (props: Props): JSX.Element | null => + props.license && props.license.name + ?
+ {props.showLabel &&

License:

} + + + +
+ : null; + +const TagContents = (props: Props): JSX.Element => + props.license.descriptionUrl + ? + {props.license.name} + + : {props.license.name} \ No newline at end of file diff --git a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx index 58d7788d8..db10f89c0 100644 --- a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx +++ b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx @@ -4,10 +4,12 @@ import React from 'react'; import { RouteComponentProps } from 'react-router-dom'; import { Language } from '../interfaces/Language'; +import { License } from '../interfaces/License'; import { List } from '../interfaces/List'; import { Tag } from '../interfaces/Tag'; import { Description } from './Description'; import { LanguageCloud } from './languageCloud'; +import { LicenseTag } from './LicenseTag'; import { LinkButton } from './LinkButton'; import { SubscribeButton } from './SubscribeButton'; import { TagCloud } from './tagCloud'; @@ -15,6 +17,7 @@ import { TagCloud } from './tagCloud'; interface Props { list: List; languages: Language[]; + license?: License; tags: Tag[]; }; @@ -45,10 +48,13 @@ export class ListInfoDrawer extends React.Component this.props.history.push("/")}> {this.props.list.languageIds - ? this.props.list.languageIds.includes(l.id))} showLabel={true} /> + ? : null} {this.props.list.tagIds - ? this.props.list.tagIds.includes(t.id))} showLabel={true} /> + ? + : null} + {this.props.license + ? : null} {this.props.list.publishedDate ?
diff --git a/src/FilterLists.Web.V2/src/components/listsTable/ListsTable.tsx b/src/FilterLists.Web.V2/src/components/listsTable/ListsTable.tsx index ca403032d..b0b657d89 100644 --- a/src/FilterLists.Web.V2/src/components/listsTable/ListsTable.tsx +++ b/src/FilterLists.Web.V2/src/components/listsTable/ListsTable.tsx @@ -59,10 +59,10 @@ export class ListsTable extends React.Component { .then(json => (json as Tag[]).sort((a, b) => a.name.localeCompare(b.name))) .then(tags => { this.setState({ tags: tags }); }) - // fetch("/api/v1/licenses") - // .then(response => response.json()) - // .then(json => (json as License[]).sort((a, b) => a.name.localeCompare(b.name))) - // .then(licenses => { this.setState({ licenses: licenses }); }) + fetch("/api/v1/licenses") + .then(response => response.json()) + .then(json => (json as License[]).sort((a, b) => a.name.localeCompare(b.name))) + .then(licenses => { this.setState({ licenses: licenses }); }) } private updatePageSize() { @@ -144,7 +144,12 @@ export class ListsTable extends React.Component { { const list = this.state.lists.find(l => l.id === +props.match.params.id); return list - ? + ? list.languageIds.includes(l.id))} + license={list.licenseId ? this.state.licenses.find((l: License) => list.licenseId === l.id) : undefined} + tags={list.tagIds && this.state.tags.filter((t: Tag) => list.tagIds.includes(t.id))} + {...this.props} /> : this.state.lists && this.state.lists.length && }} /> diff --git a/src/FilterLists.Web.V2/src/components/tagCloud/TagCloud.tsx b/src/FilterLists.Web.V2/src/components/tagCloud/TagCloud.tsx index 48dbed300..c63c775f4 100644 --- a/src/FilterLists.Web.V2/src/components/tagCloud/TagCloud.tsx +++ b/src/FilterLists.Web.V2/src/components/tagCloud/TagCloud.tsx @@ -1,15 +1,11 @@ import { Tag } from 'antd'; import React from 'react'; +import { Tag as TagInterface } from '../../interfaces/Tag'; import styles from './TagCloud.module.css'; -interface TagData { - description: string; - name: string; -}; - interface Props { - tags: TagData[] + tags: TagInterface[] showLabel?: boolean }; @@ -17,7 +13,7 @@ export const TagCloud = (props: Props): JSX.Element | null => props.tags && props.tags.length ?
{props.showLabel &&

{`Tag${props.tags.length > 1 ? "s" : ""}:`}

} - {props.tags.map((t: TagData, i: number) => + {props.tags.map((t: TagInterface, i: number) => {t.name})}
: null; \ No newline at end of file