Skip to content

Commit

Permalink
Update comment for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 17, 2023
1 parent f1fe556 commit 8ed8ff8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/dataviews/add-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const {
DropdownMenuItemV2,
} = unlock( componentsPrivateApis );

const ENUMERATION_TYPE = 'enumeration'; // TODO: merge with the one in filters.js
// TODO: find a place where these constants can be shared across components.
const ENUMERATION_TYPE = 'enumeration';

export default function AddFilter( { fields, view, onChangeView } ) {
const filters = [];
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/components/dataviews/in-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';

// TODO: find a place where these constants can be shared across components.
export const OPERATOR_IN = 'in';

export default ( { filter, view, onChangeView } ) => {
Expand Down
10 changes: 8 additions & 2 deletions packages/edit-site/src/components/dataviews/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ const sortingItemsInfo = {
desc: { icon: arrowDown, label: __( 'Sort descending' ) },
};
const sortIcons = { asc: chevronUp, desc: chevronDown };

// TODO: find a place where these constants can be shared across components.
const ENUMERATION_TYPE = 'enumeration';
const OPERATOR_IN = 'in';

function HeaderMenu( { dataView, header } ) {
if ( header.isPlaceholder ) {
return null;
Expand All @@ -68,7 +73,7 @@ function HeaderMenu( { dataView, header } ) {
const sortedDirection = header.column.getIsSorted();

let filter;
if ( header.column.columnDef.type === 'enumeration' ) {
if ( header.column.columnDef.type === ENUMERATION_TYPE ) {
filter = {
field: header.column.columnDef.id,
elements: [
Expand Down Expand Up @@ -197,7 +202,8 @@ function HeaderMenu( { dataView, header } ) {
return (
field !==
filter.field ||
operator !== 'in'
operator !==
OPERATOR_IN
);
}
);
Expand Down

0 comments on commit 8ed8ff8

Please sign in to comment.