Skip to content

Commit

Permalink
Post fields: clean up (#66941)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored Nov 12, 2024
1 parent af6d302 commit 7a6f7a8
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { MediaUpload } from '@wordpress/media-utils';
import { lineSolid } from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';
import type { DataFormControlProps } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import { __ } from '@wordpress/i18n';

export const FeaturedImageEdit = ( {
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*/
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';

export const FeaturedImageView = ( {
item,
Expand Down
3 changes: 1 addition & 2 deletions packages/fields/src/fields/featured-image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import { __ } from '@wordpress/i18n';
import { FeaturedImageEdit } from './featured-image-edit';
import { FeaturedImageView } from './featured-image-view';

const featuredImageField: Field< BasePost > = {
id: 'featured_media',
type: 'text',
label: __( 'Featured Image' ),
getValue: ( { item } ) => item.featured_media,
Edit: FeaturedImageEdit,
render: FeaturedImageView,
enableSorting: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/fields/src/fields/order/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
*/
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';

const orderField: Field< BasePost > = {
type: 'integer',
id: 'menu_order',
type: 'integer',
label: __( 'Order' ),
description: __( 'Determines the order of pages.' ),
};
Expand Down
3 changes: 1 addition & 2 deletions packages/fields/src/fields/parent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import { __ } from '@wordpress/i18n';
import { ParentEdit } from './parent-edit';
import { ParentView } from './parent-view';

const parentField: Field< BasePost > = {
id: 'parent',
type: 'text',
label: __( 'Parent' ),
getValue: ( { item } ) => item.parent,
Edit: ParentEdit,
render: ParentView,
enableSorting: true,
Expand Down
18 changes: 9 additions & 9 deletions packages/fields/src/fields/parent/parent-edit.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import removeAccents from 'remove-accents';

/**
* WordPress dependencies
*/
Expand All @@ -12,21 +17,16 @@ import {
// @ts-ignore
import { store as coreStore } from '@wordpress/core-data';
import type { DataFormControlProps } from '@wordpress/dataviews';

/**
* External dependencies
*/
import removeAccents from 'remove-accents';
import { debounce } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
import { __, sprintf } from '@wordpress/i18n';
import { filterURLForDisplay } from '@wordpress/url';

/**
* Internal dependencies
*/
import { debounce } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
import { __, sprintf } from '@wordpress/i18n';
import type { BasePost } from '../../types';
import { getTitleWithFallbackName } from './utils';
import { filterURLForDisplay } from '@wordpress/url';

type TreeBase = {
id: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/fields/src/fields/parent/parent-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
*/
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
import { getTitleWithFallbackName } from './utils';
import { __ } from '@wordpress/i18n';

export const ParentView = ( {
item,
Expand Down
1 change: 0 additions & 1 deletion packages/fields/src/fields/password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import PasswordEdit from './edit';
const passwordField: Field< BasePost > = {
id: 'password',
type: 'text',
getValue: ( { item } ) => item.password,
Edit: PasswordEdit,
enableSorting: false,
enableHiding: false,
Expand Down
3 changes: 1 addition & 2 deletions packages/fields/src/fields/slug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import { __ } from '@wordpress/i18n';
import SlugEdit from './slug-edit';
import SlugView from './slug-view';

const slugField: Field< BasePost > = {
id: 'slug',
type: 'text',
label: __( 'Slug' ),
getValue: ( { item } ) => item.slug,
Edit: SlugEdit,
render: SlugView,
};
Expand Down

0 comments on commit 7a6f7a8

Please sign in to comment.