Skip to content
Merged
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
2 changes: 1 addition & 1 deletion frontend/src/components/EventList/EventHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const EventHeader: React.FC<{ device?: IDevice }> = ({ device }) => {
<ListItem dense>
<DatePicker onChange={handleChangeDate} minDay={minDate} selectedDate={selectedDate} />
<ListItemSecondaryAction>
<EventTypeFilterMenu value={eventTypes} onChange={handleChangeEventTypes} />
<EventTypeFilterMenu device={device} value={eventTypes} onChange={handleChangeEventTypes} />
<CSVDownloadButton fetchUrl={fetchCsvUrl} />
</ListItemSecondaryAction>
</ListItem>
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/components/EventList/EventTypeFilterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ import { State } from '../../store'
import { useSelector } from 'react-redux'
import { Icon } from '../Icon'
import { IconButton } from '../../buttons/IconButton'
import { eventFilterOptions } from './eventTypes'
import { deviceHiddenEventFilterOptionKeys, eventFilterOptions } from './eventTypes'
import { EventFilterIcon } from './EventFilterIcon'
import { EventTypeFilterMenuItem } from './EventTypeFilterMenuItem'

type Props = {
device?: IDevice
value?: IEventType[]
onChange: (value?: IEventType[]) => void
}

export const EventTypeFilterMenu: React.FC<Props> = ({ value, onChange }) => {
export const EventTypeFilterMenu: React.FC<Props> = ({ device, value, onChange }) => {
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null)
const user = useSelector((state: State) => state.user)
const selectedValues = value || []
const activeTypes = useMemo(() => new Set(selectedValues), [selectedValues])
const visibleOptions = useMemo(
() =>
device ? eventFilterOptions.filter(option => !deviceHiddenEventFilterOptionKeys.has(option.key)) : eventFilterOptions,
[device]
)
const isFiltered = selectedValues.length > 0

const handleToggle = (types?: IEventType[]) => {
Expand Down Expand Up @@ -63,7 +69,7 @@ export const EventTypeFilterMenu: React.FC<Props> = ({ value, onChange }) => {
icon={<Icon name="asterisk" size="md" color={!isFiltered ? 'primary' : 'gray'} />}
/>
<Divider />
{eventFilterOptions.map(option => {
{visibleOptions.map(option => {
const selected = option.types.every(type => activeTypes.has(type))

return (
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/EventList/eventTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ export type EventFilterOption = {
iconTypes?: IEventType[]
}

export const deviceHiddenEventFilterOptionKeys = new Set([
'login-activity',
'password-activity',
'phone-change',
'mfa-change',
'license-updated',
])

export const eventFilterOptions: EventFilterOption[] = [
{
key: 'login-activity',
Expand Down
Loading