@wordpress/edit-site 5.21.0 → 5.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/actions/index.js +121 -0
  3. package/build/components/actions/index.js.map +1 -0
  4. package/build/components/block-editor/use-site-editor-settings.js +12 -4
  5. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  6. package/build/components/dataviews/dataviews.js +10 -2
  7. package/build/components/dataviews/dataviews.js.map +1 -1
  8. package/build/components/dataviews/filters.js +30 -17
  9. package/build/components/dataviews/filters.js.map +1 -1
  10. package/build/components/dataviews/in-filter.js +5 -7
  11. package/build/components/dataviews/in-filter.js.map +1 -1
  12. package/build/components/dataviews/item-actions.js +62 -0
  13. package/build/components/dataviews/item-actions.js.map +1 -0
  14. package/build/components/dataviews/pagination.js +31 -50
  15. package/build/components/dataviews/pagination.js.map +1 -1
  16. package/build/components/dataviews/{text-filter.js → search.js} +10 -10
  17. package/build/components/dataviews/search.js.map +1 -0
  18. package/build/components/dataviews/view-grid.js +3 -3
  19. package/build/components/dataviews/view-grid.js.map +1 -1
  20. package/build/components/dataviews/view-list.js +2 -2
  21. package/build/components/dataviews/view-list.js.map +1 -1
  22. package/build/components/global-styles/font-library-modal/font-collection.js +1 -1
  23. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  24. package/build/components/global-styles/screen-block.js +1 -8
  25. package/build/components/global-styles/screen-block.js.map +1 -1
  26. package/build/components/page-pages/default-views.js +62 -0
  27. package/build/components/page-pages/default-views.js.map +1 -0
  28. package/build/components/page-pages/index.js +73 -52
  29. package/build/components/page-pages/index.js.map +1 -1
  30. package/build/components/page-patterns/rename-category-menu-item.js +27 -9
  31. package/build/components/page-patterns/rename-category-menu-item.js.map +1 -1
  32. package/build/components/save-button/index.js +4 -2
  33. package/build/components/save-button/index.js.map +1 -1
  34. package/build/components/sidebar/index.js +3 -1
  35. package/build/components/sidebar/index.js.map +1 -1
  36. package/build/components/sidebar-dataviews/index.js +74 -0
  37. package/build/components/sidebar-dataviews/index.js.map +1 -0
  38. package/build/components/sidebar-navigation-screen-page/page-details.js +1 -1
  39. package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
  40. package/build/hooks/commands/use-edit-mode-commands.js +3 -2
  41. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  42. package/build/utils/use-activate-theme.js +8 -0
  43. package/build/utils/use-activate-theme.js.map +1 -1
  44. package/build-module/components/actions/index.js +108 -0
  45. package/build-module/components/actions/index.js.map +1 -0
  46. package/build-module/components/block-editor/use-site-editor-settings.js +12 -4
  47. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  48. package/build-module/components/dataviews/dataviews.js +10 -2
  49. package/build-module/components/dataviews/dataviews.js.map +1 -1
  50. package/build-module/components/dataviews/filters.js +30 -17
  51. package/build-module/components/dataviews/filters.js.map +1 -1
  52. package/build-module/components/dataviews/in-filter.js +5 -7
  53. package/build-module/components/dataviews/in-filter.js.map +1 -1
  54. package/build-module/components/dataviews/item-actions.js +55 -0
  55. package/build-module/components/dataviews/item-actions.js.map +1 -0
  56. package/build-module/components/dataviews/pagination.js +32 -51
  57. package/build-module/components/dataviews/pagination.js.map +1 -1
  58. package/build-module/components/dataviews/{text-filter.js → search.js} +9 -9
  59. package/build-module/components/dataviews/search.js.map +1 -0
  60. package/build-module/components/dataviews/view-grid.js +3 -3
  61. package/build-module/components/dataviews/view-grid.js.map +1 -1
  62. package/build-module/components/dataviews/view-list.js +2 -2
  63. package/build-module/components/dataviews/view-list.js.map +1 -1
  64. package/build-module/components/global-styles/font-library-modal/font-collection.js +1 -1
  65. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  66. package/build-module/components/global-styles/screen-block.js +1 -8
  67. package/build-module/components/global-styles/screen-block.js.map +1 -1
  68. package/build-module/components/page-pages/default-views.js +55 -0
  69. package/build-module/components/page-pages/default-views.js.map +1 -0
  70. package/build-module/components/page-pages/index.js +71 -52
  71. package/build-module/components/page-pages/index.js.map +1 -1
  72. package/build-module/components/page-patterns/rename-category-menu-item.js +25 -9
  73. package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -1
  74. package/build-module/components/save-button/index.js +4 -2
  75. package/build-module/components/save-button/index.js.map +1 -1
  76. package/build-module/components/sidebar/index.js +3 -1
  77. package/build-module/components/sidebar/index.js.map +1 -1
  78. package/build-module/components/sidebar-dataviews/index.js +66 -0
  79. package/build-module/components/sidebar-dataviews/index.js.map +1 -0
  80. package/build-module/components/sidebar-navigation-screen-page/page-details.js +1 -1
  81. package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
  82. package/build-module/hooks/commands/use-edit-mode-commands.js +4 -3
  83. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  84. package/build-module/utils/use-activate-theme.js +8 -0
  85. package/build-module/utils/use-activate-theme.js.map +1 -1
  86. package/build-style/style-rtl.css +9 -5
  87. package/build-style/style.css +9 -5
  88. package/package.json +40 -40
  89. package/src/components/actions/index.js +123 -0
  90. package/src/components/block-editor/use-site-editor-settings.js +21 -13
  91. package/src/components/dataviews/README.md +134 -47
  92. package/src/components/dataviews/dataviews.js +11 -1
  93. package/src/components/dataviews/filters.js +35 -17
  94. package/src/components/dataviews/in-filter.js +5 -7
  95. package/src/components/dataviews/item-actions.js +69 -0
  96. package/src/components/dataviews/pagination.js +53 -74
  97. package/src/components/dataviews/{text-filter.js → search.js} +7 -7
  98. package/src/components/dataviews/style.scss +10 -5
  99. package/src/components/dataviews/view-grid.js +7 -2
  100. package/src/components/dataviews/view-list.js +2 -2
  101. package/src/components/global-styles/font-library-modal/font-collection.js +1 -1
  102. package/src/components/global-styles/screen-block.js +1 -7
  103. package/src/components/page-pages/default-views.js +60 -0
  104. package/src/components/page-pages/index.js +85 -60
  105. package/src/components/page-patterns/rename-category-menu-item.js +29 -12
  106. package/src/components/save-button/index.js +10 -5
  107. package/src/components/sidebar/index.js +2 -0
  108. package/src/components/sidebar-dataviews/index.js +66 -0
  109. package/src/components/sidebar-navigation-screen-page/page-details.js +3 -1
  110. package/src/hooks/commands/use-edit-mode-commands.js +3 -1
  111. package/src/utils/use-activate-theme.js +5 -0
  112. package/build/components/actions/trash-post.js +0 -48
  113. package/build/components/actions/trash-post.js.map +0 -1
  114. package/build/components/dataviews/field-actions.js +0 -30
  115. package/build/components/dataviews/field-actions.js.map +0 -1
  116. package/build/components/dataviews/text-filter.js.map +0 -1
  117. package/build-module/components/actions/trash-post.js +0 -41
  118. package/build-module/components/actions/trash-post.js.map +0 -1
  119. package/build-module/components/dataviews/field-actions.js +0 -22
  120. package/build-module/components/dataviews/field-actions.js.map +0 -1
  121. package/build-module/components/dataviews/text-filter.js.map +0 -1
  122. package/src/components/actions/trash-post.js +0 -55
  123. package/src/components/dataviews/field-actions.js +0 -28
