mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add Syntax to drawer
This commit is contained in:
parent
ac6ff94083
commit
82ed18d51d
8 changed files with 71 additions and 13 deletions
|
|
@ -18,12 +18,7 @@ export const LicenseTag = (props: Props) =>
|
|||
</>
|
||||
: null;
|
||||
|
||||
interface TagContentsProps {
|
||||
name: string;
|
||||
descriptionUrl: string;
|
||||
};
|
||||
|
||||
const TagContents = (props: TagContentsProps) =>
|
||||
const TagContents = (props: Props) =>
|
||||
props.descriptionUrl
|
||||
? <a href={props.descriptionUrl}
|
||||
target="_blank"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { Language } from '../interfaces/Language';
|
|||
import { License } from '../interfaces/License';
|
||||
import { List } from '../interfaces/List';
|
||||
import { Software } from '../interfaces/Software';
|
||||
import { Syntax } from '../interfaces/Syntax';
|
||||
import { Tag } from '../interfaces/Tag';
|
||||
import { Description } from './Description';
|
||||
import { LanguageCloud } from './languageCloud';
|
||||
|
|
@ -15,13 +16,15 @@ import { LinkButton } from './LinkButton';
|
|||
import { PublishedDate } from './PublishedDate';
|
||||
import { SoftwareCloud } from './softwareCloud';
|
||||
import { SubscribeButtons } from './SubscribeButtons';
|
||||
import { SyntaxTag } from './SyntaxTag';
|
||||
import { TagCloud } from './tagCloud';
|
||||
|
||||
interface Props {
|
||||
list: List;
|
||||
languages: Language[];
|
||||
license: License;
|
||||
license: License | undefined;
|
||||
software: Software[];
|
||||
syntax: Syntax | undefined;
|
||||
tags: Tag[];
|
||||
};
|
||||
|
||||
|
|
@ -50,9 +53,14 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
|
|||
<TagCloud
|
||||
tags={props.tags}
|
||||
showLabel={true} />
|
||||
<LicenseTag
|
||||
name={props.license && props.license.name}
|
||||
descriptionUrl={props.license && props.license.descriptionUrl} />
|
||||
{props.license &&
|
||||
<LicenseTag
|
||||
name={props.license.name}
|
||||
descriptionUrl={props.license.descriptionUrl} />}
|
||||
{props.syntax &&
|
||||
<SyntaxTag
|
||||
name={props.syntax.name}
|
||||
definitionUrl={props.syntax.definitionUrl} />}
|
||||
<SoftwareCloud
|
||||
software={props.software}
|
||||
showLabel={true} />
|
||||
|
|
|
|||
30
src/FilterLists.Web.V2/src/components/SyntaxTag.tsx
Normal file
30
src/FilterLists.Web.V2/src/components/SyntaxTag.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { Tag } from 'antd';
|
||||
import * as React from 'react';
|
||||
|
||||
interface Props {
|
||||
name: string;
|
||||
definitionUrl: string;
|
||||
};
|
||||
|
||||
export const SyntaxTag = (props: Props) =>
|
||||
props.name
|
||||
? <>
|
||||
<h3>Syntax:</h3>
|
||||
<Tag>
|
||||
<TagContents
|
||||
name={props.name}
|
||||
definitionUrl={props.definitionUrl} />
|
||||
</Tag>
|
||||
</>
|
||||
: null;
|
||||
|
||||
const TagContents = (props: Props) =>
|
||||
props.definitionUrl
|
||||
? <a href={props.definitionUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
{props.name}
|
||||
</a>
|
||||
: <>
|
||||
{props.name}
|
||||
</>;
|
||||
|
|
@ -5,6 +5,7 @@ import { Language } from '../../interfaces/Language';
|
|||
import { License } from '../../interfaces/License';
|
||||
import { List } from '../../interfaces/List';
|
||||
import { Software } from '../../interfaces/Software';
|
||||
import { Syntax } from '../../interfaces/Syntax';
|
||||
import { Tag } from '../../interfaces/Tag';
|
||||
import { ListInfoDrawer } from '../ListInfoDrawer';
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ interface Props {
|
|||
languages: Language[];
|
||||
licenses: License[];
|
||||
software: Software[];
|
||||
syntaxes: Syntax[];
|
||||
tags: Tag[];
|
||||
};
|
||||
|
||||
|
|
@ -23,8 +25,9 @@ export const ListDrawer = (props: Props) => {
|
|||
? <ListInfoDrawer
|
||||
list={list as List}
|
||||
languages={list.languageIds && props.languages.filter((l: Language) => list.languageIds.includes(l.id))}
|
||||
license={(list.licenseId ? props.licenses.find((l: License) => list.licenseId === l.id) : props.licenses.find((l: License) => l.id === 5)) as License}
|
||||
license={list.licenseId ? props.licenses.find((l: License) => list.licenseId === l.id) : props.licenses.find((l: License) => l.id === 5)}
|
||||
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 && <Redirect to={{ pathname: "/", }} />) || null;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import { RouteComponentProps } from 'react-router-dom';
|
||||
|
||||
import { useLanguages, useLicenses, useLists, useSoftware, useTags } from '../../hooks';
|
||||
import { useLanguages, useLicenses, useLists, useSoftware, useSyntaxes, useTags } from '../../hooks';
|
||||
import { ListDrawer } from './ListDrawer';
|
||||
import { ListsTable } from './ListsTable';
|
||||
|
||||
|
|
@ -10,6 +10,7 @@ export const ListsTableHoc = (props: RouteComponentProps) => {
|
|||
const languages = useLanguages();
|
||||
const licenses = useLicenses();
|
||||
const software = useSoftware();
|
||||
const syntaxes = useSyntaxes();
|
||||
const tags = useTags();
|
||||
return (
|
||||
<>
|
||||
|
|
@ -25,6 +26,7 @@ export const ListsTableHoc = (props: RouteComponentProps) => {
|
|||
languages={languages}
|
||||
licenses={licenses}
|
||||
software={software}
|
||||
syntaxes={syntaxes}
|
||||
tags={tags} />
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,16 @@ import { useLanguages } from './useLanguages';
|
|||
import { useLicenses } from './useLicenses';
|
||||
import { useLists } from './useLists';
|
||||
import { useSoftware } from './useSoftware';
|
||||
import { useSyntaxes } from './useSyntaxes';
|
||||
import { useTablePageSizer } from './useTablePageSizer';
|
||||
import { useTags } from './useTags';
|
||||
|
||||
export { useLanguages, useLicenses, useLists, useSoftware, useTablePageSizer, useTags };
|
||||
export {
|
||||
useLanguages,
|
||||
useLicenses,
|
||||
useLists,
|
||||
useSoftware,
|
||||
useSyntaxes,
|
||||
useTablePageSizer,
|
||||
useTags
|
||||
};
|
||||
4
src/FilterLists.Web.V2/src/hooks/useSyntaxes.tsx
Normal file
4
src/FilterLists.Web.V2/src/hooks/useSyntaxes.tsx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { Syntax } from '../interfaces/Syntax';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useSyntaxes = () => useApiData<Syntax[]>("/api/v1/syntaxes") || [];
|
||||
7
src/FilterLists.Web.V2/src/interfaces/Syntax.ts
Normal file
7
src/FilterLists.Web.V2/src/interfaces/Syntax.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export interface Syntax {
|
||||
id: number;
|
||||
definitionUrl: string;
|
||||
filterListIds: number[];
|
||||
name: string;
|
||||
softwareIds: number[];
|
||||
};
|
||||
Loading…
Reference in a new issue