Skip to content

Commit

Permalink
fix: react hook linter supressions in SearchFilterAssetInput
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jul 31, 2024
1 parent 37ef088 commit f77ff87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {useClient} from '../../../../../../../../../hooks'
import {useTranslation} from '../../../../../../../../../i18n'
import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../../../../../../../studioClient'
import {useSource} from '../../../../../../../../source'
import {useSearchState} from '../../../../../contexts/search/useSearchState'
import {type OperatorInputComponentProps} from '../../../../../definitions/operators/operatorTypes'
import {AssetSourceError} from './AssetSourceError'
import {AssetPreview} from './preview/AssetPreview'
Expand All @@ -28,7 +27,7 @@ const ContainerBox = styled(Box)`
width: min(calc(100vw - 40px), 320px);
`

export function SearchFilterAssetInput(type?: AssetType) {
export function renderSearchFilterAssetInput(type?: AssetType) {
return function FieldInputAssetWithType({
onChange,
value,
Expand All @@ -38,10 +37,6 @@ export function SearchFilterAssetInput(type?: AssetType) {
null,
)

const {
state: {fullscreen},
} = useSearchState()

const {file, image} = useSource().form
const {t} = useTranslation()

Expand Down Expand Up @@ -102,8 +97,6 @@ export function SearchFilterAssetInput(type?: AssetType) {

const AssetSourceComponent = selectedAssetSource?.component

const fontSize = fullscreen ? 2 : 1

const buttonText = t(value ? 'search.filter-asset-change' : 'search.filter-asset-select', {
context: type,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ReferenceValue} from '@sanity/types'

import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue'
import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {renderSearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {defineSearchOperator, type SearchOperatorButtonValue} from './operatorTypes'
import {toJSON} from './operatorUtils'

Expand All @@ -15,7 +15,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
label: 'is',
type: 'assetFileEqual',
}),
Expand All @@ -26,7 +26,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
label: 'is not',
type: 'assetFileNotEqual',
}),
Expand All @@ -37,7 +37,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref == ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
label: 'is',
type: 'assetImageEqual',
}),
Expand All @@ -48,7 +48,7 @@ export const assetOperators = {
groqFilter: ({fieldPath, value}) =>
value?._ref && fieldPath ? `${fieldPath}.asset._ref != ${toJSON(value._ref)}` : null,
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
label: 'is not',
type: 'assetImageNotEqual',
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ReferenceValue} from '@sanity/types'

import {SearchButtonValueReference} from '../../components/filters/common/ButtonValue'
import {SearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {renderSearchFilterAssetInput} from '../../components/filters/filter/inputs/asset/Asset'
import {SearchFilterReferenceInput} from '../../components/filters/filter/inputs/reference/Reference'
import {
defineSearchOperator,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const referenceOperators = {
buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue<ReferenceValue>,
groqFilter: ({value}) => (value?._ref ? `references(${toJSON(value._ref)})` : null),
initialValue: null,
inputComponent: SearchFilterAssetInput('file'),
inputComponent: renderSearchFilterAssetInput('file'),
type: 'referencesAssetFile',
}),
referencesAssetImage: defineSearchOperator({
Expand All @@ -48,7 +48,7 @@ export const referenceOperators = {
buttonValueComponent: SearchButtonValueReference as SearchOperatorButtonValue<ReferenceValue>,
groqFilter: ({value}) => (value?._ref ? `references(${toJSON(value._ref)})` : null),
initialValue: null,
inputComponent: SearchFilterAssetInput('image'),
inputComponent: renderSearchFilterAssetInput('image'),
type: 'referencesAssetImage',
}),
referencesDocument: defineSearchOperator({
Expand Down

0 comments on commit f77ff87

Please sign in to comment.