Skip to content

Commit

Permalink
Move usePostFields to editor package
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 15, 2024
1 parent d049eee commit 1b76327
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 23 deletions.
3 changes: 1 addition & 2 deletions packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import { store as coreDataStore } from '@wordpress/core-data';
import { __experimentalVStack as VStack } from '@wordpress/components';
import { useState, useMemo, useEffect } from '@wordpress/element';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { usePostFields } from '@wordpress/fields';

/**
* Internal dependencies
*/
import Page from '../page';
import { unlock } from '../../lock-unlock';

const { PostCardPanel } = unlock( editorPrivateApis );
const { PostCardPanel, usePostFields } = unlock( editorPrivateApis );

const fieldsWithBulkEditSupport = [
'title',
Expand Down
3 changes: 1 addition & 2 deletions packages/edit-site/src/components/post-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { __ } from '@wordpress/i18n';
import { drawerRight } from '@wordpress/icons';
import { usePostFields } from '@wordpress/fields';

/**
* Internal dependencies
Expand All @@ -34,7 +33,7 @@ import { unlock } from '../../lock-unlock';
import { useEditPostAction } from '../dataviews-actions';
import { usePrevious } from '@wordpress/compose';

const { usePostActions } = unlock( editorPrivateApis );
const { usePostActions, usePostFields } = unlock( editorPrivateApis );
const { useLocation, useHistory } = unlock( routerPrivateApis );
const { useEntityRecordsWithPermissions } = unlock( coreDataPrivateApis );
const EMPTY_ARRAY = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
import { useMemo } from '@wordpress/element';
import { useEntityRecords } from '@wordpress/core-data';
import type { Field } from '@wordpress/dataviews';

/**
* Internal dependencies
*/
import featuredImageField from '../featured-image';
import slugField from '../slug';
import parentField from '../parent';
import passwordField from '../password';
import statusField from '../status';
import commentStatusField from '../comment-status';
import titleField from '../title';
import dateField from '../date';
import authorField from '../author';
import type { BasePostWithEmbeddedAuthor } from '../../types';
import {
featuredImageField,
slugField,
parentField,
passwordField,
statusField,
commentStatusField,
titleField,
dateField,
authorField,
} from '@wordpress/fields';
import type { BasePostWithEmbeddedAuthor } from '@wordpress/fields';

interface UsePostFieldsReturn {
isLoading: boolean;
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PluginPostExcerpt from './components/post-excerpt/plugin';
import PostCardPanel from './components/post-card-panel';
import PreferencesModal from './components/preferences-modal';
import { usePostActions } from './components/post-actions/actions';
import usePostFields from './components/post-fields';
import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';
import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';
import ResizableEditor from './components/resizable-editor';
Expand All @@ -40,6 +41,7 @@ lock( privateApis, {
PostCardPanel,
PreferencesModal,
usePostActions,
usePostFields,
ToolsMoreMenuGroup,
ViewMoreMenuGroup,
ResizableEditor,
Expand Down
4 changes: 0 additions & 4 deletions packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ Undocumented declaration.

Undocumented declaration.

### usePostFields

Hook to get the fields for a post (BasePost or BasePostWithEmbeddedAuthor).

### viewPost

Undocumented declaration.
Expand Down
1 change: 0 additions & 1 deletion packages/fields/src/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ export { default as statusField } from './status';
export { default as commentStatusField } from './comment-status';
export { default as dateField } from './date';
export { default as authorField } from './author';
export { default as usePostFields } from './use-post-fields';
1 change: 1 addition & 0 deletions packages/fields/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './fields';
export * from './actions';
export type * from './types';

0 comments on commit 1b76327

Please sign in to comment.