summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/projects/FilterPanel.js
blob: 5aaa56ac3d28069083e2b5b87c99eb9b477b2947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React from 'react'
import PropTypes from 'prop-types'
import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core'
import { filterPanel } from './FilterPanel.module.css'

export const FILTERS = { SHOW_ALL: 'All Projects', SHOW_OWN: 'My Projects', SHOW_SHARED: 'Shared with me' }

const FilterPanel = ({ onSelect, activeFilter = 'SHOW_ALL' }) => (
    <ToggleGroup className={`${filterPanel} pf-u-mb-sm`}>
        {Object.keys(FILTERS).map((filter) => (
            <ToggleGroupItem
                key={filter}
                onChange={() => activeFilter === filter || onSelect(filter)}
                isSelected={activeFilter === filter}
                text={FILTERS[filter]}
            />
        ))}
    </ToggleGroup>
)

FilterPanel.propTypes = {
    onSelect: PropTypes.func.isRequired,
    activeFilter: PropTypes.string,
}

export default FilterPanel