diff --git a/packages/dataviews/src/components/dataviews-view-config/index.tsx b/packages/dataviews/src/components/dataviews-view-config/index.tsx index f13670f27cdab7..ef96cd755f0d05 100644 --- a/packages/dataviews/src/components/dataviews-view-config/index.tsx +++ b/packages/dataviews/src/components/dataviews-view-config/index.tsx @@ -39,13 +39,8 @@ import { sortIcons, sortLabels, } from '../../constants'; -import { - VIEW_LAYOUTS, - getNotHidableFieldIds, - getVisibleFieldIds, - getHiddenFieldIds, -} from '../../dataviews-layouts'; -import type { SupportedLayouts, View, Field } from '../../types'; +import { VIEW_LAYOUTS } from '../../dataviews-layouts'; +import type { NormalizedField, SupportedLayouts, View } from '../../types'; import DataViewsContext from '../dataviews-context'; import { unlock } from '../../lock-unlock'; @@ -93,6 +88,7 @@ function ViewTypeMenu( { case 'list': case 'grid': case 'table': + // @ts-expect-error return onChangeView( { ...view, type: e.target.value, @@ -237,34 +233,28 @@ function ItemsPerPageControl() { ); } -interface FieldItemProps { - id: any; - label: string; - index: number; - isVisible: boolean; - isHidable: boolean; -} - function FieldItem( { - field: { id, label, index, isVisible, isHidable }, - fields, + index, + field, view, onChangeView, }: { - field: FieldItemProps; - fields: Field< any >[]; + index?: number; + field: NormalizedField< any >; view: View; onChangeView: ( view: View ) => void; } ) { - const visibleFieldIds = getVisibleFieldIds( view, fields ); + const visibleFieldIds = view.fields ?? []; + const isVisible = + index !== undefined && visibleFieldIds.includes( field.id ); return ( - + - { label } + { field.label }