@@ -6,45 +6,63 @@ import { __ } from '@wordpress/i18n';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import TextFilter from './text-filter';
10
9
  import InFilter from './in-filter';
11
10
 
12
11
  export default function Filters( { fields, view, onChangeView } ) {
13
- const filters = {};
12
+ const filterIndex = {};
14
13
  fields.forEach( ( field ) => {
15
14
  if ( ! field.filters ) {
16
15
  return;
17
16
  }
18
17
 
19
- field.filters.forEach( ( f ) => {
20
- filters[ f.id ] = { type: f.type };
18
+ field.filters.forEach( ( filter ) => {
19
+ let id = field.id;
20
+ if ( 'string' === typeof filter ) {
21
+ filterIndex[ id ] = {
22
+ id,
23
+ name: field.header,
24
+ type: filter,
25
+ };
26
+ }
27
+
28
+ if ( 'object' === typeof filter ) {
29
+ id = filter.id || field.id;
30
+ filterIndex[ id ] = {
31
+ id,
32
+ name: filter.name || field.header,
33
+ type: filter.type,
34
+ };
35
+ }
36
+
37
+ if ( 'enumeration' === filterIndex[ id ]?.type ) {
38
+ const elements = [
39
+ {
40
+ value: filter.resetValue || '',
41
+ label: filter.resetLabel || __( 'All' ),
42
+ },
43
+ ...( field.elements || [] ),
44
+ ];
45
+ filterIndex[ id ] = {
46
+ ...filterIndex[ id ],
47
+ elements,
48
+ };
49
+ }
21
50
  } );
22
51
  } );
23
52
 
24
53
  return (
25
54
  view.visibleFilters?.map( ( filterName ) => {
26
- const filter = filters[ filterName ];
55
+ const filter = filterIndex[ filterName ];
27
56
 
28
57
  if ( ! filter ) {
29
58
  return null;
30
59
  }
31
60
 
32
- if ( filter.type === 'search' ) {
33
- return (
34
- <TextFilter
35
- key={ filterName }
36
- id={ filterName }
37
- view={ view }
38
- onChangeView={ onChangeView }
39
- />
40
- );
41
- }
42
61
  if ( filter.type === 'enumeration' ) {
43
62
  return (
44
63
  <InFilter
45
64
  key={ filterName }
46
- id={ filterName }
47
- fields={ fields }
65
+ filter={ filter }
48
66
  view={ view }
49
67
  onChangeView={ onChangeView }
50
68
  />
@@ -14,21 +14,19 @@ import { unlock } from '../../lock-unlock';
14
14
 
15
15
  const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
16
16
 
17
- export default ( { id, fields, view, onChangeView } ) => {
18
- const field = fields.find( ( f ) => f.id === id );
19
-
17
+ export default ( { filter, view, onChangeView } ) => {
20
18
  return (
21
19
  <SelectControl
22
- value={ view.filters[ id ] }
20
+ value={ view.filters[ filter.id ] }
23
21
  prefix={
24
22
  <InputControlPrefixWrapper
25
23
  as="span"
26
24
  className="dataviews__select-control-prefix"
27
25
  >
28
- { field.header + ':' }
26
+ { filter.name + ':' }
29
27
  </InputControlPrefixWrapper>
30
28
  }
31
- options={ field?.elements || [] }
29
+ options={ filter.elements }
32
30
  onChange={ ( value ) => {
33
31
  if ( value === '' ) {
34
32
  value = undefined;
@@ -38,7 +36,7 @@ export default ( { id, fields, view, onChangeView } ) => {
38
36
  ...currentView,
39
37
  filters: cleanEmptyObject( {
40
38
  ...currentView.filters,
41
- [ id ]: value,
39
+ [ filter.id ]: value,
42
40
  } ),
43
41
  } ) );
44
42
  } }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ DropdownMenu,
6
+ MenuGroup,
7
+ MenuItem,
8
+ Button,
9
+ __experimentalHStack as HStack,
10
+ } from '@wordpress/components';
11
+ import { __ } from '@wordpress/i18n';
12
+ import { useMemo } from '@wordpress/element';
13
+ import { moreVertical } from '@wordpress/icons';
14
+
15
+ export default function ItemActions( { item, actions } ) {
16
+ const { primaryActions, secondaryActions } = useMemo( () => {
17
+ return actions.reduce(
18
+ ( accumulator, action ) => {
19
+ // If an action is eligible for all items, doesn't need
20
+ // to provide the `isEligible` function.
21
+ if ( action.isEligible && ! action.isEligible( item ) ) {
22
+ return accumulator;
23
+ }
24
+ if ( action.isPrimary && !! action.icon ) {
25
+ accumulator.primaryActions.push( action );
26
+ } else {
27
+ accumulator.secondaryActions.push( action );
28
+ }
29
+ return accumulator;
30
+ },
31
+ { primaryActions: [], secondaryActions: [] }
32
+ );
33
+ }, [ actions, item ] );
34
+ if ( ! primaryActions.length && ! secondaryActions.length ) {
35
+ return null;
36
+ }
37
+ return (
38
+ <HStack justify="flex-end">
39
+ { !! primaryActions.length &&
40
+ primaryActions.map( ( action ) => (
41
+ <Button
42
+ label={ action.label }
43
+ key={ action.id }
44
+ icon={ action.icon }
45
+ onClick={ () => action.perform( item ) }
46
+ isDestructive={ action.isDestructive }
47
+ size="compact"
48
+ />
49
+ ) ) }
50
+ { !! secondaryActions.length && (
51
+ <DropdownMenu icon={ moreVertical } label={ __( 'Actions' ) }>
52
+ { () => (
53
+ <MenuGroup>
54
+ { secondaryActions.map( ( action ) => (
55
+ <MenuItem
56
+ key={ action.id }
57
+ onClick={ () => action.perform( item ) }
58
+ isDestructive={ action.isDestructive }
59
+ >
60
+ { action.label }
61
+ </MenuItem>
62
+ ) ) }
63
+ </MenuGroup>
64
+ ) }
65
+ </DropdownMenu>
66
+ ) }
67
+ </HStack>
68
+ );
69
+ }
@@ -6,45 +6,11 @@ import {
6
6
  __experimentalHStack as HStack,
7
7
  __experimentalText as Text,
8
8
  __experimentalNumberControl as NumberControl,
9
- __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
10
- SelectControl,
11
9
  } from '@wordpress/components';
12
10
  import { createInterpolateElement } from '@wordpress/element';
13
11
  import { sprintf, __, _x, _n } from '@wordpress/i18n';
12
+ import { chevronRight, chevronLeft, previous, next } from '@wordpress/icons';
14
13
 
15
- const PAGE_SIZE_VALUES = [ 5, 20, 50 ];
16
- function PageSizeControl( { view, onChangeView } ) {
17
- const label = __( 'Rows per page:' );
18
- return (
19
- <SelectControl
20
- __nextHasNoMarginBottom
21
- label={ label }
22
- hideLabelFromVision
23
- // TODO: This should probably use a label based on the wanted design
24
- // and we could remove InputControlPrefixWrapper usage.
25
- prefix={
26
- <InputControlPrefixWrapper
27
- as="span"
28
- className="dataviews__select-control-prefix"
29
- >
30
- { label }
31
- </InputControlPrefixWrapper>
32
- }
33
- value={ view.perPage }
34
- options={ PAGE_SIZE_VALUES.map( ( pageSize ) => ( {
35
- value: pageSize,
36
- label: pageSize,
37
- } ) ) }
38
- onChange={ ( value ) =>
39
- onChangeView( { ...view, perPage: value, page: 1 } )
40
- }
41
- />
42
- );
43
- }
44
-
45
- // For now this is copied from the patterns list Pagination component, because
46
- // the datatable pagination starts from index zero(`0`). Eventually all lists will be
47
- // using this one.
48
14
  function Pagination( {
49
15
  view,
50
16
  onChangeView,
@@ -71,29 +37,37 @@ function Pagination( {
71
37
  }
72
38
  </Text>
73
39
  { !! totalItems && (
74
- <HStack expanded={ false } spacing={ 1 }>
75
- <Button
76
- variant="tertiary"
77
- onClick={ () => onChangeView( { ...view, page: 1 } ) }
78
- disabled={ view.page === 1 }
79
- aria-label={ __( 'First page' ) }
80
- >
81
- «
82
- </Button>
83
- <Button
84
- variant="tertiary"
85
- onClick={ () =>
86
- onChangeView( { ...view, page: view.page - 1 } )
87
- }
88
- disabled={ view.page === 1 }
89
- aria-label={ __( 'Previous page' ) }
90
- >
91
-
92
- </Button>
40
+ <HStack expanded={ false } spacing={ 3 }>
93
41
  <HStack
94
42
  justify="flex-start"
95
43
  expanded={ false }
96
44
  spacing={ 1 }
45
+ >
46
+ <Button
47
+ onClick={ () =>
48
+ onChangeView( { ...view, page: 1 } )
49
+ }
50
+ disabled={ view.page === 1 }
51
+ label={ __( 'First page' ) }
52
+ icon={ previous }
53
+ showTooltip
54
+ size="compact"
55
+ />
56
+ <Button
57
+ onClick={ () =>
58
+ onChangeView( { ...view, page: view.page - 1 } )
59
+ }
60
+ disabled={ view.page === 1 }
61
+ label={ __( 'Previous page' ) }
62
+ icon={ chevronLeft }
63
+ showTooltip
64
+ size="compact"
65
+ />
66
+ </HStack>
67
+ <HStack
68
+ justify="flex-start"
69
+ expanded={ false }
70
+ spacing={ 2 }
97
71
  >
98
72
  { createInterpolateElement(
99
73
  sprintf(
@@ -130,29 +104,34 @@ function Pagination( {
130
104
  }
131
105
  ) }
132
106
  </HStack>
133
- <Button
134
- variant="tertiary"
135
- onClick={ () =>
136
- onChangeView( { ...view, page: view.page + 1 } )
137
- }
138
- disabled={ view.page >= totalPages }
139
- aria-label={ __( 'Next page' ) }
140
- >
141
-
142
- </Button>
143
- <Button
144
- variant="tertiary"
145
- onClick={ () =>
146
- onChangeView( { ...view, page: totalPages } )
147
- }
148
- disabled={ view.page >= totalPages }
149
- aria-label={ __( 'Last page' ) }
107
+ <HStack
108
+ justify="flex-start"
109
+ expanded={ false }
110
+ spacing={ 1 }
150
111
  >
151
- »
152
- </Button>
112
+ <Button
113
+ onClick={ () =>
114
+ onChangeView( { ...view, page: view.page + 1 } )
115
+ }
116
+ disabled={ view.page >= totalPages }
117
+ label={ __( 'Next page' ) }
118
+ icon={ chevronRight }
119
+ showTooltip
120
+ size="compact"
121
+ />
122
+ <Button
123
+ onClick={ () =>
124
+ onChangeView( { ...view, page: totalPages } )
125
+ }
126
+ disabled={ view.page >= totalPages }
127
+ label={ __( 'Last page' ) }
128
+ icon={ next }
129
+ showTooltip
130
+ size="compact"
131
+ />
132
+ </HStack>
153
133
  </HStack>
154
134
  ) }
155
- <PageSizeControl view={ view } onChangeView={ onChangeView } />
156
135
  </HStack>
157
136
  );
158
137
  }
@@ -10,10 +10,13 @@ import { SearchControl } from '@wordpress/components';
10
10
  */
11
11
  import useDebouncedInput from '../../utils/use-debounced-input';
12
12
 
13
- export default function TextFilter( { id, view, onChangeView } ) {
13
+ export default function Search( { label, view, onChangeView } ) {
14
14
  const [ search, setSearch, debouncedSearch ] = useDebouncedInput(
15
- view.filters[ id ]
15
+ view.search
16
16
  );
17
+ useEffect( () => {
18
+ setSearch( view.search );
19
+ }, [ view ] );
17
20
  const onChangeViewRef = useRef( onChangeView );
18
21
  useEffect( () => {
19
22
  onChangeViewRef.current = onChangeView;
@@ -22,13 +25,10 @@ export default function TextFilter( { id, view, onChangeView } ) {
22
25
  onChangeViewRef.current( ( currentView ) => ( {
23
26
  ...currentView,
24
27
  page: 1,
25
- filters: {
26
- ...currentView.filters,
27
- [ id ]: debouncedSearch,
28
- },
28
+ search: debouncedSearch,
29
29
  } ) );
30
30
  }, [ debouncedSearch ] );
31
- const searchLabel = __( 'Filter list' );
31
+ const searchLabel = label || __( 'Filter list' );
32
32
  return (
33
33
  <SearchControl
34
34
  onChange={ setSearch }
@@ -1,6 +1,16 @@
1
1
  .dataviews-wrapper {
2
2
  width: 100%;
3
+ height: 100%;
4
+ overflow: auto;
3
5
  padding: $grid-unit-40;
6
+
7
+ > div {
8
+ min-height: 100%;
9
+ }
10
+ }
11
+
12
+ .dataviews-pagination {
13
+ margin-top: auto;
4
14
  }
5
15
 
6
16
  .dataviews-list-view {
@@ -30,11 +40,6 @@
30
40
  }
31
41
  }
32
42
 
33
- .dataviews__select-control-prefix {
34
- color: $gray-700;
35
- text-wrap: nowrap;
36
- }
37
-
38
43
  .dataviews-view-grid__media {
39
44
  width: 100%;
40
45
  min-height: 200px;
@@ -12,7 +12,7 @@ import {
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import FieldActions from './field-actions';
15
+ import ItemActions from './item-actions';
16
16
 
17
17
  export function ViewGrid( { data, fields, view, actions } ) {
18
18
  const mediaField = fields.find(
@@ -50,7 +50,12 @@ export function ViewGrid( { data, fields, view, actions } ) {
50
50
  ) ) }
51
51
  </VStack>
52
52
  </FlexBlock>
53
- <FieldActions item={ item } actions={ actions } />
53
+ <FlexBlock>
54
+ <ItemActions
55
+ item={ item }
56
+ actions={ actions }
57
+ />
58
+ </FlexBlock>
54
59
  </HStack>
55
60
  </VStack>
56
61
  );
@@ -34,7 +34,7 @@ import { useMemo, Children, Fragment } from '@wordpress/element';
34
34
  * Internal dependencies
35
35
  */
36
36
  import { unlock } from '../../lock-unlock';
37
- import FieldActions from './field-actions';
37
+ import ItemActions from './item-actions';
38
38
 
39
39
  const {
40
40
  DropdownMenuV2,
@@ -160,7 +160,7 @@ function ViewList( {
160
160
  id: 'actions',
161
161
  cell: ( props ) => {
162
162
  return (
163
- <FieldActions
163
+ <ItemActions
164
164
  item={ props.row.original }
165
165
  actions={ actions }
166
166
  />
@@ -244,7 +244,7 @@ function FontCollection( { id } ) {
244
244
  ! fonts.length && (
245
245
  <Text>
246
246
  { __(
247
- 'No fonts found. Try with a different seach term'
247
+ 'No fonts found. Try with a different search term'
248
248
  ) }
249
249
  </Text>
250
250
  ) }
@@ -283,13 +283,7 @@ function ScreenBlock( { name, variation } ) {
283
283
  inheritedValue={ inheritedStyleWithLayout }
284
284
  value={ styleWithLayout }
285
285
  onChange={ setStyle }
286
- settings={ {
287
- ...settings,
288
- color: {
289
- ...settings.color,
290
- customDuotone: false, //TO FIX: Custom duotone only works on the block level right now
291
- },
292
- } }
286
+ settings={ settings }
293
287
  includeLayoutControls
294
288
  />
295
289
  ) }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { trash } from '@wordpress/icons';
6
+
7
+ // DEFAULT_STATUSES is intentionally sorted. Items do not have spaces in between them.
8
+ // The reason for that is to match the default statuses coming from the endpoint
9
+ // (entity request and useEffect to update the view).
10
+ export const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All statuses but 'trash'.
11
+
12
+ const DEFAULT_PAGE_BASE = {
13
+ type: 'list',
14
+ search: '',
15
+ filters: {
16
+ status: DEFAULT_STATUSES,
17
+ },
18
+ page: 1,
19
+ perPage: 5,
20
+ sort: {
21
+ field: 'date',
22
+ direction: 'desc',
23
+ },
24
+ visibleFilters: [ 'author', 'status' ],
25
+ // All fields are visible by default, so it's
26
+ // better to keep track of the hidden ones.
27
+ hiddenFields: [ 'date', 'featured-image' ],
28
+ layout: {},
29
+ };
30
+
31
+ const DEFAULT_VIEWS = [
32
+ {
33
+ title: __( 'All' ),
34
+ slug: 'all',
35
+ view: DEFAULT_PAGE_BASE,
36
+ },
37
+ {
38
+ title: __( 'Drafts' ),
39
+ slug: 'drafts',
40
+ view: {
41
+ ...DEFAULT_PAGE_BASE,
42
+ filters: {
43
+ status: 'draft',
44
+ },
45
+ },
46
+ },
47
+ {
48
+ title: __( 'Trash' ),
49
+ slug: 'trash',
50
+ icon: trash,
51
+ view: {
52
+ ...DEFAULT_PAGE_BASE,
53
+ filters: {
54
+ status: 'trash',
55
+ },
56
+ },
57
+ },
58
+ ];
59
+
60
+ export default DEFAULT_VIEWS;