File tree Expand file tree Collapse file tree 9 files changed +74
-58
lines changed
dataviews/src/dataforms-layouts/panel Expand file tree Collapse file tree 9 files changed +74
-58
lines changed Original file line number Diff line number Diff line change 44
44
.dataforms-layouts-panel__dropdown-header {
45
45
margin-bottom : $grid-unit-20 ;
46
46
}
47
+
48
+ .components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown {
49
+ z-index : z-index (" .components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown" );
50
+ }
Original file line number Diff line number Diff line change @@ -18,10 +18,9 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
18
18
* Internal dependencies
19
19
*/
20
20
import Page from '../page' ;
21
- import usePostFields from '../post-fields' ;
22
21
import { unlock } from '../../lock-unlock' ;
23
22
24
- const { PostCardPanel } = unlock ( editorPrivateApis ) ;
23
+ const { PostCardPanel, usePostFields } = unlock ( editorPrivateApis ) ;
25
24
26
25
const fieldsWithBulkEditSupport = [
27
26
'title' ,
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -32,9 +32,8 @@ import AddNewPostModal from '../add-new-post';
32
32
import { unlock } from '../../lock-unlock' ;
33
33
import { useEditPostAction } from '../dataviews-actions' ;
34
34
import { usePrevious } from '@wordpress/compose' ;
35
- import usePostFields from '../post-fields' ;
36
35
37
- const { usePostActions } = unlock ( editorPrivateApis ) ;
36
+ const { usePostActions, usePostFields } = unlock ( editorPrivateApis ) ;
38
37
const { useLocation, useHistory } = unlock ( routerPrivateApis ) ;
39
38
const { useEntityRecordsWithPermissions } = unlock ( coreDataPrivateApis ) ;
40
39
const EMPTY_ARRAY = [ ] ;
Original file line number Diff line number Diff line change 30
30
@import " ./components/editor-canvas-container/style.scss" ;
31
31
@import " ./components/post-edit/style.scss" ;
32
32
@import " ./components/post-list/style.scss" ;
33
- @import " ./components/post-fields/style.scss" ;
34
33
@import " ./components/resizable-frame/style.scss" ;
35
34
@import " ./hooks/push-changes-to-global-styles/style.scss" ;
36
35
@import " ./components/global-styles/font-library-modal/style.scss" ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo } from '@wordpress/element' ;
5
+ import { useEntityRecords } from '@wordpress/core-data' ;
6
+ import type { Field } from '@wordpress/dataviews' ;
7
+ import {
8
+ featuredImageField ,
9
+ slugField ,
10
+ parentField ,
11
+ passwordField ,
12
+ statusField ,
13
+ commentStatusField ,
14
+ titleField ,
15
+ dateField ,
16
+ authorField ,
17
+ } from '@wordpress/fields' ;
18
+ import type { BasePostWithEmbeddedAuthor } from '@wordpress/fields' ;
19
+
20
+ interface UsePostFieldsReturn {
21
+ isLoading : boolean ;
22
+ fields : Field < BasePostWithEmbeddedAuthor > [ ] ;
23
+ }
24
+
25
+ interface Author {
26
+ id : number ;
27
+ name : string ;
28
+ }
29
+
30
+ function usePostFields ( ) : UsePostFieldsReturn {
31
+ const { records : authors , isResolving : isLoadingAuthors } =
32
+ useEntityRecords < Author > ( 'root' , 'user' , { per_page : - 1 } ) ;
33
+
34
+ const fields = useMemo (
35
+ ( ) =>
36
+ [
37
+ featuredImageField ,
38
+ titleField ,
39
+ {
40
+ ...authorField ,
41
+ elements : authors ?. map ( ( { id, name } ) => ( {
42
+ value : id ,
43
+ label : name ,
44
+ } ) ) ,
45
+ } ,
46
+ statusField ,
47
+ dateField ,
48
+ slugField ,
49
+ parentField ,
50
+ commentStatusField ,
51
+ passwordField ,
52
+ ] as Field < BasePostWithEmbeddedAuthor > [ ] ,
53
+ [ authors ]
54
+ ) ;
55
+
56
+ return {
57
+ isLoading : isLoadingAuthors ,
58
+ fields,
59
+ } ;
60
+ }
61
+
62
+ /**
63
+ * Hook to get the fields for a post (BasePost or BasePostWithEmbeddedAuthor).
64
+ */
65
+ export default usePostFields ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import PluginPostExcerpt from './components/post-excerpt/plugin';
16
16
import PostCardPanel from './components/post-card-panel' ;
17
17
import PreferencesModal from './components/preferences-modal' ;
18
18
import { usePostActions } from './components/post-actions/actions' ;
19
+ import usePostFields from './components/post-fields' ;
19
20
import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group' ;
20
21
import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group' ;
21
22
import ResizableEditor from './components/resizable-editor' ;
@@ -40,6 +41,7 @@ lock( privateApis, {
40
41
PostCardPanel,
41
42
PreferencesModal,
42
43
usePostActions,
44
+ usePostFields,
43
45
ToolsMoreMenuGroup,
44
46
ViewMoreMenuGroup,
45
47
ResizableEditor,
Original file line number Diff line number Diff line change 1
1
export * from './fields' ;
2
2
export * from './actions' ;
3
+ export type * from './types' ;
You can’t perform that action at this time.
0 commit comments