Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions packages/edit-site/src/components/page-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useEvent } from '@wordpress/compose';
import { useView } from '@wordpress/views';
import { Modal } from '@wordpress/components';
import { store as noticesStore } from '@wordpress/notices';
import { dateField } from '@wordpress/fields';

/**
* Internal dependencies
Expand All @@ -43,8 +44,7 @@ import {
getActiveViewOverridesForTab,
} from './view-utils';

const { usePostActions, usePostFields, templateTitleField } =
unlock( editorPrivateApis );
const { usePostActions, templateTitleField } = unlock( editorPrivateApis );
const { useHistory, useLocation } = unlock( routerPrivateApis );
const { useEntityRecordsWithPermissions } = unlock( corePrivateApis );

Expand Down Expand Up @@ -218,10 +218,6 @@ export default function PageTemplates() {
[ history, path, view?.type ]
);

const postTypeFields = usePostFields( {
postType: TEMPLATE_POST_TYPE,
} );
const dateField = postTypeFields.find( ( field ) => field.id === 'date' );
const themeField = useThemeField();
const fields = useMemo( () => {
const _fields = [
Expand All @@ -233,9 +229,7 @@ export default function PageTemplates() {
];
if ( activeView === 'user' ) {
_fields.push( themeField );
if ( dateField ) {
_fields.push( dateField );
}
_fields.push( dateField );
}
const elements = [];
for ( const author in users ) {
Expand All @@ -249,7 +243,7 @@ export default function PageTemplates() {
elements,
} );
return _fields;
}, [ users, activeView, themeField, dateField ] );
}, [ users, activeView, themeField ] );

const { data, paginationInfo } = useMemo( () => {
return filterSortAndPaginate( records, view, fields );
Expand Down
9 changes: 7 additions & 2 deletions routes/template-list/stage-activation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useMemo, useCallback, useState } from '@wordpress/element';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import { published, commentAuthorAvatar } from '@wordpress/icons';
import { dateField } from '@wordpress/fields';

/**
* Internal dependencies
Expand Down Expand Up @@ -143,7 +144,7 @@ function TemplateListActivation() {
label: users[ author ]?.name ?? author,
} );
}
return [
const _fields = [
previewField,
templateTitleField,
descriptionField,
Expand All @@ -154,7 +155,11 @@ function TemplateListActivation() {
elements,
},
];
}, [ users ] );
if ( activeView === 'user' ) {
_fields.push( dateField );
}
return _fields;
}, [ users, activeView ] );

// Apply filtering, sorting, and pagination on the client side
const { data: posts, paginationInfo } = useMemo( () => {
Expand Down
Loading