Skip to content

Commit

Permalink
feedback part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Nov 7, 2023
1 parent 81770f0 commit ecc788f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/dataviews/view-list.js
Expand Up @@ -320,7 +320,7 @@ function ViewList( {
* @return {Array} The transformed TanStack column filters.
*/
const toTanStackColumnFilters = ( filters ) =>
filters.map( ( filter ) => ( {
filters?.map( ( filter ) => ( {
[ filter.field + ':' + filter.operator ]: filter.value,
} ) );

Expand Down
Expand Up @@ -12,10 +12,9 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useState, useMemo, useCallback, useEffect } from '@wordpress/element';
import { useState, useMemo, useCallback } from '@wordpress/element';
import { useEntityRecords } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
* Internal dependencies
Expand All @@ -25,35 +24,32 @@ import Link from '../routes/link';
import AddedBy from '../list/added-by';
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
import { DataViews } from '../dataviews';
import DEFAULT_VIEWS from './default-views';
import { useResetTemplateAction } from './template-actions';
import { unlock } from '../../lock-unlock';

const { useLocation } = unlock( routerPrivateApis );

const EMPTY_ARRAY = [];
const defaultConfigPerViewType = {
list: {},
grid: {},
};

const DEFAULT_VIEW = {
type: 'list',
search: '',
page: 1,
perPage: 5, //20,
// All fields are visible by default, so it's
// better to keep track of the hidden ones.
hiddenFields: [],
layout: {},
};

function normalizeSearchInput( input = '' ) {
return removeAccents( input.trim().toLowerCase() );
}

export default function DataviewsTemplates() {
const {
params: { path, activeView = 'all' },
} = useLocation();
const initialView = DEFAULT_VIEWS.find(
( { slug } ) => slug === activeView
).view;
const [ view, setView ] = useState( initialView );
useEffect( () => {
setView(
DEFAULT_VIEWS.find( ( { slug } ) => slug === activeView ).view
);
}, [ path, activeView ] );
const [ view, setView ] = useState( DEFAULT_VIEW );

const { records: allTemplates, isResolving: isLoadingData } =
useEntityRecords( 'postType', TEMPLATE_POST_TYPE, {
per_page: -1,
Expand Down Expand Up @@ -130,11 +126,6 @@ export default function DataviewsTemplates() {
) || __( '(no title)' ) }
</Link>
</Heading>
{ item.description && (
<Text variant="muted">
{ decodeEntities( item.description ) }
</Text>
) }
</VStack>
);
},
Expand All @@ -143,8 +134,23 @@ export default function DataviewsTemplates() {
enableHiding: false,
},
{
header: __( 'Added by' ),
id: 'added-by',
header: __( 'Description' ),
id: 'description',
getValue: ( { item } ) => item.description,
render: ( { item } ) => {
return (
item.description && (
<Text variant="muted">
{ decodeEntities( item.description ) }
</Text>
)
);
},
enableSorting: false,
},
{
header: __( 'Author' ),
id: 'author',
getValue: () => {},
render: ( { item } ) => {
return (
Expand Down
25 changes: 0 additions & 25 deletions packages/edit-site/src/components/page-templates/default-views.js

This file was deleted.

0 comments on commit ecc788f

Please sign in to comment.