Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ export const MEDIA_OPTIONS = [
] as const;
export type MediaOptions = (typeof MEDIA_OPTIONS)[number];

export const SOCIAL_MEDIA_OPTIONS = [
"twitter",
// "tiktok",
// "instagram",
// "RSS",
// "truthsocial",
// "youtube",
// "facebook",
] as const satisfies readonly MediaOptions[];

export const ALERT_MEDIA_OPTIONS = [
"ioda",
"cloudflare",
] as const satisfies readonly MediaOptions[];

export const DATA_SOURCE_OPTIONS = [
"Active Probing",
"BGP",
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Reports/AllReportsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useQueryParams } from "../../hooks/useQueryParams";
import { formatPageCount } from "../../utils/format";
import { getReports } from "../../api/reports";
import type { ReportQueryState } from "../../api/reports/types";
import { ALERT_MEDIA_OPTIONS, SOCIAL_MEDIA_OPTIONS } from "../../api/common";

import ReportListItem from "./components/ReportListItem";
import ReportsFilters from "./components/ReportsFilters";
Expand Down Expand Up @@ -55,13 +56,20 @@ const AllReportsList = ({ alerts }: IProps) => {
navigate({ pathname: `${id}`, search: searchParams.toString() });
}

const platformOptions = alerts
? [...ALERT_MEDIA_OPTIONS]
: [...SOCIAL_MEDIA_OPTIONS];

return (
<>
<div className='px-1 py-2 bg-gray-50 dark:bg-gray-800 backdrop-blur-sm sticky top-0 z-10 '>
<ReportsFilters
reportCount={reports && reports.total}
isFetching={isFetching}
refetch={refetch}
platformOptions={platformOptions}
showEntityLevelFilter={alerts}
showSignalSourcesFilter={alerts}
headerElement={
multiSelect.isActive ? (
<AggieButton
Expand Down
38 changes: 24 additions & 14 deletions src/pages/Reports/components/ReportsFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ interface IReportFilters {
fromGroup?: string;
refetch: () => void;
isFetching: boolean;
platformOptions?: string[];
showEntityLevelFilter?: boolean;
showSignalSourcesFilter?: boolean;
}

const ReportFilters = ({
Expand All @@ -42,6 +45,9 @@ const ReportFilters = ({
fromGroup,
refetch,
isFetching,
platformOptions = [...MEDIA_OPTIONS],
showEntityLevelFilter = true,
showSignalSourcesFilter = true,
}: IReportFilters) => {
const {
searchParams,
Expand Down Expand Up @@ -172,23 +178,27 @@ const ReportFilters = ({
/>
<FilterListbox
label='Platforms'
options={[...MEDIA_OPTIONS]}
options={platformOptions}
value={getParam("media") as string}
onChange={(e) => setParams({ media: e as string})}
/>
<FilterListbox
label='Entity Level'
options={[...ENTITY_LEVEL_OPTIONS]}
value={getParam("entityLevel") as string}
onChange={(e) => setParams({ entityLevel: e as string})}
/>
<FilterListbox
label='Signal Sources'
options={[...DATA_SOURCE_OPTIONS]}
value={getParam("dataSources") ? getParam("dataSources").split(",") as string[] : []}
onChange={(e) => setParams({ dataSources: e as string[]})}
isMultiSelect={true}
/>
{showEntityLevelFilter && (
<FilterListbox
label='Entity Level'
options={[...ENTITY_LEVEL_OPTIONS]}
value={getParam("entityLevel") as string}
onChange={(e) => setParams({ entityLevel: e as string})}
/>
)}
{showSignalSourcesFilter && (
<FilterListbox
label='Signal Sources'
options={[...DATA_SOURCE_OPTIONS]}
value={getParam("dataSources") ? getParam("dataSources").split(",") as string[] : []}
onChange={(e) => setParams({ dataSources: e as string[]})}
isMultiSelect={true}
/>
)}
{/* <FilterComboBox
label='Sources'
list={sourcesList(sources)}
Expand Down