Skip to content

Commit

Permalink
edit-site: Fix no-string-literals warnings (#32156)
Browse files Browse the repository at this point in the history
* edit-site: Fix no-string-literals warnings

* store should be a string here. Use a const

* use coreStore.name
  • Loading branch information
aristath authored May 25, 2021
1 parent d56f338 commit cb90b0b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 17 deletions.
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/navigate-to-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { edit } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { store as coreStore } from '@wordpress/core-data';

export default function NavigateToLink( {
type,
Expand All @@ -19,7 +20,7 @@ export default function NavigateToLink( {
type &&
id &&
type !== 'URL' &&
select( 'core' ).getEntityRecord( 'postType', type, id ),
select( coreStore ).getEntityRecord( 'postType', type, id ),
[ type, id ]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -27,7 +28,7 @@ export default function ContentCategoriesMenu() {
const { categories, isResolved } = useSelect(
( select ) => {
const { getEntityRecords, hasFinishedResolution } = select(
'core'
coreStore
);
const getEntityRecordsArgs = [
'taxonomy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -27,7 +28,7 @@ export default function ContentPagesMenu() {
const { pages, isResolved } = useSelect(
( select ) => {
const { getEntityRecords, hasFinishedResolution } = select(
'core'
coreStore
);
const getEntityRecordsArgs = [
'postType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { __ } from '@wordpress/i18n';
import { useCallback } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -32,7 +33,7 @@ export default function ContentPostsMenu() {
getEntityRecords,
getEditedEntityRecord,
hasFinishedResolution,
} = select( 'core' );
} = select( coreStore );
const getEntityRecodsArgs = [
'postType',
'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useDispatch, useSelect } from '@wordpress/data';
import { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';
import { getPathAndQueryString } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -15,7 +16,7 @@ const getEntityTitle = ( kind, entity ) =>

export default function NavigationEntityItems( { kind, name, query = {} } ) {
const entities = useSelect(
( select ) => select( 'core' ).getEntityRecords( kind, name, query ),
( select ) => select( coreStore ).getEntityRecords( kind, name, query ),
[ kind, name, query ]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { Icon, plus } from '@wordpress/icons';
import { store as editorStore } from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -27,8 +29,8 @@ export default function NewTemplateDropdown() {
const { defaultTemplateTypes, templates } = useSelect( ( select ) => {
const {
__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes,
} = select( 'core/editor' );
const templateEntities = select( 'core' ).getEntityRecords(
} = select( editorStore );
const templateEntities = select( coreStore ).getEntityRecords(
'postType',
'wp_template'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { __ } from '@wordpress/i18n';
*/
import { normalizedSearch } from './utils';
import { useSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';
import TemplateNavigationItem from './template-navigation-item';
import ContentNavigationItem from './content-navigation-item';

Expand All @@ -37,7 +38,7 @@ export default function SearchResults( { items, search, disableFilter } ) {
if ( itemType === 'wp_template' ) {
const {
__experimentalGetTemplateInfo: getTemplateInfo,
} = select( 'core/editor' );
} = select( editorStore );

return items.map( ( item ) => ( {
slug: item.slug,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { useDispatch, useSelect } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -20,7 +21,7 @@ export default function TemplateNavigationItem( { item } ) {
const { title, description } = useSelect(
( select ) =>
'wp_template' === item.type
? select( 'core/editor' ).__experimentalGetTemplateInfo( item )
? select( editorStore ).__experimentalGetTemplateInfo( item )
: {
title: item?.title?.rendered || item?.slug,
description: '',
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/template-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
__experimentalText as Text,
} from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -19,7 +20,7 @@ import { store as editSiteStore } from '../../store';
export default function TemplateDetails( { template, onClose } ) {
const { title, description } = useSelect(
( select ) =>
select( 'core/editor' ).__experimentalGetTemplateInfo( template ),
select( editorStore ).__experimentalGetTemplateInfo( template ),
[]
);
const { openNavigationPanelToMenu, revertTemplate } = useDispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -12,7 +13,7 @@ import ConvertToTemplatePart from './convert-to-template-part';
export default function TemplatePartConverter() {
const { clientIds, blocks } = useSelect( ( select ) => {
const { getSelectedBlockClientIds, getBlocksByClientId } = select(
'core/block-editor'
blockEditorStore
);
const selectedBlockClientIds = getSelectedBlockClientIds();
return {
Expand Down
12 changes: 6 additions & 6 deletions packages/edit-site/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function* setTemplate( templateId, templateSlug ) {
const pageContext = { templateSlug };
if ( ! templateSlug ) {
const template = yield controls.resolveSelect(
'core',
coreStore.name,
'getEntityRecord',
'postType',
'wp_template',
Expand All @@ -78,7 +78,7 @@ export function* setTemplate( templateId, templateSlug ) {
*/
export function* addTemplate( template ) {
const newTemplate = yield controls.dispatch(
'core',
coreStore.name,
'saveEntityRecord',
'postType',
'wp_template',
Expand All @@ -87,7 +87,7 @@ export function* addTemplate( template ) {

if ( template.content ) {
yield controls.dispatch(
'core',
coreStore.name,
'editEntityRecord',
'postType',
'wp_template',
Expand Down Expand Up @@ -160,7 +160,7 @@ export function setHomeTemplateId( homeTemplateId ) {
export function* setPage( page ) {
if ( ! page.path && page.context?.postId ) {
const entity = yield controls.resolveSelect(
'core',
coreStore.name,
'getEntityRecord',
'postType',
page.context.postType || 'post',
Expand All @@ -170,7 +170,7 @@ export function* setPage( page ) {
page.path = getPathAndQueryString( entity.link );
}
const { id: templateId, slug: templateSlug } = yield controls.resolveSelect(
'core',
coreStore.name,
'__experimentalGetTemplateForLink',
page.path
);
Expand Down Expand Up @@ -198,7 +198,7 @@ export function* showHomepage() {
show_on_front: showOnFront,
page_on_front: frontpageId,
} = yield controls.resolveSelect(
'core',
coreStore.name,
'getEntityRecord',
'root',
'site'
Expand Down

0 comments on commit cb90b0b

Please sign in to comment.