diff --git a/src/FilterLists.Web/ClientApp/modules/home/Home.tsx b/src/FilterLists.Web/ClientApp/modules/home/Home.tsx index 249320651..21e074839 100644 --- a/src/FilterLists.Web/ClientApp/modules/home/Home.tsx +++ b/src/FilterLists.Web/ClientApp/modules/home/Home.tsx @@ -3,11 +3,12 @@ import { IColumnVisibility, ILanguage, IList, IMaintainer, ISoftware, ITag } fro import { ListsTable, Oneliner } from "./components"; const columnVisibilityDefaults: IColumnVisibility[] = [ + { column: "Maintainers", visible: false }, { column: "Software", visible: true }, { column: "Tags", visible: true }, { column: "Languages", visible: true }, - { column: "Maintainers", visible: false }, - { column: "Updated Date", visible: true } + { column: "Updated Date", visible: true }, + { column: "Rule Count", visible: true } ]; interface IProps { diff --git a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/ListsTable.tsx b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/ListsTable.tsx index f36e36a38..ab2ee3114 100644 --- a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/ListsTable.tsx +++ b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/ListsTable.tsx @@ -4,7 +4,7 @@ import "../../../../utils/loader.css"; import ReactTable from "react-table"; import "react-table/react-table.css"; import "./listsTable.css"; -import { DetailsButton, Languages, Maintainers, Name, Software, Tags, UpdatedDate } from "./columns"; +import { DetailsButton, Languages, Maintainers, Name, RuleCount, Software, Tags, UpdatedDate } from "./columns"; import { IListDetails } from "../../components/detailsExpander"; import { DetailsExpander } from "../../components"; @@ -31,6 +31,7 @@ export const ListsTable = (props: IProps) => Tags(props.columnVisibility, props.tags), Languages(props.columnVisibility, props.languages), UpdatedDate(props.columnVisibility), + RuleCount(props.columnVisibility), DetailsButton ]} defaultSorted={[{ id: "name" }]} diff --git a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/RuleCount.tsx b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/RuleCount.tsx new file mode 100644 index 000000000..a2771bfeb --- /dev/null +++ b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/RuleCount.tsx @@ -0,0 +1,26 @@ +import * as React from "react"; +import { Column } from "react-table"; +import { IColumnVisibility } from "../../../interfaces"; + +export const RuleCount = (columnVisibility: IColumnVisibility[]) => +({ + Header: "Rules", + accessor: "ruleCount", + sortMethod: (a: string, b: string) => sortMethod(a, b), + Cell: (c: any) => Cell(c.value), + style: { whiteSpace: "inherit" }, + width: 80, + headerClassName: "d-none d-md-block", + className: "d-none d-md-block", + show: columnVisibility.filter((c: IColumnVisibility) => c.column === "Rule Count")[0].visible +} as Column); + +const sortMethod = (a: string, b: string) => + a > b + ? 1 + : -1; + +const Cell = (ruleCount: number) => + ruleCount + ? {ruleCount.toLocaleString() } + : null; \ No newline at end of file diff --git a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/index.ts b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/index.ts index d6e1cc65a..7cecfdbe5 100644 --- a/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/index.ts +++ b/src/FilterLists.Web/ClientApp/modules/home/components/listsTable/columns/index.ts @@ -2,6 +2,7 @@ import { Languages } from "./Languages"; import { Maintainers } from "./Maintainers"; import { Name } from "./Name"; +import { RuleCount } from "./RuleCount"; import { Software } from "./Software"; import { Tags } from "./Tags"; import { UpdatedDate } from "./UpdatedDate"; @@ -11,6 +12,7 @@ export { Languages, Maintainers, Name, + RuleCount, Software, Tags, UpdatedDate