Disable claim type search if filtering by channel
This commit is contained in:
parent
62c7216b43
commit
ddae2e8ac5
2 changed files with 15 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
import { SEARCH_OPTIONS } from 'constants/search';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Form, FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
|
||||
|
@ -16,6 +16,11 @@ const SearchOptions = (props: Props) => {
|
|||
const { options, setSearchOption, expanded, toggleSearchExpanded } = props;
|
||||
const resultCount = options[SEARCH_OPTIONS.RESULT_COUNT];
|
||||
|
||||
const isFilteringByChannel = useMemo(() => {
|
||||
const claimType = String(options[SEARCH_OPTIONS.CLAIM_TYPE] || '');
|
||||
return claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS);
|
||||
}, [options]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
|
@ -54,7 +59,7 @@ const SearchOptions = (props: Props) => {
|
|||
))}
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<fieldset disabled={isFilteringByChannel}>
|
||||
<legend className="search__legend">{__('Type')}</legend>
|
||||
{[
|
||||
{
|
||||
|
@ -85,7 +90,7 @@ const SearchOptions = (props: Props) => {
|
|||
blockWrap={false}
|
||||
disabled={options[SEARCH_OPTIONS.CLAIM_TYPE] === SEARCH_OPTIONS.INCLUDE_CHANNELS}
|
||||
label={label}
|
||||
checked={options[option]}
|
||||
checked={!isFilteringByChannel && options[option]}
|
||||
onChange={() => setSearchOption(option, !options[option])}
|
||||
/>
|
||||
))}
|
||||
|
@ -97,7 +102,7 @@ const SearchOptions = (props: Props) => {
|
|||
type="select"
|
||||
name="result-count"
|
||||
value={resultCount}
|
||||
onChange={e => setSearchOption(SEARCH_OPTIONS.RESULT_COUNT, e.target.value)}
|
||||
onChange={(e) => setSearchOption(SEARCH_OPTIONS.RESULT_COUNT, e.target.value)}
|
||||
blockWrap={false}
|
||||
label={__('Returned Results')}
|
||||
>
|
||||
|
|
|
@ -46,9 +46,12 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
|
|||
if (claimType) {
|
||||
queryParams.push(`claimType=${claimType}`);
|
||||
|
||||
const searchingFiles = claimType.includes(SEARCH_OPTIONS.INCLUDE_FILES);
|
||||
|
||||
if (searchingFiles) {
|
||||
/*
|
||||
* Due to limitations in lighthouse, we can't pass
|
||||
* the mediaType parameter when searching for
|
||||
* channels or "everything".
|
||||
*/
|
||||
if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) {
|
||||
queryParams.push(
|
||||
`mediaType=${[
|
||||
SEARCH_OPTIONS.MEDIA_FILE,
|
||||
|
|
Loading…
Reference in a new issue