From 55f455ef88aca055e957d1b07e58449291a397c4 Mon Sep 17 00:00:00 2001 From: Marko Andrijasevic Date: Tue, 7 Aug 2018 23:06:17 +0200 Subject: [PATCH] Reduce the number of edit-post components used --- .../sections/gutenberg-editor.scss | 12 - client/boot/app.js | 4 + .../components/browser-url/README.md | 4 - .../edit-post/components/browser-url/index.js | 103 ------ .../components/browser-url/test/index.js | 106 ------ .../header/fixed-toolbar-toggle/index.js | 37 --- .../components/header/header-toolbar/index.js | 49 --- .../header/header-toolbar/style.scss | 78 ----- .../edit-post/components/header/index.js | 92 ------ .../components/header/mode-switcher/index.js | 61 ---- .../components/header/more-menu/index.js | 47 --- .../components/header/more-menu/style.scss | 28 -- .../test/__snapshots__/index.js.snap | 72 ----- .../components/header/more-menu/test/index.js | 21 -- .../components/header/pinned-plugins/index.js | 27 -- .../header/pinned-plugins/style.scss | 27 -- .../plugin-sidebar-more-menu-item/index.js | 55 ---- .../header/plugins-more-menu-group/index.js | 24 -- .../edit-post/components/header/style.scss | 99 ------ .../components/header/tips-toggle/index.js | 40 --- .../components/keyboard-shortcuts/index.js | 5 + .../edit-post/components/layout/index.js | 57 +--- .../edit-post/components/meta-boxes/index.js | 23 -- .../meta-boxes/meta-boxes-area/index.js | 82 ----- .../meta-boxes/meta-boxes-area/style.scss | 81 ----- .../components/sidebar/block-sidebar/index.js | 30 -- .../sidebar/block-sidebar/style.scss | 21 -- .../sidebar/discussion-panel/index.js | 47 --- .../sidebar/document-sidebar/index.js | 42 --- .../sidebar/featured-image/index.js | 60 ---- .../edit-post/components/sidebar/index.js | 44 --- .../components/sidebar/last-revision/index.js | 21 -- .../sidebar/last-revision/style.scss | 8 - .../sidebar/page-attributes/index.js | 62 ---- .../plugin-post-publish-panel/index.js | 22 -- .../test/__snapshots__/index.js.snap | 57 ---- .../plugin-post-publish-panel/test/index.js | 35 -- .../sidebar/plugin-post-status-info/index.js | 22 -- .../test/__snapshots__/index.js.snap | 18 -- .../plugin-post-status-info/test/index.js | 31 -- .../sidebar/plugin-pre-publish-panel/index.js | 22 -- .../test/__snapshots__/index.js.snap | 57 ---- .../plugin-pre-publish-panel/test/index.js | 35 -- .../sidebar/plugin-sidebar/index.js | 115 ------- .../components/sidebar/post-author/index.js | 22 -- .../components/sidebar/post-author/style.scss | 3 - .../components/sidebar/post-excerpt/index.js | 37 --- .../components/sidebar/post-format/index.js | 17 - .../sidebar/post-pending-status/index.js | 17 - .../components/sidebar/post-schedule/index.js | 38 --- .../sidebar/post-schedule/style.scss | 16 - .../components/sidebar/post-status/index.js | 59 ---- .../components/sidebar/post-status/style.scss | 5 - .../components/sidebar/post-sticky/index.js | 17 - .../sidebar/post-taxonomies/index.js | 46 --- .../sidebar/post-taxonomies/taxonomy-panel.js | 46 --- .../components/sidebar/post-trash/index.js | 20 -- .../components/sidebar/post-trash/style.scss | 10 - .../sidebar/post-visibility/index.js | 41 --- .../sidebar/post-visibility/style.scss | 38 --- .../sidebar/settings-header/index.js | 57 ---- .../sidebar/settings-header/style.scss | 29 -- .../sidebar/sidebar-header/index.js | 51 --- .../sidebar/sidebar-header/style.scss | 33 -- .../edit-post/components/sidebar/style.scss | 167 ---------- .../edit-post/components/text-editor/index.js | 5 + .../visual-editor/block-inspector-button.js | 5 + .../components/visual-editor/index.js | 5 + client/gutenberg/editor/edit-post/editor.js | 8 +- .../edit-post/hooks/components/index.js | 17 - .../hooks/components/media-upload/index.js | 200 ------------ .../gutenberg/editor/edit-post/hooks/index.js | 6 - .../more-menu/copy-content-menu-item/index.js | 29 -- .../editor/edit-post/hooks/more-menu/index.js | 20 -- .../hooks/validate-multiple-use/index.js | 131 -------- client/gutenberg/editor/edit-post/index.js | 8 - .../editor/edit-post/store/effects.js | 104 +----- .../editor/edit-post/store/test/actions.js | 113 ------- .../editor/edit-post/store/test/reducer.js | 243 -------------- .../editor/edit-post/store/test/selectors.js | 306 ------------------ .../editor/edit-post/utils/meta-boxes.js | 16 - client/gutenberg/editor/main.jsx | 1 - npm-shrinkwrap.json | 40 +-- package.json | 5 - 84 files changed, 49 insertions(+), 3965 deletions(-) delete mode 100644 client/gutenberg/editor/edit-post/components/browser-url/README.md delete mode 100644 client/gutenberg/editor/edit-post/components/browser-url/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/browser-url/test/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/fixed-toolbar-toggle/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/header-toolbar/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/header-toolbar/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/header/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/mode-switcher/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/more-menu/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/more-menu/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/header/more-menu/test/__snapshots__/index.js.snap delete mode 100644 client/gutenberg/editor/edit-post/components/header/more-menu/test/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/pinned-plugins/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/pinned-plugins/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/header/plugin-sidebar-more-menu-item/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/plugins-more-menu-group/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/header/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/header/tips-toggle/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/meta-boxes/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/discussion-panel/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/document-sidebar/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/featured-image/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/last-revision/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/last-revision/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/page-attributes/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/plugin-sidebar/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-author/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-author/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-excerpt/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-format/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-pending-status/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-schedule/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-schedule/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-status/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-status/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-sticky/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/taxonomy-panel.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-trash/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-trash/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-visibility/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/post-visibility/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/settings-header/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/settings-header/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/index.js delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/style.scss delete mode 100644 client/gutenberg/editor/edit-post/components/sidebar/style.scss delete mode 100644 client/gutenberg/editor/edit-post/hooks/components/index.js delete mode 100644 client/gutenberg/editor/edit-post/hooks/components/media-upload/index.js delete mode 100644 client/gutenberg/editor/edit-post/hooks/index.js delete mode 100644 client/gutenberg/editor/edit-post/hooks/more-menu/copy-content-menu-item/index.js delete mode 100644 client/gutenberg/editor/edit-post/hooks/more-menu/index.js delete mode 100644 client/gutenberg/editor/edit-post/hooks/validate-multiple-use/index.js delete mode 100644 client/gutenberg/editor/edit-post/store/test/actions.js delete mode 100644 client/gutenberg/editor/edit-post/store/test/reducer.js delete mode 100644 client/gutenberg/editor/edit-post/store/test/selectors.js delete mode 100644 client/gutenberg/editor/edit-post/utils/meta-boxes.js diff --git a/assets/stylesheets/sections/gutenberg-editor.scss b/assets/stylesheets/sections/gutenberg-editor.scss index 1dab18e860cf04..1b8401df9b8c04 100644 --- a/assets/stylesheets/sections/gutenberg-editor.scss +++ b/assets/stylesheets/sections/gutenberg-editor.scss @@ -17,20 +17,8 @@ @import 'gutenberg/editor/edit-post/assets/stylesheets/z-index'; @import 'gutenberg/editor/edit-post/assets/stylesheets/main'; -@import 'gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/style'; @import 'gutenberg/editor/edit-post/components/visual-editor/style'; -@import 'gutenberg/editor/edit-post/components/header/pinned-plugins/style'; @import 'gutenberg/editor/edit-post/components/layout/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/post-schedule/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/post-visibility/style'; -@import 'gutenberg/editor/edit-post/components/header/header-toolbar/style'; -@import 'gutenberg/editor/edit-post/components/header/more-menu/style'; @import 'gutenberg/editor/edit-post/components/text-editor/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/sidebar-header/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/block-sidebar/style'; -@import 'gutenberg/editor/edit-post/components/header/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/settings-header/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/last-revision/style'; -@import 'gutenberg/editor/edit-post/components/sidebar/style'; @import '../../../node_modules/@wordpress/editor/build-style/style'; diff --git a/client/boot/app.js b/client/boot/app.js index 5db2d2ccf43f16..337dcc968db5e6 100644 --- a/client/boot/app.js +++ b/client/boot/app.js @@ -45,3 +45,7 @@ window.AppBoot = () => { user.once( 'change', () => boot( user ) ); } }; + +// Gutenberg expects some global values +// TODO: find a way to remove this later +window.userSettings = { uid: 'gutenberg-test' }; diff --git a/client/gutenberg/editor/edit-post/components/browser-url/README.md b/client/gutenberg/editor/edit-post/components/browser-url/README.md deleted file mode 100644 index 3c279b8d03b408..00000000000000 --- a/client/gutenberg/editor/edit-post/components/browser-url/README.md +++ /dev/null @@ -1,4 +0,0 @@ -BrowserURL -========== - -`` is a component used to keep the editor's saved post ID in sync with the browser's URL. Using the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API), it makes an in-place replacement (using `window.replaceState`) of the URL if the post ID changes and is not an auto-draft. diff --git a/client/gutenberg/editor/edit-post/components/browser-url/index.js b/client/gutenberg/editor/edit-post/components/browser-url/index.js deleted file mode 100644 index 7d50e897725407..00000000000000 --- a/client/gutenberg/editor/edit-post/components/browser-url/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * WordPress dependencies - */ -import { Component } from '@wordpress/element'; -import { withSelect } from '@wordpress/data'; -import { addQueryArgs } from '@wordpress/url'; - -/** - * Returns the Post's Edit URL. - * - * @param {number} postId Post ID. - * - * @return {string} Post edit URL. - */ -export function getPostEditURL( postId ) { - return addQueryArgs( 'post.php', { post: postId, action: 'edit' } ); -} - -/** - * Returns the Post's Trashedd URL. - * - * @param {number} postId Post ID. - * @param {string} postType Post Type. - * - * @return {string} Post trashed URL. - */ -export function getPostTrashedURL( postId, postType ) { - return addQueryArgs( 'edit.php', { - trashed: 1, - post_type: postType, - ids: postId, - } ); -} - -export class BrowserURL extends Component { - constructor() { - super( ...arguments ); - - this.state = { - historyId: null, - }; - } - - componentDidUpdate( prevProps ) { - const { postId, postStatus, postType } = this.props; - const { historyId } = this.state; - - if ( postStatus === 'trash' ) { - this.setTrashURL( postId, postType ); - return; - } - - if ( ( postId !== prevProps.postId || postId !== historyId ) && postStatus !== 'auto-draft' ) { - this.setBrowserURL( postId ); - } - } - - /** - * Navigates the browser to the post trashed URL to show a notice about the trashed post. - * - * @param {number} postId Post ID. - * @param {string} postType Post Type. - */ - setTrashURL( postId, postType ) { - window.location.href = getPostTrashedURL( postId, postType ); - } - - /** - * Replaces the browser URL with a post editor link for the given post ID. - * - * Note it is important that, since this function may be called when the - * editor first loads, the result generated `getPostEditURL` matches that - * produced by the server. Otherwise, the URL will change unexpectedly. - * - * @param {number} postId Post ID for which to generate post editor URL. - */ - setBrowserURL( postId ) { - window.history.replaceState( - { id: postId }, - 'Post ' + postId, - getPostEditURL( postId ) - ); - - this.setState( () => ( { - historyId: postId, - } ) ); - } - - render() { - return null; - } -} - -export default withSelect( ( select ) => { - const { getCurrentPost } = select( 'core/editor' ); - const { id, status, type } = getCurrentPost(); - - return { - postId: id, - postStatus: status, - postType: type, - }; -} )( BrowserURL ); diff --git a/client/gutenberg/editor/edit-post/components/browser-url/test/index.js b/client/gutenberg/editor/edit-post/components/browser-url/test/index.js deleted file mode 100644 index a669896f5ca03e..00000000000000 --- a/client/gutenberg/editor/edit-post/components/browser-url/test/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * External dependencies - */ -import { shallow } from 'enzyme'; - -/** - * Internal dependencies - */ -import { getPostEditURL, getPostTrashedURL, BrowserURL } from '../'; - -describe( 'getPostEditURL', () => { - it( 'should generate relative path with post and action arguments', () => { - const url = getPostEditURL( 1 ); - - expect( url ).toBe( 'post.php?post=1&action=edit' ); - } ); -} ); - -describe( 'getPostTrashedURL', () => { - it( 'should generate relative path with post and action arguments', () => { - const url = getPostTrashedURL( 1, 'page' ); - - expect( url ).toBe( 'edit.php?trashed=1&post_type=page&ids=1' ); - } ); -} ); - -describe( 'BrowserURL', () => { - let replaceStateSpy; - - beforeAll( () => { - replaceStateSpy = jest.spyOn( window.history, 'replaceState' ); - } ); - - beforeEach( () => { - replaceStateSpy.mockReset(); - } ); - - afterAll( () => { - replaceStateSpy.mockRestore(); - } ); - - it( 'not update URL if post is auto-draft', () => { - const wrapper = shallow( ); - wrapper.setProps( { - postId: 1, - postStatus: 'auto-draft', - } ); - - expect( replaceStateSpy ).not.toHaveBeenCalled(); - } ); - - it( 'update URL if post is no longer auto-draft', () => { - const wrapper = shallow( ); - wrapper.setProps( { - postId: 1, - postStatus: 'auto-draft', - } ); - wrapper.setProps( { - postStatus: 'draft', - } ); - - expect( replaceStateSpy ).toHaveBeenCalledWith( - { id: 1 }, - 'Post 1', - 'post.php?post=1&action=edit' - ); - } ); - - it( 'not update URL if history is already set', () => { - const wrapper = shallow( ); - wrapper.setProps( { - postId: 1, - postStatus: 'draft', - } ); - replaceStateSpy.mockReset(); - wrapper.setProps( { - postId: 1, - } ); - - expect( replaceStateSpy ).not.toHaveBeenCalled(); - } ); - - it( 'update URL if post ID changes', () => { - const wrapper = shallow( ); - wrapper.setProps( { - postId: 1, - postStatus: 'draft', - } ); - replaceStateSpy.mockReset(); - wrapper.setProps( { - postId: 2, - } ); - - expect( replaceStateSpy ).toHaveBeenCalledWith( - { id: 2 }, - 'Post 2', - 'post.php?post=2&action=edit' - ); - } ); - - it( 'renders nothing', () => { - const wrapper = shallow( ); - - expect( wrapper.type() ).toBeNull(); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/components/header/fixed-toolbar-toggle/index.js b/client/gutenberg/editor/edit-post/components/header/fixed-toolbar-toggle/index.js deleted file mode 100644 index eb7080d2c653f1..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/fixed-toolbar-toggle/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * WordPress Dependencies - */ -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * WordPress Dependencies - */ -import { __ } from '@wordpress/i18n'; -import { compose } from '@wordpress/compose'; -import { MenuItem } from '@wordpress/components'; -import { ifViewportMatches } from '@wordpress/viewport'; - -function FixedToolbarToggle( { onToggle, isActive } ) { - return ( - - { __( 'Fix Toolbar to Top' ) } - - ); -} - -export default compose( [ - withSelect( ( select ) => ( { - isActive: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), - } ) ), - withDispatch( ( dispatch, ownProps ) => ( { - onToggle() { - dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' ); - ownProps.onToggle(); - }, - } ) ), - ifViewportMatches( 'medium' ), -] )( FixedToolbarToggle ); diff --git a/client/gutenberg/editor/edit-post/components/header/header-toolbar/index.js b/client/gutenberg/editor/edit-post/components/header/header-toolbar/index.js deleted file mode 100644 index 42c35390e01ebe..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/header-toolbar/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * WordPress dependencies - */ -import { compose } from '@wordpress/compose'; -import { withSelect } from '@wordpress/data'; -import { withViewportMatch } from '@wordpress/viewport'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { - Inserter, - BlockToolbar, - TableOfContents, - EditorHistoryRedo, - EditorHistoryUndo, - NavigableToolbar, -} from '@wordpress/editor'; - -/** - * Internal dependencies - */ - -function HeaderToolbar( { hasFixedToolbar, isLargeViewport } ) { - return ( - - - - - - { hasFixedToolbar && isLargeViewport && ( -
- -
- ) } -
- ); -} - -export default compose( [ - withSelect( ( select ) => ( { - hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), - } ) ), - withViewportMatch( { isLargeViewport: 'medium' } ), -] )( HeaderToolbar ); diff --git a/client/gutenberg/editor/edit-post/components/header/header-toolbar/style.scss b/client/gutenberg/editor/edit-post/components/header/header-toolbar/style.scss deleted file mode 100644 index 41d08213520ebb..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/header-toolbar/style.scss +++ /dev/null @@ -1,78 +0,0 @@ -// Hide all action buttons except the inserter on mobile. -.edit-post-header-toolbar > .components-button { - display: none; - - @include break-small() { - display: inline-flex; - } -} - -.edit-post-header-toolbar { - display: inline-flex; - align-items: center; - - @include break-large() { - .editor-block-switcher .components-toolbar { - border-left: 1px solid $light-gray-500; - } - } -} - -// Block toolbar when fixed to the top of the screen. -.edit-post-header-toolbar__block-toolbar { - // Stack toolbar below Editor Bar. - position: absolute; - top: $header-height; - left: 0; - right: 0; - background: $white; - min-height: $block-toolbar-height; - border-bottom: 1px solid $light-gray-500; - - .editor-block-toolbar { - border-left: none; - } - - .editor-block-toolbar .components-toolbar { - border-top: none; - border-bottom: none; - } - - .is-sidebar-opened & { - display: none; - } - - @include break-medium { - .is-sidebar-opened & { - display: block; - right: $sidebar-width; - } - } - - // Move toolbar into top Editor Bar. - @include break-large { - padding-left: $item-spacing; - position: static; - left: auto; - right: auto; - background: none; - border-bottom: none; - min-height: auto; - - .is-sidebar-opened & { - right: auto; - } - } -} - -.edit-post-header-toolbar .table-of-contents { - display: none; - - .is-sidebar-opened & { - right: $sidebar-width + 16px; - } - - @include break-small() { - display: block; - } -} diff --git a/client/gutenberg/editor/edit-post/components/header/index.js b/client/gutenberg/editor/edit-post/components/header/index.js deleted file mode 100644 index 91b31d84a49699..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/index.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { IconButton } from '@wordpress/components'; -import { - PostPreviewButton, - PostSavedState, - PostPublishPanelToggle, -} from '@wordpress/editor'; -import { withDispatch, withSelect } from '@wordpress/data'; -import { compose } from '@wordpress/compose'; -import { DotTip } from '@wordpress/nux'; - -/** - * Internal dependencies - */ -import MoreMenu from './more-menu'; -import HeaderToolbar from './header-toolbar'; -import PinnedPlugins from './pinned-plugins'; - -function Header( { - isEditorSidebarOpened, - openGeneralSidebar, - closeGeneralSidebar, - isPublishSidebarOpened, - togglePublishSidebar, - hasActiveMetaboxes, - isSaving, -} ) { - const toggleGeneralSidebar = isEditorSidebarOpened ? closeGeneralSidebar : openGeneralSidebar; - - return ( -
- - { ! isPublishSidebarOpened && ( -
- - - - - - { __( 'You’ll find more settings for your page and blocks in the sidebar. Click ‘Settings’ to open it.' ) } - - - - -
- ) } -
- ); -} - -export default compose( - withSelect( ( select ) => ( { - isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(), - isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(), - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), - hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(), - } ) ), - withDispatch( ( dispatch, { hasBlockSelection } ) => { - const { openGeneralSidebar, closeGeneralSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' ); - const sidebarToOpen = hasBlockSelection ? 'edit-post/block' : 'edit-post/document'; - return { - openGeneralSidebar: () => openGeneralSidebar( sidebarToOpen ), - closeGeneralSidebar: closeGeneralSidebar, - togglePublishSidebar: togglePublishSidebar, - hasBlockSelection: undefined, - }; - } ), -)( Header ); diff --git a/client/gutenberg/editor/edit-post/components/header/mode-switcher/index.js b/client/gutenberg/editor/edit-post/components/header/mode-switcher/index.js deleted file mode 100644 index 527e77f1011172..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/mode-switcher/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { MenuItemsChoice, MenuGroup } from '@wordpress/components'; -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import shortcuts from '../../../keyboard-shortcuts'; -/** - * Set of available mode options. - * - * @type {Array} - */ -const MODES = [ - { - value: 'visual', - label: __( 'Visual Editor' ), - }, - { - value: 'text', - label: __( 'Code Editor' ), - }, -]; - -function ModeSwitcher( { onSwitch, mode } ) { - const choices = MODES.map( ( choice ) => { - if ( choice.value !== mode ) { - return { ...choice, shortcut: shortcuts.toggleEditorMode.label }; - } - return choice; - } ); - - return ( - - - - ); -} - -export default compose( [ - withSelect( ( select ) => ( { - mode: select( 'core/edit-post' ).getEditorMode(), - } ) ), - withDispatch( ( dispatch, ownProps ) => ( { - onSwitch( mode ) { - dispatch( 'core/edit-post' ).switchEditorMode( mode ); - ownProps.onSelect( mode ); - }, - } ) ), -] )( ModeSwitcher ); diff --git a/client/gutenberg/editor/edit-post/components/header/more-menu/index.js b/client/gutenberg/editor/edit-post/components/header/more-menu/index.js deleted file mode 100644 index 3ac9b8eb958f93..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/more-menu/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { IconButton, Dropdown, MenuGroup } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import ModeSwitcher from '../mode-switcher'; -import FixedToolbarToggle from '../fixed-toolbar-toggle'; -import PluginMoreMenuGroup from '../plugins-more-menu-group'; -import TipsToggle from '../tips-toggle'; - -const MoreMenu = () => ( - ( - - ) } - renderContent={ ( { onClose } ) => ( -
- - - - - - - -
- ) } - /> -); - -export default MoreMenu; diff --git a/client/gutenberg/editor/edit-post/components/header/more-menu/style.scss b/client/gutenberg/editor/edit-post/components/header/more-menu/style.scss deleted file mode 100644 index c707269a3e4702..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/more-menu/style.scss +++ /dev/null @@ -1,28 +0,0 @@ -.edit-post-more-menu { - margin-left: -4px; - - // the padding and margin of the more menu is intentionally non-standard - .components-icon-button { - width: auto; - padding: 8px 2px; - } - - @include break-small() { - margin-left: 4px; - - .components-icon-button { - padding: 8px 4px; - } - } - - .components-button svg { - transform: rotate(90deg); - } -} - -.edit-post-more-menu__content { - .components-menu-group:not(:last-child), - > div:not(:last-child) .components-menu-group { - border-bottom: 1px solid $light-gray-500; - } -} diff --git a/client/gutenberg/editor/edit-post/components/header/more-menu/test/__snapshots__/index.js.snap b/client/gutenberg/editor/edit-post/components/header/more-menu/test/__snapshots__/index.js.snap deleted file mode 100644 index b4b682a24b1fd9..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/more-menu/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,72 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MoreMenu should match snapshot 1`] = ` - - -
-
- - - - - - -
-
-
-
-`; diff --git a/client/gutenberg/editor/edit-post/components/header/more-menu/test/index.js b/client/gutenberg/editor/edit-post/components/header/more-menu/test/index.js deleted file mode 100644 index 99946fe94f0e86..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/more-menu/test/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * External dependencies - */ -import { mount } from 'enzyme'; - -/** - * Internal dependencies - */ -import MoreMenu from '../index'; - -jest.mock( '../../../../../packages/components/src/button' ); - -describe( 'MoreMenu', () => { - it( 'should match snapshot', () => { - const wrapper = mount( - - ); - - expect( wrapper ).toMatchSnapshot(); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/components/header/pinned-plugins/index.js b/client/gutenberg/editor/edit-post/components/header/pinned-plugins/index.js deleted file mode 100644 index cf6e8259be2ffa..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/pinned-plugins/index.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - -/** - * WordPress dependencies - */ -import { createSlotFill } from '@wordpress/components'; - -/** - * Internal dependencies - */ - -const { Fill: PinnedPlugins, Slot } = createSlotFill( 'PinnedPlugins' ); - -PinnedPlugins.Slot = ( props ) => ( - - { ( fills ) => ! isEmpty( fills ) && ( -
- { fills } -
- ) } -
-); - -export default PinnedPlugins; diff --git a/client/gutenberg/editor/edit-post/components/header/pinned-plugins/style.scss b/client/gutenberg/editor/edit-post/components/header/pinned-plugins/style.scss deleted file mode 100644 index 3e08c6033ee781..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/pinned-plugins/style.scss +++ /dev/null @@ -1,27 +0,0 @@ -.edit-post-pinned-plugins { - display: flex; - - .components-icon-button { - margin-left: 4px; - } - - // Colorize plugin icons to ensure contrast and cohesion, but allow plugin developers to override. - .components-icon-button:not( .is-toggled ) svg, - .components-icon-button:not( .is-toggled ) svg * { - stroke: $dark-gray-500; - fill: $dark-gray-500; - } - - // Forcefully colorize hover and toggled plugin icon states to ensure legibility and consistency. - .components-icon-button.is-toggled svg, - .components-icon-button.is-toggled svg * { - stroke: $white !important; - fill: $white !important; - } - - .components-icon-button:hover svg, - .components-icon-button:hover svg * { - stroke: $dark-gray-900 !important; - fill: $dark-gray-900 !important; - } -} diff --git a/client/gutenberg/editor/edit-post/components/header/plugin-sidebar-more-menu-item/index.js b/client/gutenberg/editor/edit-post/components/header/plugin-sidebar-more-menu-item/index.js deleted file mode 100644 index fa36e95c38b412..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/plugin-sidebar-more-menu-item/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * WordPress dependencies - */ -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; -import { MenuItem } from '@wordpress/components'; -import { withPluginContext } from '@wordpress/plugins'; - -/** - * Internal dependencies - */ -import PluginsMoreMenuGroup from '../plugins-more-menu-group'; - -const PluginSidebarMoreMenuItem = ( { children, icon, isSelected, onClick } ) => ( - - { ( fillProps ) => ( - - { children } - - ) } - -); - -export default compose( - withPluginContext( ( context, ownProps ) => { - return { - icon: ownProps.icon || context.icon, - sidebarName: `${ context.name }/${ ownProps.target }`, - }; - } ), - withSelect( ( select, { sidebarName } ) => { - const { - getActiveGeneralSidebarName, - } = select( 'core/edit-post' ); - - return { - isSelected: getActiveGeneralSidebarName() === sidebarName, - }; - } ), - withDispatch( ( dispatch, { isSelected, sidebarName } ) => { - const { - closeGeneralSidebar, - openGeneralSidebar, - } = dispatch( 'core/edit-post' ); - const onClick = isSelected ? - closeGeneralSidebar : - () => openGeneralSidebar( sidebarName ); - - return { onClick }; - } ), -)( PluginSidebarMoreMenuItem ); diff --git a/client/gutenberg/editor/edit-post/components/header/plugins-more-menu-group/index.js b/client/gutenberg/editor/edit-post/components/header/plugins-more-menu-group/index.js deleted file mode 100644 index 82fe50c4d53ec5..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/plugins-more-menu-group/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - -/** - * WordPress dependencies - */ -import { createSlotFill, MenuGroup } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -const { Fill: PluginsMoreMenuGroup, Slot } = createSlotFill( 'PluginsMoreMenuGroup' ); - -PluginsMoreMenuGroup.Slot = ( { fillProps } ) => ( - - { ( fills ) => ! isEmpty( fills ) && ( - - { fills } - - ) } - -); - -export default PluginsMoreMenuGroup; diff --git a/client/gutenberg/editor/edit-post/components/header/style.scss b/client/gutenberg/editor/edit-post/components/header/style.scss deleted file mode 100644 index db312fee2fcf35..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/style.scss +++ /dev/null @@ -1,99 +0,0 @@ -.edit-post-header { - height: $header-height; - padding: $item-spacing 2px; - border-bottom: 1px solid $light-gray-500; - background: $white; - display: flex; - flex-direction: row; - align-items: stretch; - justify-content: space-between; - z-index: z-index( '.edit-post-header' ); - left: 0; - right: 0; - - // mobile edgecase for toolbar - top: 0; - position: sticky; - - // on mobile the main content area has to scroll - // otherwise you can invoke the overscroll bounce on the non-scrolling container, causing (ノಠ益ಠ)ノ彡┻━┻ - @include break-small { - position: fixed; - padding: $item-spacing; - top: $admin-bar-height-big; - } - - @include break-medium() { - top: $admin-bar-height; - } - - .editor-post-switch-to-draft + .editor-post-preview { - display: none; - - @include break-small { - display: inline-flex; - } - } -} - -@include editor-left('.edit-post-header'); - -.edit-post-header__settings { - display: inline-flex; - align-items: center; -} - -.edit-post-header .components-button { - border-radius: $button-style__radius-roundrect; - - // header toggle buttons - &.is-toggled { - color: $white; - } - - // put the gray background on a separate layer, so as to match the size of the publish button (34px) - &.is-toggled:before { - content: ""; - border-radius: $button-style__radius-roundrect; - position: absolute; - z-index: -1; - background: $dark-gray-500; - top: 1px; - right: 1px; - bottom: 1px; - left: 1px; - } - - &.is-toggled:hover, - &.is-toggled:focus { - box-shadow: 0 0 0 1px $dark-gray-500, inset 0 0 0 1px $white; - color: $white; - background: $dark-gray-500; - } - - &.editor-post-switch-to-draft, - &.editor-post-preview, - &.editor-post-publish-button, - &.editor-post-publish-panel__toggle { - margin: 2px; - height: 33px; - line-height: 32px; - padding: 0 5px 2px; - font-size: $default-font-size; - - @include break-small() { - padding: 0 12px 2px; - } - } - - @include break-medium() { - &.editor-post-preview { - margin: 0 3px 0 12px; - } - - &.editor-post-publish-button, - &.editor-post-publish-panel__toggle { - margin: 0 12px 0 3px; - } - } -} diff --git a/client/gutenberg/editor/edit-post/components/header/tips-toggle/index.js b/client/gutenberg/editor/edit-post/components/header/tips-toggle/index.js deleted file mode 100644 index 807fd3eb652edb..00000000000000 --- a/client/gutenberg/editor/edit-post/components/header/tips-toggle/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * WordPress Dependencies - */ -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * WordPress Dependencies - */ -import { __ } from '@wordpress/i18n'; -import { compose } from '@wordpress/compose'; -import { MenuItem } from '@wordpress/components'; - -function TipsToggle( { onToggle, isActive } ) { - return ( - - { __( 'Show Tips' ) } - - ); -} - -export default compose( [ - withSelect( ( select ) => ( { - isActive: select( 'core/nux' ).areTipsEnabled(), - } ) ), - withDispatch( ( dispatch, ownProps ) => ( { - onToggle() { - const { disableTips, enableTips } = dispatch( 'core/nux' ); - if ( ownProps.isActive ) { - disableTips(); - } else { - enableTips(); - } - ownProps.onToggle(); - }, - } ) ), -] )( TipsToggle ); diff --git a/client/gutenberg/editor/edit-post/components/keyboard-shortcuts/index.js b/client/gutenberg/editor/edit-post/components/keyboard-shortcuts/index.js index 91667b2b54fda4..091798c9e7edae 100644 --- a/client/gutenberg/editor/edit-post/components/keyboard-shortcuts/index.js +++ b/client/gutenberg/editor/edit-post/components/keyboard-shortcuts/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import React from 'react'; + /** * WordPress dependencies */ diff --git a/client/gutenberg/editor/edit-post/components/layout/index.js b/client/gutenberg/editor/edit-post/components/layout/index.js index 0063e31694e7b4..3642bea2099d3a 100644 --- a/client/gutenberg/editor/edit-post/components/layout/index.js +++ b/client/gutenberg/editor/edit-post/components/layout/index.js @@ -1,8 +1,8 @@ /** * External dependencies */ +import React from 'react'; import classnames from 'classnames'; -import { some } from 'lodash'; /** * WordPress dependencies @@ -11,7 +11,6 @@ import { Button, Popover, ScrollLock, navigateRegions } from '@wordpress/compone import { __ } from '@wordpress/i18n'; import { AutosaveMonitor, - UnsavedChangesWarning, EditorNotices, PostPublishPanel, DocumentTitle, @@ -26,32 +25,21 @@ import { compose } from '@wordpress/compose'; /** * Internal dependencies */ -import BrowserURL from '../browser-url'; -import BlockSidebar from '../sidebar/block-sidebar'; -import DocumentSidebar from '../sidebar/document-sidebar'; -import Header from '../header'; import TextEditor from '../text-editor'; import VisualEditor from '../visual-editor'; import EditorModeKeyboardShortcuts from '../keyboard-shortcuts'; -import MetaBoxes from '../meta-boxes'; -import { getMetaBoxContainer } from '../../utils/meta-boxes'; -import Sidebar from '../sidebar'; -import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel'; -import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel'; function Layout( { - mode, - editorSidebarOpened, - pluginSidebarOpened, - publishSidebarOpened, - hasFixedToolbar, - closePublishSidebar, - togglePublishSidebar, - metaBoxes, - hasActiveMetaboxes, - isSaving, - isMobileViewport, -} ) { + mode, + editorSidebarOpened, + pluginSidebarOpened, + publishSidebarOpened, + hasFixedToolbar, + closePublishSidebar, + togglePublishSidebar, + isSaving, + isMobileViewport, + } ) { const sidebarIsOpened = editorSidebarOpened || pluginSidebarOpened || publishSidebarOpened; const className = classnames( 'edit-post-layout', { @@ -68,15 +56,7 @@ function Layout( { return (
- - { - return some( metaBoxes, ( metaBox, location ) => { - return metaBox.isActive && - jQuery( getMetaBoxContainer( location ) ).serialize() !== metaBox.data; - } ); - } } /> -
{ mode === 'text' && } { mode === 'visual' && } -
- -
-
- -
{ publishSidebarOpened ? ( ) : ( @@ -118,9 +89,6 @@ function Layout( { { __( 'Open publish panel' ) }
- - - { isMobileViewport && sidebarIsOpened && } @@ -139,9 +107,6 @@ export default compose( pluginSidebarOpened: select( 'core/edit-post' ).isPluginSidebarOpened(), publishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(), hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), - metaBoxes: select( 'core/edit-post' ).getMetaBoxes(), - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), } ) ), withDispatch( ( dispatch ) => { const { closePublishSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' ); diff --git a/client/gutenberg/editor/edit-post/components/meta-boxes/index.js b/client/gutenberg/editor/edit-post/components/meta-boxes/index.js deleted file mode 100644 index 9cabfa600e031d..00000000000000 --- a/client/gutenberg/editor/edit-post/components/meta-boxes/index.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * WordPress dependencies - */ -import { withSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import MetaBoxesArea from './meta-boxes-area'; - -function MetaBoxes( { location, isActive } ) { - if ( ! isActive ) { - return null; - } - - return ; -} - -export default withSelect( - ( select, ownProps ) => ( { - isActive: select( 'core/edit-post' ).getMetaBox( ownProps.location ).isActive, - } ), -)( MetaBoxes ); diff --git a/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/index.js b/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/index.js deleted file mode 100644 index 50d7af138e4022..00000000000000 --- a/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; - -/** - * WordPress dependencies - */ -import { Component } from '@wordpress/element'; -import { Spinner } from '@wordpress/components'; -import { withSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ - -class MetaBoxesArea extends Component { - /** - * @inheritdoc - */ - constructor() { - super( ...arguments ); - this.bindContainerNode = this.bindContainerNode.bind( this ); - } - - /** - * @inheritdoc - */ - componentDidMount() { - this.form = document.querySelector( '.metabox-location-' + this.props.location ); - if ( this.form ) { - this.container.appendChild( this.form ); - } - } - - /** - * Get the meta box location form from the original location. - */ - componentWillUnmount() { - if ( this.form ) { - document.querySelector( '#metaboxes' ).appendChild( this.form ); - } - } - - /** - * Binds the metabox area container node. - * - * @param {Element} node DOM Node. - */ - bindContainerNode( node ) { - this.container = node; - } - - /** - * @inheritdoc - */ - render() { - const { location, isSaving } = this.props; - - const classes = classnames( - 'edit-post-meta-boxes-area', - `is-${ location }`, - { - 'is-loading': isSaving, - } - ); - - return ( -
- { isSaving && } -
-
-
- ); - } -} - -export default withSelect( ( select ) => { - return { - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), - }; -} )( MetaBoxesArea ); diff --git a/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/style.scss b/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/style.scss deleted file mode 100644 index 1b92ba35657127..00000000000000 --- a/client/gutenberg/editor/edit-post/components/meta-boxes/meta-boxes-area/style.scss +++ /dev/null @@ -1,81 +0,0 @@ - -.edit-post-meta-boxes-area { - position: relative; - - /** - * The wordpress default for most meta-box elements is content-box. Some - * elements such as textarea and input are set to border-box in forms.css. - * These elements therefore specifically set back to border-box here, while - * other elements (such as .button) are unaffected by Gutenberg's style - * because of their higher specificity. - */ - &__container, - .inside { - box-sizing: content-box; - } - - textarea, input { - box-sizing: border-box; - } - - /* Match width and positioning of the meta boxes. Override default styles. */ - #poststuff { - margin: 0 auto; - padding-top: 0; - min-width: auto; - } - - /* Override Default meta box stylings */ - #poststuff h3.hndle, - #poststuff .stuffbox > h3, - #poststuff h2.hndle { /* WordPress selectors yolo */ - border-bottom: 1px solid $light-gray-500; - box-sizing: border-box; - color: inherit; - font-weight: 600; - outline: none; - padding: 15px; - position: relative; - width: 100%; - } - - .postbox { - border: 0; - color: inherit; - margin-bottom: 0; - } - - .postbox > .inside { - border-bottom: 1px solid $light-gray-500; - color: inherit; - padding: 0 $block-padding $block-padding; - margin: 0; - } - - .postbox .handlediv { - height: 44px; - width: 44px; - } - - &.is-loading:before { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - content: ''; - background: transparent; - z-index: z-index( '.edit-post-meta-boxes-area.is-loading:before'); - } - - .spinner { - position: absolute; - top: 10px; - right: 20px; - z-index: z-index( '.edit-post-meta-boxes-area .spinner'); - } -} - -.edit-post-meta-boxes-area__clear { - clear: both; -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/index.js b/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/index.js deleted file mode 100644 index d16e76540fb37e..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * WordPress dependencies - */ -import { Panel, PanelBody } from '@wordpress/components'; -import { BlockInspector } from '@wordpress/editor'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal Dependencies - */ -import SettingsHeader from '../settings-header'; -import Sidebar from '../'; - -const SIDEBAR_NAME = 'edit-post/block'; - -const BlockSidebar = () => ( - - - - - - - - -); - -export default BlockSidebar; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/style.scss deleted file mode 100644 index b07f8733a14005..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/block-sidebar/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -.edit-post-block-sidebar__panel .components-panel__body { - border: none; - border-top: 1px solid $light-gray-500; - margin: 0 -16px; - - .components-base-control { - margin: 0 0 1em 0; - } - - .components-panel__body-toggle { - color: $dark-gray-500; - } - - &:first-child { - margin-top: 16px; - } - - &:last-child { - margin-bottom: -16px; - } -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/discussion-panel/index.js b/client/gutenberg/editor/edit-post/components/sidebar/discussion-panel/index.js deleted file mode 100644 index 27bd6e04b2cb73..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/discussion-panel/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelBody, PanelRow } from '@wordpress/components'; -import { PostComments, PostPingbacks, PostTypeSupportCheck } from '@wordpress/editor'; -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Module Constants - */ -const PANEL_NAME = 'discussion-panel'; - -function DiscussionPanel( { isOpened, onTogglePanel } ) { - return ( - - - - - - - - - - - - - - - - ); -} - -export default compose( [ - withSelect( ( select ) => { - return { - isOpened: select( 'core/edit-post' ).isEditorSidebarPanelOpened( PANEL_NAME ), - }; - } ), - withDispatch( ( dispatch ) => ( { - onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleGeneralSidebarEditorPanel( PANEL_NAME ); - }, - } ) ), -] )( DiscussionPanel ); - diff --git a/client/gutenberg/editor/edit-post/components/sidebar/document-sidebar/index.js b/client/gutenberg/editor/edit-post/components/sidebar/document-sidebar/index.js deleted file mode 100644 index 34f3401711a6ed..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/document-sidebar/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * WordPress dependencies - */ -import { Panel } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal Dependencies - */ -import PostStatus from '../post-status'; -import PostExcerpt from '../post-excerpt'; -import PostTaxonomies from '../post-taxonomies'; -import FeaturedImage from '../featured-image'; -import DiscussionPanel from '../discussion-panel'; -import LastRevision from '../last-revision'; -import PageAttributes from '../page-attributes'; -import MetaBoxes from '../../meta-boxes'; -import SettingsHeader from '../settings-header'; -import Sidebar from '../'; - -const SIDEBAR_NAME = 'edit-post/document'; - -const DocumentSidebar = () => ( - - - - - - - - - - - - - -); - -export default DocumentSidebar; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/featured-image/index.js b/client/gutenberg/editor/edit-post/components/sidebar/featured-image/index.js deleted file mode 100644 index a5e8aeb3b2e964..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/featured-image/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * External dependencies - */ -import { get, partial } from 'lodash'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelBody } from '@wordpress/components'; -import { PostFeaturedImage, PostFeaturedImageCheck } from '@wordpress/editor'; -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Module Constants - */ -const PANEL_NAME = 'featured-image'; - -function FeaturedImage( { isOpened, postType, onTogglePanel } ) { - return ( - - - - - - ); -} - -const applyWithSelect = withSelect( ( select ) => { - const { getEditedPostAttribute } = select( 'core/editor' ); - const { getPostType } = select( 'core' ); - const { isEditorSidebarPanelOpened } = select( 'core/edit-post' ); - - return { - postType: getPostType( getEditedPostAttribute( 'type' ) ), - isOpened: isEditorSidebarPanelOpened( PANEL_NAME ), - }; -} ); - -const applyWithDispatch = withDispatch( ( dispatch ) => { - const { toggleGeneralSidebarEditorPanel } = dispatch( 'core/edit-post' ); - - return { - onTogglePanel: partial( toggleGeneralSidebarEditorPanel, PANEL_NAME ), - }; -} ); - -export default compose( - applyWithSelect, - applyWithDispatch, -)( FeaturedImage ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/index.js b/client/gutenberg/editor/edit-post/components/sidebar/index.js deleted file mode 100644 index 3ea709bb736caa..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * WordPress Dependencies - */ -import { createSlotFill, withFocusReturn } from '@wordpress/components'; -import { withSelect } from '@wordpress/data'; -import { ifCondition, compose } from '@wordpress/compose'; - -/** - * Internal Dependencies - */ - -const { Fill, Slot } = createSlotFill( 'Sidebar' ); - -/** - * Renders a sidebar with its content. - * - * @return {Object} The rendered sidebar. - */ -const Sidebar = ( { children, label } ) => { - return ( - -
- { children } -
-
- ); -}; - -const WrappedSidebar = compose( - withSelect( ( select, { name } ) => ( { - isActive: select( 'core/edit-post' ).getActiveGeneralSidebarName() === name, - } ) ), - ifCondition( ( { isActive } ) => isActive ), - withFocusReturn, -)( Sidebar ); - -WrappedSidebar.Slot = Slot; - -export default WrappedSidebar; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/last-revision/index.js b/client/gutenberg/editor/edit-post/components/sidebar/last-revision/index.js deleted file mode 100644 index 4dc1121e13a262..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/last-revision/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelBody } from '@wordpress/components'; -import { PostLastRevision, PostLastRevisionCheck } from '@wordpress/editor'; - -/** - * Internal dependencies - */ - -function LastRevision() { - return ( - - - - - - ); -} - -export default LastRevision; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/last-revision/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/last-revision/style.scss deleted file mode 100644 index 772119aa43d5c0..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/last-revision/style.scss +++ /dev/null @@ -1,8 +0,0 @@ -// Needs specificity, because this panel is just a button -.components-panel__body.is-opened.edit-post-last-revision__panel { - padding: 0; -} - -.editor-post-last-revision__title { - padding: #{ $panel-padding - 3px } $panel-padding; // subtract extra height of dashicon -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/page-attributes/index.js b/client/gutenberg/editor/edit-post/components/sidebar/page-attributes/index.js deleted file mode 100644 index b6250faf4e2ef8..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/page-attributes/index.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * External dependencies - */ -import { get, partial } from 'lodash'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelBody, PanelRow } from '@wordpress/components'; -import { compose } from '@wordpress/compose'; -import { PageAttributesCheck, PageAttributesOrder, PageAttributesParent, PageTemplate } from '@wordpress/editor'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Module Constants - */ -const PANEL_NAME = 'page-attributes'; - -export function PageAttributes( { isOpened, onTogglePanel, postType } ) { - if ( ! postType ) { - return null; - } - return ( - - - - - - - - - - ); -} - -const applyWithSelect = withSelect( ( select ) => { - const { getEditedPostAttribute } = select( 'core/editor' ); - const { isEditorSidebarPanelOpened } = select( 'core/edit-post' ); - const { getPostType } = select( 'core' ); - return { - isOpened: isEditorSidebarPanelOpened( PANEL_NAME ), - postType: getPostType( getEditedPostAttribute( 'type' ) ), - }; -} ); - -const applyWithDispatch = withDispatch( ( dispatch ) => { - const { toggleGeneralSidebarEditorPanel } = dispatch( 'core/edit-post' ); - - return { - onTogglePanel: partial( toggleGeneralSidebarEditorPanel, PANEL_NAME ), - }; -} ); - -export default compose( - applyWithSelect, - applyWithDispatch, -)( PageAttributes ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/index.js deleted file mode 100644 index a23dd1a9a2ff65..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * WordPress dependencies - */ -import { createSlotFill, PanelBody } from '@wordpress/components'; - -const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' ); - -const PluginPostPublishPanel = ( { children, className, title, initialOpen = false } ) => ( - - - { children } - - -); - -PluginPostPublishPanel.Slot = Slot; - -export default PluginPostPublishPanel; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap deleted file mode 100644 index ab22e02bb67b70..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`PluginPostPublishPanel renders fill properly 1`] = ` -
- -
-

- - -

- My panel content -
-
-
-`; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/index.js deleted file mode 100644 index a0cef34649103d..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-publish-panel/test/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * External dependencies - */ -import { mount } from 'enzyme'; - -/** - * WordPress dependencies - */ -import { SlotFillProvider } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import PluginPostPublishPanel from '../'; - -jest.mock( '../../../../../packages/components/src/button' ); - -describe( 'PluginPostPublishPanel', () => { - test( 'renders fill properly', () => { - const wrapper = mount( - - - My panel content - - - - ); - - expect( wrapper.find( 'Slot' ).children() ).toMatchSnapshot(); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/index.js deleted file mode 100644 index 43fedee759309b..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Defines as extensibility slot for the Status & Visibility panel. - */ - -/** - * WordPress dependencies - */ -import { createSlotFill, PanelRow } from '@wordpress/components'; - -export const { Fill, Slot } = createSlotFill( 'PluginPostStatusInfo' ); - -const PluginPostStatusInfo = ( { children, className } ) => ( - - - { children } - - -); - -PluginPostStatusInfo.Slot = Slot; - -export default PluginPostStatusInfo; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap deleted file mode 100644 index 9acda7281b2351..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`PluginPostStatusInfo renders fill properly 1`] = ` -
- -
- My plugin post status info -
-
-
-`; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/index.js deleted file mode 100644 index 3b8736ddf700c0..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-post-status-info/test/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * External dependencies - */ -import { mount } from 'enzyme'; - -/** - * WordPress dependencies - */ -import { SlotFillProvider } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import PluginPostStatusInfo from '../'; - -describe( 'PluginPostStatusInfo', () => { - test( 'renders fill properly', () => { - const wrapper = mount( - - - My plugin post status info - - - - ); - - expect( wrapper.find( 'Slot' ).children() ).toMatchSnapshot(); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/index.js deleted file mode 100644 index 6803b039e26280..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * WordPress dependencies - */ -import { createSlotFill, PanelBody } from '@wordpress/components'; - -const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' ); - -const PluginPrePublishPanel = ( { children, className, title, initialOpen = false } ) => ( - - - { children } - - -); - -PluginPrePublishPanel.Slot = Slot; - -export default PluginPrePublishPanel; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap b/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap deleted file mode 100644 index 581d1faa7f0086..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`PluginPrePublishPanel renders fill properly 1`] = ` -
- -
-

- - -

- My panel content -
-
-
-`; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/index.js deleted file mode 100644 index 61f8a3138c47b2..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-pre-publish-panel/test/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * External dependencies - */ -import { mount } from 'enzyme'; - -/** - * WordPress dependencies - */ -import { SlotFillProvider } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import PluginPrePublishPanel from '../'; - -jest.mock( '../../../../../packages/components/src/button' ); - -describe( 'PluginPrePublishPanel', () => { - test( 'renders fill properly', () => { - const wrapper = mount( - - - My panel content - - - - ); - - expect( wrapper.find( 'Slot' ).children() ).toMatchSnapshot(); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/plugin-sidebar/index.js b/client/gutenberg/editor/edit-post/components/sidebar/plugin-sidebar/index.js deleted file mode 100644 index 3594ad34666bc3..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/plugin-sidebar/index.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * WordPress dependencies - */ -import { IconButton, Panel } from '@wordpress/components'; -import { withDispatch, withSelect } from '@wordpress/data'; -import { Fragment } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; -import { withPluginContext } from '@wordpress/plugins'; -import { compose } from '@wordpress/compose'; - -/** - * Internal dependencies - */ -import PinnedPlugins from '../../header/pinned-plugins'; -import Sidebar from '../'; -import SidebarHeader from '../sidebar-header'; - -/** - * Renders the plugin sidebar component. - * - * @param {Object} props Element props. - * - * @return {WPElement} Plugin sidebar component. - */ -function PluginSidebar( props ) { - const { - children, - icon, - isActive, - isPinnable = true, - isPinned, - sidebarName, - title, - togglePin, - toggleSidebar, - } = props; - - return ( - - { isPinnable && ( - - { isPinned && } - - ) } - - - { title } - { isPinnable && ( - - ) } - - - { children } - - - - ); -} - -export default compose( - withPluginContext( ( context, ownProps ) => { - return { - icon: ownProps.icon || context.icon, - sidebarName: `${ context.name }/${ ownProps.name }`, - }; - } ), - withSelect( ( select, { sidebarName } ) => { - const { - getActiveGeneralSidebarName, - isPluginItemPinned, - } = select( 'core/edit-post' ); - - return { - isActive: getActiveGeneralSidebarName() === sidebarName, - isPinned: isPluginItemPinned( sidebarName ), - }; - } ), - withDispatch( ( dispatch, { isActive, sidebarName } ) => { - const { - closeGeneralSidebar, - openGeneralSidebar, - togglePinnedPluginItem, - } = dispatch( 'core/edit-post' ); - - return { - togglePin() { - togglePinnedPluginItem( sidebarName ); - }, - toggleSidebar() { - if ( isActive ) { - closeGeneralSidebar(); - } else { - openGeneralSidebar( sidebarName ); - } - }, - }; - } ), -)( PluginSidebar ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-author/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-author/index.js deleted file mode 100644 index c61f7e70ec2d56..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-author/index.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelRow } from '@wordpress/components'; -import { PostAuthor as PostAuthorForm, PostAuthorCheck } from '@wordpress/editor'; - -/** - * Internal dependencies - */ -import './style.scss'; - -export function PostAuthor() { - return ( - - - - - - ); -} - -export default PostAuthor; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-author/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/post-author/style.scss deleted file mode 100644 index a423d651051b82..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-author/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -.editor-post-author__select { - margin: -5px 0; -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-excerpt/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-excerpt/index.js deleted file mode 100644 index 0a603f58b7a6ba..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-excerpt/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelBody } from '@wordpress/components'; -import { PostExcerpt as PostExcerptForm, PostExcerptCheck } from '@wordpress/editor'; -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Module Constants - */ -const PANEL_NAME = 'post-excerpt'; - -function PostExcerpt( { isOpened, onTogglePanel } ) { - return ( - - - - - - ); -} - -export default compose( [ - withSelect( ( select ) => { - return { - isOpened: select( 'core/edit-post' ).isEditorSidebarPanelOpened( PANEL_NAME ), - }; - } ), - withDispatch( ( dispatch ) => ( { - onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleGeneralSidebarEditorPanel( PANEL_NAME ); - }, - } ) ), -] )( PostExcerpt ); - diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-format/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-format/index.js deleted file mode 100644 index c70dbf70017fa9..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-format/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelRow } from '@wordpress/components'; -import { PostFormat as PostFormatForm, PostFormatCheck } from '@wordpress/editor'; - -export function PostFormat() { - return ( - - - - - - ); -} - -export default PostFormat; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-pending-status/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-pending-status/index.js deleted file mode 100644 index f961c0880b91c2..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-pending-status/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelRow } from '@wordpress/components'; -import { PostPendingStatus as PostPendingStatusForm, PostPendingStatusCheck } from '@wordpress/editor'; - -export function PostPendingStatus() { - return ( - - - - - - ); -} - -export default PostPendingStatus; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/index.js deleted file mode 100644 index 622cb6b1a9c79d..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelRow, Dropdown, Button } from '@wordpress/components'; -import { PostSchedule as PostScheduleForm, PostScheduleLabel, PostScheduleCheck } from '@wordpress/editor'; - -/** - * Internal dependencies - */ - -export function PostSchedule() { - return ( - - - { __( 'Publish' ) } - ( - - ) } - renderContent={ () => } - /> - - - ); -} - -export default PostSchedule; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/style.scss deleted file mode 100644 index 800fe7c6e6d24c..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-schedule/style.scss +++ /dev/null @@ -1,16 +0,0 @@ -.edit-post-post-schedule { - width: 100%; - position: relative; -} - -.components-button.edit-post-post-schedule__toggle { - text-align: right; -} - -.edit-post-post-schedule__dialog .components-popover__content { - padding: 10px; - - @include break-medium { - width: 270px; - } -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-status/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-status/index.js deleted file mode 100644 index 3b11c2d78de0cb..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-status/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelBody } from '@wordpress/components'; -import { Fragment } from '@wordpress/element'; -import { withSelect, withDispatch } from '@wordpress/data'; -import { compose } from '@wordpress/compose'; - -/** - * Internal Dependencies - */ -import './style.scss'; -import PostVisibility from '../post-visibility'; -import PostTrash from '../post-trash'; -import PostSchedule from '../post-schedule'; -import PostSticky from '../post-sticky'; -import PostAuthor from '../post-author'; -import PostFormat from '../post-format'; -import PostPendingStatus from '../post-pending-status'; -import PluginPostStatusInfo from '../plugin-post-status-info'; - -/** - * Module Constants - */ -const PANEL_NAME = 'post-status'; - -function PostStatus( { isOpened, onTogglePanel } ) { - return ( - - - { ( fills ) => ( - - - - - - - - { fills } - - - ) } - - - ); -} - -export default compose( [ - withSelect( ( select ) => ( { - isOpened: select( 'core/edit-post' ).isEditorSidebarPanelOpened( PANEL_NAME ), - } ) ), - withDispatch( ( dispatch ) => ( { - onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleGeneralSidebarEditorPanel( PANEL_NAME ); - }, - } ) ), -] )( PostStatus ); - diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-status/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/post-status/style.scss deleted file mode 100644 index 381c0744967962..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-status/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -.edit-post-post-status .edit-post-post-publish-dropdown__switch-to-draft { - margin-top: 15px; - width: 100%; - text-align: center; -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-sticky/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-sticky/index.js deleted file mode 100644 index a8dc776b7b0c1f..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-sticky/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelRow } from '@wordpress/components'; -import { PostSticky as PostStickyForm, PostStickyCheck } from '@wordpress/editor'; - -export function PostSticky() { - return ( - - - - - - ); -} - -export default PostSticky; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/index.js deleted file mode 100644 index b5376f5bb84b3f..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * WordPress dependencies - */ -import { PostTaxonomies as PostTaxonomiesForm, PostTaxonomiesCheck } from '@wordpress/editor'; -import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import TaxonomyPanel from './taxonomy-panel'; - -/** - * Module Constants - */ -const PANEL_NAME = 'post-taxonomies'; - -function PostTaxonomies() { - return ( - - { - return ( - - { content } - - ); - } } - /> - - ); -} - -export default compose( [ - withSelect( ( select ) => { - return { - isOpened: select( 'core/edit-post' ).isEditorSidebarPanelOpened( PANEL_NAME ), - }; - } ), - withDispatch( ( dispatch ) => ( { - onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleGeneralSidebarEditorPanel( PANEL_NAME ); - }, - } ) ), -] )( PostTaxonomies ); - diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/taxonomy-panel.js b/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/taxonomy-panel.js deleted file mode 100644 index d8d9ed58c35714..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-taxonomies/taxonomy-panel.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * External Dependencies - */ -import { get } from 'lodash'; - -/** - * WordPress dependencies - */ -import { compose } from '@wordpress/compose'; -import { PanelBody } from '@wordpress/components'; -import { withSelect, withDispatch } from '@wordpress/data'; - -function TaxonomyPanel( { taxonomy, isOpened, onTogglePanel, children } ) { - const taxonomyMenuName = get( taxonomy, [ 'labels', 'menu_name' ] ); - if ( ! taxonomyMenuName ) { - return null; - } - return ( - - { children } - - ); -} - -export default compose( - withSelect( ( select, ownProps ) => { - const slug = get( ownProps.taxonomy, [ 'slug' ] ); - const panelName = slug ? `taxonomy-panel-${ slug }` : ''; - return { - panelName, - isOpened: slug ? - select( 'core/edit-post' ).isEditorSidebarPanelOpened( panelName ) : - false, - }; - } ), - withDispatch( ( dispatch, ownProps ) => ( { - onTogglePanel: () => { - dispatch( 'core/edit-post' ). - toggleGeneralSidebarEditorPanel( ownProps.panelName ); - }, - } ) ), -)( TaxonomyPanel ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-trash/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-trash/index.js deleted file mode 100644 index b6c404c09ff1a1..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-trash/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * WordPress dependencies - */ -import { PanelRow } from '@wordpress/components'; -import { PostTrash as PostTrashLink, PostTrashCheck } from '@wordpress/editor'; - -/** - * Internal dependencies - */ -import './style.scss'; - -export default function PostTrash() { - return ( - - - - - - ); -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-trash/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/post-trash/style.scss deleted file mode 100644 index 846abf44cec46c..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-trash/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -.edit-post-post-trash { - margin-left: auto !important; - text-decoration: underline; - - .dashicon { - display: inline-block; - vertical-align: middle; - margin: -3px -4px 0 10px; - } -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/index.js b/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/index.js deleted file mode 100644 index 95be86126bee3e..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { PanelRow, Dropdown, Button } from '@wordpress/components'; -import { PostVisibility as PostVisibilityForm, PostVisibilityLabel, PostVisibilityCheck } from '@wordpress/editor'; - -/** - * Internal Dependencies - */ - -export function PostVisibility() { - return ( - ( - - { __( 'Visibility' ) } - { ! canEdit && } - { canEdit && ( - ( - - ) } - renderContent={ () => } - /> - ) } - - ) } /> - ); -} - -export default PostVisibility; diff --git a/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/style.scss deleted file mode 100644 index 49f0d372202d6c..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/post-visibility/style.scss +++ /dev/null @@ -1,38 +0,0 @@ -.edit-post-post-visibility { - width: 100%; -} - -.edit-post-post-visibility__dialog .components-popover__content { - padding: 10px; - - @include break-medium { - // 279px (sidebar width) - 20px (padding) - 2px (horizontal borders) - width: 257px; - } -} - -.edit-post-post-visibility__dialog-legend { - font-weight: 600; -} - -.edit-post-post-visibility__choice { - margin: 10px 0; -} - -.edit-post-post-visibility__dialog-radio, -.edit-post-post-visibility__dialog-label { - vertical-align: top; -} - -.edit-post-post-visibility__dialog-password-input { - width: calc( 100% - 20px ); - margin-left: 20px; -} - -.edit-post-post-visibility__dialog-info { - color: $dark-gray-200; - padding-left: 20px; - font-style: italic; - margin: 4px 0 0; - line-height: 1.4; -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/settings-header/index.js b/client/gutenberg/editor/edit-post/components/sidebar/settings-header/index.js deleted file mode 100644 index 4da5779b4de018..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/settings-header/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * WordPress dependencies - */ -import { compose } from '@wordpress/compose'; -import { __, _n, sprintf } from '@wordpress/i18n'; -import { withDispatch, withSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import SidebarHeader from '../sidebar-header'; - -const SettingsHeader = ( { count, openDocumentSettings, openBlockSettings, sidebarName } ) => { - // Do not display "0 Blocks". - count = count === 0 ? 1 : count; - - return ( - - - - - ); -}; - -export default compose( - withSelect( ( select ) => ( { - count: select( 'core/editor' ).getSelectedBlockCount(), - } ) ), - withDispatch( ( dispatch ) => { - const { openGeneralSidebar } = dispatch( 'core/edit-post' ); - const { clearSelectedBlock } = dispatch( 'core/editor' ); - return { - openDocumentSettings() { - openGeneralSidebar( 'edit-post/document' ); - clearSelectedBlock(); - }, - openBlockSettings() { - openGeneralSidebar( 'edit-post/block' ); - }, - }; - } ), -)( SettingsHeader ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/settings-header/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/settings-header/style.scss deleted file mode 100644 index 0ff5c13d5d1e94..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/settings-header/style.scss +++ /dev/null @@ -1,29 +0,0 @@ -.components-panel__header.edit-post-sidebar__panel-tabs { - justify-content: flex-start; - padding-left: 0; - padding-right: $panel-padding / 2; - border-top: 0; -} - -.edit-post-sidebar__panel-tab { - background: transparent; - border: none; - border-radius: 0; - cursor: pointer; - height: 50px; - padding: 3px 15px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode - margin-left: 0; - font-weight: 400; - color: $dark-gray-900; - @include square-style__neutral; - - &.is-active { - padding-bottom: 0; - border-bottom: 3px solid theme( primary ); - font-weight: 600; - } - - &:focus { - @include square-style__focus; - } -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/index.js b/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/index.js deleted file mode 100644 index 5ac082574148a5..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; -import { compose } from '@wordpress/compose'; -import { __ } from '@wordpress/i18n'; -import { IconButton } from '@wordpress/components'; -import { withDispatch, withSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ - -const SidebarHeader = ( { children, className, closeLabel, closeSidebar, title } ) => { - return ( - -
- - { title || __( '(no title)' ) } - - -
-
- { children } - -
-
- ); -}; - -export default compose( - withSelect( ( select ) => ( { - title: select( 'core/editor' ).getEditedPostAttribute( 'title' ), - } ) ), - withDispatch( ( dispatch ) => ( { - closeSidebar: dispatch( 'core/edit-post' ).closeGeneralSidebar, - } ) ), -)( SidebarHeader ); diff --git a/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/style.scss deleted file mode 100644 index 9350e87f0c2103..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/sidebar-header/style.scss +++ /dev/null @@ -1,33 +0,0 @@ -/* Text Editor specific */ -.components-panel__header.edit-post-sidebar-header__small { - background: $white; - padding-right: $panel-padding / 2; - - .edit-post-sidebar__title { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - width: 100%; - } - - @include break-medium() { - display: none; - } -} - -.components-panel__header.edit-post-sidebar-header { - padding-right: $panel-padding / 2; - - .components-icon-button { - display: none; - margin-left: auto; - - ~ .components-icon-button { - margin-left: 0; - } - - @include break-medium() { - display: flex; - } - } -} diff --git a/client/gutenberg/editor/edit-post/components/sidebar/style.scss b/client/gutenberg/editor/edit-post/components/sidebar/style.scss deleted file mode 100644 index 8f4b5f7f5f253a..00000000000000 --- a/client/gutenberg/editor/edit-post/components/sidebar/style.scss +++ /dev/null @@ -1,167 +0,0 @@ -.edit-post-sidebar { - position: fixed; - z-index: z-index( '.edit-post-sidebar' ); - top: 0; - right: 0; - bottom: 0; - width: $sidebar-width; - border-left: 1px solid $light-gray-500; - background: $light-gray-300; - color: $dark-gray-500; - height: 100vh; - overflow: hidden; - - @include break-small() { - top: $admin-bar-height-big + $header-height; - z-index: z-index( '.edit-post-sidebar {greater than small}' ); - height: auto; - overflow: auto; - -webkit-overflow-scrolling: touch; - } - - @include break-medium() { - top: $admin-bar-height + $header-height; - } - - > .components-panel { - border-left: none; - border-right: none; - overflow: auto; - -webkit-overflow-scrolling: touch; - height: auto; - max-height: calc( 100vh - #{ $admin-bar-height-big + $panel-header-height } ); - margin-top: -1px; - margin-bottom: -1px; - - @include break-small() { - overflow: inherit; - height: auto; - max-height: none; - } - } - - > .components-panel .components-panel__header { - position: fixed; - z-index: z-index( '.components-panel__header' ); - top: 0; - left: 0; - right: 0; - height: $panel-header-height; - - @include break-small() { - position: inherit; - top: auto; - left: auto; - right: auto; - } - } - - p { - margin-top: 0; - } - - h2, - h3 { - font-size: $default-font-size; - color: $dark-gray-500; - margin-bottom: 1.5em; - } - - hr { - border-top: none; - border-bottom: 1px solid $light-gray-500; - margin: 1.5em 0; - } - - div.components-toolbar { - box-shadow: none; - margin-bottom: 1.5em; - } - - p + div.components-toolbar { - margin-top: -1em; - } - - .editor-skip-to-selected-block:focus { - top: auto; - right: 10px; - bottom: 10px; - left: auto; - } -} - -/* Visual and Text editor both */ -.edit-post-layout.is-sidebar-opened .edit-post-layout__content { - @include break-medium() { - margin-right: $sidebar-width; - } -} - -.edit-post-layout.is-sidebar-opened { - .edit-post-sidebar, - .edit-post-plugin-sidebar__sidebar-layout { - /* Sidebar covers screen on mobile */ - width: 100%; - - /* Sidebar sits on the side on larger breakpoints */ - @include break-medium() { - width: $sidebar-width; - } - } -} - -/* Text Editor specific */ -.components-panel__header.edit-post-sidebar__header { - background: $white; - padding-right: $panel-padding / 2; - - .edit-post-sidebar__title { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - width: 100%; - } - - @include break-medium() { - display: none; - } -} - -.components-panel__header.edit-post-sidebar__panel-tabs { - justify-content: flex-start; - padding-left: 0; - padding-right: $panel-padding / 2; - border-top: 0; - margin-top: 0; - - .components-icon-button { - display: none; - margin-left: auto; - - @include break-medium() { - display: flex; - } - } -} - -.edit-post-sidebar__panel-tab { - background: transparent; - border: none; - border-radius: 0; - cursor: pointer; - height: 50px; - padding: 3px 15px; // Use padding to offset the is-active border, this benefits Windows High Contrast mode - margin-left: 0; - font-weight: 400; - @include square-style__neutral; - - &.is-active { - padding-bottom: 0; - border-bottom: 3px solid theme( primary ); - font-weight: 600; - } - - &:focus { - @include square-style__focus; - } -} diff --git a/client/gutenberg/editor/edit-post/components/text-editor/index.js b/client/gutenberg/editor/edit-post/components/text-editor/index.js index 1b2e327659f04d..b3bbd40d72ea5d 100644 --- a/client/gutenberg/editor/edit-post/components/text-editor/index.js +++ b/client/gutenberg/editor/edit-post/components/text-editor/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import React from 'react'; + /** * WordPress dependencies */ diff --git a/client/gutenberg/editor/edit-post/components/visual-editor/block-inspector-button.js b/client/gutenberg/editor/edit-post/components/visual-editor/block-inspector-button.js index e6014d55e025b9..59726e8cd61bc3 100644 --- a/client/gutenberg/editor/edit-post/components/visual-editor/block-inspector-button.js +++ b/client/gutenberg/editor/edit-post/components/visual-editor/block-inspector-button.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import React from 'react'; + /** * External dependencies */ diff --git a/client/gutenberg/editor/edit-post/components/visual-editor/index.js b/client/gutenberg/editor/edit-post/components/visual-editor/index.js index e9f11b7cc9a62d..eadb4b181d7d39 100644 --- a/client/gutenberg/editor/edit-post/components/visual-editor/index.js +++ b/client/gutenberg/editor/edit-post/components/visual-editor/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import React from 'react'; + /** * WordPress dependencies */ diff --git a/client/gutenberg/editor/edit-post/editor.js b/client/gutenberg/editor/edit-post/editor.js index 42ff1f5da83031..2ea557e369ac68 100644 --- a/client/gutenberg/editor/edit-post/editor.js +++ b/client/gutenberg/editor/edit-post/editor.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import React from 'react'; + /** * WordPress dependencies */ @@ -9,6 +14,7 @@ import { StrictMode } from '@wordpress/element'; * Internal dependencies */ import Layout from './components/layout'; +import './store'; function Editor( { settings, hasFixedToolbar, post, overridePost, onError, ...props } ) { if ( ! post ) { @@ -33,5 +39,5 @@ function Editor( { settings, hasFixedToolbar, post, overridePost, onError, ...pr export default withSelect( ( select, { postId, postType } ) => ( { hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), - post: select( 'core' ).getEntityRecord( 'postType', postType, postId ), + post: select( 'core' ).getEntityRecord( 'postType', postType, postId ), } ) )( Editor ); diff --git a/client/gutenberg/editor/edit-post/hooks/components/index.js b/client/gutenberg/editor/edit-post/hooks/components/index.js deleted file mode 100644 index 20f16a7461def2..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/components/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * WordPress dependencies - */ -import { addFilter } from '@wordpress/hooks'; - -/** - * Internal dependencies - */ -import MediaUpload from './media-upload'; - -const replaceMediaUpload = () => MediaUpload; - -addFilter( - 'editor.MediaUpload', - 'core/edit-post/components/media-upload/replace-media-upload', - replaceMediaUpload -); diff --git a/client/gutenberg/editor/edit-post/hooks/components/media-upload/index.js b/client/gutenberg/editor/edit-post/hooks/components/media-upload/index.js deleted file mode 100644 index 59d2c115f363b3..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/components/media-upload/index.js +++ /dev/null @@ -1,200 +0,0 @@ -/** - * External Dependencies - */ -import { castArray, pick } from 'lodash'; - -/** - * WordPress dependencies - */ -import { parseWithAttributeSchema } from '@wordpress/blocks'; -import { Component } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; - -// Getter for the sake of unit tests. -const getGalleryDetailsMediaFrame = () => { - /** - * Custom gallery details frame. - * - * @link https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js - * @class GalleryDetailsMediaFrame - * @constructor - */ - return wp.media.view.MediaFrame.Post.extend( { - - /** - * Create the default states. - * - * @return {void} - */ - createStates: function createStates() { - this.states.add( [ - new wp.media.controller.Library( { - id: 'gallery', - title: wp.media.view.l10n.createGalleryTitle, - priority: 40, - toolbar: 'main-gallery', - filterable: 'uploaded', - multiple: 'add', - editable: false, - - library: wp.media.query( _.defaults( { - type: 'image', - }, this.options.library ) ), - } ), - - new wp.media.controller.GalleryEdit( { - library: this.options.selection, - editing: this.options.editing, - menu: 'gallery', - displaySettings: false, - multiple: true, - } ), - - new wp.media.controller.GalleryAdd(), - ] ); - }, - } ); -}; - -// the media library image object contains numerous attributes -// we only need this set to display the image in the library -const slimImageObject = ( img ) => { - const attrSet = [ 'sizes', 'mime', 'type', 'subtype', 'id', 'url', 'alt', 'link', 'caption' ]; - return pick( img, attrSet ); -}; - -const getAttachmentsCollection = ( ids ) => { - return wp.media.query( { - order: 'ASC', - orderby: 'post__in', - perPage: -1, - post__in: ids, - query: true, - type: 'image', - } ); -}; - -class MediaUpload extends Component { - constructor( { multiple = false, type, gallery = false, title = __( 'Select or Upload Media' ), modalClass, value } ) { - super( ...arguments ); - this.openModal = this.openModal.bind( this ); - this.onOpen = this.onOpen.bind( this ); - this.onSelect = this.onSelect.bind( this ); - this.onUpdate = this.onUpdate.bind( this ); - this.onClose = this.onClose.bind( this ); - this.processMediaCaption = this.processMediaCaption.bind( this ); - - if ( gallery ) { - const currentState = value ? 'gallery-edit' : 'gallery'; - const GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame(); - const attachments = getAttachmentsCollection( value ); - const selection = new wp.media.model.Selection( attachments.models, { - props: attachments.props.toJSON(), - multiple, - } ); - this.frame = new GalleryDetailsMediaFrame( { - mimeType: type, - state: currentState, - multiple, - selection, - editing: ( value ) ? true : false, - } ); - wp.media.frame = this.frame; - } else { - const frameConfig = { - title, - button: { - text: __( 'Select' ), - }, - multiple, - }; - if ( !! type ) { - frameConfig.library = { type }; - } - - this.frame = wp.media( frameConfig ); - } - - if ( modalClass ) { - this.frame.$el.addClass( modalClass ); - } - - // When an image is selected in the media frame... - this.frame.on( 'select', this.onSelect ); - this.frame.on( 'update', this.onUpdate ); - this.frame.on( 'open', this.onOpen ); - this.frame.on( 'close', this.onClose ); - } - - componentWillUnmount() { - this.frame.remove(); - } - - onUpdate( selections ) { - const { onSelect, multiple = false } = this.props; - const state = this.frame.state(); - const selectedImages = selections || state.get( 'selection' ); - - if ( ! selectedImages || ! selectedImages.models.length ) { - return; - } - - if ( multiple ) { - onSelect( selectedImages.models.map( ( model ) => this.processMediaCaption( slimImageObject( model.toJSON() ) ) ) ); - } else { - onSelect( this.processMediaCaption( slimImageObject( ( selectedImages.models[ 0 ].toJSON() ) ) ) ); - } - } - - onSelect() { - const { onSelect, multiple = false } = this.props; - // Get media attachment details from the frame state - const attachment = this.frame.state().get( 'selection' ).toJSON(); - onSelect( - multiple ? - attachment.map( this.processMediaCaption ) : - this.processMediaCaption( attachment[ 0 ] ) - ); - } - - onOpen() { - if ( ! this.props.value ) { - return; - } - if ( ! this.props.gallery ) { - const selection = this.frame.state().get( 'selection' ); - castArray( this.props.value ).map( ( id ) => { - selection.add( wp.media.attachment( id ) ); - } ); - } - // load the images so they are available in the media modal. - getAttachmentsCollection( castArray( this.props.value ) ).more(); - } - - onClose() { - const { onClose } = this.props; - - if ( onClose ) { - onClose(); - } - } - - openModal() { - this.frame.open(); - } - - processMediaCaption( mediaObject ) { - return ! mediaObject.caption ? - mediaObject : - { ...mediaObject, caption: parseWithAttributeSchema( mediaObject.caption, { - source: 'children', - } ) }; - } - - render() { - return this.props.render( { open: this.openModal } ); - } -} - -export default MediaUpload; - diff --git a/client/gutenberg/editor/edit-post/hooks/index.js b/client/gutenberg/editor/edit-post/hooks/index.js deleted file mode 100644 index ef9c274541dae3..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/index.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Internal dependencies - */ -import './components'; -import './more-menu'; -import './validate-multiple-use'; diff --git a/client/gutenberg/editor/edit-post/hooks/more-menu/copy-content-menu-item/index.js b/client/gutenberg/editor/edit-post/hooks/more-menu/copy-content-menu-item/index.js deleted file mode 100644 index 345d792c0e4d3a..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/more-menu/copy-content-menu-item/index.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * WordPress dependencies - */ -import { ClipboardButton } from '@wordpress/components'; -import { withSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; -import { withState, compose } from '@wordpress/compose'; - -function CopyContentMenuItem( { editedPostContent, hasCopied, setState } ) { - return ( - setState( { hasCopied: true } ) } - onFinishCopy={ () => setState( { hasCopied: false } ) } - > - { hasCopied ? - __( 'Copied!' ) : - __( 'Copy All Content' ) } - - ); -} - -export default compose( - withSelect( ( select ) => ( { - editedPostContent: select( 'core/editor' ).getEditedPostAttribute( 'content' ), - } ) ), - withState( { hasCopied: false } ) -)( CopyContentMenuItem ); diff --git a/client/gutenberg/editor/edit-post/hooks/more-menu/index.js b/client/gutenberg/editor/edit-post/hooks/more-menu/index.js deleted file mode 100644 index 52989ffc575da8..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/more-menu/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * WordPress dependencies - */ -import { addFilter } from '@wordpress/hooks'; - -/** - * Internal dependencies - */ -import CopyContentMenuItem from './copy-content-menu-item'; - -const withCopyContentMenuItem = ( menuItems ) => [ - ...menuItems, - , -]; - -addFilter( - 'editPost.MoreMenu.tools', - 'core/edit-post/more-menu/withCopyContentMenuItem', - withCopyContentMenuItem -); diff --git a/client/gutenberg/editor/edit-post/hooks/validate-multiple-use/index.js b/client/gutenberg/editor/edit-post/hooks/validate-multiple-use/index.js deleted file mode 100644 index 7a165bfbec71c7..00000000000000 --- a/client/gutenberg/editor/edit-post/hooks/validate-multiple-use/index.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * External dependencies - */ -import { find } from 'lodash'; - -/** - * WordPress dependencies - */ -import { - createBlock, - findTransform, - getBlockTransforms, - getBlockType, - hasBlockSupport, -} from '@wordpress/blocks'; -import { Button } from '@wordpress/components'; -import { withSelect, withDispatch } from '@wordpress/data'; -import { Warning } from '@wordpress/editor'; -import { addFilter } from '@wordpress/hooks'; -import { __ } from '@wordpress/i18n'; -import { compose, createHigherOrderComponent } from '@wordpress/compose'; - -const enhance = compose( - /** - * For blocks whose block type doesn't support `multiple`, provides the - * wrapped component with `originalBlockClientId` -- a reference to the - * first block of the same type in the content -- if and only if that - * "original" block is not the current one. Thus, an inexisting - * `originalBlockClientId` prop signals that the block is valid. - * - * @param {Component} WrappedBlockEdit A filtered BlockEdit instance. - * - * @return {Component} Enhanced component with merged state data props. - */ - withSelect( ( select, block ) => { - const blocks = select( 'core/editor' ).getBlocks(); - const multiple = hasBlockSupport( block.name, 'multiple', true ); - - // For block types with `multiple` support, there is no "original - // block" to be found in the content, as the block itself is valid. - if ( multiple ) { - return {}; - } - - // Otherwise, only pass `originalBlockClientId` if it refers to a different - // block from the current one. - const firstOfSameType = find( blocks, ( { name } ) => block.name === name ); - const isInvalid = firstOfSameType && firstOfSameType.clientId !== block.clientId; - return { - originalBlockClientId: isInvalid && firstOfSameType.clientId, - }; - } ), - withDispatch( ( dispatch, { originalBlockClientId } ) => ( { - selectFirst: () => dispatch( 'core/editor' ).selectBlock( originalBlockClientId ), - } ) ), -); - -const withMultipleValidation = createHigherOrderComponent( ( BlockEdit ) => { - return enhance( ( { - originalBlockClientId, - selectFirst, - ...props - } ) => { - if ( ! originalBlockClientId ) { - return ; - } - - const blockType = getBlockType( props.name ); - const outboundType = getOutboundType( props.name ); - - return [ -
- -
, - - { __( 'Find original' ) } - , - , - outboundType && ( - - ), - ] } - > - { blockType.title }: - { __( 'This block may not be used more than once.' ) } - , - ]; - } ); -}, 'withMultipleValidation' ); - -/** - * Given a base block name, returns the default block type to which to offer - * transforms. - * - * @param {string} blockName Base block name. - * - * @return {?Object} The chosen default block type. - */ -function getOutboundType( blockName ) { - // Grab the first outbound transform - const transform = findTransform( - getBlockTransforms( 'to', blockName ), - ( { type, blocks } ) => type === 'block' && blocks.length === 1 // What about when .length > 1? - ); - - if ( ! transform ) { - return null; - } - - return getBlockType( transform.blocks[ 0 ] ); -} - -addFilter( - 'editor.BlockEdit', - 'core/edit-post/validate-multiple-use/with-multiple-validation', - withMultipleValidation -); diff --git a/client/gutenberg/editor/edit-post/index.js b/client/gutenberg/editor/edit-post/index.js index a9f231dac77413..080d852262c43f 100644 --- a/client/gutenberg/editor/edit-post/index.js +++ b/client/gutenberg/editor/edit-post/index.js @@ -8,7 +8,6 @@ import deprecated from '@wordpress/deprecated'; /** * Internal dependencies */ -import './hooks'; import store from './store'; import { initializeMetaBoxState } from './store/actions'; import Editor from './editor'; @@ -83,11 +82,4 @@ export function initializeEditor( id, postType, postId, settings, overridePost ) }, }; } - -export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel'; -export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info'; -export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel'; -export { default as PluginSidebar } from './components/sidebar/plugin-sidebar'; -export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item'; - setupPersistence( STORAGE_KEY ); diff --git a/client/gutenberg/editor/edit-post/store/effects.js b/client/gutenberg/editor/edit-post/store/effects.js index 651bc6682e669f..ac1bef0b9446f4 100644 --- a/client/gutenberg/editor/edit-post/store/effects.js +++ b/client/gutenberg/editor/edit-post/store/effects.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { reduce, some } from 'lodash'; - /** * WordPress dependencies */ @@ -15,110 +10,13 @@ import apiFetch from '@wordpress/api-fetch'; * Internal dependencies */ import { - metaBoxUpdatesSuccess, - setMetaBoxSavedData, - requestMetaBoxUpdates, openGeneralSidebar, closeGeneralSidebar, } from './actions'; -import { getMetaBoxes, getActiveGeneralSidebarName } from './selectors'; -import { getMetaBoxContainer } from '../utils/meta-boxes'; +import { getActiveGeneralSidebarName } from './selectors'; import { onChangeListener } from './utils'; const effects = { - INITIALIZE_META_BOX_STATE( action, store ) { - const hasActiveMetaBoxes = some( action.metaBoxes ); - if ( ! hasActiveMetaBoxes ) { - return; - } - - // Allow toggling metaboxes panels - // We need to wait for all scripts to load - // If the meta box loads the post script, it will already trigger this. - // After merge in Core, make sure to drop the timeout and update the postboxes script - // to avoid the double binding. - setTimeout( () => { - const postType = select( 'core/editor' ).getCurrentPostType(); - if ( window.postboxes.page !== postType ) { - window.postboxes.add_postbox_toggles( postType ); - } - } ); - - // Initialize metaboxes state - const dataPerLocation = reduce( action.metaBoxes, ( memo, isActive, location ) => { - if ( isActive ) { - memo[ location ] = jQuery( getMetaBoxContainer( location ) ).serialize(); - } - return memo; - }, {} ); - store.dispatch( setMetaBoxSavedData( dataPerLocation ) ); - - let wasSavingPost = select( 'core/editor' ).isSavingPost(); - let wasAutosavingPost = select( 'core/editor' ).isAutosavingPost(); - // Save metaboxes when performing a full save on the post. - subscribe( () => { - const isSavingPost = select( 'core/editor' ).isSavingPost(); - const isAutosavingPost = select( 'core/editor' ).isAutosavingPost(); - - // Save metaboxes on save completion when past save wasn't an autosave. - const shouldTriggerMetaboxesSave = wasSavingPost && ! wasAutosavingPost && ! isSavingPost && ! isAutosavingPost; - - // Save current state for next inspection. - wasSavingPost = isSavingPost; - wasAutosavingPost = isAutosavingPost; - - if ( shouldTriggerMetaboxesSave ) { - store.dispatch( requestMetaBoxUpdates() ); - } - } ); - }, - REQUEST_META_BOX_UPDATES( action, store ) { - const state = store.getState(); - const dataPerLocation = reduce( getMetaBoxes( state ), ( memo, metabox, location ) => { - if ( metabox.isActive ) { - memo[ location ] = jQuery( getMetaBoxContainer( location ) ).serialize(); - } - return memo; - }, {} ); - store.dispatch( setMetaBoxSavedData( dataPerLocation ) ); - - // Additional data needed for backwards compatibility. - // If we do not provide this data the post will be overriden with the default values. - const post = select( 'core/editor' ).getCurrentPost( state ); - const additionalData = [ - post.comment_status ? [ 'comment_status', post.comment_status ] : false, - post.ping_status ? [ 'ping_status', post.ping_status ] : false, - post.sticky ? [ 'sticky', post.sticky ] : false, - [ 'post_author', post.author ], - ].filter( Boolean ); - - // We gather all the metaboxes locations data and the base form data - const baseFormData = new window.FormData( document.querySelector( '.metabox-base-form' ) ); - const formDataToMerge = reduce( getMetaBoxes( state ), ( memo, metabox, location ) => { - if ( metabox.isActive ) { - memo.push( new window.FormData( getMetaBoxContainer( location ) ) ); - } - return memo; - }, [ baseFormData ] ); - - // Merge all form data objects into a single one. - const formData = reduce( formDataToMerge, ( memo, currentFormData ) => { - for ( const [ key, value ] of currentFormData ) { - memo.append( key, value ); - } - return memo; - }, new window.FormData() ); - additionalData.forEach( ( [ key, value ] ) => formData.append( key, value ) ); - - // Save the metaboxes - apiFetch( { - url: window._wpMetaBoxUrl, - method: 'POST', - body: formData, - parse: false, - } ) - .then( () => store.dispatch( metaBoxUpdatesSuccess() ) ); - }, SWITCH_MODE( action ) { const message = action.mode === 'visual' ? __( 'Visual editor selected' ) : __( 'Code editor selected' ); speak( message, 'assertive' ); diff --git a/client/gutenberg/editor/edit-post/store/test/actions.js b/client/gutenberg/editor/edit-post/store/test/actions.js deleted file mode 100644 index c0ae7ea9753aaa..00000000000000 --- a/client/gutenberg/editor/edit-post/store/test/actions.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Internal dependencies - */ -import { - toggleGeneralSidebarEditorPanel, - openGeneralSidebar, - closeGeneralSidebar, - openPublishSidebar, - closePublishSidebar, - togglePublishSidebar, - toggleFeature, - togglePinnedPluginItem, - requestMetaBoxUpdates, - initializeMetaBoxState, -} from '../actions'; - -describe( 'actions', () => { - describe( 'openGeneralSidebar', () => { - it( 'should return OPEN_GENERAL_SIDEBAR action', () => { - const name = 'plugin/my-name'; - expect( openGeneralSidebar( name ) ).toEqual( { - type: 'OPEN_GENERAL_SIDEBAR', - name, - } ); - } ); - } ); - - describe( 'closeGeneralSidebar', () => { - it( 'should return CLOSE_GENERAL_SIDEBAR action', () => { - expect( closeGeneralSidebar() ).toEqual( { - type: 'CLOSE_GENERAL_SIDEBAR', - } ); - } ); - } ); - - describe( 'openPublishSidebar', () => { - it( 'should return an OPEN_PUBLISH_SIDEBAR action', () => { - expect( openPublishSidebar() ).toEqual( { - type: 'OPEN_PUBLISH_SIDEBAR', - } ); - } ); - } ); - - describe( 'closePublishSidebar', () => { - it( 'should return an CLOSE_PUBLISH_SIDEBAR action', () => { - expect( closePublishSidebar() ).toEqual( { - type: 'CLOSE_PUBLISH_SIDEBAR', - } ); - } ); - } ); - - describe( 'togglePublishSidebar', () => { - it( 'should return an TOGGLE_PUBLISH_SIDEBAR action', () => { - expect( togglePublishSidebar() ).toEqual( { - type: 'TOGGLE_PUBLISH_SIDEBAR', - } ); - } ); - } ); - - describe( 'toggleSidebarPanel', () => { - it( 'should return TOGGLE_GENERAL_SIDEBAR_EDITOR_PANEL action', () => { - const panel = 'panelName'; - expect( toggleGeneralSidebarEditorPanel( panel ) ).toEqual( { - type: 'TOGGLE_GENERAL_SIDEBAR_EDITOR_PANEL', - panel, - } ); - } ); - } ); - - describe( 'toggleFeature', () => { - it( 'should return TOGGLE_FEATURE action', () => { - const feature = 'name'; - expect( toggleFeature( feature ) ).toEqual( { - type: 'TOGGLE_FEATURE', - feature, - } ); - } ); - } ); - - describe( 'togglePinnedPluginItem', () => { - it( 'should return TOGGLE_PINNED_PLUGIN_ITEM action', () => { - const pluginName = 'foo/bar'; - - expect( togglePinnedPluginItem( pluginName ) ).toEqual( { - type: 'TOGGLE_PINNED_PLUGIN_ITEM', - pluginName, - } ); - } ); - } ); - - describe( 'requestMetaBoxUpdates', () => { - it( 'should return the REQUEST_META_BOX_UPDATES action', () => { - expect( requestMetaBoxUpdates() ).toEqual( { - type: 'REQUEST_META_BOX_UPDATES', - } ); - } ); - } ); - - describe( 'initializeMetaBoxState', () => { - it( 'should return the META_BOX_STATE_CHANGED action with a hasChanged flag', () => { - const metaBoxes = { - side: true, - normal: true, - advanced: false, - }; - - expect( initializeMetaBoxState( metaBoxes ) ).toEqual( { - type: 'INITIALIZE_META_BOX_STATE', - metaBoxes, - } ); - } ); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/store/test/reducer.js b/client/gutenberg/editor/edit-post/store/test/reducer.js deleted file mode 100644 index 18bdf6cfbbd6e1..00000000000000 --- a/client/gutenberg/editor/edit-post/store/test/reducer.js +++ /dev/null @@ -1,243 +0,0 @@ -/** - * External dependencies - */ -import deepFreeze from 'deep-freeze'; - -/** - * Internal dependencies - */ -import { - preferences, - isSavingMetaBoxes, - metaBoxes, -} from '../reducer'; - -describe( 'state', () => { - describe( 'preferences()', () => { - it( 'should apply all defaults', () => { - const state = preferences( undefined, {} ); - - expect( state ).toEqual( { - activeGeneralSidebar: 'edit-post/document', - editorMode: 'visual', - panels: { 'post-status': true }, - features: { fixedToolbar: false }, - pinnedPluginItems: {}, - } ); - } ); - - it( 'should set the general sidebar', () => { - const original = deepFreeze( preferences( undefined, {} ) ); - const state = preferences( original, { - type: 'OPEN_GENERAL_SIDEBAR', - name: 'edit-post/document', - } ); - - expect( state.activeGeneralSidebar ).toBe( 'edit-post/document' ); - } ); - - it( 'should save activeGeneralSidebar default value when serializing if the value was edit-post/block', () => { - const state = preferences( { - activeGeneralSidebar: 'edit-post/block', - editorMode: 'visual', - panels: { 'post-status': true }, - features: { fixedToolbar: false }, - }, { - type: 'SERIALIZE', - } ); - - expect( state ).toEqual( { - activeGeneralSidebar: 'edit-post/document', - editorMode: 'visual', - panels: { 'post-status': true }, - features: { fixedToolbar: false }, - pinnedPluginItems: {}, - } ); - } ); - - it( 'should does not update if sidebar is already set to value', () => { - const original = deepFreeze( preferences( undefined, { - type: 'OPEN_GENERAL_SIDEBAR', - name: 'edit-post/document', - } ) ); - const state = preferences( original, { - type: 'OPEN_GENERAL_SIDEBAR', - name: 'edit-post/document', - } ); - - expect( original ).toBe( state ); - } ); - - it( 'should unset the general sidebar', () => { - const original = deepFreeze( preferences( undefined, { - type: 'OPEN_GENERAL_SIDEBAR', - name: 'edit-post/document', - } ) ); - const state = preferences( original, { - type: 'CLOSE_GENERAL_SIDEBAR', - } ); - - expect( state.activeGeneralSidebar ).toBe( null ); - } ); - - it( 'should set the sidebar panel open flag to true if unset', () => { - const state = preferences( deepFreeze( { panels: {} } ), { - type: 'TOGGLE_GENERAL_SIDEBAR_EDITOR_PANEL', - panel: 'post-taxonomies', - } ); - - expect( state.panels ).toEqual( { 'post-taxonomies': true } ); - } ); - - it( 'should toggle the sidebar panel open flag', () => { - const state = preferences( deepFreeze( { panels: { 'post-taxonomies': true } } ), { - type: 'TOGGLE_GENERAL_SIDEBAR_EDITOR_PANEL', - panel: 'post-taxonomies', - } ); - - expect( state.panels ).toEqual( { 'post-taxonomies': false } ); - } ); - - it( 'should return switched mode', () => { - const state = preferences( deepFreeze( { editorMode: 'visual' } ), { - type: 'SWITCH_MODE', - mode: 'text', - } ); - - expect( state.editorMode ).toBe( 'text' ); - } ); - - it( 'should toggle a feature flag', () => { - const state = preferences( deepFreeze( { features: { chicken: true } } ), { - type: 'TOGGLE_FEATURE', - feature: 'chicken', - } ); - - expect( state.features ).toEqual( { chicken: false } ); - } ); - - describe( 'pinnedPluginItems', () => { - const initialState = deepFreeze( { - pinnedPluginItems: { - 'foo/enabled': true, - 'foo/disabled': false, - }, - } ); - - it( 'should disable a pinned plugin flag when the value does not exist', () => { - const state = preferences( initialState, { - type: 'TOGGLE_PINNED_PLUGIN_ITEM', - pluginName: 'foo/does-not-exist', - } ); - - expect( state.pinnedPluginItems[ 'foo/does-not-exist' ] ).toBe( false ); - } ); - - it( 'should disable a pinned plugin flag when it is enabled', () => { - const state = preferences( initialState, { - type: 'TOGGLE_PINNED_PLUGIN_ITEM', - pluginName: 'foo/enabled', - } ); - - expect( state.pinnedPluginItems[ 'foo/enabled' ] ).toBe( false ); - } ); - - it( 'should enable a pinned plugin flag when it is disabled', () => { - const state = preferences( initialState, { - type: 'TOGGLE_PINNED_PLUGIN_ITEM', - pluginName: 'foo/disabled', - } ); - - expect( state.pinnedPluginItems[ 'foo/disabled' ] ).toBe( true ); - } ); - } ); - } ); - - describe( 'isSavingMetaBoxes', () => { - it( 'should return default state', () => { - const actual = isSavingMetaBoxes( undefined, {} ); - expect( actual ).toBe( false ); - } ); - - it( 'should set saving flag to true', () => { - const action = { - type: 'REQUEST_META_BOX_UPDATES', - }; - const actual = isSavingMetaBoxes( false, action ); - - expect( actual ).toBe( true ); - } ); - - it( 'should set saving flag to false', () => { - const action = { - type: 'META_BOX_UPDATES_SUCCESS', - }; - const actual = isSavingMetaBoxes( true, action ); - - expect( actual ).toBe( false ); - } ); - } ); - - describe( 'metaBoxes()', () => { - it( 'should return default state', () => { - const actual = metaBoxes( undefined, {} ); - const expected = { - normal: { - isActive: false, - }, - side: { - isActive: false, - }, - advanced: { - isActive: false, - }, - }; - - expect( actual ).toEqual( expected ); - } ); - - it( 'should set the sidebar to active', () => { - const theMetaBoxes = { - normal: false, - advanced: false, - side: true, - }; - - const action = { - type: 'INITIALIZE_META_BOX_STATE', - metaBoxes: theMetaBoxes, - }; - - const actual = metaBoxes( undefined, action ); - const expected = { - normal: { - isActive: false, - }, - side: { - isActive: true, - }, - advanced: { - isActive: false, - }, - }; - - expect( actual ).toEqual( expected ); - } ); - - it( 'should set the meta boxes saved data', () => { - const action = { - type: 'META_BOX_SET_SAVED_DATA', - dataPerLocation: { - side: 'a=b', - }, - }; - - const theMetaBoxes = metaBoxes( { normal: { isActive: true }, side: { isActive: false } }, action ); - expect( theMetaBoxes ).toEqual( { - advanced: { data: undefined }, - normal: { isActive: true, data: undefined }, - side: { isActive: false, data: 'a=b' }, - } ); - } ); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/store/test/selectors.js b/client/gutenberg/editor/edit-post/store/test/selectors.js deleted file mode 100644 index d706c4b3ecfc65..00000000000000 --- a/client/gutenberg/editor/edit-post/store/test/selectors.js +++ /dev/null @@ -1,306 +0,0 @@ -/** - * Internal dependencies - */ -import { - getEditorMode, - getPreference, - isEditorSidebarOpened, - isEditorSidebarPanelOpened, - isFeatureActive, - isPluginSidebarOpened, - isPluginItemPinned, - getMetaBoxes, - hasMetaBoxes, - isSavingMetaBoxes, - getMetaBox, -} from '../selectors'; - -describe( 'selectors', () => { - describe( 'getEditorMode', () => { - it( 'should return the selected editor mode', () => { - const state = { - preferences: { editorMode: 'text' }, - }; - - expect( getEditorMode( state ) ).toEqual( 'text' ); - } ); - - it( 'should fallback to visual if not set', () => { - const state = { - preferences: {}, - }; - - expect( getEditorMode( state ) ).toEqual( 'visual' ); - } ); - } ); - - describe( 'getPreference', () => { - it( 'should return the preference value if set', () => { - const state = { - preferences: { chicken: true }, - }; - - expect( getPreference( state, 'chicken' ) ).toBe( true ); - } ); - - it( 'should return undefined if the preference is unset', () => { - const state = { - preferences: { chicken: true }, - }; - - expect( getPreference( state, 'ribs' ) ).toBeUndefined(); - } ); - - it( 'should return the default value if provided', () => { - const state = { - preferences: {}, - }; - - expect( getPreference( state, 'ribs', 'chicken' ) ).toEqual( 'chicken' ); - } ); - } ); - - describe( 'isEditorSidebarOpened', () => { - it( 'should return false when the editor sidebar is not opened', () => { - const state = { - preferences: { - activeGeneralSidebar: null, - }, - }; - - expect( isEditorSidebarOpened( state ) ).toBe( false ); - } ); - - it( 'should return false when the plugin sidebar is opened', () => { - const state = { - preferences: { - activeGeneralSidebar: 'my-plugin/my-sidebar', - }, - }; - - expect( isEditorSidebarOpened( state ) ).toBe( false ); - } ); - - it( 'should return true when the editor sidebar is opened', () => { - const state = { - preferences: { - activeGeneralSidebar: 'edit-post/document', - }, - }; - - expect( isEditorSidebarOpened( state ) ).toBe( true ); - } ); - } ); - - describe( 'isPluginSidebarOpened', () => { - it( 'should return false when the plugin sidebar is not opened', () => { - const state = { - preferences: { - activeGeneralSidebar: null, - }, - }; - - expect( isPluginSidebarOpened( state ) ).toBe( false ); - } ); - - it( 'should return false when the editor sidebar is opened', () => { - const state = { - preferences: { - activeGeneralSidebar: 'edit-post/document', - }, - }; - - expect( isPluginSidebarOpened( state ) ).toBe( false ); - } ); - - it( 'should return true when the plugin sidebar is opened', () => { - const name = 'plugin-sidebar/my-plugin/my-sidebar'; - const state = { - preferences: { - activeGeneralSidebar: name, - }, - }; - - expect( isPluginSidebarOpened( state ) ).toBe( true ); - } ); - } ); - - describe( 'isEditorSidebarPanelOpened', () => { - it( 'should return false if no panels preference', () => { - const state = { - preferences: {}, - }; - - expect( isEditorSidebarPanelOpened( state, 'post-taxonomies' ) ).toBe( false ); - } ); - - it( 'should return false if the panel value is not set', () => { - const state = { - preferences: { panels: {} }, - }; - - expect( isEditorSidebarPanelOpened( state, 'post-taxonomies' ) ).toBe( false ); - } ); - - it( 'should return the panel value', () => { - const state = { - preferences: { panels: { 'post-taxonomies': true } }, - }; - - expect( isEditorSidebarPanelOpened( state, 'post-taxonomies' ) ).toBe( true ); - } ); - } ); - - describe( 'isFeatureActive', () => { - it( 'should return true if feature is active', () => { - const state = { - preferences: { - features: { - chicken: true, - }, - }, - }; - - expect( isFeatureActive( state, 'chicken' ) ).toBe( true ); - } ); - - it( 'should return false if feature is not active', () => { - const state = { - preferences: { - features: { - chicken: false, - }, - }, - }; - - expect( isFeatureActive( state, 'chicken' ) ).toBe( false ); - } ); - - it( 'should return false if feature is not referred', () => { - const state = { - preferences: { - features: { - }, - }, - }; - - expect( isFeatureActive( state, 'chicken' ) ).toBe( false ); - } ); - } ); - - describe( 'isPluginItemPinned', () => { - const state = { - preferences: { - pinnedPluginItems: { - 'foo/pinned': true, - 'foo/unpinned': false, - }, - }, - }; - - it( 'should return true if the flag is not set for the plugin item', () => { - expect( isPluginItemPinned( state, 'foo/unknown' ) ).toBe( true ); - } ); - - it( 'should return true if plugin item is not pinned', () => { - expect( isPluginItemPinned( state, 'foo/pinned' ) ).toBe( true ); - } ); - - it( 'should return false if plugin item item is unpinned', () => { - expect( isPluginItemPinned( state, 'foo/unpinned' ) ).toBe( false ); - } ); - } ); - - describe( 'hasMetaBoxes', () => { - it( 'should return true if there are active meta boxes', () => { - const state = { - metaBoxes: { - normal: { - isActive: false, - }, - side: { - isActive: true, - }, - }, - }; - - expect( hasMetaBoxes( state ) ).toBe( true ); - } ); - - it( 'should return false if there are no active meta boxes', () => { - const state = { - metaBoxes: { - normal: { - isActive: false, - }, - side: { - isActive: false, - }, - }, - }; - - expect( hasMetaBoxes( state ) ).toBe( false ); - } ); - } ); - - describe( 'isSavingMetaBoxes', () => { - it( 'should return true if some meta boxes are saving', () => { - const state = { - isSavingMetaBoxes: true, - }; - - expect( isSavingMetaBoxes( state ) ).toBe( true ); - } ); - - it( 'should return false if no meta boxes are saving', () => { - const state = { - isSavingMetaBoxes: false, - }; - - expect( isSavingMetaBoxes( state ) ).toBe( false ); - } ); - } ); - - describe( 'getMetaBoxes', () => { - it( 'should return the state of all meta boxes', () => { - const state = { - metaBoxes: { - normal: { - isActive: true, - }, - side: { - isActive: true, - }, - }, - }; - - expect( getMetaBoxes( state ) ).toEqual( { - normal: { - isActive: true, - }, - side: { - isActive: true, - }, - } ); - } ); - } ); - - describe( 'getMetaBox', () => { - it( 'should return the state of selected meta box', () => { - const state = { - metaBoxes: { - normal: { - isActive: false, - }, - side: { - isActive: true, - }, - }, - }; - - expect( getMetaBox( state, 'side' ) ).toEqual( { - isActive: true, - } ); - } ); - } ); -} ); diff --git a/client/gutenberg/editor/edit-post/utils/meta-boxes.js b/client/gutenberg/editor/edit-post/utils/meta-boxes.js deleted file mode 100644 index 055a239f1c1d92..00000000000000 --- a/client/gutenberg/editor/edit-post/utils/meta-boxes.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Function returning the current Meta Boxes DOM Node in the editor - * whether the meta box area is opened or not. - * If the MetaBox Area is visible returns it, and returns the original container instead. - * - * @param {string} location Meta Box location. - * @return {string} HTML content. - */ -export const getMetaBoxContainer = ( location ) => { - const area = document.querySelector( `.edit-post-meta-boxes-area.is-${ location } .metabox-location-${ location }` ); - if ( area ) { - return area; - } - - return document.querySelector( '#metaboxes .metabox-location-' + location ); -}; diff --git a/client/gutenberg/editor/main.jsx b/client/gutenberg/editor/main.jsx index a0ab6b17099af8..2cdec3b6fb1656 100644 --- a/client/gutenberg/editor/main.jsx +++ b/client/gutenberg/editor/main.jsx @@ -13,7 +13,6 @@ import { /** * Internal dependencies */ -import './edit-post'; import Editor from './edit-post/editor.js'; import * as paragraph from './core-blocks/paragraph'; import * as heading from './core-blocks/heading'; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 329bb738e8bf9c..b2d0dac3374e4f 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1649,34 +1649,6 @@ "@wordpress/data": "^1.1.0", "@wordpress/element": "^1.0.2", "lodash": "^4.17.10" - }, - "dependencies": { - "@wordpress/data": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@wordpress/data/-/data-1.1.0.tgz", - "integrity": "sha512-9aRhkJNTVQFdsLi84LBFU3ll9W0lFGyafbP1yN95UZ+Gp1WAwwq1n5aWoIDQq22wtbtQjrb9ubuVeJTOoMgmyA==", - "requires": { - "@babel/runtime": "^7.0.0-beta.52", - "@wordpress/compose": "^1.0.2", - "@wordpress/deprecated": "^1.0.2", - "@wordpress/element": "^1.0.2", - "@wordpress/is-shallow-equal": "^1.1.2", - "equivalent-key-map": "^0.2.1", - "lodash": "^4.17.10", - "redux": "^3.7.2" - } - }, - "redux": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz", - "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==", - "requires": { - "lodash": "^4.2.1", - "lodash-es": "^4.2.1", - "loose-envify": "^1.1.0", - "symbol-observable": "^1.0.3" - } - } } }, "@wordpress/wordcount": { @@ -11894,9 +11866,9 @@ "dev": true }, "popper.js": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.3.tgz", - "integrity": "sha1-FDj5jQRqz3tNeM1QK/QYrGTU8JU=" + "version": "1.14.4", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.14.4.tgz", + "integrity": "sha1-juwdj/AqWjoVLdQ0FKFce3n9abY=" }, "posix-character-classes": { "version": "0.1.1", @@ -12881,9 +12853,9 @@ } }, "react-datepicker": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-1.5.0.tgz", - "integrity": "sha512-Neh1rz0d1QeR7KuoTiYeR6oj73DJkqt0vuNSgfMuxXEwGmz/4sPynouYGo6gdKiQbxIXBJJ/FLDLHJEr5XNThw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-1.6.0.tgz", + "integrity": "sha512-wfFfw3Tn+CCTtP7PPPhSAfkfVT3UTifFb8BmuhtwWKK3g4S83EEPRQE18XFtxd22dKGqp336NVtDTTyUJ1p9+g==", "requires": { "classnames": "^2.2.5", "prop-types": "^15.6.0", diff --git a/package.json b/package.json index 6ae67c56da2343..efed66509d7ce5 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,7 @@ "@babel/preset-react": "7.0.0-beta.53", "@babel/runtime": "7.0.0-beta.53", "@wordpress/blocks": "1.0.2", - "@wordpress/compose": "1.0.2", - "@wordpress/data": "1.1.0", "@wordpress/editor": "1.0.1", - "@wordpress/element": "1.0.2", - "@wordpress/i18n": "1.2.2", - "@wordpress/keycodes": "1.0.2", "@wordpress/plugins": "1.0.2", "autoprefixer": "9.0.2", "autosize": "4.0.2",