From 8d36c599f50e73ca3d0f8e54dddcc8fa2cb0881b Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 22 Jun 2020 14:19:39 +0200 Subject: [PATCH] Remove templatePartIds state and selector --- lib/edit-site-page.php | 22 +++---------------- packages/edit-site/src/store/reducer.js | 12 ---------- packages/edit-site/src/store/selectors.js | 11 ---------- packages/edit-site/src/store/test/reducer.js | 12 ---------- .../edit-site/src/store/test/selectors.js | 8 ------- 5 files changed, 3 insertions(+), 62 deletions(-) diff --git a/lib/edit-site-page.php b/lib/edit-site-page.php index 367793605d95f..09df84234f676 100644 --- a/lib/edit-site-page.php +++ b/lib/edit-site-page.php @@ -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', diff --git a/packages/edit-site/src/store/reducer.js b/packages/edit-site/src/store/reducer.js index e5468ee7614ed..bd7cfd8740eb1 100644 --- a/packages/edit-site/src/store/reducer.js +++ b/packages/edit-site/src/store/reducer.js @@ -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. * @@ -198,7 +187,6 @@ export default combineReducers( { templateId, templatePartId, templateType, - templatePartIds, page, showOnFront, } ); diff --git a/packages/edit-site/src/store/selectors.js b/packages/edit-site/src/store/selectors.js index b5992376e4828..aaaf9e870d619 100644 --- a/packages/edit-site/src/store/selectors.js +++ b/packages/edit-site/src/store/selectors.js @@ -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. * diff --git a/packages/edit-site/src/store/test/reducer.js b/packages/edit-site/src/store/test/reducer.js index 0a22ecfa6d115..c220305c6dd70 100644 --- a/packages/edit-site/src/store/test/reducer.js +++ b/packages/edit-site/src/store/test/reducer.js @@ -13,7 +13,6 @@ import { templateId, templatePartId, templateType, - templatePartIds, page, showOnFront, } from '../reducer'; @@ -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( {} ); diff --git a/packages/edit-site/src/store/test/selectors.js b/packages/edit-site/src/store/test/selectors.js index 02c3febe7a0c2..8335492fdf559 100644 --- a/packages/edit-site/src/store/test/selectors.js +++ b/packages/edit-site/src/store/test/selectors.js @@ -9,7 +9,6 @@ import { getTemplateId, getTemplatePartId, getTemplateType, - getTemplatePartIds, getPage, getShowOnFront, } from '../selectors'; @@ -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: {} };