Skip to content

Commit

Permalink
Remove templatePartIds state and selector
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Jun 28, 2020
1 parent e1c2a85 commit 8d36c59
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 62 deletions.
22 changes: 3 additions & 19 deletions lib/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,11 @@ function gutenberg_edit_site_init( $hook ) {
}
$settings['styles'] = gutenberg_get_editor_styles();

$template_part_ids = array();
foreach ( get_template_types() as $template_type ) {
// Skip 'embed' for now because it is not a regular template type.
// Skip 'index' because it's a fallback that we handle differently.
if ( in_array( $template_type, array( 'embed', 'index' ), true ) ) {
continue;
}

$current_template = gutenberg_find_template_post_and_parts( $template_type );
if ( isset( $current_template ) ) {
$template_part_ids = $template_part_ids + $current_template['template_part_ids'];
}
}

$settings['editSiteInitialState'] = array();

$settings['editSiteInitialState']['templateType'] = 'wp_template';
$settings['editSiteInitialState']['templatePartIds'] = array_values( $template_part_ids );

$settings['editSiteInitialState']['showOnFront'] = get_option( 'show_on_front' );
$settings['editSiteInitialState']['page'] = array(
$settings['editSiteInitialState']['templateType'] = 'wp_template';
$settings['editSiteInitialState']['showOnFront'] = get_option( 'show_on_front' );
$settings['editSiteInitialState']['page'] = array(
'path' => '/',
'context' => 'page' === $settings['editSiteInitialState']['showOnFront'] ? array(
'postType' => 'page',
Expand Down
12 changes: 0 additions & 12 deletions packages/edit-site/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,6 @@ export function templateType( state, action ) {
return state;
}

/**
* Reducer returning the list of template part IDs.
*
* @param {Object} state Current state.
*
* @return {Object} Updated state.
*/
export function templatePartIds( state = [] ) {
return state;
}

/**
* Reducer returning the page being edited.
*
Expand Down Expand Up @@ -198,7 +187,6 @@ export default combineReducers( {
templateId,
templatePartId,
templateType,
templatePartIds,
page,
showOnFront,
} );
11 changes: 0 additions & 11 deletions packages/edit-site/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,6 @@ export function getTemplateType( state ) {
return state.templateType;
}

/**
* Returns the current template part IDs.
*
* @param {Object} state Global application state.
*
* @return {number[]} Template part IDs.
*/
export function getTemplatePartIds( state ) {
return state.templatePartIds;
}

/**
* Returns the current page object.
*
Expand Down
12 changes: 0 additions & 12 deletions packages/edit-site/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
templateId,
templatePartId,
templateType,
templatePartIds,
page,
showOnFront,
} from '../reducer';
Expand Down Expand Up @@ -164,17 +163,6 @@ describe( 'state', () => {
} );
} );

describe( 'templatePartIds()', () => {
it( 'should apply default state', () => {
expect( templatePartIds( undefined, {} ) ).toEqual( [] );
} );

it( 'should default to returning the same state', () => {
const state = {};
expect( templatePartIds( state, {} ) ).toBe( state );
} );
} );

describe( 'page()', () => {
it( 'should apply default state', () => {
expect( page( undefined, {} ) ).toEqual( {} );
Expand Down
8 changes: 0 additions & 8 deletions packages/edit-site/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
getTemplateId,
getTemplatePartId,
getTemplateType,
getTemplatePartIds,
getPage,
getShowOnFront,
} from '../selectors';
Expand Down Expand Up @@ -130,13 +129,6 @@ describe( 'selectors', () => {
} );
} );

describe( 'getTemplatePartIds', () => {
it( 'returns the template part IDs', () => {
const state = { templatePartIds: {} };
expect( getTemplatePartIds( state ) ).toBe( state.templatePartIds );
} );
} );

describe( 'getPage', () => {
it( 'returns the page object', () => {
const state = { page: {} };
Expand Down

0 comments on commit 8d36c59

Please sign in to comment.