| | |
| | | import React from 'react'; |
| | | import {Dropdown, DropdownItem, DropdownMenu, DropdownToggle} from 'reactstrap'; |
| | | import PropTypes from 'prop-types'; |
| | | import {FormButton, FormInput, FormLabel, FormOption, FormSelect} from '../../general/forms/FormComponents'; |
| | | import { |
| | | FormButton, |
| | | FormCheckbox, |
| | | FormInput, |
| | | FormLabel, |
| | | FormOption, |
| | | FormSelect |
| | | } from '../../general/forms/FormComponents'; |
| | | import {IconRefresh} from '../../general/IconComponents'; |
| | | import I18n from '../../general/translation/I18n'; |
| | | |
| | | function FileListFilter({reload, changeFilter, filter, currentArchiveId, archiveShortInfoList}) { |
| | | class FileListFilter extends React.Component { |
| | | constructor(props) { |
| | | super(props); |
| | | |
| | | this.toggle = this.toggle.bind(this); |
| | | this.state = { |
| | | dropdownOpen: false |
| | | }; |
| | | } |
| | | |
| | | toggle() { |
| | | this.setState(prevState => ({ |
| | | dropdownOpen: !prevState.dropdownOpen |
| | | })); |
| | | } |
| | | |
| | | render = () => { |
| | | const archiveShortInfoList = this.props.archiveShortInfoList; |
| | | const currentArchiveId = this.props.currentArchiveId; |
| | | const reload = this.props.reload; |
| | | const filter = this.props.filter; |
| | | let archiveOptions = |
| | | archiveShortInfoList |
| | | .map(archive => { |
| | |
| | | <FormInput |
| | | value={filter.search} |
| | | name={'search'} |
| | | onChange={changeFilter} |
| | | fieldLength={5} |
| | | onChange={this.props.changeFilter} |
| | | fieldLength={7} |
| | | autoFocus |
| | | hint={'You may enter several key words separated by white spaces. Hit simply return to proceed. Example: \'borg xls !film\' searches for Excel files containing \'borg\', but not \'film\'.'} |
| | | /> |
| | | |
| | | <FormSelect |
| | | value={filter.diffArchiveId} |
| | | name={'diffArchiveId'} |
| | | onChange={(event) => { |
| | | this.props.changeFilter(event, () => reload(event)) |
| | | }} |
| | | hint={'Show differences between current archive and this selected archive.'} |
| | | > |
| | | <FormOption value={''} label={'Select diff archive'}/> |
| | | {archiveOptions} |
| | | </FormSelect> |
| | | <Dropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}> |
| | | <DropdownToggle outline color="secondary" caret> |
| | | Settings |
| | | </DropdownToggle> |
| | | <DropdownMenu> |
| | | <DropdownItem disabled> |
| | | <div className={'label'}>Mode:{' '}</div> |
| | | <div className={'value'}> |
| | | <FormSelect |
| | | value={filter.mode} |
| | | name={'mode'} |
| | | onChange={changeFilter} |
| | | onChange={this.props.changeFilter} |
| | | > |
| | | <FormOption value={'tree'}/> |
| | | <FormOption value={'flat'}/> |
| | | </FormSelect> |
| | | </div> |
| | | </DropdownItem> |
| | | <DropdownItem disabled> |
| | | <div className={'label'}>Result size:{' '}</div> |
| | | <div className={'value'}> |
| | | <FormSelect |
| | | value={filter.maxSize} |
| | | name={'maxSize'} |
| | | onChange={changeFilter} |
| | | onChange={this.props.changeFilter} |
| | | hint={<I18n name={'common.limitsResultSize'}/>} |
| | | > |
| | | <FormOption value={'50'}/> |
| | |
| | | <FormOption value={'1000'}/> |
| | | <FormOption value={'10000'}/> |
| | | </FormSelect> |
| | | <FormSelect |
| | | value={filter.diffArchiveId} |
| | | name={'diffArchiveId'} |
| | | onChange={(event) => {changeFilter(event, () => reload(event))}} |
| | | hint={'Show differences between current archive and this selected archive.'} |
| | | > |
| | | <FormOption value={''} label={'Select diff archive'}/> |
| | | {archiveOptions} |
| | | </FormSelect> |
| | | </div> |
| | | </DropdownItem> |
| | | <DropdownItem divider/> |
| | | <DropdownItem disabled> |
| | | <FormCheckbox checked={filter.autoChangeDirectoryToLeafItem} |
| | | hint={'Step automatically into single sub directories.'} |
| | | name="autoChangeDirectoryToLeafItem" |
| | | label={'Step automatically into sub dirs'} |
| | | onChange={this.props.changeFilterCheckbox}/> |
| | | </DropdownItem> |
| | | <DropdownItem disabled> |
| | | <FormCheckbox checked={filter.openDownloads} |
| | | name="openDownloads" |
| | | label={'Open downloads automatically'} |
| | | onChange={this.props.changeFilterCheckbox}/> |
| | | </DropdownItem> |
| | | </DropdownMenu> |
| | | </Dropdown> |
| | | <FormButton type={'submit'} bsStyle={'primary'}> |
| | | <IconRefresh/> |
| | | </FormButton> |
| | | </form> |
| | | ); |
| | | } |
| | | } |
| | | |
| | | FileListFilter.propTypes = { |
| | | changeFilter: PropTypes.func.isRequired, |
| | | changeFilterCheckbox: PropTypes.func.isRequired, |
| | | filter: PropTypes.shape({ |
| | | search: PropTypes.string, |
| | | maxSize: PropTypes.oneOf(['50', '100', '500', '1000', '10000']), |