mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
expose Rule Count column in table
This commit is contained in:
parent
bc8ced6be9
commit
1db169a2d2
4 changed files with 33 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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" }]}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
? <span>{ruleCount.toLocaleString() }</span>
|
||||
: null;
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue