Skip to content

Commit

Permalink
edit-post: no-string-literals fix (#32195)
Browse files Browse the repository at this point in the history
* edit-post: no-string-literals fix

* use string in actions.js
  • Loading branch information
aristath authored May 27, 2021
1 parent 8dabee3 commit 4834fad
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 45 deletions.
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/browser-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Component } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { store as editorStore } from '@wordpress/editor';

/**
* Returns the Post's Edit URL.
Expand Down Expand Up @@ -98,7 +99,7 @@ export class BrowserURL extends Component {
}

export default withSelect( ( select ) => {
const { getCurrentPost, isSavingPost } = select( 'core/editor' );
const { getCurrentPost, isSavingPost } = select( editorStore );
const post = getCurrentPost();
let { id, status, type } = post;
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes( type );
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/components/device-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { Icon, MenuGroup } from '@wordpress/components';
import { PostPreviewButton } from '@wordpress/editor';
import { PostPreviewButton, store as editorStore } from '@wordpress/editor';
import { external } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
Expand All @@ -23,7 +23,7 @@ export default function DevicePreview() {
( select ) => ( {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isSaving: select( editPostStore ).isSavingMetaBoxes(),
isPostSaveable: select( 'core/editor' ).isEditedPostSaveable(),
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
deviceType: select(
editPostStore
).__experimentalGetPreviewDeviceType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect, useRef } from '@wordpress/element';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -23,7 +25,7 @@ export const useBlockSelectionListener = ( postId ) => {
const { hasBlockSelection, isEditorSidebarOpened } = useSelect(
( select ) => ( {
hasBlockSelection: !! select(
'core/block-editor'
blockEditorStore
).getBlockSelectionStart(),
isEditorSidebarOpened: select( STORE_NAME ).isEditorSidebarOpened(),
} ),
Expand Down Expand Up @@ -53,7 +55,7 @@ export const useBlockSelectionListener = ( postId ) => {
export const useUpdatePostLinkListener = ( postId ) => {
const { newPermalink } = useSelect(
( select ) => ( {
newPermalink: select( 'core/editor' ).getCurrentPost().link,
newPermalink: select( editorStore ).getCurrentPost().link,
} ),
[ postId ]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Button, Icon } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { wordpress } from '@wordpress/icons';
import { store as editorStore } from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand All @@ -20,10 +22,10 @@ import { store as editPostStore } from '../../../store';
function FullscreenModeClose( { showTooltip, icon, href } ) {
const { isActive, isRequestingSiteIcon, postType, siteIconUrl } = useSelect(
( select ) => {
const { getCurrentPostType } = select( 'core/editor' );
const { getCurrentPostType } = select( editorStore );
const { isFeatureActive } = select( editPostStore );
const { isResolving } = select( 'core/data' );
const { getEntityRecord, getPostType } = select( 'core' );
const { getEntityRecord, getPostType } = select( coreStore );
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -38,9 +39,9 @@ function ModeSwitcher() {
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
isRichEditingEnabled: select( editorStore ).getEditorSettings()
.richEditingEnabled,
isCodeEditingEnabled: select( 'core/editor' ).getEditorSettings()
isCodeEditingEnabled: select( editorStore ).getEditorSettings()
.codeEditingEnabled,
mode: select( editPostStore ).getEditorMode(),
} ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { get } from 'lodash';
*/
import { useViewportMatch, compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { PostPublishButton } from '@wordpress/editor';
import { PostPublishButton, store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -84,20 +84,20 @@ export function PostPublishButtonOrToggle( {
export default compose(
withSelect( ( select ) => ( {
hasPublishAction: get(
select( 'core/editor' ).getCurrentPost(),
select( editorStore ).getCurrentPost(),
[ '_links', 'wp:action-publish' ],
false
),
isBeingScheduled: select( 'core/editor' ).isEditedPostBeingScheduled(),
isPending: select( 'core/editor' ).isCurrentPostPending(),
isPublished: select( 'core/editor' ).isCurrentPostPublished(),
isBeingScheduled: select( editorStore ).isEditedPostBeingScheduled(),
isPending: select( editorStore ).isCurrentPostPending(),
isPublished: select( editorStore ).isCurrentPostPublished(),
isPublishSidebarEnabled: select(
'core/editor'
editorStore
).isPublishSidebarEnabled(),
isPublishSidebarOpened: select(
editPostStore
).isPublishSidebarOpened(),
isScheduled: select( 'core/editor' ).isCurrentPostScheduled(),
isScheduled: select( editorStore ).isCurrentPostScheduled(),
} ) ),
withDispatch( ( dispatch ) => {
const { togglePublishSidebar } = dispatch( editPostStore );
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-post/src/components/layout/actions-panel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* WordPress dependencies
*/
import { EntitiesSavedStates, PostPublishPanel } from '@wordpress/editor';
import {
EntitiesSavedStates,
PostPublishPanel,
store as editorStore,
} from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { Button, createSlotFill } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -38,7 +42,7 @@ export default function ActionsPanel( {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isSavingMetaBoxes: select( editPostStore ).isSavingMetaBoxes(),
hasNonPostEntityChanges: select(
'core/editor'
editorStore
).hasNonPostEntityChanges(),
};
}, [] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { filter, map } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { withSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -48,7 +49,7 @@ export function MetaBoxesSection( {
}

export default withSelect( ( select ) => {
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( editorStore );
const { getAllMetaBoxes } = select( editPostStore );

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,6 +59,6 @@ export function EnableCustomFieldsOption( { label, areCustomFieldsEnabled } ) {
}

export default withSelect( ( select ) => ( {
areCustomFieldsEnabled: !! select( 'core/editor' ).getEditorSettings()
areCustomFieldsEnabled: !! select( editorStore ).getEditorSettings()
.enableCustomFields,
} ) )( EnableCustomFieldsOption );
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { ifViewportMatches } from '@wordpress/viewport';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -12,11 +13,11 @@ import BaseOption from './base';

export default compose(
withSelect( ( select ) => ( {
isChecked: select( 'core/editor' ).isPublishSidebarEnabled(),
isChecked: select( editorStore ).isPublishSidebarEnabled(),
} ) ),
withDispatch( ( dispatch ) => {
const { enablePublishSidebar, disablePublishSidebar } = dispatch(
'core/editor'
editorStore
);
return {
onChange: ( isEnabled ) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ import { get, partial } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { PanelBody } from '@wordpress/components';
import { PostFeaturedImage, PostFeaturedImageCheck } from '@wordpress/editor';
import {
PostFeaturedImage,
PostFeaturedImageCheck,
store as editorStore,
} from '@wordpress/editor';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -45,8 +50,8 @@ function FeaturedImage( { isEnabled, isOpened, postType, onTogglePanel } ) {
}

const applyWithSelect = withSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const { getPostType } = select( 'core' );
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( coreStore );
const { isEditorPanelEnabled, isEditorPanelOpened } = select(
editPostStore
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComplementaryArea } from '@wordpress/interface';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -79,9 +80,7 @@ import { store as editPostStore } from '../../../store';
export default function PluginSidebarEditPost( { className, ...props } ) {
const { postTitle, shortcut, showIconLabels } = useSelect( ( select ) => {
return {
postTitle: select( 'core/editor' ).getEditedPostAttribute(
'title'
),
postTitle: select( editorStore ).getEditedPostAttribute( 'title' ),
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
Expand Down
9 changes: 5 additions & 4 deletions packages/edit-post/src/components/sidebar/post-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { __ } from '@wordpress/i18n';
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose, ifCondition, withState } from '@wordpress/compose';
import { cleanForSlug } from '@wordpress/editor';
import { cleanForSlug, store as editorStore } from '@wordpress/editor';
import { safeDecodeURIComponent } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -136,11 +137,11 @@ export default compose( [
getPermalinkParts,
getEditedPostAttribute,
getEditedPostSlug,
} = select( 'core/editor' );
} = select( editorStore );
const { isEditorPanelEnabled, isEditorPanelOpened } = select(
editPostStore
);
const { getPostType } = select( 'core' );
const { getPostType } = select( coreStore );

const { link } = getCurrentPost();

Expand All @@ -167,7 +168,7 @@ export default compose( [
} ),
withDispatch( ( dispatch ) => {
const { toggleEditorPanelOpened } = dispatch( editPostStore );
const { editPost } = dispatch( 'core/editor' );
const { editPost } = dispatch( editorStore );
return {
onTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ),
editPermalink: ( newSlug ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import { Button } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -17,8 +19,8 @@ const SettingsHeader = ( { sidebarName } ) => {
const openBlockSettings = () => openGeneralSidebar( 'edit-post/block' );

const { documentLabel, isTemplateMode } = useSelect( ( select ) => {
const currentPostType = select( 'core/editor' ).getCurrentPostType();
const postType = select( 'core' ).getPostType( currentPostType );
const currentPostType = select( editorStore ).getCurrentPostType();
const postType = select( coreStore ).getPostType( currentPostType );

return {
documentLabel:
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PostTextEditor,
PostTitle,
TextEditorGlobalKeyboardShortcuts,
store as editorStore,
} from '@wordpress/editor';
import { Button } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
Expand Down Expand Up @@ -43,7 +44,7 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {

export default compose(
withSelect( ( select ) => ( {
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
isRichEditingEnabled: select( editorStore ).getEditorSettings()
.richEditingEnabled,
} ) ),
withDispatch( ( dispatch ) => {
Expand Down
6 changes: 4 additions & 2 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import {
EditorProvider,
ErrorBoundary,
PostLockedModal,
store as editorStore,
} from '@wordpress/editor';
import { StrictMode, useMemo } from '@wordpress/element';
import { KeyboardShortcuts, SlotFillProvider } from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
Expand Down Expand Up @@ -55,9 +57,9 @@ function Editor( {
getEditedPostTemplate,
} = select( editPostStore );
const { getEntityRecord, getPostType, getEntityRecords } = select(
'core'
coreStore
);
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( editorStore );
const { getBlockTypes } = select( blocksStore );
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
postType
Expand Down
Loading

0 comments on commit 4834fad

Please sign in to comment.