Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b795e9c
move default template types and template part areas to REST API
gigitux Oct 25, 2024
61b90b5
fix logic
gigitux Oct 25, 2024
6aaf160
fix E2E test
gigitux Nov 1, 2024
d141278
move default template types and template part areas to REST API
gigitux Nov 4, 2024
bde1d80
fix error
gigitux Nov 4, 2024
de703b5
remove not necessary file
gigitux Nov 4, 2024
f8962ce
fix naming
gigitux Nov 4, 2024
fc95c3f
remove duplicate code
gigitux Nov 4, 2024
d20b8ad
remove duplicated code
gigitux Nov 5, 2024
d361487
Merge branch 'trunk' of github.com:WordPress/gutenberg into fix/rest-…
gigitux Nov 5, 2024
afe5365
improve logic
gigitux Nov 5, 2024
ac06843
fix naming
gigitux Nov 5, 2024
69c3d6d
fix unit test
gigitux Nov 5, 2024
a5647de
update doc
gigitux Nov 5, 2024
2a04ba1
add unit test for getTemplateInfo function
gigitux Nov 5, 2024
6723634
Merge branch 'trunk' of github.com:WordPress/gutenberg into fix/rest-…
gigitux Nov 14, 2024
7241bad
restore not necessary changes
gigitux Nov 14, 2024
8f47873
fix e2e test
gigitux Nov 14, 2024
6acc708
Merge branch 'trunk' of github.com:WordPress/gutenberg into fix/rest-…
gigitux Nov 25, 2024
7aab231
remove not necessary variable
gigitux Nov 25, 2024
ffdcc1d
replace add_action with add_filter
gigitux Nov 25, 2024
e395bf6
improve readibility code
gigitux Nov 25, 2024
1f47713
make getTemplateInfo private
gigitux Nov 25, 2024
078d2f6
make templateAreas optional
gigitux Nov 25, 2024
fdc291d
add default_template_part_areas and default_template_types
gigitux Nov 25, 2024
b2c0bf5
move code to rest-api.php file
gigitux Nov 25, 2024
8f8649b
Merge branch 'trunk' of github.com:WordPress/gutenberg into fix/rest-…
gigitux Nov 26, 2024
230ba72
remove not used import
gigitux Nov 26, 2024
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
Prev Previous commit
Next Next commit
fix naming
  • Loading branch information
gigitux committed Nov 5, 2024
commit ac06843cd8909a0932f1e30aeadb7533d0a377b3
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function useTemplatePartAreaLabel( clientId ) {

const defaultTemplatePartAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const definedAreas = defaultTemplatePartAreas.map( ( item ) => ( {
...item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function TemplatePartAdvancedControls( {
const defaultTemplatePartAreas = useSelect(
( select ) =>
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [],
?.default_template_part_areas || [],
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function useTemplatePartArea( area ) {
( select ) => {
const definedAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const selectedArea = definedAreas.find(
( definedArea ) => definedArea.area === area
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const useDefaultTemplateTypes = () => {
return useSelect(
( select ) =>
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [],
?.default_template_types || [],
[]
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/page-patterns/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function PatternsHeader( {
const templatePartAreas = useSelect(
( select ) =>
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [],
?.default_template_part_areas || [],
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const selectTemplateParts = createSelector(
// parts can be treated as uncategorized.
const knownAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const templatePartAreas = knownAreas.map( ( area ) => area.area );

Expand Down Expand Up @@ -80,7 +80,7 @@ const selectTemplateParts = createSelector(
{ per_page: -1 },
] ),
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas,
?.default_template_part_areas,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const useTemplatePartsGroupedByArea = ( items ) => {
const templatePartAreas = useSelect(
( select ) =>
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [],
?.default_template_part_areas || [],
[]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export default function useEditedEntityRecord( postType, postId ) {

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [];
?.default_template_types || [];

const templateInfo = getTemplateInfo( {
template: _record,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function CreateTemplatePartModalContents( {
const templatePartAreas = useSelect(
( select ) =>
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [],
?.default_template_part_areas || [],
[]
);

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export default function DocumentBar( props ) {

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [];
?.default_template_types || [];
const _templateInfo = getTemplateInfo( {
templateAreas,
templateTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export default function EntityRecordItem( { record, checked, onChange } ) {

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [];
?.default_template_types || [];

return {
entityRecordTitle: getTemplateInfo( {
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export default function PostCardPanel( {

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [];
?.default_template_types || [];

const _templateInfo = [
TEMPLATE_POST_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const getPostIcon = createRegistrySelector(
select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
)?.defaultTemplatePartAreas || []
)?.default_template_part_areas || []
).find( ( item ) => options.area === item.area )?.icon ||
layout
);
Expand Down
14 changes: 7 additions & 7 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1709,11 +1709,11 @@ export const __experimentalGetDefaultTemplateTypes = createRegistrySelector(
{
since: '6.7',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be 6.8? (same below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I'm going to open a follow-up PR! Thanks 🙇

alternative:
"select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.defaultTemplateTypes",
"select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.default_template_types",
}
);
return select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes;
?.default_template_types;
}
);

Expand All @@ -1732,13 +1732,13 @@ export const __experimentalGetDefaultTemplatePartAreas = createRegistrySelector(
{
since: '6.7',
alternative:
"select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.defaultTemplatePartAreas",
"select('core/core-data').getEntityRecord( 'root', '__unstableBase' )?.default_template_part_areas",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, missing the last piece of the logic:

areas.map( ( item ) => {
				return { ...item, icon: getTemplatePartIcon( item.icon ) };
			} );

Not sure if I should add this line under the alternative key or simply remove it altogether.

}
);

const areas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

return areas.map( ( item ) => {
return { ...item, icon: getTemplatePartIcon( item.icon ) };
Expand Down Expand Up @@ -1766,7 +1766,7 @@ export const __experimentalGetDefaultTemplateType = createRegistrySelector(
const templateTypes = select( coreStore ).getEntityRecord(
'root',
'__unstableBase'
)?.defaultTemplateTypes;
)?.default_template_types;

if ( ! templateTypes ) {
return EMPTY_OBJECT;
Expand Down Expand Up @@ -1801,11 +1801,11 @@ export const __experimentalGetTemplateInfo = createRegistrySelector(

const templateTypes =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplateTypes || [];
?.default_template_types || [];

const templateAreas =
select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
?.defaultTemplatePartAreas || [];
?.default_template_part_areas || [];

return getTemplateInfo( {
template,
Expand Down