misc. linting

This commit is contained in:
Collin M. Barrett 2019-09-02 09:07:15 -05:00
parent 5d7726dc40
commit ada31e297a
7 changed files with 44 additions and 28 deletions

View file

@ -4,15 +4,16 @@ import * as React from 'react';
interface Props {
name: string;
descriptionUrl: string;
showLabel?: boolean
};
export const LicenseTag = (props: Props) =>
props.name
? <>
{props.showLabel && <h3>License:</h3>}
<h3>License:</h3>
<Tag>
<TagContents name={props.name} descriptionUrl={props.descriptionUrl} />
<TagContents
name={props.name}
descriptionUrl={props.descriptionUrl} />
</Tag>
</>
: null;
@ -25,7 +26,8 @@ interface TagContentsProps {
const TagContents = (props: TagContentsProps) =>
props.descriptionUrl
? <a href={props.descriptionUrl}
target="_blank" rel="noopener noreferrer">
target="_blank"
rel="noopener noreferrer">
{props.name}
</a>
: <>

View file

@ -19,7 +19,8 @@ export const LinkButton = (props: Props) =>
block
style={{ borderLeftColor: "rgb(217, 217, 217)" }} //HACK: override buggy style in antd
icon={props.icon}
target="_blank" rel="noopener noreferrer" >
target="_blank"
rel="noopener noreferrer" >
{props.text}
</Button >
: null;

View file

@ -51,15 +51,12 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
tags={props.tags}
showLabel={true} />
<LicenseTag
name={props.license.name}
descriptionUrl={props.license.descriptionUrl}
showLabel={true} />
name={props.license && props.license.name}
descriptionUrl={props.license.descriptionUrl} />
<SoftwareCloud
software={props.software}
showLabel={true} />
<PublishedDate
publishedDate={props.list.publishedDate}
showLabel={true} />
<PublishedDate publishedDate={props.list.publishedDate} />
<Divider />
<ButtonGroup style={{ display: "inherit" }}>
<SubscribeButtons

View file

@ -2,13 +2,12 @@ import React from 'react';
interface Props {
publishedDate: string;
showLabel?: boolean;
};
export const PublishedDate = (props: Props) =>
props.publishedDate
? <>
{props.showLabel && <h3>First Published Date:</h3>}
<h3>First Published Date:</h3>
{new Date(props.publishedDate).toDateString()}
</>
: null;

View file

@ -34,14 +34,20 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
rowKey={record => record.id.toString()}
loading={lists.length ? false : true}
size="small"
pagination={{ size: "small", simple: true, style: { float: "left" }, pageSize: tablePageSize.pageSize }}
pagination={{
size: "small",
simple: true,
style: { float: "left" },
pageSize: tablePageSize.pageSize
}}
scroll={{ x: tablePageSize.isNarrowWindow ? undefined : 1200 }}>
<Table.Column<List>
title="Info"
dataIndex={nameof<List>("id")}
className={styles.nogrow}
fixed="left"
render={(_text: string, record: List) => <ListInfoButton listName={record.name} {...routeComponentProps} />} />
render={(_id: number, list: List) =>
<ListInfoButton listName={list.name} {...routeComponentProps} />} />
<Table.Column<List>
title="Name"
dataIndex={nameof<List>("name")}
@ -50,14 +56,18 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
width={tablePageSize.isNarrowWindow ? undefined : 200}
className={styles.nogrow}
fixed="left"
render={(text: string) => <div>{text}</div>} />
render={(name: string) =>
<div>{name}</div>} />
{tablePageSize.isNarrowWindow
? null
: <Table.Column<List>
title="Description"
dataIndex={nameof<List>("description")}
className={styles.nogrow}
render={(_text: string, record: List) => <Description {...record} />} />}
render={(description: string, list: List) =>
<Description
description={description}
descriptionSourceUrl={list.descriptionSourceUrl} />} />}
{tablePageSize.isNarrowWindow
? null
: <Table.Column<List>
@ -65,13 +75,14 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
dataIndex={nameof<List>("syntaxId")}
sorter={(a, b) => {
const getSoftwareIds = (l: List) => software.filter((s: Software) => s.syntaxIds.includes(l.syntaxId)).map(s => s.id);
const aSoftwareIds = getSoftwareIds(a);
const bSoftwareIds = getSoftwareIds(b);
return arraySorter(aSoftwareIds, bSoftwareIds, software);
return arraySorter(getSoftwareIds(a), getSoftwareIds(b), software);
}}
width={143}
className={styles.nogrow}
render={(syntaxId: number) => syntaxId ? <SoftwareCloud software={software.filter((s: Software) => s.syntaxIds.includes(syntaxId))} /> : null} />}
render={(syntaxId: number) =>
syntaxId
? <SoftwareCloud software={software.filter((s: Software) => s.syntaxIds.includes(syntaxId))} />
: null} />}
{tablePageSize.isNarrowWindow
? null
: <Table.Column<List>
@ -80,7 +91,10 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
sorter={(a, b) => arraySorter(a.languageIds, b.languageIds, languages)}
width={125}
className={styles.nogrow}
render={(languageIds: number[]) => languageIds ? <LanguageCloud languages={languages.filter((l: Language) => languageIds.includes(l.id))} /> : null} />}
render={(languageIds: number[]) =>
languageIds
? <LanguageCloud languages={languages.filter((l: Language) => languageIds.includes(l.id))} />
: null} />}
{tablePageSize.isNarrowWindow
? null
: <Table.Column<List>
@ -89,7 +103,10 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
sorter={(a, b) => arraySorter(a.tagIds, b.tagIds, tags)}
width={275}
className={styles.nogrow}
render={(tagIds: number[]) => tagIds ? <TagCloud tags={tags.filter((t: Tag) => tagIds.includes(t.id))} /> : null} />}
render={(tagIds: number[]) =>
tagIds
? <TagCloud tags={tags.filter((t: Tag) => tagIds.includes(t.id))} />
: null} />}
</Table>
);
};

View file

@ -7,8 +7,8 @@ export const arraySorter = (a: number[], b: number[], entities: ArraySortableEnt
a && a.length
? b && b.length
? a.length === b.length
? entities.filter((e: ArraySortableEntity) => a.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
> entities.filter((e: ArraySortableEntity) => b.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
? entities.filter((e: ArraySortableEntity) => a.includes(e.id)).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
> entities.filter((e: ArraySortableEntity) => b.includes(e.id)).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
? 1
: -1
: a.length > b.length

View file

@ -15,10 +15,10 @@ export const SoftwareCloud = (props: Props) =>
{props.showLabel && <h3>{`Software:`}</h3>}
{props.software.map((s: Software, i: number) =>
s.homeUrl
? <a
key={i}
? <a key={i}
href={s.homeUrl}
target="_blank" rel="noopener noreferrer">
target="_blank"
rel="noopener noreferrer">
<SoftwareIcon id={s.id} />
</a>
: <SoftwareIcon key={i} id={s.id} />)}